idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
31,600 | public function delete_instance ( $ instance ) { global $ DB ; $ name = $ this -> get_name ( ) ; if ( $ instance -> enrol !== $ name ) { throw new coding_exception ( 'invalid enrol instance!' ) ; } $ participants = $ DB -> get_recordset ( 'user_enrolments' , array ( 'enrolid' => $ instance -> id ) ) ; foreach ( $ parti... | Delete course enrol plugin instance unenrol all users . |
31,601 | public function add_course_navigation ( $ instancesnode , stdClass $ instance ) { if ( $ this -> use_standard_editing_ui ( ) ) { $ context = context_course :: instance ( $ instance -> courseid ) ; $ cap = 'enrol/' . $ instance -> enrol . ':config' ; if ( has_capability ( $ cap , $ context ) ) { $ linkparams = array ( '... | Adds navigation links into course admin block . |
31,602 | public function get_action_icons ( stdClass $ instance ) { global $ OUTPUT ; $ icons = array ( ) ; if ( $ this -> use_standard_editing_ui ( ) ) { $ linkparams = array ( 'courseid' => $ instance -> courseid , 'id' => $ instance -> id , 'type' => $ instance -> enrol ) ; $ editlink = new moodle_url ( "/enrol/editinstance.... | Returns edit icons for the page with list of instances |
31,603 | public function is_cron_required ( ) { global $ CFG ; $ name = $ this -> get_name ( ) ; $ versionfile = "$CFG->dirroot/enrol/$name/version.php" ; $ plugin = new stdClass ( ) ; include ( $ versionfile ) ; if ( empty ( $ plugin -> cron ) ) { return false ; } $ lastexecuted = $ this -> get_config ( 'lastcron' , 0 ) ; if (... | Reads version . php and determines if it is necessary to execute the cron job now . |
31,604 | public function user_delete ( $ user ) { global $ DB ; $ sql = "SELECT e.* FROM {enrol} e JOIN {user_enrolments} ue ON (ue.enrolid = e.id) WHERE e.enrol = :name AND ue.userid = :userid" ; $ params = array ( 'name' => $ this -> get_name ( ) , 'userid' => $ user -> id ) ;... | Called when user is about to be deleted |
31,605 | public function get_user_enrolment_actions ( course_enrolment_manager $ manager , $ ue ) { $ actions = [ ] ; $ context = $ manager -> get_context ( ) ; $ instance = $ ue -> enrolmentinstance ; $ params = $ manager -> get_moodlepage ( ) -> url -> params ( ) ; $ params [ 'ue' ] = $ ue -> id ; if ( $ this -> allow_manage ... | Gets an array of the user enrolment actions |
31,606 | protected static function get_chat_ids_to_cmids_from_cmids ( array $ cmids ) { global $ DB ; list ( $ insql , $ inparams ) = $ DB -> get_in_or_equal ( $ cmids , SQL_PARAMS_NAMED ) ; $ sql = " SELECT c.id, cm.id AS cmid FROM {chat} c JOIN {modules} m ON m.name = :chat ... | Return a dict of chat IDs mapped to their course module ID . |
31,607 | public static function build ( $ config , $ context ) { $ id_accumulator = new HTMLPurifier_IDAccumulator ( ) ; $ id_accumulator -> load ( $ config -> get ( 'Attr.IDBlacklist' ) ) ; return $ id_accumulator ; } | Builds an IDAccumulator also initializing the default blacklist |
31,608 | public function add ( $ id ) { if ( isset ( $ this -> ids [ $ id ] ) ) { return false ; } return $ this -> ids [ $ id ] = true ; } | Add an ID to the lookup table . |
31,609 | protected static function get_url_for_image ( question_attempt $ qa , $ filearea , $ itemid = 0 ) { $ question = $ qa -> get_question ( ) ; $ qubaid = $ qa -> get_usage_id ( ) ; $ slot = $ qa -> get_slot ( ) ; $ fs = get_file_storage ( ) ; if ( $ filearea == 'bgimage' ) { $ itemid = $ question -> id ; } $ componentname... | Returns the URL for an image |
31,610 | protected function hidden_field_for_qt_var ( question_attempt $ qa , $ varname , $ value = null , $ classes = null ) { if ( $ value === null ) { $ value = $ qa -> get_last_qt_var ( $ varname ) ; } $ fieldname = $ qa -> get_qt_field_name ( $ varname ) ; $ attributes = array ( 'type' => 'hidden' , 'id' => str_replace ( '... | Returns a hidden field for a qt variable |
31,611 | public function getEigenvectors ( ) { $ vectors = $ this -> V ; $ vectors = new Matrix ( $ vectors ) ; $ vectors = array_map ( function ( $ vect ) { $ sum = 0 ; for ( $ i = 0 ; $ i < count ( $ vect ) ; ++ $ i ) { $ sum += $ vect [ $ i ] ** 2 ; } $ sum = sqrt ( $ sum ) ; for ( $ i = 0 ; $ i < count ( $ vect ) ; ++ $ i )... | Return the eigenvector matrix |
31,612 | public function save_changes ( ) { foreach ( $ this -> changed as $ changedcap ) { assign_capability ( $ changedcap , $ this -> permissions [ $ changedcap ] , $ this -> roleid , $ this -> context -> id , true ) ; } } | Save the new values of any permissions that have been changed . |
31,613 | public function get_risk_icon ( $ type ) { global $ OUTPUT ; $ alt = get_string ( "{$type}short" , "admin" ) ; $ title = get_string ( $ type , "admin" ) ; $ text = $ OUTPUT -> pix_icon ( 'i/' . str_replace ( 'risk' , 'risk_' , $ type ) , $ alt , 'moodle' , [ 'title' => $ title , ] ) ; $ action = new popup_action ( 'cli... | Print a risk icon as a link to the Risks page on Moodle Docs . |
31,614 | public function get_forum_vault ( ) : forum_vault { return new forum_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'forum' ) ) ; } | Create a forum vault . |
31,615 | public function get_discussion_vault ( ) : discussion_vault { return new discussion_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'discussion' ) ) ; } | Create a discussion vault . |
31,616 | public function get_discussions_in_forum_vault ( ) : discussion_list_vault { return new discussion_list_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'discussion' ) ) ; } | Create a discussion list vault . |
31,617 | public function get_post_vault ( ) : post_vault { return new post_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'post' ) ) ; } | Create a post vault . |
31,618 | public function get_author_vault ( ) : author_vault { return new author_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'author' ) ) ; } | Create an author vault . |
31,619 | public function get_post_read_receipt_collection_vault ( ) : post_read_receipt_collection_vault { return new post_read_receipt_collection_vault ( $ this -> db , $ this -> entityfactory , $ this -> legacymapper -> get_legacy_data_mapper_for_vault ( 'post' ) ) ; } | Create a post read receipt collection vault . |
31,620 | public function download_grades ( ) { global $ CFG ; require_capability ( 'mod/assign:grade' , $ this -> assignment -> get_context ( ) ) ; require_once ( $ CFG -> dirroot . '/mod/assign/gradingtable.php' ) ; $ groupmode = groups_get_activity_groupmode ( $ this -> assignment -> get_course_module ( ) ) ; $ groupid = 0 ; ... | Download a marking worksheet |
31,621 | public function is_enabled ( ) { if ( $ this -> enabledcache === null ) { $ gradingmanager = get_grading_manager ( $ this -> assignment -> get_context ( ) , 'mod_assign' , 'submissions' ) ; $ controller = $ gradingmanager -> get_active_controller ( ) ; $ active = ! empty ( $ controller ) ; if ( $ active ) { $ this -> e... | Override the default is_enabled to disable this plugin if advanced grading is active |
31,622 | public static function is_domain_name ( $ domainname ) { if ( ! is_string ( $ domainname ) ) { return false ; } $ domainname = rtrim ( $ domainname , '.' ) ; if ( strlen ( $ domainname ) > 253 ) { return false ; } $ domaintertiary = '([a-zA-Z0-9](([a-zA-Z0-9-]{0,61})[a-zA-Z0-9])?\.)*' ; $ domaintoplevel = '([a-zA-Z](([... | Syntax checking for domain names including fully qualified domain names . |
31,623 | public static function is_domain_matching_pattern ( $ pattern ) { if ( ! is_string ( $ pattern ) ) { return false ; } $ pattern = rtrim ( $ pattern , '.' ) ; if ( strlen ( $ pattern ) > 253 ) { return false ; } $ wildcard = '((\*)\.){1}' ; $ domaintertiary = '([a-zA-Z0-9](([a-zA-Z0-9-]{0,61})[a-zA-Z0-9])?\.)*' ; $ doma... | Checks whether the input string is a valid wildcard domain matching pattern . |
31,624 | private function upgrade_mod_assign ( ) { global $ DB , $ CFG ; $ pluginmanager = core_plugin_manager :: instance ( ) ; $ plugininfo = $ pluginmanager -> get_plugin_info ( 'mod_assign' ) ; if ( $ plugininfo && $ plugininfo -> is_installed_and_upgraded ( ) ) { require_once ( $ CFG -> dirroot . '/mod/assign/upgradelib.ph... | This function will attempt to upgrade the newly restored assignment to an instance of mod_assign if mod_assignment is currently disabled and mod_assign is enabled and mod_assign says it can upgrade this assignment . |
31,625 | protected function is_valid_assignment_subplugin ( $ type ) { static $ subplugins = null ; if ( is_null ( $ subplugins ) ) { $ subplugins = get_plugin_list ( 'assignment' ) ; } return array_key_exists ( $ type , $ subplugins ) ; } | Determine if a sub - plugin is supported or not |
31,626 | public function export ( string $ zipfilename , bool $ includeweights = true ) : string { if ( ! $ this -> model ) { throw new \ coding_exception ( 'No model object provided.' ) ; } if ( ! $ this -> model -> can_export_configuration ( ) ) { throw new \ moodle_exception ( 'errornoexportconfigrequirements' , 'analytics' ... | Exports a model to a zip using the provided file name . |
31,627 | public function import ( string $ zipfilepath ) : \ core_analytics \ model { list ( $ modeldata , $ mlbackenddir ) = $ this -> extract_import_contents ( $ zipfilepath ) ; $ target = \ core_analytics \ manager :: get_target ( $ modeldata -> target ) ; $ indicators = [ ] ; foreach ( $ modeldata -> indicators as $ indicat... | Imports the provided model configuration into a new model . |
31,628 | public function check_dependencies ( \ stdClass $ modeldata , bool $ ignoreversionmismatches ) : ? string { $ siteversions = \ core_component :: get_all_versions ( ) ; $ missingcomponents = [ ] ; $ versionmismatches = [ ] ; $ missingclasses = [ ] ; foreach ( $ modeldata -> dependencies as $ component => $ importversion... | Check that the provided model configuration can be deployed in this site . |
31,629 | public static function get_class_component ( string $ fullclassname ) : ? string { $ fullclassname = ltrim ( $ fullclassname , '\\' ) ; $ nextbackslash = strpos ( $ fullclassname , '\\' ) ; if ( $ nextbackslash === false ) { return 'core' ; } $ component = substr ( $ fullclassname , 0 , $ nextbackslash ) ; if ( strpos ... | Returns the component the class belongs to . |
31,630 | public function extract_import_contents ( string $ zipfilepath ) : array { $ importtempdir = make_request_directory ( 'analyticsimport' . microtime ( false ) ) ; $ zip = new \ zip_packer ( ) ; $ filelist = $ zip -> extract_to_pathname ( $ zipfilepath , $ importtempdir ) ; if ( empty ( $ filelist [ self :: CONFIG_FILE_N... | Extracts the import zip contents . |
31,631 | protected function export_model_data ( ) : \ stdClass { $ versions = \ core_component :: get_all_versions ( ) ; $ data = new \ stdClass ( ) ; $ data -> target = $ this -> model -> get_target ( ) -> get_id ( ) ; $ requiredclasses [ ] = $ data -> target ; $ data -> timesplitting = $ this -> model -> get_time_splitting ( ... | Exports the configuration of the model . |
31,632 | public function render_core_availability_multiple_messages ( core_availability_multiple_messages $ renderable ) { $ out = get_string ( 'list_' . ( $ renderable -> root ? 'root_' : '' ) . ( $ renderable -> andoperator ? 'and' : 'or' ) . ( $ renderable -> treehidden ? '_hidden' : '' ) , 'availability' ) ; $ out .= html_w... | Renders HTML for the result of two or more availability restriction messages being combined in a list . |
31,633 | public static function add ( $ message , $ level = null ) { global $ PAGE , $ SESSION ; if ( $ PAGE && $ PAGE -> state === \ moodle_page :: STATE_IN_BODY ) { $ id = uniqid ( ) ; echo \ html_writer :: span ( $ PAGE -> get_renderer ( 'core' ) -> render ( new \ core \ output \ notification ( $ message , $ level ) ) , '' ,... | Add a message to the session notification stack . |
31,634 | public function get_months ( ) { $ months = array ( ) ; $ date = new \ DateTime ( '@1263556800' ) ; $ date -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; for ( $ i = 1 ; $ i <= 12 ; $ i ++ ) { $ date -> setDate ( 2000 , $ i , 15 ) ; $ months [ $ i ] = userdate ( $ date -> getTimestamp ( ) , '%B' , 'UTC' ) ; } return... | Returns a list of all the names of the months . |
31,635 | public function get_years ( $ minyear = null , $ maxyear = null ) { if ( is_null ( $ minyear ) ) { $ minyear = $ this -> get_min_year ( ) ; } if ( is_null ( $ maxyear ) ) { $ maxyear = $ this -> get_max_year ( ) ; } $ years = array ( ) ; for ( $ i = $ minyear ; $ i <= $ maxyear ; $ i ++ ) { $ years [ $ i ] = $ i ; } re... | Returns an array of years . |
31,636 | public function get_date_order ( $ minyear = null , $ maxyear = null ) { $ dateinfo = array ( ) ; $ dateinfo [ 'day' ] = $ this -> get_days ( ) ; $ dateinfo [ 'month' ] = $ this -> get_months ( ) ; $ dateinfo [ 'year' ] = $ this -> get_years ( $ minyear , $ maxyear ) ; return $ dateinfo ; } | Returns a multidimensional array with information for day month year and the order they are displayed when selecting a date . The order in the array will be the order displayed when selecting a date . Override this function to change the date selector order . |
31,637 | public function get_weekdays ( ) { return array ( 0 => array ( 'shortname' => get_string ( 'sun' , 'calendar' ) , 'fullname' => get_string ( 'sunday' , 'calendar' ) ) , 1 => array ( 'shortname' => get_string ( 'mon' , 'calendar' ) , 'fullname' => get_string ( 'monday' , 'calendar' ) ) , 2 => array ( 'shortname' => get_... | Returns an indexed list of all the names of the weekdays . |
31,638 | public function get_starting_weekday ( ) { global $ CFG ; if ( isset ( $ CFG -> calendar_startwday ) ) { $ firstday = $ CFG -> calendar_startwday ; } else { $ firstday = get_string ( 'firstdayofweek' , 'langconfig' ) ; } if ( ! is_numeric ( $ firstday ) ) { $ startingweekday = CALENDAR_DEFAULT_STARTING_WEEKDAY ; } else... | Returns the index of the starting week day . |
31,639 | public function get_weekday ( $ year , $ month , $ day ) { return intval ( date ( 'w' , mktime ( 12 , 0 , 0 , $ month , $ day , $ year ) ) ) ; } | Returns the index of the weekday for a specific calendar date . |
31,640 | public function timestamp_to_date_string ( $ time , $ format , $ timezone , $ fixday , $ fixhour ) { global $ CFG ; if ( empty ( $ format ) ) { $ format = get_string ( 'strftimedaydatetime' , 'langconfig' ) ; } if ( ! empty ( $ CFG -> nofixday ) ) { $ fixday = false ; } else if ( $ fixday ) { $ formatnoday = str_replac... | Returns a formatted string that represents a date in user time . |
31,641 | public function setLogLevel ( $ level = 0 ) { if ( is_string ( $ level ) ) { $ level = defined ( 'Horde_Log::' . $ level ) ? constant ( 'Horde_Log::' . $ level ) : 0 ; } $ this -> _logLevel = $ level ; } | Sets the log level . |
31,642 | public function lookup_consumer ( $ consumerkey ) { if ( strpos ( $ consumerkey , "http://" ) === 0 ) { $ consumer = new OAuthConsumer ( $ consumerkey , "secret" , null ) ; return $ consumer ; } if ( $ this -> consumers [ $ consumerkey ] ) { $ consumer = new OAuthConsumer ( $ consumerkey , $ this -> consumers [ $ consu... | Get OAuth consumer given its key |
31,643 | function & getRule ( $ ruleName ) { list ( $ class , $ path ) = $ GLOBALS [ '_HTML_QuickForm_registered_rules' ] [ $ ruleName ] ; if ( ! isset ( $ this -> _rules [ $ class ] ) ) { if ( ! empty ( $ path ) ) { include_once ( $ path ) ; } $ this -> _rules [ $ class ] = new $ class ( ) ; } $ this -> _rules [ $ class ] -> s... | Returns a reference to the requested rule object |
31,644 | function validate ( $ ruleName , $ values , $ options = null , $ multiple = false ) { $ rule = & $ this -> getRule ( $ ruleName ) ; if ( is_array ( $ values ) && ! $ multiple ) { $ result = 0 ; foreach ( $ values as $ value ) { if ( $ rule -> validate ( $ value , $ options ) === true ) { $ result ++ ; } } return ( $ re... | Performs validation on the given values |
31,645 | function getValidationScript ( & $ element , $ elementName , $ ruleData ) { $ reset = ( isset ( $ ruleData [ 'reset' ] ) ) ? $ ruleData [ 'reset' ] : false ; $ rule = & $ this -> getRule ( $ ruleData [ 'type' ] ) ; if ( ! is_array ( $ element ) ) { list ( $ jsValue , $ jsReset ) = $ this -> _getJsValue ( $ element , $ ... | Returns the validation test in javascript code |
31,646 | public static function has_existing_issuer_match ( \ core \ oauth2 \ issuer $ issuer , $ username ) { global $ DB ; $ where = "issuerid = :issuerid AND username = :username AND (confirmtokenexpires = 0 OR confirmtokenexpires > :maxexpiry)" ; $ count = $ DB -> count_records_select ( static :: T... | Check whether there are any valid linked accounts for this issuer and username combination . |
31,647 | public static function delete_orphaned ( $ issuerid = false ) { global $ DB ; $ sql = "DELETE FROM {" . self :: TABLE . "} WHERE issuerid NOT IN (SELECT id FROM {" . \ core \ oauth2 \ issuer :: TABLE . "})" ; $ params = [ ] ; if ( ! empty ( $ issuerid ) ) { $ sql .= ' AND issuerid = ?' ; $ params [ 'iss... | Remove all linked logins that are using issuers that have been deleted . |
31,648 | function display_search_field ( $ value = 0 ) { $ selectors = html_writer :: select_time ( 'days' , 'f_' . $ this -> field -> id . '_d' , $ value [ 'timestamp' ] ) . html_writer :: select_time ( 'months' , 'f_' . $ this -> field -> id . '_m' , $ value [ 'timestamp' ] ) . html_writer :: select_time ( 'years' , 'f_' . $ ... | Enable the following three functions once core API issues have been addressed . |
31,649 | protected function get_strategy_handler ( $ strategy ) { global $ CFG ; if ( is_null ( $ this -> strategyhandlers ) ) { $ this -> strategyhandlers = array ( ) ; $ subplugins = core_component :: get_plugin_list ( 'workshopform' ) ; foreach ( $ subplugins as $ name => $ dir ) { $ handlerfile = $ dir . '/backup/moodle1/li... | Factory method returning the handler of the given grading strategy subplugin |
31,650 | public function add_result ( $ result ) { if ( ! is_array ( $ result ) ) { throw new coding_exception ( 'Associative array is expected as a parameter of add_result()' ) ; } $ this -> results = array_merge ( $ this -> results , $ result ) ; } | Add the passed info to the plan results |
31,651 | protected function get_enabled_plugins ( ) { $ plugins = \ core \ plugininfo \ fileconverter :: get_enabled_plugins ( ) ; $ pluginclasses = [ ] ; foreach ( $ plugins as $ plugin ) { $ pluginclasses [ $ plugin ] = \ core \ plugininfo \ fileconverter :: get_classname ( $ plugin ) ; } return $ pluginclasses ; } | Get a list of enabled plugins and classes . |
31,652 | public function start_conversion ( stored_file $ file , $ format , $ forcerefresh = false ) { $ conversions = conversion :: get_conversions_for_file ( $ file , $ format ) ; if ( $ forcerefresh || count ( $ conversions ) > 1 ) { while ( $ conversion = array_shift ( $ conversions ) ) { if ( $ conversion -> get ( 'id' ) )... | Start the conversion for a stored_file into a new format . |
31,653 | public function poll_conversion ( conversion $ conversion ) { $ format = $ conversion -> get ( 'targetformat' ) ; $ file = $ conversion -> get_sourcefile ( ) ; if ( $ conversion -> get ( 'status' ) == conversion :: STATUS_IN_PROGRESS ) { if ( $ instance = $ conversion -> get_converter_instance ( ) ) { $ instance -> pol... | Poll for updates to the supplied conversion . |
31,654 | protected function get_next_converter ( $ converters , $ currentconverter = null ) { if ( $ currentconverter ) { $ keys = array_keys ( $ converters , $ currentconverter ) ; $ key = $ keys [ 0 ] ; if ( isset ( $ converters [ $ key + 1 ] ) ) { return $ converters [ $ key + 1 ] ; } else { return false ; } } else if ( ! em... | Fetch the next converter to try . |
31,655 | protected function get_document_converter_classes ( $ from , $ to ) { $ classes = [ ] ; $ converters = $ this -> get_enabled_plugins ( ) ; foreach ( $ converters as $ plugin => $ classname ) { if ( ! class_exists ( $ classname ) ) { continue ; } if ( ! $ classname :: are_requirements_met ( ) ) { continue ; } if ( $ cla... | Fetch the class for the preferred document converter . |
31,656 | public function can_convert_storedfile_to ( stored_file $ file , $ to ) { if ( $ file -> is_directory ( ) ) { return false ; } if ( ! $ file -> get_filesize ( ) ) { return false ; } $ from = pathinfo ( $ file -> get_filename ( ) , PATHINFO_EXTENSION ) ; if ( ! $ from ) { return false ; } return $ this -> can_convert_fo... | Check whether document conversion is supported for this file and target format . |
31,657 | public function prepareGenerator ( $ config ) { $ all = $ config -> getAll ( ) ; $ context = new HTMLPurifier_Context ( ) ; $ this -> generator = new HTMLPurifier_Generator ( $ config , $ context ) ; } | Give generator necessary configuration if possible |
31,658 | protected function start ( $ tag , $ attr = array ( ) ) { return $ this -> generator -> generateFromToken ( new HTMLPurifier_Token_Start ( $ tag , $ attr ? $ attr : array ( ) ) ) ; } | Returns a start tag |
31,659 | protected function element ( $ tag , $ contents , $ attr = array ( ) , $ escape = true ) { return $ this -> start ( $ tag , $ attr ) . ( $ escape ? $ this -> escape ( $ contents ) : $ contents ) . $ this -> end ( $ tag ) ; } | Prints a complete element with content inside |
31,660 | protected function escape ( $ string ) { $ string = HTMLPurifier_Encoder :: cleanUTF8 ( $ string ) ; $ string = htmlspecialchars ( $ string , ENT_COMPAT , 'UTF-8' ) ; return $ string ; } | Escapes a string for HTML output . |
31,661 | protected function listify ( $ array , $ polite = false ) { if ( empty ( $ array ) ) { return 'None' ; } $ ret = '' ; $ i = count ( $ array ) ; foreach ( $ array as $ value ) { $ i -- ; $ ret .= $ value ; if ( $ i > 0 && ! ( $ polite && $ i == 1 ) ) { $ ret .= ', ' ; } if ( $ polite && $ i == 1 ) { $ ret .= 'and ' ; } ... | Takes a list of strings and turns them into a single list |
31,662 | protected function getClass ( $ obj , $ sec_prefix = '' ) { static $ five = null ; if ( $ five === null ) { $ five = version_compare ( PHP_VERSION , '5' , '>=' ) ; } $ prefix = 'HTMLPurifier_' . $ sec_prefix ; if ( ! $ five ) { $ prefix = strtolower ( $ prefix ) ; } $ class = str_replace ( $ prefix , '' , get_class ( $... | Retrieves the class of an object without prefixes as well as metadata |
31,663 | final public function get_url ( ) { global $ PAGE ; $ params = array ( $ this -> get_varsearch ( ) => $ this -> get_search ( ) ) ; return ( $ this -> url !== null ) ? new moodle_url ( $ this -> url , $ params ) : new moodle_url ( $ PAGE -> url , $ params ) ; } | The URL for this search |
31,664 | final public function require_capability ( $ capability , $ user = null ) { if ( ! is_int ( $ user ) ) { $ user = null ; } $ this -> requiredcapabilities [ ] = array ( 'capability' => $ capability , 'user' => $ user ) ; } | Adds a required capability which all results will be checked against |
31,665 | protected function get_searchsql ( ) { global $ DB ; $ ctxselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)" ; $ params = array ( 'contextlevel' => CONTEXT_COURSE , 'fullnamesearch' => '%' . $... | Get the search SQL . |
31,666 | protected function get_searchsql ( ) { global $ DB ; $ ctxselect = ', ' . context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ ctxjoin = "LEFT JOIN {context} ctx ON (ctx.instanceid = c.id AND ctx.contextlevel = :contextlevel)" ; $ params = array ( 'contextlevel' => CONTEXT_COURSECAT , 'namesearch' => '%' . $ ... | Returns the search SQL . |
31,667 | public function search ( $ query ) { if ( $ result = parent :: search ( $ query ) ) { return $ result ; } $ found = false ; foreach ( core_component :: get_plugin_list ( $ this -> subtype ) as $ name => $ notused ) { if ( strpos ( core_text :: strtolower ( get_string ( 'pluginname' , $ this -> subtype . '_' . $ name ) ... | Search plugins for the specified string |
31,668 | public function get_sorted_plugins_list ( ) { $ names = core_component :: get_plugin_list ( $ this -> subtype ) ; $ result = array ( ) ; foreach ( $ names as $ name => $ path ) { $ idx = get_config ( $ this -> subtype . '_' . $ name , 'sortorder' ) ; if ( ! $ idx ) { $ idx = 0 ; } while ( array_key_exists ( $ idx , $ r... | Return a list of plugins sorted by the order defined in the admin interface |
31,669 | private function format_icon_link ( $ action , $ plugin , $ icon , $ alt ) { global $ OUTPUT ; $ url = $ this -> pageurl ; if ( $ action === 'delete' ) { $ url = core_plugin_manager :: instance ( ) -> get_uninstall_url ( $ this -> subtype . '_' . $ plugin , 'manage' ) ; if ( ! $ url ) { return ' ' ; } return html_... | Util function for writing an action icon link |
31,670 | private function view_header ( ) { global $ OUTPUT ; admin_externalpage_setup ( 'manage' . $ this -> subtype . 'plugins' ) ; echo $ OUTPUT -> header ( ) ; echo $ OUTPUT -> heading ( get_string ( 'manage' . $ this -> subtype . 'plugins' , 'assign' ) ) ; } | Write the page header |
31,671 | public function move_plugin ( $ plugintomove , $ dir ) { $ plugins = $ this -> get_sorted_plugins_list ( ) ; $ currentindex = 0 ; $ plugins = array_values ( $ plugins ) ; foreach ( $ plugins as $ key => $ plugin ) { if ( $ plugin == $ plugintomove ) { $ currentindex = $ key ; break ; } } if ( $ dir == 'up' ) { if ( $ c... | Change the order of this plugin . |
31,672 | public function get_calculation_outcome ( $ value , $ ignoredsubtype = false ) { $ diff = static :: get_max_value ( ) - static :: get_min_value ( ) ; if ( ( $ value - static :: get_min_value ( ) ) / $ diff >= 0.5 ) { return self :: OUTCOME_VERY_POSITIVE ; } return self :: OUTCOME_VERY_NEGATIVE ; } | How positive is this calculated value? |
31,673 | public function execute ( ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/repository/lib.php' ) ; $ instances = \ repository :: get_instances ( [ 'type' => 'dropbox' ] ) ; foreach ( $ instances as $ instance ) { $ instance -> cron ( ) ; } } | Run dropbox repository cron . |
31,674 | public static function get ( $ id , $ strictness = MUST_EXIST , $ alwaysreturnhidden = false , $ user = null ) { if ( ! $ id ) { if ( $ alwaysreturnhidden || self :: top ( ) -> is_uservisible ( ) ) { return self :: top ( ) ; } if ( $ strictness == MUST_EXIST ) { throw new moodle_exception ( 'cannotviewcategory' ) ; } r... | Returns coursecat object for requested category |
31,675 | public static function user_top ( ) { $ children = self :: top ( ) -> get_children ( ) ; if ( count ( $ children ) == 1 ) { return reset ( $ children ) ; } if ( count ( $ children ) > 1 ) { return self :: top ( ) ; } return self :: get ( 0 , IGNORE_MISSING ) ; } | Returns the top - most category for the current user |
31,676 | public static function get_many ( array $ ids ) { global $ DB ; $ coursecatrecordcache = cache :: make ( 'core' , 'coursecatrecords' ) ; $ categories = $ coursecatrecordcache -> get_many ( $ ids ) ; $ toload = array ( ) ; foreach ( $ categories as $ id => $ result ) { if ( $ result === false ) { $ toload [ ] = $ id ; }... | Load many core_course_category objects . |
31,677 | public static function get_all ( $ options = [ ] ) { global $ DB ; $ coursecatrecordcache = cache :: make ( 'core' , 'coursecatrecords' ) ; $ catcontextsql = \ context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ catsql = "SELECT cc.*, {$catcontextsql} FROM {course_categories} cc ... | Load all core_course_category objects . |
31,678 | public static function get_default ( ) { if ( $ visiblechildren = self :: top ( ) -> get_children ( ) ) { $ defcategory = reset ( $ visiblechildren ) ; } else { $ toplevelcategories = self :: get_tree ( 0 ) ; $ defcategoryid = $ toplevelcategories [ 0 ] ; $ defcategory = self :: get ( $ defcategoryid , MUST_EXIST , tru... | Returns the first found category |
31,679 | public static function can_view_category ( $ category , $ user = null ) { if ( ! $ category -> id ) { return has_capability ( 'moodle/category:viewcourselist' , context_system :: instance ( ) , $ user ) ; } $ context = context_coursecat :: instance ( $ category -> id ) ; if ( ! $ category -> visible && ! has_capability... | Checks if current user has access to the category |
31,680 | public static function can_view_course_info ( $ course , $ user = null ) { if ( $ course -> id == SITEID ) { return true ; } if ( ! $ course -> visible ) { $ coursecontext = context_course :: instance ( $ course -> id ) ; if ( ! has_capability ( 'moodle/course:viewhiddencourses' , $ coursecontext , $ user ) ) { return ... | Checks if current user can view course information or enrolment page . |
31,681 | public function get_db_record ( ) { global $ DB ; if ( $ record = $ DB -> get_record ( 'course_categories' , array ( 'id' => $ this -> id ) ) ) { return $ record ; } else { return ( object ) convert_to_array ( $ this ) ; } } | Returns the complete corresponding record from DB table course_categories |
31,682 | protected static function get_tree ( $ id ) { global $ DB ; $ coursecattreecache = cache :: make ( 'core' , 'coursecattree' ) ; $ rv = $ coursecattreecache -> get ( $ id ) ; if ( $ rv !== false ) { return $ rv ; } $ sql = "SELECT cc.id, cc.parent, cc.visible FROM {course_categories} cc ORD... | Returns the entry from categories tree and makes sure the application - level tree cache is built |
31,683 | protected static function get_records ( $ whereclause , $ params ) { global $ DB ; $ fields = array_keys ( array_filter ( self :: $ coursecatfields ) ) ; $ ctxselect = context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ sql = "SELECT cc." . join ( ',cc.' , $ fields ) . ", $ctxselect FROM {cour... | Retrieves number of records from course_categories table |
31,684 | public static function role_assignment_changed ( $ roleid , $ context ) { global $ CFG , $ DB ; if ( $ context -> contextlevel > CONTEXT_COURSE ) { return ; } cache_helper :: purge_by_event ( 'changesincategoryenrolment' ) ; if ( ! $ CFG -> coursecontact || ! in_array ( $ roleid , explode ( ',' , $ CFG -> coursecontact... | Resets course contact caches when role assignments were changed |
31,685 | public static function user_enrolment_changed ( $ courseid , $ userid , $ status , $ timestart = null , $ timeend = null ) { $ cache = cache :: make ( 'core' , 'coursecontacts' ) ; $ contacts = $ cache -> get ( $ courseid ) ; if ( $ contacts === false ) { return ; } $ enrolmentactive = ( $ status == 0 ) && ( ! $ timest... | Executed when user enrolment was changed to check if course contacts cache needs to be cleared |
31,686 | public static function preload_custom_fields ( array & $ records ) { $ customfields = \ core_course \ customfield \ course_handler :: create ( ) -> get_instances_data ( array_keys ( $ records ) ) ; foreach ( $ customfields as $ courseid => $ data ) { $ records [ $ courseid ] -> customfields = $ data ; } } | Preloads the custom fields values in bulk |
31,687 | protected static function ensure_users_enrolled ( $ courseusers ) { global $ DB ; $ maxcoursesinquery = 20 ; if ( count ( $ courseusers ) > $ maxcoursesinquery ) { $ rv = array ( ) ; for ( $ offset = 0 ; $ offset < count ( $ courseusers ) ; $ offset += $ maxcoursesinquery ) { $ chunk = array_slice ( $ courseusers , $ o... | Verify user enrollments for multiple course - user combinations |
31,688 | protected static function get_course_records ( $ whereclause , $ params , $ options , $ checkvisibility = false ) { global $ DB ; $ ctxselect = context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; $ fields = array ( 'c.id' , 'c.category' , 'c.sortorder' , 'c.shortname' , 'c.fullname' , 'c.idnumber' , 'c.startda... | Retrieves number of records from course table |
31,689 | protected function get_not_visible_children_ids ( ) { global $ DB ; $ coursecatcache = cache :: make ( 'core' , 'coursecat' ) ; if ( ( $ invisibleids = $ coursecatcache -> get ( 'ic' . $ this -> id ) ) === false ) { $ hidden = self :: get_tree ( $ this -> id . 'i' ) ; $ catids = self :: get_tree ( $ this -> id ) ; $ in... | Returns array of ids of children categories that current user can not see |
31,690 | protected static function sort_records ( & $ records , $ sortfields ) { if ( empty ( $ records ) ) { return ; } if ( array_key_exists ( 'displayname' , $ sortfields ) ) { foreach ( $ records as $ key => $ record ) { if ( ! isset ( $ record -> displayname ) ) { $ records [ $ key ] -> displayname = get_course_display_nam... | Sorts list of records by several fields |
31,691 | public static function has_capability_on_any ( $ capabilities ) { global $ DB ; if ( ! isloggedin ( ) || isguestuser ( ) ) { return false ; } if ( ! is_array ( $ capabilities ) ) { $ capabilities = array ( $ capabilities ) ; } $ keys = array ( ) ; foreach ( $ capabilities as $ capability ) { $ keys [ $ capability ] = s... | Checks if the user has at least one of the given capabilities on any category . |
31,692 | public function get_children_count ( ) { $ sortedids = self :: get_tree ( $ this -> id ) ; $ invisibleids = $ this -> get_not_visible_children_ids ( ) ; return count ( $ sortedids ) - count ( $ invisibleids ) ; } | Returns number of subcategories visible to the current user |
31,693 | public static function search_courses_count ( $ search , $ options = array ( ) , $ requiredcapabilities = array ( ) ) { $ coursecatcache = cache :: make ( 'core' , 'coursecat' ) ; $ cntcachekey = 'scnt-' . serialize ( $ search ) . serialize ( $ requiredcapabilities ) ; if ( ( $ cnt = $ coursecatcache -> get ( $ cntcach... | Returns number of courses in the search results |
31,694 | public function get_courses_count ( $ options = array ( ) ) { $ cntcachekey = 'lcnt-' . $ this -> id . '-' . ( ! empty ( $ options [ 'recursive' ] ) ? 'r' : '' ) ; $ coursecatcache = cache :: make ( 'core' , 'coursecat' ) ; if ( ( $ cnt = $ coursecatcache -> get ( $ cntcachekey ) ) === false ) { unset ( $ options [ 'of... | Returns number of courses visible to the user |
31,695 | public function can_delete_full ( ) { global $ DB ; if ( ! $ this -> id ) { return false ; } $ context = $ this -> get_context ( ) ; if ( ! $ this -> is_uservisible ( ) || ! has_capability ( 'moodle/category:manage' , $ context ) ) { return false ; } $ sql = context_helper :: get_preload_record_columns_sql ( 'ctx' ) ; ... | Returns true if user can delete current category and all its contents |
31,696 | public function delete_full ( $ showfeedback = true ) { global $ CFG , $ DB ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; require_once ( $ CFG -> libdir . '/questionlib.php' ) ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ settimeout = core_php_time_limit :: raise ( ) ; if ( $ pluginsfunction = ge... | Recursively delete category including all subcategories and courses |
31,697 | public function can_move_content_to ( $ newcatid ) { global $ CFG ; require_once ( $ CFG -> libdir . '/questionlib.php' ) ; $ context = $ this -> get_context ( ) ; if ( ! $ this -> is_uservisible ( ) || ! has_capability ( 'moodle/category:manage' , $ context ) ) { return false ; } $ testcaps = array ( ) ; if ( $ this -... | Checks if user has capability to move all category content to the new parent before removing this category |
31,698 | public function can_change_parent ( $ newparentcat ) { if ( ! has_capability ( 'moodle/category:manage' , $ this -> get_context ( ) ) ) { return false ; } if ( is_object ( $ newparentcat ) ) { $ newparentcat = self :: get ( $ newparentcat -> id , IGNORE_MISSING ) ; } else { $ newparentcat = self :: get ( ( int ) $ newp... | Checks if user can move current category to the new parent |
31,699 | protected function change_parent_raw ( core_course_category $ newparentcat ) { global $ DB ; $ context = $ this -> get_context ( ) ; $ hidecat = false ; if ( empty ( $ newparentcat -> id ) ) { $ DB -> set_field ( 'course_categories' , 'parent' , 0 , array ( 'id' => $ this -> id ) ) ; $ newparent = context_system :: ins... | Moves the category under another parent category . All associated contexts are moved as well |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.