idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
27,900
public function record_exists_select ( $ table , $ select , array $ params = null ) { if ( $ select ) { $ select = "WHERE $select" ; } return $ this -> record_exists_sql ( "SELECT 'x' FROM {" . $ table . "} $select" , $ params ) ; }
Test whether any records exists in a table which match a particular WHERE clause .
27,901
public function record_exists_sql ( $ sql , array $ params = null ) { $ mrs = $ this -> get_recordset_sql ( $ sql , $ params , 0 , 1 ) ; $ return = $ mrs -> valid ( ) ; $ mrs -> close ( ) ; return $ return ; }
Test whether a SQL SELECT statement returns any records .
27,902
public function delete_records ( $ table , array $ conditions = null ) { if ( is_null ( $ conditions ) && empty ( $ this -> transactions ) ) { return $ this -> execute ( "TRUNCATE TABLE {" . $ table . "}" ) ; } list ( $ select , $ params ) = $ this -> where_clause ( $ table , $ conditions ) ; return $ this -> delete_re...
Delete the records from a table where all the given conditions met . If conditions not specified table is truncated .
27,903
public function delete_records_list ( $ table , $ field , array $ values ) { list ( $ select , $ params ) = $ this -> where_clause_list ( $ field , $ values ) ; return $ this -> delete_records_select ( $ table , $ select , $ params ) ; }
Delete the records from a table where one field match one list of values .
27,904
public function sql_like_escape ( $ text , $ escapechar = '\\' ) { $ text = str_replace ( '_' , $ escapechar . '_' , $ text ) ; $ text = str_replace ( '%' , $ escapechar . '%' , $ text ) ; return $ text ; }
Escape sql LIKE special characters like _ or % .
27,905
public function sql_isnotempty ( $ tablename , $ fieldname , $ nullablefield , $ textfield ) { return ' ( NOT ' . $ this -> sql_isempty ( $ tablename , $ fieldname , $ nullablefield , $ textfield ) . ') ' ; }
Returns the proper SQL to know if one field is not empty .
27,906
public function replace_all_text ( $ table , database_column_info $ column , $ search , $ replace ) { if ( ! $ this -> replace_all_text_supported ( ) ) { return ; } $ columnname = $ this -> get_manager ( ) -> generator -> getEncQuoted ( $ column -> name ) ; $ searchsql = $ this -> sql_like ( $ columnname , '?' ) ; $ se...
Replace given text in all rows of column .
27,907
public function commit_delegated_transaction ( moodle_transaction $ transaction ) { if ( $ transaction -> is_disposed ( ) ) { throw new dml_transaction_exception ( 'Transactions already disposed' , $ transaction ) ; } $ transaction -> dispose ( ) ; if ( empty ( $ this -> transactions ) ) { throw new dml_transaction_exc...
Indicates delegated transaction finished successfully . The real database transaction is committed only if all delegated transactions committed .
27,908
public function rollback_delegated_transaction ( moodle_transaction $ transaction , $ e ) { if ( ! ( $ e instanceof Exception ) && ! ( $ e instanceof Throwable ) ) { $ e = new \ coding_exception ( "Must be given an Exception or Throwable object!" ) ; } if ( $ transaction -> is_disposed ( ) ) { throw new dml_transaction...
Call when delegated transaction failed this rolls back all delegated transactions up to the top most level .
27,909
public function force_transaction_rollback ( ) { if ( $ this -> transactions ) { try { $ this -> rollback_transaction ( ) ; } catch ( dml_exception $ e ) { } } $ this -> transactions = array ( ) ; $ this -> force_rollback = false ; \ core \ event \ manager :: database_transaction_rolledback ( ) ; \ core \ message \ man...
Force rollback of all delegated transaction . Does not throw any exceptions and does not log anything .
27,910
public function compare ( $ key1 , $ key2 ) { $ record1 = $ this -> contents [ $ key1 ] ; $ record2 = $ this -> contents [ $ key2 ] ; if ( ( $ record1 -> required && $ record2 -> required ) || ( ! $ record1 -> required && ! $ record2 -> required ) ) { if ( $ record1 -> priority === $ record2 -> priority ) { return $ ke...
comparator function overriden for sorting the records ... as per required and priotirity field values
27,911
protected function set_key ( $ key ) { $ bytes = strlen ( $ key ) ; if ( $ bytes !== backup :: CIPHERKEYLEN ) { $ info = ( object ) array ( 'expected' => backup :: CIPHERKEYLEN , 'found' => $ bytes ) ; throw new base_element_struct_exception ( 'encrypted_final_element incorrect key length' , $ info ) ; } $ this -> key ...
Set the encryption key manually overriding default backup_encryptkey config .
27,912
public function set_value ( $ value ) { if ( ! function_exists ( 'openssl_encrypt' ) ) { return ; } if ( ! function_exists ( 'hash_hmac' ) ) { return ; } if ( ! in_array ( backup :: CIPHER , openssl_get_cipher_methods ( ) ) ) { return ; } if ( empty ( $ this -> key ) ) { $ enckey = get_config ( 'backup' , 'backup_encry...
Set the value of the field .
27,913
private function writeBubbles ( $ plotSeriesValues , $ objWriter , PHPExcel_Worksheet $ pSheet ) { if ( is_null ( $ plotSeriesValues ) ) { return ; } $ objWriter -> startElement ( 'c:bubbleSize' ) ; $ objWriter -> startElement ( 'c:numLit' ) ; $ objWriter -> startElement ( 'c:formatCode' ) ; $ objWriter -> writeRawData...
Write Bubble Chart Details
27,914
public static function var_names_from_context ( $ classname , $ pluginname = '' ) { $ pluginname = trim ( $ pluginname ) ; if ( ! empty ( $ pluginname ) ) { $ categoryvar = $ classname . '_' . $ pluginname . '_category' ; $ purposevar = $ classname . '_' . $ pluginname . '_purpose' ; } else { $ categoryvar = $ classnam...
Returns purpose and category var names from a context class name
27,915
public static function get_defaults ( $ contextlevel , $ pluginname = '' ) { $ classname = \ context_helper :: get_class_for_level ( $ contextlevel ) ; list ( $ purposevar , $ categoryvar ) = self :: var_names_from_context ( $ classname , $ pluginname ) ; $ purposeid = get_config ( 'tool_dataprivacy' , $ purposevar ) ;...
Returns the default purpose id and category id for the provided context level .
27,916
public static function defaults_set ( ) { list ( $ purposeid , $ categoryid ) = self :: get_defaults ( CONTEXT_SYSTEM ) ; if ( empty ( $ purposeid ) || empty ( $ categoryid ) ) { return false ; } return true ; }
Are data registry defaults set?
27,917
public static function get_site_categories ( ) { global $ DB ; if ( method_exists ( '\core_course_category' , 'get_all' ) ) { $ categories = \ core_course_category :: get_all ( [ 'returnhidden' => true ] ) ; } else { $ ids = $ DB -> get_fieldset_select ( 'course_categories' , 'id' , '' ) ; $ categories = \ core_course_...
Returns all site categories that are visible to the current user .
27,918
public static function get_subject_scope ( \ context $ context ) { if ( $ contextcourse = $ context -> get_course_context ( false ) ) { $ courseroles = get_roles_used_in_context ( $ contextcourse , false ) ; $ roles = $ courseroles + get_roles_used_in_context ( $ context , false ) ; } else { $ roles = get_roles_used_in...
Returns the roles assigned to the provided level .
27,919
public static function get_effective_contextlevel_value ( $ contextlevel , $ element ) { if ( $ element !== 'purpose' && $ element !== 'category' ) { throw new coding_exception ( 'Only \'purpose\' and \'category\' are supported.' ) ; } $ fieldname = $ element . 'id' ; if ( $ contextlevel != CONTEXT_SYSTEM && $ contextl...
Returns the effective value for a context level .
27,920
public static function get_effective_default_contextlevel_purpose_and_category ( $ contextlevel , $ forcedpurposevalue = false , $ forcedcategoryvalue = false , $ component = '' ) { list ( $ purposeid , $ categoryid ) = self :: get_defaults ( $ contextlevel , $ component ) ; if ( $ forcedpurposevalue ) { $ purposeid = ...
Returns the effective default purpose and category for a context level .
27,921
private static function get_element_instance ( $ element , $ id ) { if ( $ element !== 'purpose' && $ element !== 'category' ) { throw new coding_exception ( 'No other elements than purpose and category are allowed' ) ; } $ classname = '\tool_dataprivacy\\' . $ element ; return new $ classname ( $ id ) ; }
Returns an instance of the provided element .
27,922
protected function getSharedStringTempFilePath ( $ sharedStringIndex ) { $ numTempFile = intval ( $ sharedStringIndex / $ this -> maxNumStringsPerTempFile ) ; return $ this -> tempFolder . '/sharedstrings' . $ numTempFile ; }
Returns the path for the temp file that should contain the string for the given index
27,923
public function getStringAtIndex ( $ sharedStringIndex ) { $ tempFilePath = $ this -> getSharedStringTempFilePath ( $ sharedStringIndex ) ; $ indexInFile = $ sharedStringIndex % $ this -> maxNumStringsPerTempFile ; if ( ! $ this -> globalFunctionsHelper -> file_exists ( $ tempFilePath ) ) { throw new SharedStringNotFou...
Returns the string located at the given index from the cache .
27,924
public static function get_qtype ( $ qtypename , $ mustexist = true ) { global $ CFG ; if ( isset ( self :: $ questiontypes [ $ qtypename ] ) ) { return self :: $ questiontypes [ $ qtypename ] ; } $ file = core_component :: get_plugin_directory ( 'qtype' , $ qtypename ) . '/questiontype.php' ; if ( ! is_readable ( $ fi...
Get the question type class for a particular question type .
27,925
public static function sort_qtype_array ( $ qtypes , $ config = null ) { if ( is_null ( $ config ) ) { $ config = self :: get_config ( ) ; } $ sortorder = array ( ) ; $ otherqtypes = array ( ) ; foreach ( $ qtypes as $ name => $ localname ) { $ sortvar = $ name . '_sortorder' ; if ( isset ( $ config -> $ sortvar ) ) { ...
Sort an array of question types according to the order the admin set up and then alphabetically for the rest .
27,926
public static function get_all_question_types_in_categories ( $ categories ) { global $ DB ; list ( $ categorysql , $ params ) = $ DB -> get_in_or_equal ( $ categories ) ; $ sql = "SELECT DISTINCT q.qtype FROM {question} q WHERE q.category $categorysql" ; $ qtypes = $ DB -> get_fieldset_sq...
Return a list of the different question types present in the given categories .
27,927
public function get_questions_from_categories ( $ categoryids , $ extraconditions , $ extraparams = array ( ) ) { global $ DB ; list ( $ qcsql , $ qcparams ) = $ DB -> get_in_or_equal ( $ categoryids , SQL_PARAMS_NAMED , 'qc' ) ; if ( $ extraconditions ) { $ extraconditions = ' AND (' . $ extraconditions . ')' ; } retu...
Get the ids of all the questions in a list of categories .
27,928
public function get_questions_from_categories_with_usage_counts ( $ categoryids , qubaid_condition $ qubaids , $ extraconditions = '' , $ extraparams = array ( ) ) { return $ this -> get_questions_from_categories_and_tags_with_usage_counts ( $ categoryids , $ qubaids , $ extraconditions , $ extraparams ) ; }
Get the ids of all the questions in a list of categories with the number of times they have already been used in a given set of usages .
27,929
public function get_questions_from_categories_and_tags_with_usage_counts ( $ categoryids , qubaid_condition $ qubaids , $ extraconditions = '' , $ extraparams = array ( ) , $ tagids = array ( ) ) { global $ DB ; list ( $ qcsql , $ qcparams ) = $ DB -> get_in_or_equal ( $ categoryids , SQL_PARAMS_NAMED , 'qc' ) ; $ sele...
Get the ids of all the questions in a list of categories that have ALL the provided tags with the number of times they have already been used in a given set of usages .
27,930
function validation ( $ data , $ files ) { global $ CFG , $ COURSE ; $ errors = parent :: validation ( $ data , $ files ) ; if ( $ data [ 'allocateby' ] != 'no' ) { $ source = array ( ) ; if ( $ data [ 'cohortid' ] ) { $ source [ 'cohortid' ] = $ data [ 'cohortid' ] ; } if ( $ data [ 'groupingid' ] ) { $ source [ 'grou...
Performs validation of the form information
27,931
public function delete ( $ id ) { $ file = $ this -> collectionWrapper -> findFileById ( $ id ) ; $ this -> collectionWrapper -> deleteFileAndChunksById ( $ id ) ; if ( $ file === null ) { throw FileNotFoundException :: byId ( $ id , $ this -> getFilesNamespace ( ) ) ; } }
Delete a file from the GridFS bucket .
27,932
public function downloadToStream ( $ id , $ destination ) { if ( ! is_resource ( $ destination ) || get_resource_type ( $ destination ) != "stream" ) { throw InvalidArgumentException :: invalidType ( '$destination' , $ destination , 'resource' ) ; } stream_copy_to_stream ( $ this -> openDownloadStream ( $ id ) , $ dest...
Writes the contents of a GridFS file to a writable stream .
27,933
public function downloadToStreamByName ( $ filename , $ destination , array $ options = [ ] ) { if ( ! is_resource ( $ destination ) || get_resource_type ( $ destination ) != "stream" ) { throw InvalidArgumentException :: invalidType ( '$destination' , $ destination , 'resource' ) ; } stream_copy_to_stream ( $ this -> ...
Writes the contents of a GridFS file which is selected by name and revision to a writable stream .
27,934
public function getFileIdForStream ( $ stream ) { $ file = $ this -> getRawFileDocumentForStream ( $ stream ) ; $ typeMap = [ 'root' => 'stdClass' ] + $ this -> typeMap ; $ file = \ MongoDB \ apply_type_map_to_document ( $ file , $ typeMap ) ; if ( ! isset ( $ file -> _id ) && ! property_exists ( $ file , '_id' ) ) { t...
Gets the file document s ID of the GridFS file associated with a stream .
27,935
public function openDownloadStream ( $ id ) { $ file = $ this -> collectionWrapper -> findFileById ( $ id ) ; if ( $ file === null ) { throw FileNotFoundException :: byId ( $ id , $ this -> getFilesNamespace ( ) ) ; } return $ this -> openDownloadStreamByFile ( $ file ) ; }
Opens a readable stream for reading a GridFS file .
27,936
public function openDownloadStreamByName ( $ filename , array $ options = [ ] ) { $ options += [ 'revision' => - 1 ] ; $ file = $ this -> collectionWrapper -> findFileByFilenameAndRevision ( $ filename , $ options [ 'revision' ] ) ; if ( $ file === null ) { throw FileNotFoundException :: byFilenameAndRevision ( $ filen...
Opens a readable stream stream to read a GridFS file which is selected by name and revision .
27,937
public function openUploadStream ( $ filename , array $ options = [ ] ) { $ options += [ 'chunkSizeBytes' => $ this -> chunkSizeBytes ] ; $ path = $ this -> createPathForUpload ( ) ; $ context = stream_context_create ( [ self :: $ streamWrapperProtocol => [ 'collectionWrapper' => $ this -> collectionWrapper , 'filename...
Opens a writable stream for writing a GridFS file .
27,938
public function rename ( $ id , $ newFilename ) { $ updateResult = $ this -> collectionWrapper -> updateFilenameForId ( $ id , $ newFilename ) ; if ( $ updateResult -> getModifiedCount ( ) === 1 ) { return ; } $ found = $ updateResult -> getMatchedCount ( ) !== null ? $ updateResult -> getMatchedCount ( ) === 1 : $ thi...
Renames the GridFS file with the specified ID .
27,939
public function uploadFromStream ( $ filename , $ source , array $ options = [ ] ) { if ( ! is_resource ( $ source ) || get_resource_type ( $ source ) != "stream" ) { throw InvalidArgumentException :: invalidType ( '$source' , $ source , 'resource' ) ; } $ destination = $ this -> openUploadStream ( $ filename , $ optio...
Writes the contents of a readable stream to a GridFS file .
27,940
private function createPathForFile ( stdClass $ file ) { if ( ! is_object ( $ file -> _id ) || method_exists ( $ file -> _id , '__toString' ) ) { $ id = ( string ) $ file -> _id ; } else { $ id = \ MongoDB \ BSON \ toJSON ( \ MongoDB \ BSON \ fromPHP ( [ '_id' => $ file -> _id ] ) ) ; } return sprintf ( '%s://%s/%s.fil...
Creates a path for an existing GridFS file .
27,941
private function createPathForUpload ( ) { return sprintf ( '%s://%s/%s.files' , self :: $ streamWrapperProtocol , urlencode ( $ this -> databaseName ) , urlencode ( $ this -> bucketName ) ) ; }
Creates a path for a new GridFS file which does not yet have an ID .
27,942
private function openDownloadStreamByFile ( stdClass $ file ) { $ path = $ this -> createPathForFile ( $ file ) ; $ context = stream_context_create ( [ self :: $ streamWrapperProtocol => [ 'collectionWrapper' => $ this -> collectionWrapper , 'file' => $ file , ] , ] ) ; return fopen ( $ path , 'r' , false , $ context )...
Opens a readable stream for the GridFS file .
27,943
public function get_min_max_of ( $ attribute ) { $ getmethod = 'get_min_max_of_' . $ attribute ; if ( method_exists ( $ this , $ getmethod ) ) { return $ this -> $ getmethod ( ) ; } else { $ min = $ max = null ; $ set = false ; foreach ( array_column ( $ this -> subqstats , $ attribute ) as $ value ) { if ( is_scalar (...
Returns the minimum and maximum values of the given attribute in the summarised calculated stats .
27,944
protected function get_min_max_of_sd ( ) { $ min = $ max = null ; $ set = false ; foreach ( $ this -> subqstats as $ subqstat ) { if ( isset ( $ subqstat -> sd ) && $ subqstat -> maxmark ) { $ value = $ subqstat -> sd / $ subqstat -> maxmark ; } else { $ value = null ; } if ( ! $ set ) { $ min = $ value ; $ max = $ val...
Returns the minimum and maximum values of the standard deviation in the summarised calculated stats .
27,945
protected function max ( float $ value1 = null , float $ value2 = null ) { $ temp1 = $ value1 ? : 0 ; $ temp2 = $ value2 ? : 0 ; $ tempmax = max ( $ temp1 , $ temp2 ) ; if ( ! $ tempmax && $ value1 !== 0 && $ value2 !== 0 ) { $ max = null ; } else { $ max = $ tempmax ; } return $ max ; }
Find higher value . A zero value is almost considered equal to zero in comparisons . The only difference is that when being compared to zero zero is higher than null .
27,946
protected function min ( float $ value1 = null , float $ value2 = null ) { $ temp1 = $ value1 ? : 0 ; $ temp2 = $ value2 ? : 0 ; $ tempmin = min ( $ temp1 , $ temp2 ) ; if ( ! $ tempmin && $ value1 !== 0 && $ value2 !== 0 ) { $ min = null ; } else { $ min = $ tempmin ; } return $ min ; }
Find lower value . A zero value is almost considered equal to zero in comparisons . The only difference is that when being compared to zero zero is lower than null .
27,947
public function writeString ( $ string ) { fwrite ( $ this -> sharedStringsFilePointer , '<si><t xml:space="preserve">' . $ this -> stringsEscaper -> escape ( $ string ) . '</t></si>' ) ; $ this -> numSharedStrings ++ ; return ( $ this -> numSharedStrings - 1 ) ; }
Writes the given string into the sharedStrings . xml file . Starting and ending whitespaces are preserved .
27,948
public function close ( ) { if ( ! is_resource ( $ this -> sharedStringsFilePointer ) ) { return ; } fwrite ( $ this -> sharedStringsFilePointer , '</sst>' ) ; $ firstPartHeaderLength = strlen ( self :: SHARED_STRINGS_XML_FILE_FIRST_PART_HEADER ) ; $ defaultStringsCountPartLength = strlen ( self :: DEFAULT_STRINGS_COUN...
Finishes writing the data in the sharedStrings . xml file and closes the file .
27,949
public static function get_lock_factory ( $ type ) { global $ CFG , $ DB ; $ lockfactory = null ; if ( during_initial_install ( ) ) { $ lockfactory = new \ core \ lock \ installation_lock_factory ( $ type ) ; } else if ( isset ( $ CFG -> lock_factory ) && $ CFG -> lock_factory != 'auto' ) { if ( ! class_exists ( $ CFG ...
Get an instance of the currently configured locking subclass .
27,950
protected static function export_recentitems ( int $ userid , \ context $ context ) { global $ DB ; $ sql = "SELECT ra.id, c.fullname, ra.timeaccess, m.name, ra.cmid FROM {block_recentlyaccesseditems} ra JOIN {course} c ON c.id = ra.courseid JOIN {course_modules} cm on...
Export information about the most recently accessed items .
27,951
public function create_answers ( $ properties ) { if ( isset ( $ properties -> enableotheranswers ) && $ properties -> enableotheranswers ) { $ properties -> response_editor = array_values ( $ properties -> response_editor ) ; $ properties -> jumpto = array_values ( $ properties -> jumpto ) ; $ properties -> score = ar...
Creates answers for this page type .
27,952
public function update ( $ properties , $ context = null , $ maxbytes = null ) { if ( $ properties -> enableotheranswers ) { $ properties -> response_editor = array_values ( $ properties -> response_editor ) ; $ properties -> jumpto = array_values ( $ properties -> jumpto ) ; $ properties -> score = array_values ( $ pr...
Update the answers for this page type .
27,953
public function update_form_data ( stdClass $ data ) : stdClass { $ answercount = count ( $ this -> get_answers ( ) ) ; $ lastanswer = $ data -> { 'answer_editor[' . ( $ answercount - 1 ) . ']' } ; if ( strpos ( $ lastanswer , LESSON_OTHER_ANSWERS ) !== false ) { $ data -> { 'answer_editor[' . ( $ this -> lesson -> max...
Make updates to the form data if required . In this case to put the all other answer data into the write section of the form .
27,954
public static function annotate_files ( $ backupid , $ contextid , $ component , $ filearea , $ itemid , \ core \ progress \ base $ progress = null ) { global $ DB ; $ sql = 'SELECT id FROM {files} WHERE contextid = ? AND component = ?' ; $ params = array ( $ contextid...
Adds backup id database record for all files in the given file area .
27,955
public static function move_annotations_to_final ( $ backupid , $ itemname , \ core \ progress \ base $ progress ) { global $ DB ; $ progress -> start_progress ( 'move_annotations_to_final' ) ; $ rs = $ DB -> get_recordset ( 'backup_ids_temp' , array ( 'backupid' => $ backupid , 'itemname' => $ itemname ) ) ; $ progres...
Moves all the existing item annotations to their final itemfinal ones for a given backup .
27,956
public function execute ( ) { global $ CFG , $ DB ; if ( ! empty ( $ CFG -> gradehistorylifetime ) ) { $ now = time ( ) ; $ histlifetime = $ now - ( $ CFG -> gradehistorylifetime * DAYSECS ) ; $ tables = [ 'grade_outcomes_history' , 'grade_categories_history' , 'grade_items_history' , 'grade_grades_history' , 'scale_hi...
Cleanup history tables .
27,957
public function sort_nodes ( ) { $ tempnodes = array ( ) ; $ this -> validate_after_order ( ) ; foreach ( $ this -> nodes as $ node ) { $ after = $ node -> after ; $ content = $ node -> content ; if ( ( $ after == null && ! empty ( $ content ) ) || $ node -> name === 'editprofile' ) { $ tempnodes = array_merge ( $ temp...
Sort nodes of the category in the order in which they should be displayed .
27,958
protected function validate_after_order ( ) { $ nodearray = $ this -> nodes ; foreach ( $ this -> nodes as $ node ) { $ after = $ node -> after ; if ( ! empty ( $ after ) ) { if ( empty ( $ nodearray [ $ after ] ) ) { throw new \ coding_exception ( 'node {$node->name} specified contains invalid \'after\' property' ) ; ...
Verifies that node with content can come after node with content only . Also verifies the same thing for nodes without content .
27,959
protected function find_nodes_after ( $ node ) { $ return = array ( ) ; $ nodearray = $ this -> nodes ; foreach ( $ nodearray as $ nodeelement ) { if ( $ nodeelement -> after === $ node -> name ) { $ return = array_merge ( $ return , array ( $ nodeelement -> name => $ nodeelement ) , $ this -> find_nodes_after ( $ node...
Given a node object find all node objects that should appear after it .
27,960
function user_login ( $ username , $ password ) { $ this -> connectCAS ( ) ; return phpCAS :: isAuthenticated ( ) && ( trim ( core_text :: strtolower ( phpCAS :: getUser ( ) ) ) == $ username ) ; }
Authenticates user against CAS Returns true if the username and password work and false if they are wrong or don t exist .
27,961
function sync_users ( $ do_updates = true ) { if ( empty ( $ this -> config -> host_url ) ) { error_log ( '[AUTH CAS] ' . get_string ( 'noldapserver' , 'auth_cas' ) ) ; return ; } parent :: sync_users ( $ do_updates ) ; }
Syncronizes users from LDAP server to moodle user table .
27,962
public function postlogout_hook ( $ user ) { global $ CFG ; if ( ! empty ( $ this -> config -> logoutcas ) && $ user -> auth == $ this -> authtype ) { $ backurl = ! empty ( $ this -> config -> logout_return_url ) ? $ this -> config -> logout_return_url : $ CFG -> wwwroot ; $ this -> connectCAS ( ) ; phpCAS :: logoutWit...
Post logout hook .
27,963
protected static function replace_sql_legacy ( $ selectwhere , array $ params , $ sort = '' ) { if ( $ selectwhere == "userid = :userid AND courseid = :courseid AND eventname = :eventname AND timecreated > :since" and empty ( $ sort ) ) { $ replace = "module = 'course' AND action = 'new' AND userid = :userid AND url = ...
This method contains mapping required for Moodle core to make legacy store compatible with other sql_reader based queries .
27,964
protected function process_book_chapter ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> course = $ this -> get_courseid ( ) ; $ data -> bookid = $ this -> get_new_parentid ( 'book' ) ; $ newitemid = $ DB -> insert_record ( 'book_chapters' , $ data ) ; $ this -> set_mapping ( '...
Process chapter tag information
27,965
public static function build_tree ( $ user , $ iscurrentuser , $ course = null ) { global $ CFG ; $ tree = new tree ( ) ; require_once ( $ CFG -> libdir . "/myprofilelib.php" ) ; core_myprofile_navigation ( $ tree , $ user , $ iscurrentuser , $ course ) ; $ components = \ core_component :: get_core_subsystems ( ) ; for...
Parse all callbacks and builds the tree .
27,966
protected function in_alternative_role ( $ context ) { global $ USER , $ PAGE ; if ( ! empty ( $ USER -> access [ 'rsw' ] ) && is_array ( $ USER -> access [ 'rsw' ] ) ) { if ( ! empty ( $ PAGE -> context ) && ! empty ( $ USER -> access [ 'rsw' ] [ $ PAGE -> context -> path ] ) ) { return $ USER -> access [ 'rsw' ] [ $ ...
Determine whether the user is assuming another role
27,967
protected function get_cognitive_indicator ( $ modname ) { $ indicators = \ core_analytics \ manager :: get_all_indicators ( ) ; foreach ( $ indicators as $ indicator ) { if ( $ indicator instanceof community_of_inquiry_activity && $ indicator -> get_indicator_type ( ) === community_of_inquiry_activity :: INDICATOR_COG...
Returns the cognitive depth class of this indicator .
27,968
protected function is_only_numbers ( ) { $ args = func_get_args ( ) ; foreach ( $ args as $ arg ) { if ( 0 === preg_match ( '!^[0-9]+$!' , $ arg ) ) { return false ; } } return true ; }
Test if all passed parameters consist of only numbers .
27,969
protected function is_point_in_bounding_box ( $ pointxy , $ xleftytop , $ xrightybottom ) { if ( $ pointxy [ 0 ] < $ xleftytop [ 0 ] ) { return false ; } else if ( $ pointxy [ 0 ] > $ xrightybottom [ 0 ] ) { return false ; } else if ( $ pointxy [ 1 ] < $ xleftytop [ 1 ] ) { return false ; } else if ( $ pointxy [ 1 ] > ...
Checks if the point is within the bounding box made by top left and bottom right
27,970
public function get_coords_interpreter_error ( ) { if ( $ this -> error ) { $ a = new stdClass ( ) ; $ a -> shape = self :: human_readable_name ( true ) ; $ a -> coordsstring = self :: human_readable_coords_format ( ) ; return get_string ( 'formerror_' . $ this -> error , 'qtype_ddmarker' , $ a ) ; } else { return fals...
Gets any coordinate error
27,971
public static function human_readable_name ( $ lowercase = false ) { $ stringid = 'shape_' . self :: name ( ) ; if ( $ lowercase ) { $ stringid .= '_lowercase' ; } return get_string ( $ stringid , 'qtype_ddmarker' ) ; }
Return a human readable name of the shape .
27,972
public function dist ( $ other ) { return sqrt ( pow ( $ this -> x - $ other -> x , 2 ) + pow ( $ this -> y - $ other -> y , 2 ) ) ; }
Return the distance between this point and another
27,973
public static function export_user_data ( approved_contextlist $ contextlist ) { global $ DB ; if ( ! count ( $ contextlist ) ) { return ; } $ user = $ contextlist -> get_user ( ) ; foreach ( $ contextlist -> get_contexts ( ) as $ context ) { if ( $ context -> contextlevel != CONTEXT_MODULE ) { continue ; } $ data = he...
Export personal data stored in the given contexts .
27,974
protected static function export_assessment_forms ( \ stdClass $ user , \ context $ context , array $ subcontext , int $ assessmentid ) { foreach ( \ workshop :: available_strategies_list ( ) as $ strategy => $ title ) { $ providername = '\workshopform_' . $ strategy . '\privacy\provider' ; if ( is_subclass_of ( $ prov...
Export the grading strategy data related to the particular assessment .
27,975
public static function delete_data_for_all_users_in_context ( \ context $ context ) { global $ CFG , $ DB ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; if ( $ context -> contextlevel != CONTEXT_MODULE ) { return ; } $ cm = get_coursemodule_from_id ( 'workshop' , $ context -> instanceid , 0 , false , IGNORE_MIS...
Delete personal data for all users in the context .
27,976
public function addRequest ( CAS_Request_RequestInterface $ request ) { if ( $ this -> _sent ) { throw new CAS_OutOfSequenceException ( 'Request has already been sent cannot ' . __METHOD__ ) ; } if ( ! $ request instanceof CAS_Request_CurlRequest ) { throw new CAS_InvalidArgumentException ( 'As a CAS_Request_CurlMultiR...
Add a new Request to this batch . Note implementations will likely restrict requests to their own concrete class hierarchy .
27,977
public function send ( ) { if ( $ this -> _sent ) { throw new CAS_OutOfSequenceException ( 'Request has already been sent cannot send again.' ) ; } if ( ! count ( $ this -> _requests ) ) { throw new CAS_OutOfSequenceException ( 'At least one request must be added via addRequest() before the multi-request can be sent.' ...
Perform the request . After sending all requests will have their responses poulated .
27,978
public function get_attachments ( ) { global $ CFG ; require_once ( $ CFG -> libdir . '/filelib.php' ) ; $ syscontext = context_system :: instance ( ) ; $ fs = get_file_storage ( ) ; $ files = $ fs -> get_area_files ( $ syscontext -> id , 'blog' , 'attachment' , $ this -> id ) ; $ attachments = array ( ) ; foreach ( $ ...
Gets the entry attachments list
27,979
public function edit ( $ params = array ( ) , $ form = null , $ summaryoptions = array ( ) , $ attachmentoptions = array ( ) ) { global $ CFG , $ DB ; $ sitecontext = context_system :: instance ( ) ; $ entry = $ this ; $ this -> form = $ form ; foreach ( $ params as $ var => $ val ) { $ entry -> $ var = $ val ; } $ ent...
Updates this entry in the database . Access control checks must be done by calling code .
27,980
public function delete ( ) { global $ DB ; $ this -> delete_attachments ( ) ; $ this -> remove_associations ( ) ; $ record = $ DB -> get_record ( 'post' , array ( 'id' => $ this -> id ) ) ; $ DB -> delete_records ( 'post' , array ( 'id' => $ this -> id ) ) ; core_tag_tag :: remove_all_item_tags ( 'core' , 'post' , $ th...
Deletes this entry from the database . Access control checks must be done by calling code .
27,981
public function add_associations ( $ unused = null ) { if ( $ unused !== null ) { debugging ( 'Illegal argument used in blog_entry->add_associations()' , DEBUG_DEVELOPER ) ; } $ this -> remove_associations ( ) ; if ( ! empty ( $ this -> courseassoc ) ) { $ this -> add_association ( $ this -> courseassoc ) ; } if ( ! em...
Function to add all context associations to an entry .
27,982
public function add_association ( $ contextid , $ unused = null ) { global $ DB ; if ( $ unused !== null ) { debugging ( 'Illegal argument used in blog_entry->add_association()' , DEBUG_DEVELOPER ) ; } $ assocobject = new StdClass ; $ assocobject -> contextid = $ contextid ; $ assocobject -> blogid = $ this -> id ; $ i...
Add a single association for a blog entry
27,983
public function remove_associations ( ) { global $ DB ; $ associations = $ DB -> get_records ( 'blog_association' , array ( 'blogid' => $ this -> id ) ) ; foreach ( $ associations as $ association ) { $ context = context :: instance_by_id ( $ association -> contextid ) ; $ eventparam = array ( 'objectid' => $ this -> i...
remove all associations for a blog entry
27,984
public function delete_attachments ( ) { $ fs = get_file_storage ( ) ; $ fs -> delete_area_files ( SYSCONTEXTID , 'blog' , 'attachment' , $ this -> id ) ; $ fs -> delete_area_files ( SYSCONTEXTID , 'blog' , 'post' , $ this -> id ) ; }
Deletes all the user files in the attachments area for an entry
27,985
public static function get_applicable_publish_states ( ) { global $ CFG ; $ options = array ( ) ; if ( $ CFG -> bloglevel >= BLOG_USER_LEVEL ) { $ options [ 'draft' ] = get_string ( 'publishtonoone' , 'blog' ) ; } if ( $ CFG -> bloglevel > BLOG_USER_LEVEL ) { $ options [ 'site' ] = get_string ( 'publishtosite' , 'blog'...
Use this function to retrieve a list of publish states available for the currently logged in user .
27,986
public function get_entries ( $ start = 0 , $ limit = 10 ) { global $ DB ; if ( $ this -> entries === null ) { if ( $ sqlarray = $ this -> get_entry_fetch_sql ( false , 'created DESC' ) ) { $ this -> entries = $ DB -> get_records_sql ( $ sqlarray [ 'sql' ] , $ sqlarray [ 'params' ] , $ start , $ limit ) ; if ( ! $ star...
Fetches the array of blog entries .
27,987
public function count_entries ( ) { global $ DB ; if ( $ this -> totalentries === null ) { if ( $ sqlarray = $ this -> get_entry_fetch_sql ( true ) ) { $ this -> totalentries = $ DB -> count_records_sql ( $ sqlarray [ 'sql' ] , $ sqlarray [ 'params' ] ) ; } else { $ this -> totalentries = 0 ; } } return $ this -> total...
Finds total number of blog entries
27,988
public function print_entries ( ) { global $ CFG , $ USER , $ DB , $ OUTPUT , $ PAGE ; $ sitecontext = context_system :: instance ( ) ; $ output = $ PAGE -> get_renderer ( 'blog' ) ; $ page = optional_param ( 'blogpage' , 0 , PARAM_INT ) ; $ limit = optional_param ( 'limit' , get_user_preferences ( 'blogpagesize' , 10 ...
Outputs all the blog entries aggregated by this blog listing .
27,989
public function filter ( $ text , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'originalformat' ] ) ) { return $ text ; } if ( in_array ( $ options [ 'originalformat' ] , explode ( ',' , get_config ( 'filter_emoticon' , 'formats' ) ) ) ) { return $ this -> replace_emoticons ( $ text ) ; } return $ text ; ...
Apply the filter to the text
27,990
protected function replace_emoticons ( $ text ) { global $ CFG , $ OUTPUT , $ PAGE ; $ lang = current_language ( ) ; $ theme = $ PAGE -> theme -> name ; if ( ! isset ( self :: $ emoticontexts [ $ lang ] [ $ theme ] ) or ! isset ( self :: $ emoticonimgs [ $ lang ] [ $ theme ] ) ) { $ manager = get_emoticon_manager ( ) ;...
Replace emoticons found in the text with their images
27,991
public function add_import_options ( ) { $ mform = $ this -> _form ; $ mform -> addElement ( 'header' , 'importoptionshdr' , get_string ( 'importoptions' , 'tool_uploadcourse' ) ) ; $ mform -> setExpanded ( 'importoptionshdr' , true ) ; $ choices = array ( tool_uploadcourse_processor :: MODE_CREATE_NEW => get_string ( ...
Adds the import settings part .
27,992
public static function export_user_data ( approved_contextlist $ contextlist ) { global $ DB ; $ context = \ context_user :: instance ( $ contextlist -> get_user ( ) -> id ) ; $ sql = "SELECT ll.id, ll.username, ll.email, ll.timecreated, ll.timemodified, oi.name as issuername FROM {auth_oauth2_linked_log...
Export all oauth2 information for the list of contexts and this user .
27,993
public function format_definition ( $ line , $ grade ) { foreach ( $ this -> definition ( ) as $ i => $ field ) { $ tab = ( $ i * $ this -> total ) + $ this -> index ; $ classname = '\\gradereport_singleview\\local\\ui\\' . $ field ; $ html = new $ classname ( $ grade , $ tab ) ; if ( $ field == 'finalgrade' and ! empt...
Get a element to generate the HTML for this table row
27,994
public function html ( ) { global $ OUTPUT ; if ( ! empty ( $ this -> initerrors ) ) { $ warnings = '' ; foreach ( $ this -> initerrors as $ mesg ) { $ warnings .= $ OUTPUT -> notification ( $ mesg ) ; } return $ warnings ; } $ table = new html_table ( ) ; $ table -> head = $ this -> headers ( ) ; $ summary = $ this ->...
Get the HTML for the whole table
27,995
protected function setup_table_ajax ( ) { $ filter = $ this -> setup_filters ( ) ; $ this -> tablelog = new report_loglive_table_log_ajax ( 'report_loglive' , $ filter ) ; $ this -> tablelog -> define_baseurl ( $ this -> url ) ; }
Setup table log for ajax output .
27,996
protected function set_refresh_rate ( ) { if ( defined ( 'BEHAT_SITE_RUNNING' ) ) { $ this -> refresh = 5 ; } else { if ( defined ( 'REPORT_LOGLIVE_REFRESH' ) ) { $ this -> refresh = REPORT_LOGLIVE_REFERESH ; } else { $ this -> refresh = 60 ; } } }
Set refresh rate of the live updates .
27,997
public function get_table ( $ ajax = false ) { if ( empty ( $ this -> tablelog ) ) { if ( $ ajax ) { $ this -> setup_table_ajax ( ) ; } else { $ this -> setup_table ( ) ; } } return $ this -> tablelog ; }
Setup table and return it .
27,998
protected function define_structure ( ) { $ paths = array ( ) ; $ userinfo = $ this -> get_setting_value ( 'userinfo' ) ; $ paths [ ] = new restore_path_element ( 'assign' , '/activity/assign' ) ; if ( $ userinfo ) { $ submission = new restore_path_element ( 'assign_submission' , '/activity/assign/submissions/submissio...
Define the structure of the restore workflow .
27,999
protected function process_assign ( $ data ) { global $ DB ; $ data = ( object ) $ data ; $ oldid = $ data -> id ; $ data -> course = $ this -> get_courseid ( ) ; $ data -> allowsubmissionsfromdate = $ this -> apply_date_offset ( $ data -> allowsubmissionsfromdate ) ; $ data -> duedate = $ this -> apply_date_offset ( $...
Process an assign restore .