idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
33,100
public function load ( $ areaid ) { global $ DB ; $ this -> areacache = $ DB -> get_record ( 'grading_areas' , array ( 'id' => $ areaid ) , '*' , MUST_EXIST ) ; $ this -> context = context :: instance_by_id ( $ this -> areacache -> contextid , MUST_EXIST ) ; $ this -> component = $ this -> areacache -> component ; $ th...
Loads the gradable area info from the database
33,101
public static function available_methods ( $ includenone = true ) { if ( $ includenone ) { $ list = array ( '' => get_string ( 'gradingmethodnone' , 'core_grading' ) ) ; } else { $ list = array ( ) ; } foreach ( core_component :: get_plugin_list ( 'gradingform' ) as $ name => $ location ) { $ list [ $ name ] = get_stri...
Returns the list of installed grading plugins together optionally extended with a simple direct grading .
33,102
public static function available_areas ( $ component ) { global $ CFG ; list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ component ) ; if ( $ component === 'core_grading' ) { return array ( ) ; } else if ( $ plugintype === 'mod' ) { return plugin_callback ( 'mod' , $ pluginname , 'gradin...
Returns the list of gradable areas provided by the given component
33,103
public function get_available_areas ( ) { global $ CFG ; $ this -> ensure_isset ( array ( 'context' , 'component' ) ) ; if ( $ this -> get_context ( ) -> contextlevel == CONTEXT_SYSTEM ) { if ( $ this -> get_component ( ) !== 'core_grading' ) { throw new coding_exception ( 'Unsupported component at the system context' ...
Returns the list of gradable areas in the given context and component
33,104
public function get_active_method ( ) { global $ DB ; $ this -> ensure_isset ( array ( 'context' , 'component' , 'area' ) ) ; if ( is_null ( $ this -> areacache ) ) { $ this -> areacache = $ DB -> get_record ( 'grading_areas' , array ( 'contextid' => $ this -> context -> id , 'component' => $ this -> component , 'arean...
Returns the currently active grading method in the gradable area
33,105
public function set_active_method ( $ method ) { global $ DB ; $ this -> ensure_isset ( array ( 'context' , 'component' , 'area' ) ) ; if ( empty ( $ method ) ) { $ method = null ; } else { if ( 'gradingform_' . $ method !== clean_param ( 'gradingform_' . $ method , PARAM_COMPONENT ) ) { throw new moodle_exception ( 'i...
Sets the currently active grading method in the gradable area
33,106
public function extend_settings_navigation ( settings_navigation $ settingsnav , navigation_node $ modulenode = null ) { $ this -> ensure_isset ( array ( 'context' , 'component' ) ) ; $ areas = $ this -> get_available_areas ( ) ; if ( empty ( $ areas ) ) { return ; } else if ( count ( $ areas ) == 1 ) { $ areatitle = r...
Extends the settings navigation with the grading settings
33,107
public function extend_navigation ( global_navigation $ navigation , navigation_node $ modulenode = null ) { $ this -> ensure_isset ( array ( 'context' , 'component' ) ) ; $ areas = $ this -> get_available_areas ( ) ; foreach ( $ areas as $ areaname => $ areatitle ) { $ this -> set_area ( $ areaname ) ; if ( $ controll...
Extends the module navigation with the advanced grading information
33,108
public function get_controller ( $ method ) { global $ CFG , $ DB ; $ this -> ensure_isset ( array ( 'context' , 'component' , 'area' ) ) ; if ( 'gradingform_' . $ method !== clean_param ( 'gradingform_' . $ method , PARAM_COMPONENT ) ) { throw new moodle_exception ( 'invalid_method_name' , 'core_grading' ) ; } $ avail...
Returns the given method s controller in the gradable area
33,109
public function get_active_controller ( ) { if ( $ gradingmethod = $ this -> get_active_method ( ) ) { $ controller = $ this -> get_controller ( $ gradingmethod ) ; if ( $ controller -> is_form_available ( ) ) { return $ controller ; } } return null ; }
Returns the controller for the active method if it is available
33,110
public function get_management_url ( moodle_url $ returnurl = null ) { $ this -> ensure_isset ( array ( 'context' , 'component' ) ) ; if ( $ this -> areacache ) { $ params = array ( 'areaid' => $ this -> areacache -> id ) ; } else { $ params = array ( 'contextid' => $ this -> context -> id , 'component' => $ this -> co...
Returns the URL of the grading area management page
33,111
public function create_shared_area ( $ method ) { global $ DB ; $ name = $ method . '_' . sha1 ( rand ( ) . uniqid ( $ method , true ) ) ; $ area = array ( 'contextid' => context_system :: instance ( ) -> id , 'component' => 'core_grading' , 'areaname' => $ name , 'activemethod' => $ method ) ; return $ DB -> insert_re...
Creates a new shared area to hold a grading form template
33,112
public static function delete_all_for_context ( $ contextid ) { global $ DB ; $ areaids = $ DB -> get_fieldset_select ( 'grading_areas' , 'id' , 'contextid = ?' , array ( $ contextid ) ) ; $ methods = array_keys ( self :: available_methods ( false ) ) ; foreach ( $ areaids as $ areaid ) { $ manager = get_grading_manage...
Removes all data associated with the given context
33,113
public static function tokenize ( $ needle ) { if ( preg_match ( '/^[\s]*"[\s]*(.*?)[\s]*"[\s]*$/' , $ needle , $ matches ) ) { $ token = $ matches [ 1 ] ; if ( $ token === '' ) { return array ( ) ; } else { return array ( $ token ) ; } } $ tokens = preg_split ( "/\W/u" , $ needle ) ; $ tokens = array_filter ( $ tokens...
Helper method to tokenize the given string
33,114
private function ensure_isset ( array $ properties ) { foreach ( $ properties as $ property ) { if ( ! isset ( $ this -> $ property ) ) { throw new coding_exception ( 'The property "' . $ property . '" is not set.' ) ; } } }
Make sure that the given properties were set to some not - null value
33,115
public function delete_all_items ( ) { $ items = $ this -> get_items ( ) ; foreach ( $ items as $ item ) { if ( $ this -> can_delete ( ) ) { $ this -> delete_item ( $ item ) ; } } }
Empty the recycle bin .
33,116
public function delete ( ) : bool { global $ DB ; $ fs = get_file_storage ( ) ; $ fs -> delete_area_files ( $ this -> get_handler ( ) -> get_configuration_context ( ) -> id , 'customfield_textarea' , 'defaultvalue' , $ this -> get ( 'id' ) ) ; $ params = [ 'component' => 'customfield_textarea' , 'filearea' => 'value' ,...
Before delete bulk actions
33,117
public function prepare_for_config_form ( \ stdClass $ formdata ) { if ( ! empty ( $ formdata -> configdata [ 'defaultvalue' ] ) ) { $ textoptions = $ this -> value_editor_options ( ) ; $ context = $ textoptions [ 'context' ] ; $ record = new \ stdClass ( ) ; $ record -> defaultvalue = $ formdata -> configdata [ 'defau...
Prepare the field data to set in the configuration form
33,118
public function value_editor_options ( \ context $ context = null ) { global $ CFG ; require_once ( $ CFG -> libdir . '/formslib.php' ) ; if ( ! $ context ) { $ context = $ this -> get_handler ( ) -> get_configuration_context ( ) ; } return [ 'maxfiles' => EDITOR_UNLIMITED_FILES , 'maxbytes' => $ CFG -> maxbytes , 'con...
Options for editor
33,119
public function save ( ) { $ configdata = $ this -> get ( 'configdata' ) ; if ( ! array_key_exists ( 'defaultvalue_editor' , $ configdata ) ) { $ this -> field -> save ( ) ; return ; } if ( ! $ this -> get ( 'id' ) ) { $ this -> field -> save ( ) ; } $ textoptions = $ this -> value_editor_options ( ) ; $ tempvalue = ( ...
Saves the field configuration
33,120
public function get_context_from_competency ( competency $ competency ) { $ frameworkid = $ competency -> get ( 'competencyframeworkid' ) ; if ( ! isset ( $ this -> frameworkscontexts [ $ frameworkid ] ) ) { $ framework = $ this -> get_framework_from_competency ( $ competency ) ; $ this -> frameworkscontexts [ $ framew...
Get the context of a competency .
33,121
public function get_framework_from_competency ( competency $ competency ) { $ frameworkid = $ competency -> get ( 'competencyframeworkid' ) ; if ( ! isset ( $ this -> frameworks [ $ frameworkid ] ) ) { $ this -> frameworks [ $ frameworkid ] = $ competency -> get_framework ( ) ; } return $ this -> frameworks [ $ framewo...
Get the framework of a competency .
33,122
public function get_scale_from_competency ( competency $ competency ) { $ scaleid = $ competency -> get ( 'scaleid' ) ; if ( $ scaleid !== null && ! isset ( $ this -> scales [ $ scaleid ] ) ) { $ this -> scales [ $ scaleid ] = $ competency -> get_scale ( ) ; } else if ( $ scaleid === null ) { $ framework = $ this -> ge...
Get the scale of a competency .
33,123
public function ingest_framework ( competency_framework $ framework ) { $ id = $ framework -> get ( 'id' ) ; $ this -> frameworks [ $ id ] = $ framework ; }
Ingest a framework to avoid additional fetching .
33,124
public static function validate_context ( $ context ) { global $ CFG , $ PAGE ; if ( empty ( $ context ) ) { throw new invalid_parameter_exception ( 'Context does not exist' ) ; } if ( empty ( self :: $ contextrestriction ) ) { self :: $ contextrestriction = context_system :: instance ( ) ; } $ rcontext = self :: $ con...
Makes sure user may execute functions in this context .
33,125
protected static function get_context_from_params ( $ param ) { $ levels = context_helper :: get_all_levels ( ) ; if ( ! empty ( $ param [ 'contextid' ] ) ) { return context :: instance_by_id ( $ param [ 'contextid' ] , IGNORE_MISSING ) ; } else if ( ! empty ( $ param [ 'contextlevel' ] ) && isset ( $ param [ 'instance...
Get context from passed parameters . The passed array must either contain a contextid or a combination of context level and instance id to fetch the context . For example the context level can be course and instanceid can be courseid .
33,126
public static function validate_courses ( $ courseids , $ courses = array ( ) , $ addcontext = false ) { $ courseids = array_unique ( $ courseids ) ; $ warnings = array ( ) ; $ courses = array_intersect_key ( $ courses , array_flip ( $ courseids ) ) ; foreach ( $ courseids as $ cid ) { try { $ context = context_course ...
Validate a list of courses returning the complete course objects for valid courses .
33,127
public static function get_properties_for_exporter ( ) { return [ 'filename' => array ( 'type' => PARAM_FILE , 'description' => 'File name.' , 'optional' => true , 'null' => NULL_NOT_ALLOWED , ) , 'filepath' => array ( 'type' => PARAM_PATH , 'description' => 'File path.' , 'optional' => true , 'null' => NULL_NOT_ALLOWE...
Return the properties ready to be used by an exporter .
33,128
public function getFieldSQL ( $ xmldb_table , $ xmldb_field , $ skip_type_clause = NULL , $ skip_default_clause = NULL , $ skip_notnull_clause = NULL , $ specify_nulls_clause = NULL , $ specify_field_name = true ) { if ( $ error = $ xmldb_field -> validateDefinition ( $ xmldb_table ) ) { throw new coding_exception ( $ ...
Given one correct xmldb_field returns the complete SQL line to create it .
33,129
public function getKeySQL ( $ xmldb_table , $ xmldb_key ) { $ key = '' ; switch ( $ xmldb_key -> getType ( ) ) { case XMLDB_KEY_PRIMARY : if ( $ this -> primary_keys ) { if ( $ this -> primary_key_name !== null ) { $ key = $ this -> getEncQuoted ( $ this -> primary_key_name ) ; } else { $ key = $ this -> getNameForObje...
Given one correct xmldb_key returns its specs .
33,130
public function getDefaultValue ( $ xmldb_field ) { $ default = null ; if ( $ xmldb_field -> getDefault ( ) !== NULL ) { if ( $ xmldb_field -> getType ( ) == XMLDB_TYPE_CHAR || $ xmldb_field -> getType ( ) == XMLDB_TYPE_TEXT ) { if ( $ xmldb_field -> getDefault ( ) === '' ) { $ default = "'" . $ this -> default_for_cha...
Give one xmldb_field returns the correct default value for the current configuration
33,131
public function getDefaultClause ( $ xmldb_field ) { $ defaultvalue = $ this -> getDefaultValue ( $ xmldb_field ) ; if ( $ defaultvalue !== null ) { return ' DEFAULT ' . $ defaultvalue ; } else { return null ; } }
Given one xmldb_field returns the correct default clause for the current configuration .
33,132
public function getDropFieldSQL ( $ xmldb_table , $ xmldb_field ) { $ results = array ( ) ; $ tablename = $ this -> getTableName ( $ xmldb_table ) ; $ fieldname = $ this -> getEncQuoted ( $ xmldb_field -> getName ( ) ) ; $ results [ ] = 'ALTER TABLE ' . $ tablename . ' DROP COLUMN ' . $ fieldname ; return $ results ; }
Given one xmldb_table and one xmldb_field return the SQL statements needed to drop the field from the table .
33,133
function getRenameIndexSQL ( $ xmldb_table , $ xmldb_index , $ newname ) { if ( empty ( $ this -> rename_index_sql ) ) { return array ( ) ; } $ dbindexname = $ this -> mdb -> get_manager ( ) -> find_index_name ( $ xmldb_table , $ xmldb_index ) ; $ renamesql = str_replace ( 'TABLENAME' , $ this -> getTableName ( $ xmldb...
Given one xmldb_table and one xmldb_index return the SQL statements needed to rename the index in the table Experimental! Shouldn t be used at all!
33,134
function getExecuteInsertSQL ( $ statement ) { $ results = array ( ) ; if ( $ sentences = $ statement -> getSentences ( ) ) { foreach ( $ sentences as $ sentence ) { $ fields = $ statement -> getFieldsFromInsertSentence ( $ sentence ) ; $ values = $ statement -> getValuesFromInsertSentence ( $ sentence ) ; foreach ( $ ...
Given one XMLDB Statement build the needed SQL insert sentences to execute it .
33,135
public static function getAllReservedWords ( ) { global $ CFG ; $ generators = array ( 'mysql' , 'postgres' , 'oracle' , 'mssql' ) ; $ reserved_words = array ( ) ; foreach ( $ generators as $ generator ) { $ class = $ generator . '_sql_generator' ; require_once ( "$CFG->libdir/ddl/$class.php" ) ; foreach ( call_user_fu...
Returns all reserved words in supported databases . Reserved words should be lowercase .
33,136
public function get_nullable_fields_in_index ( $ xmldb_table , $ xmldb_index ) { global $ DB ; $ fieldsfromdb = null ; $ nullablefields = [ ] ; foreach ( $ xmldb_index -> getFields ( ) as $ fieldname ) { if ( $ field = $ xmldb_table -> getField ( $ fieldname ) ) { if ( $ field -> getNotNull ( ) !== XMLDB_NOTNULL ) { $ ...
Get the fields from an index definition that might be null .
33,137
public static function get_signup_settings_returns ( ) { return new external_single_structure ( array ( 'namefields' => new external_multiple_structure ( new external_value ( PARAM_NOTAGS , 'The order of the name fields' ) ) , 'passwordpolicy' => new external_value ( PARAM_RAW , 'Password policy' , VALUE_OPTIONAL ) , '...
Describes the get_signup_settings return value .
33,138
public static function signup_user_parameters ( ) { return new external_function_parameters ( array ( 'username' => new external_value ( core_user :: get_property_type ( 'username' ) , 'Username' ) , 'password' => new external_value ( core_user :: get_property_type ( 'password' ) , 'Plain text password' ) , 'firstname'...
Describes the parameters for signup_user .
33,139
public function stream_open ( $ path , $ mode , $ options , & $ openedPath ) { $ this -> initProtocol ( $ path ) ; $ this -> mode = $ mode ; if ( $ mode === 'r' ) { return $ this -> initReadableStream ( ) ; } if ( $ mode === 'w' ) { return $ this -> initWritableStream ( ) ; } return false ; }
Opens the stream .
33,140
public function stream_seek ( $ offset , $ whence = \ SEEK_SET ) { $ size = $ this -> stream -> getSize ( ) ; if ( $ whence === \ SEEK_CUR ) { $ offset += $ this -> stream -> tell ( ) ; } if ( $ whence === \ SEEK_END ) { $ offset += $ size ; } if ( $ this -> stream instanceof WritableStream ) { return $ offset === $ si...
Return the current position of the stream .
33,141
public function stream_stat ( ) { $ stat = $ this -> getStatTemplate ( ) ; $ stat [ 2 ] = $ stat [ 'mode' ] = $ this -> stream instanceof ReadableStream ? 0100444 : 0100222 ; $ stat [ 7 ] = $ stat [ 'size' ] = $ this -> stream -> getSize ( ) ; $ file = $ this -> stream -> getFile ( ) ; if ( isset ( $ file -> uploadDate...
Return information about the stream .
33,142
private function initReadableStream ( ) { $ context = stream_context_get_options ( $ this -> context ) ; $ this -> stream = new ReadableStream ( $ context [ $ this -> protocol ] [ 'collectionWrapper' ] , $ context [ $ this -> protocol ] [ 'file' ] ) ; return true ; }
Initialize the internal stream for reading .
33,143
private function initWritableStream ( ) { $ context = stream_context_get_options ( $ this -> context ) ; $ this -> stream = new WritableStream ( $ context [ $ this -> protocol ] [ 'collectionWrapper' ] , $ context [ $ this -> protocol ] [ 'filename' ] , $ context [ $ this -> protocol ] [ 'options' ] ) ; return true ; }
Initialize the internal stream for writing .
33,144
protected static function get_file_list ( $ directory ) { global $ CFG ; $ directoryroot = $ CFG -> dirroot ; $ finalfiles = array ( ) ; if ( is_dir ( $ directory ) ) { if ( $ handle = opendir ( $ directory ) ) { $ files = scandir ( $ directory ) ; foreach ( $ files as $ file ) { if ( $ file != '.' && $ file != '..' ) ...
Returns a list of files with a full directory path in a specified directory .
33,145
public static function get_all_eventlist ( $ withoutcomponent = false ) { if ( $ withoutcomponent ) { $ return = array_merge ( self :: get_core_eventlist ( ) , self :: get_non_core_eventlist ( $ withoutcomponent ) ) ; array_multisort ( $ return , SORT_NATURAL ) ; } else { $ return = array_merge ( array ( 'core' => self...
Get a list of events present in the system .
33,146
public static function get_plugin_list ( $ eventlist = array ( ) ) { if ( empty ( $ eventlist ) ) { $ eventlist = self :: get_all_eventlist ( ) ; } $ plugins = array_keys ( $ eventlist ) ; $ return = array ( ) ; foreach ( $ plugins as $ plugin ) { if ( $ plugin === 'core' ) { $ return [ $ plugin ] = get_string ( 'core'...
Return list of plugins that have events .
33,147
public static function validate_event_plugin ( $ plugin , $ eventname , $ eventlist = array ( ) ) { if ( empty ( $ eventlist ) ) { $ eventlist = self :: get_all_eventlist ( ) ; } if ( isset ( $ eventlist [ $ plugin ] [ $ eventname ] ) ) { return true ; } return false ; }
validate if the given event belongs to the given plugin .
33,148
public static function get_size_choices ( ) { $ options = array ( ) ; for ( $ size = self :: MIN_SIZE ; $ size <= self :: MAX_SIZE ; $ size ++ ) { $ options [ $ size ] = get_string ( 'sitesize_' . $ size , 'tool_generator' ) ; } return $ options ; }
Gets a list of size choices supported by this backend .
33,149
protected function run_create_course ( $ shortname , $ coursesize ) { $ command = 'php admin/tool/generator/cli/maketestcourse.php' ; $ options = array ( '--shortname="' . $ shortname . '"' , '--size="' . get_string ( 'shortsize_' . $ coursesize , 'tool_generator' ) . '"' ) ; if ( ! $ this -> progress ) { $ options [ ]...
Creates a course with the specified shortname coursesize and the provided maketestsite options .
33,150
public function is_ready ( ) { if ( empty ( $ this -> pathtopython ) ) { $ settingurl = new \ moodle_url ( '/admin/settings.php' , array ( 'section' => 'systempaths' ) ) ; return get_string ( 'pythonpathnotdefined' , 'mlbackend_python' , $ settingurl -> out ( ) ) ; } $ cmd = "{$this->pathtopython} -m moodlemlbackend.ve...
Is the plugin ready to be used? .
33,151
public static function check_pip_package_version ( $ actual , $ required = self :: REQUIRED_PIP_PACKAGE_VERSION ) { if ( empty ( $ actual ) ) { return - 1 ; } if ( version_compare ( $ actual , $ required , '<' ) ) { return - 1 ; } $ parts = explode ( '.' , $ required ) ; $ requiredapiver = reset ( $ parts ) ; $ parts =...
Check that the given package version can be used and return the error status .
33,152
public static function course_module_criteria_review ( \ core \ event \ course_module_completion_updated $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; $ eventdata = $ event -> get_record_snapshot ( 'course_modules_completion' , $ ...
Triggered when course_module_completion_updated event is triggered .
33,153
public static function competency_criteria_review ( \ core \ event \ competency_evidence_created $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; if ( ! get_config ( 'core_competency' , 'enabled' ) ) { return ; } $ ucid = $ event -> ...
Triggered when \ core \ event \ competency_evidence_created event is triggered .
33,154
public static function course_criteria_review ( \ core \ event \ course_completed $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; $ userid = $ event -> relateduserid ; $ courseid = $ event -> courseid ; if ( $ rs = $ DB -> get_recor...
Triggered when course_completed event is triggered .
33,155
public static function badge_criteria_review ( \ core \ event \ badge_awarded $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; $ userid = $ event -> relateduserid ; if ( $ rs = $ DB -> get_records ( 'badge_criteria' , array ( 'criter...
Triggered when badge_awarded event happens .
33,156
public static function profile_criteria_review ( \ core \ event \ user_updated $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; $ userid = $ event -> objectid ; if ( $ rs = $ DB -> get_records ( 'badge_criteria' , array ( 'criteriaty...
Triggered when user_updated event happens .
33,157
public static function cohort_criteria_review ( \ core \ event \ cohort_member_added $ event ) { global $ DB , $ CFG ; if ( ! empty ( $ CFG -> enablebadges ) ) { require_once ( $ CFG -> dirroot . '/lib/badgeslib.php' ) ; $ cohortid = $ event -> objectid ; $ userid = $ event -> relateduserid ; $ badgesql = "SELECT badge...
Triggered when the cohort_member_added event happens .
33,158
protected function _init ( ) { if ( ! isset ( $ this -> _ob ) || ( $ this -> _ob -> md5 != hash ( 'md5' , $ this -> key ) ) ) { switch ( $ this -> cipher ) { case 'cbc' : $ this -> _ob = new Horde_Crypt_Blowfish_Php_Cbc ( $ this -> key ) ; break ; case 'ecb' : $ this -> _ob = new Horde_Crypt_Blowfish_Php_Ecb ( $ this -...
Initialize the subclass .
33,159
public function get_name ( ) { if ( get_string_manager ( ) -> string_exists ( 'pluginname' , $ this -> component ) ) { return get_string ( 'pluginname' , $ this -> component ) ; } return $ this -> store ; }
Default get name api .
33,160
public function get_description ( ) { if ( get_string_manager ( ) -> string_exists ( 'pluginname_desc' , $ this -> component ) ) { return get_string ( 'pluginname_desc' , $ this -> component ) ; } return $ this -> store ; }
Default get description method .
33,161
public static function decode_other ( ? string $ other ) { if ( $ other === 'N;' || preg_match ( '~^.:~' , $ other ) ) { return unserialize ( $ other ) ; } else { return json_decode ( $ other , true ) ; } }
Function decodes the other field into an array using either PHP serialisation or JSON .
33,162
public function decode_content ( $ content ) { if ( ! $ content = $ this -> precheck_content ( $ content ) ) { return false ; } foreach ( $ this -> rules as $ rule ) { $ content = $ rule -> decode ( $ content ) ; } return $ content ; }
Receive content from restore_decode_content objects and apply all the restore_decode_rules to them
33,163
public function removeSelector ( $ mSelector ) { if ( $ mSelector instanceof Selector ) { $ mSelector = $ mSelector -> getSelector ( ) ; } foreach ( $ this -> aSelectors as $ iKey => $ oSelector ) { if ( $ oSelector -> getSelector ( ) === $ mSelector ) { unset ( $ this -> aSelectors [ $ iKey ] ) ; return true ; } } ret...
remove one of the selector of the block
33,164
public function get_endpoint_url ( $ type ) { $ endpoint = endpoint :: get_record ( [ 'issuerid' => $ this -> get ( 'id' ) , 'name' => $ type . '_endpoint' ] ) ; if ( $ endpoint ) { return $ endpoint -> get ( 'url' ) ; } return false ; }
Helper the get a named service endpoint .
33,165
public function is_valid_login_domain ( $ email ) { if ( empty ( $ this -> get ( 'alloweddomains' ) ) ) { return true ; } $ validdomains = explode ( ',' , $ this -> get ( 'alloweddomains' ) ) ; $ parts = explode ( '@' , $ email , 2 ) ; $ emaildomain = '' ; if ( count ( $ parts ) > 1 ) { $ emaildomain = $ parts [ 1 ] ; ...
Perform matching against the list of allowed login domains for this issuer .
33,166
public function is_system_account_connected ( ) { if ( ! $ this -> is_configured ( ) ) { return false ; } $ sys = system_account :: get_record ( [ 'issuerid' => $ this -> get ( 'id' ) ] ) ; if ( empty ( $ sys ) || empty ( $ sys -> get ( 'refreshtoken' ) ) ) { return false ; } $ scopes = api :: get_system_scopes_for_iss...
Do we have a refresh token for a system account?
33,167
protected function validate_baseurl ( $ value ) { global $ CFG ; include_once ( $ CFG -> dirroot . '/lib/validateurlsyntax.php' ) ; if ( ! empty ( $ value ) && ! validateUrlSyntax ( $ value , 'S+' ) ) { return new lang_string ( 'sslonlyaccess' , 'error' ) ; } return true ; }
Custom validator for end point URLs . Because we send Bearer tokens we must ensure SSL .
33,168
public function find_problems ( ) { global $ DB ; static $ answer = null ; if ( is_null ( $ answer ) ) { $ categories = $ DB -> get_records ( 'course_categories' , array ( ) , 'id' ) ; $ missingparent = tool_health_category_find_missing_parents ( $ categories ) ; $ loops = tool_health_category_find_loops ( $ categories...
Search for problems in the course categories .
33,169
public function exists ( ) { list ( $ missingparent , $ loops ) = $ this -> find_problems ( ) ; return ! empty ( $ missingparent ) || ! empty ( $ loops ) ; }
Check if the problem exists .
33,170
public function description ( ) { list ( $ missingparent , $ loops ) = $ this -> find_problems ( ) ; $ description = '<p>The course categories should be arranged into tree ' . ' structures by the course_categories.parent field. Sometimes ' . ' this tree structure gets messed up.</p>' ; $ description .= tool_health_cate...
Generate problem description .
33,171
public function solution ( ) { global $ CFG ; list ( $ missingparent , $ loops ) = $ this -> find_problems ( ) ; $ solution = '<p>Consider executing the following SQL queries. These fix ' . 'the problem by moving some categories to the top level.</p>' ; if ( ! empty ( $ missingparent ) ) { $ solution .= "<pre>UPDATE " ...
Generate solution text .
33,172
public function get_description_editor_options ( ) { global $ CFG ; $ context = $ this -> _customdata [ 'context' ] ; $ itemid = $ this -> _customdata [ 'itemid' ] ; return array ( 'maxfiles' => EDITOR_UNLIMITED_FILES , 'maxbytes' => $ CFG -> maxbytes , 'trusttext' => true , 'context' => $ context , 'subdirs' => file_a...
Returns the description editor options .
33,173
public function validation ( $ data , $ files ) { global $ DB ; $ errors = parent :: validation ( $ data , $ files ) ; if ( ! empty ( $ data [ 'idnumber' ] ) ) { if ( $ existing = $ DB -> get_record ( 'course_categories' , array ( 'idnumber' => $ data [ 'idnumber' ] ) ) ) { if ( ! $ data [ 'id' ] || $ existing -> id !=...
Validates the data submit for this form .
33,174
public function close ( ) { global $ CFG ; foreach ( $ this -> objPHPExcel -> getAllSheets ( ) as $ sheet ) { $ sheet -> setSelectedCells ( 'A1' ) ; } $ this -> objPHPExcel -> setActiveSheetIndex ( 0 ) ; $ filename = preg_replace ( '/\.xlsx?$/i' , '' , $ this -> filename ) ; $ mimetype = 'application/vnd.openxmlformats...
Close the Moodle Workbook
33,175
public function insert_bitmap ( $ row , $ col , $ bitmap , $ x = 0 , $ y = 0 , $ scale_x = 1 , $ scale_y = 1 ) { $ objDrawing = new PHPExcel_Worksheet_Drawing ( ) ; $ objDrawing -> setPath ( $ bitmap ) ; $ objDrawing -> setCoordinates ( PHPExcel_Cell :: stringFromColumnIndex ( $ col ) . ( $ row + 1 ) ) ; $ objDrawing -...
Insert an image in a worksheet .
33,176
public function set_bg_color ( $ color ) { if ( ! isset ( $ this -> format [ 'fill' ] [ 'type' ] ) ) { $ this -> format [ 'fill' ] [ 'type' ] = PHPExcel_Style_Fill :: FILL_SOLID ; } $ this -> format [ 'fill' ] [ 'color' ] [ 'rgb' ] = $ this -> parse_color ( $ color ) ; }
Set background color of the cell .
33,177
public function set_h_align ( $ location ) { switch ( $ location ) { case 'left' : $ this -> format [ 'alignment' ] [ 'horizontal' ] = PHPExcel_Style_Alignment :: HORIZONTAL_LEFT ; break ; case 'center' : case 'centre' : $ this -> format [ 'alignment' ] [ 'horizontal' ] = PHPExcel_Style_Alignment :: HORIZONTAL_CENTER ;...
Set the cell horizontal alignment of the format .
33,178
public function set_v_align ( $ location ) { switch ( $ location ) { case 'top' : $ this -> format [ 'alignment' ] [ 'vertical' ] = PHPExcel_Style_Alignment :: VERTICAL_TOP ; break ; case 'vcentre' : case 'vcenter' : case 'centre' : case 'center' : $ this -> format [ 'alignment' ] [ 'vertical' ] = PHPExcel_Style_Alignm...
Set the cell vertical alignment of the format .
33,179
public function set_top ( $ style ) { if ( $ style == 1 ) { $ this -> format [ 'borders' ] [ 'top' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THIN ; } else if ( $ style == 2 ) { $ this -> format [ 'borders' ] [ 'top' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THICK ; } else { $ this -> format [ 'borders' ] [ ...
Set the top border of the format .
33,180
public function set_bottom ( $ style ) { if ( $ style == 1 ) { $ this -> format [ 'borders' ] [ 'bottom' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THIN ; } else if ( $ style == 2 ) { $ this -> format [ 'borders' ] [ 'bottom' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THICK ; } else { $ this -> format [ 'bord...
Set the bottom border of the format .
33,181
public function set_left ( $ style ) { if ( $ style == 1 ) { $ this -> format [ 'borders' ] [ 'left' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THIN ; } else if ( $ style == 2 ) { $ this -> format [ 'borders' ] [ 'left' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THICK ; } else { $ this -> format [ 'borders' ]...
Set the left border of the format .
33,182
public function set_right ( $ style ) { if ( $ style == 1 ) { $ this -> format [ 'borders' ] [ 'right' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THIN ; } else if ( $ style == 2 ) { $ this -> format [ 'borders' ] [ 'right' ] [ 'style' ] = PHPExcel_Style_Border :: BORDER_THICK ; } else { $ this -> format [ 'borders...
Set the right border of the format .
33,183
public static function get_events ( $ timestartfrom = null , $ timestartto = null , $ timesortfrom = null , $ timesortto = null , $ timestartaftereventid = null , $ timesortaftereventid = null , $ limitnum = 20 , $ type = null , array $ usersfilter = null , array $ groupsfilter = null , array $ coursesfilter = null , a...
Get all events restricted by various parameters taking in to account user and group overrides .
33,184
public static function get_action_events_by_timesort ( $ timesortfrom = null , $ timesortto = null , $ aftereventid = null , $ limitnum = 20 , $ limittononsuspendedevents = false , ? \ stdClass $ user = null ) { global $ USER ; if ( ! $ user ) { $ user = $ USER ; } if ( is_null ( $ timesortfrom ) && is_null ( $ timesor...
Get a list of action events for the logged in user by the given timesort values .
33,185
public static function get_action_events_by_course ( $ course , $ timesortfrom = null , $ timesortto = null , $ aftereventid = null , $ limitnum = 20 ) { global $ USER ; if ( $ limitnum < 1 || $ limitnum > 50 ) { throw new limit_invalid_parameter_exception ( "Limit must be between 1 and 50 (inclusive)" ) ; } $ vault = ...
Get a list of action events for the logged in user by the given course and timesort values .
33,186
public static function get_action_events_by_courses ( $ courses = [ ] , $ timesortfrom = null , $ timesortto = null , $ limitnum = 20 ) { $ return = [ ] ; foreach ( $ courses as $ course ) { $ return [ $ course -> id ] = self :: get_action_events_by_course ( $ course , $ timesortfrom , $ timesortto , null , $ limitnum ...
Get a list of action events for the logged in user by the given courses and timesort values .
33,187
public static function update_event_start_day ( event_interface $ event , \ DateTimeInterface $ startdate ) { global $ DB ; $ mapper = container :: get_event_mapper ( ) ; $ legacyevent = $ mapper -> from_event_to_legacy_event ( $ event ) ; $ hascoursemodule = ! empty ( $ event -> get_course_module ( ) ) ; $ moduleinsta...
Change the start day for an event . Only the date will be modified the time of day for the event will be left as is .
33,188
public static function get_user_contexts_with_script ( userlist $ userlist , \ context $ context , string $ script , int $ instance = null ) { if ( ! $ context instanceof \ context_user ) { return ; } $ params = [ 'userid' => $ context -> instanceid , 'script' => $ script ] ; $ whereinstance = '' ; if ( ! empty ( $ ins...
Get the list of users within a specific context for this system .
33,189
public static function delete_userkeys ( string $ script , $ userid = null , $ instance = null ) { global $ DB ; $ searchparams = [ 'script' => $ script , ] ; if ( null !== $ userid ) { $ searchparams [ 'userid' ] = $ userid ; } if ( null !== $ instance ) { $ searchparams [ 'instance' ] = $ instance ; } $ DB -> delete_...
Deletes all userkeys for a script .
33,190
public static function SanitizeUTF8 ( $ value ) { if ( self :: getIsIconvEnabled ( ) ) { $ value = @ iconv ( 'UTF-8' , 'UTF-8' , $ value ) ; return $ value ; } if ( self :: getIsMbstringEnabled ( ) ) { $ value = mb_convert_encoding ( $ value , 'UTF-8' , 'UTF-8' ) ; return $ value ; } return $ value ; }
Try to sanitize UTF8 stripping invalid byte sequences . Not perfect . Does not surrogate characters .
33,191
public static function Substring ( $ pValue = '' , $ pStart = 0 , $ pLength = 0 ) { if ( self :: getIsMbstringEnabled ( ) ) { return mb_substr ( $ pValue , $ pStart , $ pLength , 'UTF-8' ) ; } if ( self :: getIsIconvEnabled ( ) ) { return iconv_substr ( $ pValue , $ pStart , $ pLength , 'UTF-8' ) ; } return substr ( $ ...
Get a substring of a UTF - 8 encoded string . First try mbstring then iconv finally strlen
33,192
public static function StrCaseReverse ( $ pValue = '' ) { if ( self :: getIsMbstringEnabled ( ) ) { $ characters = self :: mb_str_split ( $ pValue ) ; foreach ( $ characters as & $ character ) { if ( self :: mb_is_upper ( $ character ) ) { $ character = mb_strtolower ( $ character , 'UTF-8' ) ; } else { $ character = m...
Reverse the case of a string so that all uppercase characters become lowercase and all lowercase characters become uppercase
33,193
public static function convertToNumberIfFraction ( & $ operand ) { if ( preg_match ( '/^' . self :: STRING_REGEXP_FRACTION . '$/i' , $ operand , $ match ) ) { $ sign = ( $ match [ 1 ] == '-' ) ? '-' : '+' ; $ fractionFormula = '=' . $ sign . $ match [ 2 ] . $ sign . $ match [ 3 ] ; $ operand = PHPExcel_Calculation :: g...
Identify whether a string contains a fractional numeric value and convert it to a numeric if it is
33,194
private function get_options ( ) { if ( ! isset ( $ this -> field -> param5 ) ) { $ this -> field -> param5 = 0 ; } $ options = array ( ) ; $ options [ 'trusttext' ] = false ; $ options [ 'forcehttps' ] = false ; $ options [ 'subdirs' ] = false ; $ options [ 'maxfiles' ] = - 1 ; $ options [ 'context' ] = $ this -> cont...
Returns options for embedded files
33,195
function display_browse_field ( $ recordid , $ template ) { global $ DB ; if ( $ content = $ DB -> get_record ( 'data_content' , array ( 'fieldid' => $ this -> field -> id , 'recordid' => $ recordid ) ) ) { if ( isset ( $ content -> content ) ) { $ options = new stdClass ( ) ; if ( $ this -> field -> param1 == '1' ) { ...
Display the content of the field in browse mode
33,196
public static function update ( $ itemid , $ newvalue ) { $ context = context_module :: instance ( $ itemid ) ; \ external_api :: validate_context ( $ context ) ; require_capability ( 'moodle/course:manageactivities' , $ context ) ; set_coursemodule_name ( $ itemid , $ newvalue ) ; $ coursemodulerecord = get_coursemodu...
Updates course module name
33,197
public function load ( string $ component , string $ name , string $ themename , bool $ includecomments = false ) : string { $ source = ( $ this -> gettemplatesource ) ( $ component , $ name , $ themename ) ; if ( ! $ includecomments ) { $ source = $ this -> strip_template_comments ( $ source ) ; } return $ source ; }
Load the template source from the component and template name .
33,198
protected function scan_template_source_for_dependencies ( string $ source ) : array { $ tokenizer = new Mustache_Tokenizer ( ) ; $ tokens = $ tokenizer -> scan ( $ source ) ; $ templates = [ ] ; $ strings = [ ] ; $ addtodependencies = function ( $ dependencies , $ component , $ id ) { $ id = trim ( $ id ) ; $ componen...
Scan over a template source string and return a list of dependencies it requires . At the moment the list will only include other templates and strings .
33,199
public function shift ( ) { if ( empty ( $ this -> output ) ) { $ this -> output = array_reverse ( $ this -> input ) ; $ this -> input = array ( ) ; } if ( empty ( $ this -> output ) ) { return NULL ; } return array_pop ( $ this -> output ) ; }
Shifts an element off the front of the queue .