idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
32,400
public function archive_to_pathname ( array $ files , $ archivefile , $ ignoreinvalidfiles = true , file_progress $ progress = null ) { $ ziparch = new zip_archive ( ) ; if ( ! $ ziparch -> open ( $ archivefile , file_archive :: OVERWRITE ) ) { return false ; } $ abort = false ; foreach ( $ files as $ archivepath => $ ...
Zip files and store the result in os file .
32,401
private function archive_stored ( $ ziparch , $ archivepath , $ file , file_progress $ progress = null ) { $ result = $ file -> archive_file ( $ ziparch , $ archivepath ) ; if ( ! $ result ) { return false ; } if ( ! $ file -> is_directory ( ) ) { return true ; } $ baselength = strlen ( $ file -> get_filepath ( ) ) ; $...
Perform archiving file from stored file .
32,402
private function archive_pathname ( $ ziparch , $ archivepath , $ file , file_progress $ progress = null ) { if ( $ progress ) { $ progress -> progress ( ) ; } if ( ! file_exists ( $ file ) ) { return false ; } if ( is_file ( $ file ) ) { if ( ! is_readable ( $ file ) ) { return false ; } return $ ziparch -> add_file_f...
Perform archiving file from file path .
32,403
private static function nbrConversionFormat ( $ xVal , $ places ) { if ( ! is_null ( $ places ) ) { if ( strlen ( $ xVal ) <= $ places ) { return substr ( str_pad ( $ xVal , $ places , '0' , STR_PAD_LEFT ) , - 10 ) ; } else { return PHPExcel_Calculation_Functions :: NaN ( ) ; } } return substr ( $ xVal , - 10 ) ; }
Formats a number base string value with leading zeroes
32,404
protected function after_execute_question ( ) { global $ DB ; $ essayswithoutoptions = $ DB -> get_records_sql ( " SELECT q.* FROM {question} q JOIN {backup_ids_temp} bi ON bi.newitemid = q.id LEFT JOIN {qtype_essay_options} qeo ON qeo.questio...
When restoring old data that does not have the essay options information in the XML supply defaults .
32,405
protected function doesStartOrEndWithSingleQuote ( $ name ) { $ startsWithSingleQuote = ( $ this -> stringHelper -> getCharFirstOccurrencePosition ( '\'' , $ name ) === 0 ) ; $ endsWithSingleQuote = ( $ this -> stringHelper -> getCharLastOccurrencePosition ( '\'' , $ name ) === ( $ this -> stringHelper -> getStringLeng...
Returns whether the given name starts or ends with a single quote
32,406
protected function isNameUnique ( $ name ) { foreach ( self :: $ SHEETS_NAME_USED [ $ this -> associatedWorkbookId ] as $ sheetIndex => $ sheetName ) { if ( $ sheetIndex !== $ this -> index && $ sheetName === $ name ) { return false ; } } return true ; }
Returns whether the given name is unique .
32,407
public function render_event_list ( $ form , $ tabledata ) { global $ PAGE ; $ title = get_string ( 'pluginname' , 'report_eventlist' ) ; $ html = $ this -> output -> header ( ) ; $ html .= $ this -> output -> heading ( $ title ) ; ob_start ( ) ; $ form -> display ( ) ; $ html .= ob_get_contents ( ) ; ob_end_clean ( ) ...
Renders the event list page with filter form and datatable .
32,408
public function getTableName ( xmldb_table $ xmldb_table , $ quoted = true ) { if ( $ this -> temptables -> is_temptable ( $ xmldb_table -> getName ( ) ) ) { $ tablename = $ this -> temptables -> get_correct_name ( $ xmldb_table -> getName ( ) ) ; } else { $ tablename = $ this -> prefix . $ xmldb_table -> getName ( ) ;...
Given one xmldb_table returns it s correct name depending of all the parametrization Overridden to allow change of names in temp tables
32,409
public function getCreateTriggerSQL ( $ xmldb_table , $ xmldb_field , $ sequence_name ) { $ trigger_name = $ this -> getNameForObject ( $ xmldb_table -> getName ( ) , $ xmldb_field -> getName ( ) , 'trg' ) ; $ trigger = "CREATE TRIGGER " . $ trigger_name ; $ trigger .= "\n BEFORE INSERT" ; $ trigger .= "\nON " . $ t...
Returns the code needed to create one trigger for the xmldb_table and xmldb_field passed
32,410
public function getDropSequenceSQL ( $ xmldb_table , $ xmldb_field , $ include_trigger = false ) { $ result = array ( ) ; if ( $ sequence_name = $ this -> getSequenceFromDB ( $ xmldb_table ) ) { $ result [ ] = "DROP SEQUENCE " . $ sequence_name ; } if ( $ trigger_name = $ this -> getTriggerFromDB ( $ xmldb_table ) && $...
Returns the code needed to drop one sequence for the xmldb_table and xmldb_field passed Can optionally specify if the underlying trigger will be also dropped
32,411
public function process_question ( array $ data , array $ raw ) { if ( isset ( $ data [ 'answers' ] ) ) { $ this -> write_answers ( $ data [ 'answers' ] , $ this -> pluginname ) ; } if ( isset ( $ data [ 'calculated' ] [ 0 ] [ 'numerical_units' ] ) ) { $ numericalunits = $ data [ 'calculated' ] [ 0 ] [ 'numerical_units...
Appends the calculated specific information to the question
32,412
public static function uuidgen ( $ prefix = '' , $ suffix = '' , $ uppercase = true ) { $ uuid = trim ( sprintf ( '%s%04x%04x%s' , $ prefix , mt_rand ( 0 , 65535 ) , mt_rand ( 0 , 65535 ) , $ suffix ) ) ; $ result = $ uppercase ? strtoupper ( $ uuid ) : strtolower ( $ uuid ) ; return $ result ; }
Generates unique identifier
32,413
public static function randomdir ( $ where , $ prefix = '' , $ suffix = '' ) { global $ CFG ; $ dirname = false ; $ randomname = self :: uuidgen ( $ prefix , $ suffix , false ) ; $ newdirname = $ where . DIRECTORY_SEPARATOR . $ randomname ; if ( mkdir ( $ newdirname ) ) { chmod ( $ newdirname , $ CFG -> directorypermis...
Creates new folder with random name
32,414
private function reset ( ) { $ this -> state = self :: IN_TEXT ; $ this -> tagType = null ; $ this -> buffer = '' ; $ this -> tokens = array ( ) ; $ this -> seenTag = false ; $ this -> line = 0 ; $ this -> otag = '{{' ; $ this -> ctag = '}}' ; $ this -> otagLen = 2 ; $ this -> ctagLen = 2 ; }
Helper function to reset tokenizer internal state .
32,415
private function flushBuffer ( ) { if ( strlen ( $ this -> buffer ) > 0 ) { $ this -> tokens [ ] = array ( self :: TYPE => self :: T_TEXT , self :: LINE => $ this -> line , self :: VALUE => $ this -> buffer , ) ; $ this -> buffer = '' ; } }
Flush the current buffer to a token .
32,416
private function changeDelimiters ( $ text , $ index ) { $ startIndex = strpos ( $ text , '=' , $ index ) + 1 ; $ close = '=' . $ this -> ctag ; $ closeIndex = strpos ( $ text , $ close , $ index ) ; $ this -> setDelimiters ( trim ( substr ( $ text , $ startIndex , $ closeIndex - $ startIndex ) ) ) ; $ this -> tokens [...
Change the current Mustache delimiters . Set new otag and ctag values .
32,417
private function setDelimiters ( $ delimiters ) { list ( $ otag , $ ctag ) = explode ( ' ' , $ delimiters ) ; $ this -> otag = $ otag ; $ this -> ctag = $ ctag ; $ this -> otagLen = strlen ( $ otag ) ; $ this -> ctagLen = strlen ( $ ctag ) ; }
Set the current Mustache otag and ctag delimiters .
32,418
private function addPragma ( $ text , $ index ) { $ end = strpos ( $ text , $ this -> ctag , $ index ) ; $ pragma = trim ( substr ( $ text , $ index + 2 , $ end - $ index - 2 ) ) ; array_unshift ( $ this -> tokens , array ( self :: TYPE => self :: T_PRAGMA , self :: NAME => $ pragma , self :: LINE => 0 , ) ) ; return $...
Add pragma token .
32,419
private function tagChange ( $ tag , $ tagLen , $ text , $ index ) { return substr ( $ text , $ index , $ tagLen ) === $ tag ; }
Test whether it s time to change tags .
32,420
public function setAuthClass ( $ class ) { $ prev = $ this -> configuration [ 'auth_class' ] ; if ( ! isset ( $ this -> configuration [ 'classes' ] [ $ class ] ) && isset ( $ this -> configuration [ 'classes' ] [ $ prev ] ) ) { $ this -> configuration [ 'classes' ] [ $ class ] = $ this -> configuration [ 'classes' ] [ ...
Set the auth class .
32,421
public function setIoClass ( $ class ) { $ prev = $ this -> configuration [ 'io_class' ] ; if ( ! isset ( $ this -> configuration [ 'classes' ] [ $ class ] ) && isset ( $ this -> configuration [ 'classes' ] [ $ prev ] ) ) { $ this -> configuration [ 'classes' ] [ $ class ] = $ this -> configuration [ 'classes' ] [ $ pr...
Set the IO class .
32,422
public function setCacheClass ( $ class ) { $ prev = $ this -> configuration [ 'cache_class' ] ; if ( ! isset ( $ this -> configuration [ 'classes' ] [ $ class ] ) && isset ( $ this -> configuration [ 'classes' ] [ $ prev ] ) ) { $ this -> configuration [ 'classes' ] [ $ class ] = $ this -> configuration [ 'classes' ] ...
Set the cache class .
32,423
public function setLoggerClass ( $ class ) { $ prev = $ this -> configuration [ 'logger_class' ] ; if ( ! isset ( $ this -> configuration [ 'classes' ] [ $ class ] ) && isset ( $ this -> configuration [ 'classes' ] [ $ prev ] ) ) { $ this -> configuration [ 'classes' ] [ $ class ] = $ this -> configuration [ 'classes' ...
Set the logger class .
32,424
private function setAuthConfig ( $ key , $ value ) { if ( ! isset ( $ this -> configuration [ 'classes' ] [ $ this -> getAuthClass ( ) ] ) ) { $ this -> configuration [ 'classes' ] [ $ this -> getAuthClass ( ) ] = array ( ) ; } $ this -> configuration [ 'classes' ] [ $ this -> getAuthClass ( ) ] [ $ key ] = $ value ; }
Set the auth configuration for the current auth class .
32,425
public static function get_notes ( $ notes ) { global $ CFG ; $ params = self :: validate_parameters ( self :: get_notes_parameters ( ) , array ( 'notes' => $ notes ) ) ; if ( ! $ CFG -> enablenotes ) { throw new moodle_exception ( 'notesdisabled' , 'notes' ) ; } $ resultnotes = array ( ) ; foreach ( $ params [ 'notes'...
Get notes about users .
32,426
public static function get_notes_returns ( ) { return new external_single_structure ( array ( 'notes' => new external_multiple_structure ( new external_single_structure ( array ( 'noteid' => new external_value ( PARAM_INT , 'id of the note' , VALUE_OPTIONAL ) , 'userid' => new external_value ( PARAM_INT , 'id of the us...
Returns description of get_notes result value .
32,427
public static function update_notes_parameters ( ) { return new external_function_parameters ( array ( 'notes' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'id of the note' ) , 'publishstate' => new external_value ( PARAM_ALPHA , '\'personal\', \'...
Returns description of update_notes parameters .
32,428
public static function update_notes ( $ notes = array ( ) ) { global $ CFG , $ DB ; $ params = self :: validate_parameters ( self :: update_notes_parameters ( ) , array ( 'notes' => $ notes ) ) ; if ( ! $ CFG -> enablenotes ) { throw new moodle_exception ( 'notesdisabled' , 'notes' ) ; } $ warnings = array ( ) ; foreac...
Update notes about users .
32,429
protected static function create_note_list ( $ courseid , $ context , $ userid , $ state , $ author = 0 ) { $ results = array ( ) ; $ notes = note_list ( $ courseid , $ userid , $ state , $ author ) ; foreach ( $ notes as $ key => $ note ) { $ note = ( array ) $ note ; list ( $ note [ 'content' ] , $ note [ 'format' ] ...
Create a notes list
32,430
public static function get_course_notes ( $ courseid , $ userid = 0 ) { global $ CFG , $ USER ; if ( empty ( $ CFG -> enablenotes ) ) { throw new moodle_exception ( 'notesdisabled' , 'notes' ) ; } $ warnings = array ( ) ; $ arrayparams = array ( 'courseid' => $ courseid , 'userid' => $ userid , ) ; $ params = self :: v...
Get a list of course notes
32,431
protected static function get_note_structure ( ) { return array ( 'id' => new external_value ( PARAM_INT , 'id of this note' ) , 'courseid' => new external_value ( PARAM_INT , 'id of the course' ) , 'userid' => new external_value ( PARAM_INT , 'user id' ) , 'content' => new external_value ( PARAM_RAW , 'the content tex...
Returns array of note structure
32,432
protected static function make_plugin_instance ( $ type , $ typerootdir , $ name , $ namerootdir , $ typeclass , $ pluginman ) { $ plugin = new $ typeclass ( ) ; $ plugin -> type = $ type ; $ plugin -> typerootdir = $ typerootdir ; $ plugin -> name = $ name ; $ plugin -> rootdir = $ namerootdir ; $ plugin -> pluginman ...
Makes a new instance of the plugininfo class
32,433
public function is_installed_and_upgraded ( ) { if ( ! $ this -> rootdir ) { return false ; } if ( $ this -> versiondb === null and $ this -> versiondisk === null ) { return false ; } return ( ( float ) $ this -> versiondb === ( float ) $ this -> versiondisk ) ; }
Is this plugin already installed and updated?
32,434
public function is_core_dependency_satisfied ( $ moodleversion ) { if ( empty ( $ this -> versionrequires ) ) { return true ; } else { return ( double ) $ this -> versionrequires <= ( double ) $ moodleversion ; } }
Returns true if the the given Moodle version is enough to run this plugin
32,435
public function get_status ( ) { $ pluginman = $ this -> pluginman ; if ( is_null ( $ this -> versiondb ) and is_null ( $ this -> versiondisk ) ) { return core_plugin_manager :: PLUGIN_STATUS_NODB ; } else if ( is_null ( $ this -> versiondb ) and ! is_null ( $ this -> versiondisk ) ) { return core_plugin_manager :: PLU...
Returns the status of the plugin
32,436
public function is_enabled ( ) { if ( ! $ this -> rootdir ) { return false ; } $ enabled = $ this -> pluginman -> get_enabled_plugins ( $ this -> type ) ; if ( ! is_array ( $ enabled ) ) { return null ; } return isset ( $ enabled [ $ this -> name ] ) ; }
Returns the information about plugin availability
32,437
public function available_updates ( ) { if ( $ this -> availableupdates === null ) { $ this -> availableupdates = $ this -> pluginman -> load_available_updates_for_plugin ( $ this -> component ) ; } if ( empty ( $ this -> availableupdates ) or ! is_array ( $ this -> availableupdates ) ) { $ this -> availableupdates = a...
If there are updates for this plugin available returns them .
32,438
public function get_settings_url ( ) { $ section = $ this -> get_settings_section_name ( ) ; if ( $ section === null ) { return null ; } $ settings = admin_get_root ( ) -> locate ( $ section ) ; if ( $ settings && $ settings instanceof \ admin_settingpage ) { return new moodle_url ( '/admin/settings.php' , array ( 'sec...
Returns the URL of the plugin settings screen
32,439
public function compareKeys ( $ a , $ b ) { return strcoll ( Horde_String :: lower ( $ a , true , 'UTF-8' ) , Horde_String :: lower ( $ b , true , 'UTF-8' ) ) ; }
Compare array keys case insensitively for uksort .
32,440
public function reverseCompareKeys ( $ a , $ b ) { return strcoll ( Horde_String :: lower ( $ b , true , 'UTF-8' ) , Horde_String :: lower ( $ a , true , 'UTF-8' ) ) ; }
Compare in reverse order array keys case insensitively for uksort .
32,441
public static function get_linked_logins ( $ userid = false ) { global $ USER ; if ( $ userid === false ) { $ userid = $ USER -> id ; } if ( \ core \ session \ manager :: is_loggedinas ( ) ) { throw new moodle_exception ( 'notwhileloggedinas' , 'auth_oauth2' ) ; } $ context = context_user :: instance ( $ userid ) ; req...
List linked logins
32,442
public static function match_username_to_user ( $ username , $ issuer ) { $ params = [ 'issuerid' => $ issuer -> get ( 'id' ) , 'username' => $ username ] ; $ result = linked_login :: get_record ( $ params ) ; if ( $ result ) { $ user = \ core_user :: get_user ( $ result -> get ( 'userid' ) ) ; if ( ! empty ( $ user ) ...
See if there is a match for this username and issuer in the linked_login table .
32,443
public static function link_login ( $ userinfo , $ issuer , $ userid = false , $ skippermissions = false ) { global $ USER ; if ( $ userid === false ) { $ userid = $ USER -> id ; } if ( linked_login :: has_existing_issuer_match ( $ issuer , $ userinfo [ 'username' ] ) ) { throw new moodle_exception ( 'alreadylinked' , ...
Link a login to this account .
32,444
public static function send_confirm_link_login_email ( $ userinfo , $ issuer , $ userid ) { $ record = new stdClass ( ) ; $ record -> issuerid = $ issuer -> get ( 'id' ) ; $ record -> username = $ userinfo [ 'username' ] ; $ record -> userid = $ userid ; if ( linked_login :: has_existing_issuer_match ( $ issuer , $ use...
Send an email with a link to confirm linking this account .
32,445
public static function confirm_link_login ( $ userid , $ username , $ issuerid , $ token ) { if ( empty ( $ token ) || empty ( $ userid ) || empty ( $ issuerid ) || empty ( $ username ) ) { return false ; } $ params = [ 'userid' => $ userid , 'username' => $ username , 'issuerid' => $ issuerid , 'confirmtoken' => $ tok...
Look for a waiting confirmation token and if we find a match - confirm it .
32,446
public static function create_new_confirmed_account ( $ userinfo , $ issuer ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/user/profile/lib.php' ) ; require_once ( $ CFG -> dirroot . '/user/lib.php' ) ; $ user = new stdClass ( ) ; $ user -> username = $ userinfo [ 'username' ] ; $ user -> email = $ useri...
Create an account with a linked login that is already confirmed .
32,447
public static function delete_linked_login ( $ linkedloginid ) { $ login = new linked_login ( $ linkedloginid ) ; $ userid = $ login -> get ( 'userid' ) ; if ( \ core \ session \ manager :: is_loggedinas ( ) ) { throw new moodle_exception ( 'notwhileloggedinas' , 'auth_oauth2' ) ; } $ context = context_user :: instance...
Delete linked login
32,448
public static function user_deleted ( \ core \ event \ user_deleted $ event ) { global $ DB ; $ userid = $ event -> objectid ; return $ DB -> delete_records ( linked_login :: TABLE , [ 'userid' => $ userid ] ) ; }
Delete linked logins for a user .
32,449
public function send_file ( $ file ) { $ this -> googleoauth -> setHeader ( "Content-Length: 0" ) ; $ this -> googleoauth -> setHeader ( "X-Upload-Content-Length: " . $ file -> get_filesize ( ) ) ; $ this -> googleoauth -> setHeader ( "X-Upload-Content-Type: " . $ file -> get_mimetype ( ) ) ; $ this -> googleoauth -> s...
Sends a file object to google documents
32,450
public function download_file ( $ url , $ path , $ timeout = 0 ) { $ result = $ this -> googleoauth -> download_one ( $ url , null , array ( 'filepath' => $ path , 'timeout' => $ timeout ) ) ; if ( $ result === true ) { $ info = $ this -> googleoauth -> get_info ( ) ; if ( isset ( $ info [ 'http_code' ] ) && $ info [ '...
Downloads a file using authentication
32,451
public function send_file ( $ file ) { $ this -> googleoauth -> setHeader ( "Content-Length: " . $ file -> get_filesize ( ) ) ; $ this -> googleoauth -> setHeader ( "Content-Type: " . $ file -> get_mimetype ( ) ) ; $ this -> googleoauth -> setHeader ( "Slug: " . $ file -> get_filename ( ) ) ; $ this -> googleoauth -> p...
Sends a file object to picasaweb
32,452
public function get_album_photos ( $ albumid ) { $ albumcontent = $ this -> googleoauth -> get ( self :: ALBUM_PHOTO_LIST . $ albumid ) ; return $ this -> get_photo_details ( $ albumcontent ) ; }
Returns list of photos in album specified
32,453
public function do_photo_search ( $ query ) { $ content = $ this -> googleoauth -> get ( self :: PHOTO_SEARCH_URL . htmlentities ( $ query ) ) ; return $ this -> get_photo_details ( $ content ) ; }
Does text search on the users photos and returns matches in format for picasa api
32,454
public function get_albums ( ) { $ files = array ( ) ; $ content = $ this -> googleoauth -> get ( self :: LIST_ALBUMS_URL ) ; try { if ( strpos ( $ content , '<?xml' ) !== 0 ) { throw new moodle_exception ( 'invalidxmlresponse' ) ; } $ xml = new SimpleXMLElement ( $ content ) ; } catch ( Exception $ e ) { return $ file...
Gets all the users albums and returns them as a list of folders for the file picker
32,455
public function get_photo_details ( $ rawxml ) { $ files = array ( ) ; try { if ( strpos ( $ rawxml , '<?xml' ) !== 0 ) { throw new moodle_exception ( 'invalidxmlresponse' ) ; } $ xml = new SimpleXMLElement ( $ rawxml ) ; } catch ( Exception $ e ) { return $ files ; } $ this -> lastalbumname = ( string ) $ xml -> title...
Recieves XML from a picasa list of photos and returns array in format for file picker .
32,456
public function load ( $ key ) { $ fileName = $ this -> getCacheFilename ( $ key ) ; if ( ! is_file ( $ fileName ) ) { return false ; } require_once $ fileName ; return true ; }
Load the class from cache using require_once .
32,457
public function cache ( $ key , $ value ) { $ fileName = $ this -> getCacheFilename ( $ key ) ; $ this -> log ( Mustache_Logger :: DEBUG , 'Writing to template cache: "{fileName}"' , array ( 'fileName' => $ fileName ) ) ; $ this -> writeFile ( $ fileName , $ value ) ; $ this -> load ( $ key ) ; }
Cache and load the compiled class .
32,458
private function buildDirectoryForFilename ( $ fileName ) { $ dirName = dirname ( $ fileName ) ; if ( ! is_dir ( $ dirName ) ) { $ this -> log ( Mustache_Logger :: INFO , 'Creating Mustache template cache directory: "{dirName}"' , array ( 'dirName' => $ dirName ) ) ; @ mkdir ( $ dirName , 0777 , true ) ; if ( ! is_dir ...
Create cache directory .
32,459
private function writeFile ( $ fileName , $ value ) { $ dirName = $ this -> buildDirectoryForFilename ( $ fileName ) ; $ this -> log ( Mustache_Logger :: DEBUG , 'Caching compiled template to "{fileName}"' , array ( 'fileName' => $ fileName ) ) ; $ tempFile = tempnam ( $ dirName , basename ( $ fileName ) ) ; if ( false...
Write cache file .
32,460
public static function load_inforef_to_tempids ( $ restoreid , $ inforeffile , \ core \ progress \ base $ progress = null ) { if ( ! file_exists ( $ inforeffile ) ) { throw new backup_helper_exception ( 'missing_inforef_xml_file' , $ inforeffile ) ; } if ( ! $ progress ) { $ progress = new \ core \ progress \ none ( ) ...
Load one inforef . xml file to backup_ids table for future reference
32,461
public static function load_roles_to_tempids ( $ restoreid , $ rolesfile ) { if ( ! file_exists ( $ rolesfile ) ) { throw new backup_helper_exception ( 'missing_roles_xml_file' , $ rolesfile ) ; } $ xmlparser = new progressive_parser ( ) ; $ xmlparser -> set_file ( $ rolesfile ) ; $ xmlprocessor = new restore_roles_par...
Load the needed role . xml file to backup_ids table for future reference
32,462
protected static function get_backup_ids_cached ( $ restoreid , $ itemname , $ itemid ) { global $ DB ; $ key = "$itemid $itemname $restoreid" ; if ( isset ( self :: $ backupidsexist [ $ key ] ) && isset ( self :: $ backupidscache [ $ key ] ) ) { return clone self :: $ backupidscache [ $ key ] ; } if ( self :: $ backup...
Return cached backup id s
32,463
protected static function set_backup_ids_cached ( $ restoreid , $ itemname , $ itemid , $ extrarecord ) { global $ DB ; $ key = "$itemid $itemname $restoreid" ; $ record = array ( 'backupid' => $ restoreid , 'itemname' => $ itemname , 'itemid' => $ itemid , ) ; if ( ! isset ( self :: $ backupidsexist [ $ key ] ) ) { if...
Cache backup ids
32,464
protected static function update_backup_cached_record ( $ record , $ extrarecord , $ key , $ existingrecord = null ) { global $ DB ; if ( ! empty ( $ extrarecord ) ) { $ extrarecord [ 'id' ] = self :: $ backupidsexist [ $ key ] ; $ DB -> update_record ( 'backup_ids_temp' , $ extrarecord ) ; if ( isset ( self :: $ backu...
Updates existing backup record
32,465
public static function reset_backup_ids_cached ( ) { $ cachetoadd = count ( self :: $ backupidscache ) ; self :: $ backupidscache = array ( ) ; self :: $ backupidscachesize = self :: $ backupidscachesize + $ cachetoadd ; $ existstoadd = count ( self :: $ backupidsexist ) ; self :: $ backupidsexist = array ( ) ; self ::...
Reset the ids caches completely
32,466
public static function load_users_to_tempids ( $ restoreid , $ usersfile , \ core \ progress \ base $ progress = null ) { if ( ! file_exists ( $ usersfile ) ) { throw new backup_helper_exception ( 'missing_users_xml_file' , $ usersfile ) ; } if ( ! $ progress ) { $ progress = new \ core \ progress \ none ( ) ; } $ prog...
Load the needed users . xml file to backup_ids table for future reference
32,467
public static function load_categories_and_questions_to_tempids ( $ restoreid , $ questionsfile ) { if ( ! file_exists ( $ questionsfile ) ) { throw new backup_helper_exception ( 'missing_questions_xml_file' , $ questionsfile ) ; } $ xmlparser = new progressive_parser ( ) ; $ xmlparser -> set_file ( $ questionsfile ) ;...
Load the needed questions . xml file to backup_ids table for future reference
32,468
public static function restore_get_question_banks ( $ restoreid , $ contextlevel = null ) { global $ DB ; $ results = array ( ) ; $ qcats = $ DB -> get_recordset_sql ( "SELECT itemid, parentitemid AS contextid, info FROM {backup_ids_temp} WHE...
Return one array of contextid = > contextlevel pairs of question banks to be checked for one given restore operation ordered from CONTEXT_SYSTEM downto CONTEXT_MODULE If contextlevel is specified then only banks corresponding to that level are returned
32,469
public static function restore_get_questions ( $ restoreid , $ qcatid ) { global $ DB ; $ results = array ( ) ; $ qs = $ DB -> get_recordset_sql ( "SELECT itemid, info FROM {backup_ids_temp} WHERE backupid = ? ...
Return one array of question records for a given restore operation and one question category
32,470
protected static function get_missing_file_result ( $ file ) { $ result = new stdClass ( ) ; $ result -> code = 'file_missing_in_backup' ; $ result -> message = 'Missing file in backup: ' . $ file -> filepath . $ file -> filename . ' (old context ' . $ file -> contextid . ', component ' . $ file -> component . ', filea...
Returns suitable entry to include in log when there is a missing file .
32,471
public static function set_course_role_names ( $ restoreid , $ courseid ) { global $ DB ; $ coursectx = context_course :: instance ( $ courseid ) ; $ rs = $ DB -> get_recordset ( 'backup_ids_temp' , array ( 'backupid' => $ restoreid , 'itemname' => 'role' ) , '' , 'itemid, info, newitemid' ) ; foreach ( $ rs as $ recro...
For the target course context put as many custom role names as possible
32,472
public static function create_new_course ( $ fullname , $ shortname , $ categoryid ) { global $ DB ; $ category = $ DB -> get_record ( 'course_categories' , array ( 'id' => $ categoryid ) , '*' , MUST_EXIST ) ; $ course = new stdClass ; $ course -> fullname = $ fullname ; $ course -> shortname = $ shortname ; $ course ...
Creates a skeleton record within the database using the passed parameters and returns the new course id .
32,473
public static function get_form_field_from_label ( $ label , RawMinkContext $ context ) { $ fieldnode = $ context -> find_field ( $ label ) ; return self :: get_form_field ( $ fieldnode , $ context -> getSession ( ) ) ; }
Gets an instance of the form field from it s label
32,474
public static function get_field_instance ( $ type , NodeElement $ fieldnode , Session $ session ) { global $ CFG ; if ( $ type == 'field' && $ guessedtype = self :: guess_field_type ( $ fieldnode , $ session ) ) { $ type = $ guessedtype ; } $ classname = 'behat_form_' . $ type ; $ classpath = $ CFG -> libdir . '/behat...
Returns the appropiate behat_form_field according to the provided type .
32,475
public static function guess_field_type ( NodeElement $ fieldnode , Session $ session ) { $ tagname = strtolower ( $ fieldnode -> getTagName ( ) ) ; if ( $ tagname == 'textarea' ) { $ xpath = '//div[@id="' . $ fieldnode -> getAttribute ( 'id' ) . 'editable"]' ; if ( $ session -> getPage ( ) -> find ( 'xpath' , $ xpath ...
Guesses a basic field type and returns it .
32,476
public function definition ( ) { $ mform = & $ this -> _form ; $ mform -> addElement ( 'header' , 'general' , get_string ( 'note' , 'notes' ) ) ; $ mform -> addElement ( 'textarea' , 'content' , get_string ( 'content' , 'notes' ) , array ( 'rows' => 15 , 'cols' => 40 ) ) ; $ mform -> setType ( 'content' , PARAM_RAW ) ;...
Define the form for editing notes
32,477
public static function make_display_name ( $ tag , $ ashtml = true ) { global $ CFG ; if ( empty ( $ CFG -> keeptagnamecase ) ) { $ tagname = core_text :: strtotitle ( $ tag -> name ) ; } else { $ tagname = $ tag -> rawname ; } $ tagname = clean_param ( $ tagname , PARAM_TAG ) ; return $ ashtml ? htmlspecialchars ( $ t...
Prepares tag name ready to be displayed
32,478
public static function get ( $ id , $ returnfields = 'id, name, rawname, tagcollid' , $ strictness = IGNORE_MISSING ) { global $ DB ; $ record = $ DB -> get_record ( 'tag' , array ( 'id' => $ id ) , $ returnfields , $ strictness ) ; if ( $ record ) { return new static ( $ record ) ; } return false ; }
Simple function to just return a single tag object by its id
32,479
public static function get_bulk ( $ ids , $ returnfields = 'id, name, rawname, tagcollid' ) { global $ DB ; $ result = array ( ) ; if ( empty ( $ ids ) ) { return $ result ; } list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( $ ids ) ; $ records = $ DB -> get_records_select ( 'tag' , 'id ' . $ sql , $ params , '' ,...
Simple function to just return an array of tag objects by their ids
32,480
public static function get_by_name ( $ tagcollid , $ name , $ returnfields = 'id, name, rawname, tagcollid' , $ strictness = IGNORE_MISSING ) { global $ DB ; if ( $ tagcollid == 0 ) { $ tags = static :: guess_by_name ( $ name , $ returnfields ) ; if ( $ tags ) { $ tag = reset ( $ tags ) ; return $ tag ; } else if ( $ s...
Simple function to just return a single tag object by tagcollid and name
32,481
public static function guess_by_name ( $ name , $ returnfields = 'id, name, rawname, tagcollid' ) { global $ DB ; if ( empty ( $ name ) ) { return array ( ) ; } $ tagcolls = core_tag_collection :: get_collections ( ) ; list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( array_keys ( $ tagcolls ) , SQL_PARAMS_NAMED ) ...
Looking in all tag collections for the tag with the given name
32,482
public static function get_by_name_bulk ( $ tagcollid , $ tags , $ returnfields = 'id, name, rawname, tagcollid' ) { global $ DB ; if ( empty ( $ tags ) ) { return array ( ) ; } $ cleantags = self :: normalize ( self :: normalize ( $ tags , false ) ) ; list ( $ namesql , $ params ) = $ DB -> get_in_or_equal ( array_val...
Returns the list of tag objects by tag collection id and the list of tag names
32,483
public static function normalize ( $ rawtags , $ tolowercase = true ) { $ result = array ( ) ; foreach ( $ rawtags as $ rawtag ) { $ rawtag = trim ( $ rawtag ) ; if ( strval ( $ rawtag ) !== '' ) { $ clean = clean_param ( $ rawtag , PARAM_TAG ) ; if ( $ tolowercase ) { $ result [ $ rawtag ] = core_text :: strtolower ( ...
Function that normalizes a list of tag names .
32,484
public static function make_url ( $ tagcollid , $ name , $ exclusivemode = 0 , $ fromctx = 0 , $ ctx = 0 , $ rec = 1 ) { $ coll = core_tag_collection :: get_by_id ( $ tagcollid ) ; if ( ! empty ( $ coll -> customurl ) ) { $ url = '/' . ltrim ( trim ( $ coll -> customurl ) , '/' ) ; } else { $ url = '/tag/index.php' ; }...
Creates a URL to view a tag
32,485
public function get_view_url ( $ exclusivemode = 0 , $ fromctx = 0 , $ ctx = 0 , $ rec = 1 ) { return static :: make_url ( $ this -> record -> tagcollid , $ this -> record -> rawname , $ exclusivemode , $ fromctx , $ ctx , $ rec ) ; }
Returns URL to view the tag
32,486
protected function ensure_fields_exist ( $ list , $ caller ) { global $ DB ; $ missing = array_diff ( $ list , array_keys ( ( array ) $ this -> record ) ) ; if ( $ missing ) { debugging ( 'core_tag_tag::' . $ caller . '() must be called on fully retrieved tag object. Missing fields: ' . join ( ', ' , $ missing ) , DEBU...
Validates that the required fields were retrieved and retrieves them if missing
32,487
protected function delete_instance_as_record ( $ taginstance , $ fullobject = false ) { global $ DB ; $ this -> ensure_fields_exist ( array ( 'name' , 'rawname' , 'isstandard' ) , 'delete_instance_as_record' ) ; $ DB -> delete_records ( 'tag_instance' , array ( 'id' => $ taginstance -> id ) ) ; if ( is_null ( $ taginst...
Deletes the tag instance given the record from tag_instance DB table
32,488
protected function delete_instance ( $ component , $ itemtype , $ itemid , $ tiuserid = 0 ) { global $ DB ; $ params = array ( 'tagid' => $ this -> id , 'itemtype' => $ itemtype , 'itemid' => $ itemid ) ; if ( $ tiuserid ) { $ params [ 'tiuserid' ] = $ tiuserid ; } if ( $ component ) { $ params [ 'component' ] = $ comp...
Delete one instance of a tag . If the last instance was deleted it will also delete the tag unless it is standard .
32,489
public static function delete_instances_as_record ( array $ taginstances ) { global $ DB ; if ( empty ( $ taginstances ) ) { return ; } $ taginstanceids = array_map ( function ( $ taginstance ) { return $ taginstance -> id ; } , $ taginstances ) ; $ DB -> delete_records_list ( 'tag_instance' , 'id' , $ taginstanceids )...
Bulk delete all tag instances .
32,490
public static function delete_instances_by_id ( array $ taginstanceids ) { global $ DB ; if ( empty ( $ taginstanceids ) ) { return ; } list ( $ idsql , $ params ) = $ DB -> get_in_or_equal ( $ taginstanceids ) ; $ sql = "SELECT ti.*, t.name, t.rawname, t.isstandard FROM {tag_instance} ti ...
Bulk delete all tag instances by tag id .
32,491
public static function delete_instances ( $ component , $ itemtype = null , $ contextid = null ) { global $ DB ; $ sql = "SELECT ti.*, t.name, t.rawname, t.isstandard FROM {tag_instance} ti JOIN {tag} t ON ti.tagid = t.id WHERE ti.component = :compone...
Bulk delete all tag instances for a component or tag area
32,492
protected function add_instance ( $ component , $ itemtype , $ itemid , context $ context , $ ordering , $ tiuserid = 0 ) { global $ DB ; $ this -> ensure_fields_exist ( array ( 'name' , 'rawname' ) , 'add_instance' ) ; $ taginstance = new stdClass ; $ taginstance -> tagid = $ this -> id ; $ taginstance -> component = ...
Adds a tag instance
32,493
protected function update_instance_ordering ( $ instanceid , $ ordering ) { global $ DB ; $ data = new stdClass ( ) ; $ data -> id = $ instanceid ; $ data -> ordering = $ ordering ; $ data -> timemodified = time ( ) ; $ DB -> update_record ( 'tag_instance' , $ data ) ; }
Updates the ordering on tag instance
32,494
public static function get_items_tags ( $ component , $ itemtype , $ itemids , $ standardonly = self :: BOTH_STANDARD_AND_NOT , $ tiuserid = 0 ) { global $ DB ; if ( static :: is_enabled ( $ component , $ itemtype ) === false ) { return array ( ) ; } if ( empty ( $ itemids ) ) { return array ( ) ; } $ standardonly = ( ...
Get the array of core_tag_tag objects associated with a list of items .
32,495
public static function get_item_tags_array ( $ component , $ itemtype , $ itemid , $ standardonly = self :: BOTH_STANDARD_AND_NOT , $ tiuserid = 0 , $ ashtml = true ) { $ tags = array ( ) ; foreach ( static :: get_item_tags ( $ component , $ itemtype , $ itemid , $ standardonly , $ tiuserid ) as $ tag ) { $ tags [ $ ta...
Returns the list of display names of the tags that are associated with an item
32,496
public static function remove_all_item_tags ( $ component , $ itemtype , $ itemid , $ tiuserid = 0 ) { $ context = context_system :: instance ( ) ; static :: set_item_tags ( $ component , $ itemtype , $ itemid , $ context , null , $ tiuserid ) ; }
Removes all tags from an item .
32,497
public static function add_item_tag ( $ component , $ itemtype , $ itemid , context $ context , $ tagname , $ tiuserid = 0 ) { global $ DB ; if ( static :: is_enabled ( $ component , $ itemtype ) === false ) { return null ; } $ rawname = clean_param ( $ tagname , PARAM_TAG ) ; $ normalisedname = core_text :: strtolower...
Adds a tag to an item without overwriting the current tags .
32,498
public static function remove_item_tag ( $ component , $ itemtype , $ itemid , $ tagname , $ tiuserid = 0 ) { global $ DB ; if ( static :: is_enabled ( $ component , $ itemtype ) === false ) { return array ( ) ; } $ rawname = clean_param ( $ tagname , PARAM_TAG ) ; $ normalisedname = core_text :: strtolower ( $ rawname...
Removes the tag from an item without changing the other tags
32,499
public static function move_context ( $ component , $ itemtype , $ oldcontext , $ newcontext ) { global $ DB ; if ( $ oldcontext instanceof context ) { $ oldcontext = $ oldcontext -> id ; } if ( $ newcontext instanceof context ) { $ newcontext = $ newcontext -> id ; } $ DB -> set_field ( 'tag_instance' , 'contextid' , ...
Allows to move all tag instances from one context to another