idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
35,100 | protected static function prepare_cookies ( ) { global $ CFG ; $ cookiesecure = is_moodle_cookie_secure ( ) ; if ( ! isset ( $ CFG -> cookiehttponly ) ) { $ CFG -> cookiehttponly = 0 ; } if ( ! isset ( $ CFG -> sessioncookie ) ) { $ CFG -> sessioncookie = '' ; } $ sessionname = 'MoodleSession' . $ CFG -> sessioncookie ... | Make sure all cookie and session related stuff is configured properly before session start . |
35,101 | protected static function add_session_record ( $ userid ) { global $ DB ; $ record = new \ stdClass ( ) ; $ record -> state = 0 ; $ record -> sid = session_id ( ) ; $ record -> sessdata = null ; $ record -> userid = $ userid ; $ record -> timecreated = $ record -> timemodified = time ( ) ; $ record -> firstip = $ recor... | Insert new empty session record . |
35,102 | protected static function check_security ( ) { global $ CFG ; if ( ! empty ( $ _SESSION [ 'USER' ] -> id ) and ! empty ( $ CFG -> tracksessionip ) ) { $ remoteaddr = getremoteaddr ( ) ; if ( empty ( $ _SESSION [ 'USER' ] -> sessionip ) ) { $ _SESSION [ 'USER' ] -> sessionip = $ remoteaddr ; } if ( $ _SESSION [ 'USER' ]... | Do various session security checks . |
35,103 | public static function terminate_current ( ) { global $ DB ; if ( ! self :: $ sessionactive ) { self :: init_empty_session ( ) ; self :: $ sessionactive = false ; return ; } try { $ DB -> delete_records ( 'external_tokens' , array ( 'sid' => session_id ( ) , 'tokentype' => EXTERNAL_TOKEN_EMBEDDED ) ) ; } catch ( \ Exce... | Terminate current user session . |
35,104 | public static function write_close ( ) { global $ PERF ; if ( self :: $ sessionactive ) { $ PERF -> sessionlock [ 'released' ] = microtime ( true ) ; if ( ! empty ( $ PERF -> sessionlock [ 'gained' ] ) ) { $ PERF -> sessionlock [ 'held' ] = $ PERF -> sessionlock [ 'released' ] - $ PERF -> sessionlock [ 'gained' ] ; } $... | No more changes in session expected . Unblocks the sessions other scripts may start executing in parallel . |
35,105 | public static function session_exists ( $ sid ) { global $ DB , $ CFG ; if ( empty ( $ CFG -> version ) ) { return false ; } if ( ! $ record = $ DB -> get_record ( 'sessions' , array ( 'sid' => $ sid ) , 'id, userid, timemodified' ) ) { return false ; } if ( empty ( $ record -> userid ) or isguestuser ( $ record -> use... | Does the PHP session with given id exist? |
35,106 | public static function kill_all_sessions ( ) { global $ DB ; self :: terminate_current ( ) ; self :: load_handler ( ) ; self :: $ handler -> kill_all_sessions ( ) ; try { $ DB -> delete_records ( 'sessions' ) ; } catch ( \ dml_exception $ ignored ) { } } | Terminate all sessions unconditionally . |
35,107 | public static function kill_session ( $ sid ) { global $ DB ; self :: load_handler ( ) ; if ( $ sid === session_id ( ) ) { self :: write_close ( ) ; } self :: $ handler -> kill_session ( $ sid ) ; $ DB -> delete_records ( 'sessions' , array ( 'sid' => $ sid ) ) ; } | Terminate give session unconditionally . |
35,108 | public static function kill_user_sessions ( $ userid , $ keepsid = null ) { global $ DB ; $ sessions = $ DB -> get_records ( 'sessions' , array ( 'userid' => $ userid ) , 'id DESC' , 'id, sid' ) ; foreach ( $ sessions as $ session ) { if ( $ keepsid and $ keepsid === $ session -> sid ) { continue ; } self :: kill_sessi... | Terminate all sessions of given user unconditionally . |
35,109 | public static function loginas ( $ userid , \ context $ context , $ generateevent = true ) { global $ USER ; if ( self :: is_loggedinas ( ) ) { return ; } $ _SESSION = array ( ) ; $ _SESSION [ 'REALSESSION' ] = clone ( $ GLOBALS [ 'SESSION' ] ) ; $ GLOBALS [ 'SESSION' ] = new \ stdClass ( ) ; $ _SESSION [ 'SESSION' ] =... | Login as another user - no security checks here . |
35,110 | public static function keepalive ( $ identifier = 'sessionerroruser' , $ component = 'error' , $ frequency = null ) { global $ CFG , $ PAGE ; if ( $ frequency ) { if ( $ frequency > $ CFG -> sessiontimeout ) { throw new \ coding_exception ( 'Keepalive frequency is longer than the session lifespan.' ) ; } } else { $ fre... | Add a JS session keepalive to the page . |
35,111 | private static function create_login_token ( ) { global $ SESSION ; $ state = [ 'token' => random_string ( 32 ) , 'created' => time ( ) ] ; if ( ! isset ( $ SESSION -> logintoken ) ) { $ SESSION -> logintoken = [ ] ; } $ SESSION -> logintoken [ self :: $ logintokenkey ] = $ state ; return $ state ; } | Generate a new login token and store it in the session . |
35,112 | public static function get_login_token ( ) { global $ CFG , $ SESSION ; $ state = false ; if ( ! isset ( $ SESSION -> logintoken ) ) { $ SESSION -> logintoken = [ ] ; } if ( array_key_exists ( self :: $ logintokenkey , $ SESSION -> logintoken ) ) { $ state = $ SESSION -> logintoken [ self :: $ logintokenkey ] ; } if ( ... | Get the current login token or generate a new one . |
35,113 | public static function validate_login_token ( $ token = false ) { global $ CFG ; if ( ! empty ( $ CFG -> alternateloginurl ) || ! empty ( $ CFG -> disablelogintoken ) ) { return true ; } if ( $ token === false ) { return true ; } $ currenttoken = self :: get_login_token ( ) ; self :: create_login_token ( ) ; if ( $ cur... | Check the submitted value against the stored login token . |
35,114 | public static function update_recent_session_locks ( $ sessionlock ) { global $ CFG , $ SESSION ; if ( empty ( $ CFG -> debugsessionlock ) ) { return ; } $ SESSION -> recentsessionlocks = self :: get_recent_session_locks ( ) ; array_push ( $ SESSION -> recentsessionlocks , $ sessionlock ) ; self :: cleanup_recent_sessi... | Updates the recent session locks . |
35,115 | public static function cleanup_recent_session_locks ( ) { global $ SESSION ; $ locks = self :: get_recent_session_locks ( ) ; if ( count ( $ locks ) > 2 ) { for ( $ i = count ( $ locks ) - 1 ; $ i > 0 ; $ i -- ) { $ gap = $ locks [ $ i ] [ 'released' ] - $ locks [ $ i - 1 ] [ 'start' ] ; if ( $ gap >= 10 ) { $ SESSION ... | Reset recent session locks array if there is a 10 seconds time gap . |
35,116 | public static function get_locked_page_at ( $ time ) { $ recentsessionlocks = self :: get_recent_session_locks ( ) ; foreach ( $ recentsessionlocks as $ recentsessionlock ) { if ( $ time >= $ recentsessionlock [ 'gained' ] && $ time <= $ recentsessionlock [ 'released' ] ) { return $ recentsessionlock ; } } } | Get the page that blocks other pages at a specific timestamp . |
35,117 | public static function display_blocking_page ( ) { global $ PERF ; $ page = self :: get_locked_page_at ( $ PERF -> sessionlock [ 'start' ] ) ; $ output = "Script " . me ( ) . " was blocked for " ; $ output .= number_format ( $ PERF -> sessionlock [ 'wait' ] , 3 ) ; if ( $ page != null ) { $ output .= " second(s) by scr... | Display the page which blocks other pages . |
35,118 | public static function sessionlock_debugging ( ) { global $ CFG , $ PERF ; if ( ! empty ( $ CFG -> debugsessionlock ) ) { if ( isset ( $ PERF -> sessionlock [ 'held' ] ) && $ PERF -> sessionlock [ 'held' ] > $ CFG -> debugsessionlock ) { debugging ( "Script " . me ( ) . " locked the session for " . number_format ( $ PE... | Display debugging info about slow and blocked script . |
35,119 | public function get_available_saquestions_from_category ( $ categoryid , $ subcategories ) { if ( isset ( $ this -> availablesaquestionsbycategory [ $ categoryid ] [ $ subcategories ] ) ) { return $ this -> availablesaquestionsbycategory [ $ categoryid ] [ $ subcategories ] ; } if ( $ subcategories ) { $ categoryids = ... | Get all the usable shortanswer questions from a particular question category . |
35,120 | public function import_from_xml ( $ xml , $ fromform , qformat_xml $ format , $ extra = null ) { if ( ! isset ( $ xml [ '@' ] [ 'type' ] ) || $ xml [ '@' ] [ 'type' ] != $ this -> name ( ) ) { return false ; } $ fromform = $ format -> import_headers ( $ xml ) ; $ fromform -> qtype = $ this -> name ( ) ; $ format -> imp... | Imports the question from Moodle XML format . |
35,121 | public function export_to_xml ( $ question , qformat_xml $ format , $ extra = null ) { $ expout = '' ; $ expout .= $ format -> write_combined_feedback ( $ question -> options , $ question -> id , $ question -> contextid ) ; $ extraquestionfields = $ this -> extra_question_fields ( ) ; array_shift ( $ extraquestionfield... | Exports the question to Moodle XML format . |
35,122 | public function format_message_text ( $ cm , $ post ) { $ context = \ context_module :: instance ( $ cm -> id ) ; $ message = file_rewrite_pluginfile_urls ( $ post -> message , 'pluginfile.php' , $ context -> id , 'mod_forum' , 'post' , $ post -> id , [ 'includetoken' => true , ] ) ; $ options = new \ stdClass ( ) ; $ ... | The HTML version of the e - mail message . |
35,123 | public function validation ( $ usernew , $ files ) { global $ CFG , $ DB ; $ errors = parent :: validation ( $ usernew , $ files ) ; $ usernew = ( object ) $ usernew ; $ user = $ DB -> get_record ( 'user' , array ( 'id' => $ usernew -> id ) ) ; if ( ! isset ( $ usernew -> email ) ) { } else if ( ! validate_email ( $ us... | Validate incoming form data . |
35,124 | public function execute ( ) { global $ DB , $ PAGE ; $ this -> maxid = $ DB -> get_field_sql ( "SELECT MAX(id) FROM {message_email_messages}" ) ; $ noreplyuser = \ core_user :: get_noreply_user ( ) ; $ htmlrenderer = $ PAGE -> get_renderer ( 'message_email' , 'email' , 'htmlemail' ) ; $ textrenderer = $ PAGE -> get_ren... | Send out emails . |
35,125 | private function get_unique_users ( ) : moodle_recordset { global $ DB ; $ subsql = 'SELECT DISTINCT(useridto) as id FROM {message_email_messages} WHERE id <= ?' ; $ sql = "SELECT * FROM {user} u WHERE id IN ($subsql)" ; return $ DB -> get_recordse... | Returns an array of users in the given conversation . |
35,126 | private function get_conversations_for_user ( int $ userid ) : moodle_recordset { global $ DB ; $ sql = "SELECT DISTINCT mc.id, mc.name, c.id as courseid, c.fullname as coursename, g.id as groupid, g.picture, g.hidepicture FROM {message_conversations} mc ... | Returns an array of unique conversations that require processing . |
35,127 | protected function get_users_messages_for_conversation ( int $ conversationid , int $ userid ) : moodle_recordset { global $ DB ; $ usernamefields = \ user_picture :: fields ( 'u' ) ; $ sql = "SELECT $usernamefields, m.* FROM {messages} m JOIN {user} u ON u.id = m.us... | Returns the messages to send to a user for a given conversation |
35,128 | function Tables ( $ throwaway = 0 ) { $ rs = $ this -> conn -> Execute ( "select tabschema,tabname,card as rows, npages pages_used,fpages pages_allocated, tbspace tablespace from syscat.tables where tabschema not in ('SYSCAT','SYSIBM','SYSSTAT') order by 1,2" ) ; return rs2html ( $ rs , false , false , false , fals... | Gets a list of tables |
35,129 | function setElements ( $ elements ) { parent :: setElements ( $ elements ) ; foreach ( $ this -> _elements as $ element ) { if ( method_exists ( $ element , 'setHiddenLabel' ) ) { $ element -> setHiddenLabel ( true ) ; } } } | Sets the grouped elements and hides label |
35,130 | public function validateSubmitValue ( $ values ) { foreach ( $ this -> _elements as $ element ) { if ( method_exists ( $ element , 'validateSubmitValue' ) ) { $ value = $ values [ $ element -> getName ( ) ] ?? null ; $ result = $ element -> validateSubmitValue ( $ value ) ; if ( ! empty ( $ result ) && is_string ( $ re... | Calls the validateSubmitValue function for the containing elements and returns an error string as soon as it finds one . |
35,131 | protected function get_defaultexpiration_text ( \ core \ message \ inbound \ handler $ handler ) { switch ( $ handler -> defaultexpiration ) { case HOURSECS : return get_string ( 'onehour' , 'tool_messageinbound' ) ; case DAYSECS : return get_string ( 'oneday' , 'tool_messageinbound' ) ; case WEEKSECS : return get_stri... | Return a text string representing the selected default expiration for the handler . |
35,132 | public function diff ( $ rights ) { $ rlist = array_diff ( str_split ( $ rights ) , array_keys ( $ this -> _virtual ) ) ; return array ( 'added' => implode ( '' , array_diff ( $ rlist , $ this -> _rights ) ) , 'removed' => implode ( '' , array_diff ( $ this -> _rights , $ rlist ) ) ) ; } | Computes the difference to another rights string . Virtual rights are ignored . |
35,133 | public function get_status ( ) { if ( $ this -> combinedfile ) { return self :: STATUS_COMPLETE ; } if ( empty ( $ this -> sourcefiles ) ) { return self :: STATUS_FAILED ; } if ( ! empty ( $ this -> combinationstatus ) ) { return $ this -> combinationstatus ; } $ pending = false ; $ partial = false ; foreach ( $ this -... | Check the current status of the document combination . Note that the combined document may not contain all the source files if some of the source files were not able to be converted . An example is an audio file with a pdf cover sheet . Only the cover sheet will be included in the combined document . |
35,134 | public function is_partial_conversion ( ) { $ combinedfile = $ this -> get_combined_file ( ) ; if ( empty ( $ combinedfile ) ) { return false ; } $ filearea = $ combinedfile -> get_filearea ( ) ; return $ filearea == document_services :: PARTIAL_PDF_FILEAREA ; } | Return true of the combined file contained only some of the submission files . |
35,135 | public function refresh_files ( ) { $ converter = new \ core_files \ converter ( ) ; foreach ( $ this -> sourcefiles as $ file ) { if ( is_a ( $ file , \ core_files \ conversion :: class ) ) { $ status = $ file -> get ( 'status' ) ; switch ( $ status ) { case \ core_files \ conversion :: STATUS_COMPLETE : continue 2 ; ... | Refresh the files . |
35,136 | public function combine_files ( $ contextid , $ itemid ) { global $ CFG ; $ currentstatus = $ this -> get_status ( ) ; $ readystatuslist = [ self :: STATUS_READY , self :: STATUS_READY_PARTIAL ] ; if ( $ currentstatus === self :: STATUS_FAILED ) { $ this -> store_empty_document ( $ contextid , $ itemid ) ; return $ thi... | Combine all source files into a single PDF and store it in the file_storage API using the supplied contextid and itemid . |
35,137 | protected function store_combined_file ( $ tmpfile , $ contextid , $ itemid , $ partial = false ) { $ record = $ this -> get_stored_file_record ( $ contextid , $ itemid , $ partial ) ; $ fs = get_file_storage ( ) ; $ fs -> delete_area_files ( $ record -> contextid , $ record -> component , $ record -> filearea , $ reco... | Store the combined file in the file_storage API . |
35,138 | protected function store_empty_document ( $ contextid , $ itemid ) { $ record = $ this -> get_stored_file_record ( $ contextid , $ itemid ) ; $ fs = get_file_storage ( ) ; $ fs -> delete_area_files ( $ record -> contextid , $ record -> component , $ record -> filearea , $ record -> itemid ) ; $ file = $ fs -> create_fi... | Store the empty document file in the file_storage API . |
35,139 | public function get_page_count ( ) { if ( $ this -> pagecount ) { return $ this -> pagecount ; } $ status = $ this -> get_status ( ) ; if ( $ status === self :: STATUS_FAILED ) { return 1 ; } if ( $ status !== self :: STATUS_COMPLETE ) { return 0 ; } $ temparea = make_request_directory ( ) ; $ tempsrc = $ temparea . "/... | Get the total number of pages in the combined document . |
35,140 | protected function get_stored_file_record ( $ contextid , $ itemid , $ partial = false ) { $ filearea = document_services :: COMBINED_PDF_FILEAREA ; if ( $ partial ) { $ filearea = document_services :: PARTIAL_PDF_FILEAREA ; } return ( object ) [ 'contextid' => $ contextid , 'component' => 'assignfeedback_editpdf' , 'f... | Helper to fetch the stored_file record . |
35,141 | protected function calculateMeans ( array $ data , array $ classes ) : array { $ means = [ ] ; $ counts = [ ] ; $ overallMean = array_fill ( 0 , count ( $ data [ 0 ] ) , 0.0 ) ; foreach ( $ data as $ index => $ row ) { $ label = array_search ( $ classes [ $ index ] , $ this -> labels ) ; foreach ( $ row as $ col => $ v... | Calculates mean of each column for each class and returns n by m matrix where n is number of labels and m is number of columns |
35,142 | protected function calculateClassVar ( $ data , $ classes ) { $ s = array_fill ( 0 , count ( $ data [ 0 ] ) , array_fill ( 0 , count ( $ data [ 0 ] ) , 0 ) ) ; $ sW = new Matrix ( $ s , false ) ; foreach ( $ data as $ index => $ row ) { $ label = array_search ( $ classes [ $ index ] , $ this -> labels ) ; $ means = $ t... | Returns in - class scatter matrix for each class which is a n by m matrix where n is number of classes and m is number of columns |
35,143 | protected function calculateClassCov ( ) { $ s = array_fill ( 0 , count ( $ this -> overallMean ) , array_fill ( 0 , count ( $ this -> overallMean ) , 0 ) ) ; $ sB = new Matrix ( $ s , false ) ; foreach ( $ this -> means as $ index => $ classMeans ) { $ row = $ this -> calculateVar ( $ classMeans , $ this -> overallMea... | Returns between - class scatter matrix for each class which is an n by m matrix where n is number of classes and m is number of columns |
35,144 | public static function cm_updated ( \ core \ event \ course_module_updated $ event ) { if ( $ event -> other [ 'modulename' ] !== 'glossary' ) { return ; } concept_cache :: reset_course_muc ( $ event -> courseid ) ; concept_cache :: reset_global_muc ( ) ; } | Event observer do not call directly . |
35,145 | public static function reset_course_muc ( $ courseid ) { if ( empty ( $ courseid ) ) { return ; } $ cache = \ cache :: make ( 'mod_glossary' , 'concepts' ) ; $ cache -> delete ( ( int ) $ courseid ) ; } | Reset the cache for course concepts . |
35,146 | public static function reset_glossary ( $ glossary ) { if ( ! $ glossary -> usedynalink ) { return ; } self :: reset_course_muc ( $ glossary -> course ) ; if ( $ glossary -> globalglossary ) { self :: reset_global_muc ( ) ; } } | Utility method to purge caches related to given glossary . |
35,147 | protected static function fetch_concepts ( array $ glossaries ) { global $ DB ; $ glossarylist = implode ( ',' , $ glossaries ) ; $ sql = "SELECT id, glossaryid, concept, casesensitive, 0 AS category, fullmatch FROM {glossary_entries} WHERE glossaryid IN ($glossarylist) AND usedynalink ... | Fetch concepts for given glossaries . |
35,148 | protected static function get_course_concepts ( $ courseid ) { global $ DB ; if ( empty ( $ courseid ) ) { return array ( array ( ) , array ( ) ) ; } $ courseid = ( int ) $ courseid ; $ modinfo = get_fast_modinfo ( $ courseid ) ; $ cminfos = $ modinfo -> get_instances_of ( 'glossary' ) ; if ( ! $ cminfos ) { return arr... | Get all linked concepts from course . |
35,149 | protected static function get_global_concepts ( ) { global $ DB ; $ cache = \ cache :: make ( 'mod_glossary' , 'concepts' ) ; $ data = $ cache -> get ( 0 ) ; if ( is_array ( $ data ) ) { list ( $ glossaries , $ allconcepts ) = $ data ; } else { $ sql = "SELECT g.id, g.name FROM {glossary} g ... | Get all linked global concepts . |
35,150 | public static function get_concepts ( $ courseid ) { list ( $ glossaries , $ concepts ) = self :: get_course_concepts ( $ courseid ) ; list ( $ globalglossaries , $ globalconcepts ) = self :: get_global_concepts ( ) ; foreach ( $ globalconcepts as $ gid => $ cs ) { if ( ! isset ( $ concepts [ $ gid ] ) ) { $ concepts [... | Get all concepts that should be linked in the given course . |
35,151 | function validate ( $ value , $ regex = null ) { if ( isset ( $ this -> _data [ $ this -> name ] ) ) { if ( ! preg_match ( $ this -> _data [ $ this -> name ] , $ value ) ) { return false ; } } else { if ( ! preg_match ( $ regex , $ value ) ) { return false ; } } return true ; } | Validates a value using a regular expression |
35,152 | public static function get_contextlevel_customdata ( $ contextlevel ) { $ persistent = \ tool_dataprivacy \ contextlevel :: get_record_by_contextlevel ( $ contextlevel , false ) ; if ( ! $ persistent ) { $ persistent = new \ tool_dataprivacy \ contextlevel ( ) ; $ persistent -> set ( 'contextlevel' , $ contextlevel ) ;... | Returns the customdata array for the provided context level . |
35,153 | public function process_assignfeedback_editpdf_files ( $ data ) { $ data = ( object ) $ data ; $ this -> add_related_files ( 'assignfeedback_editpdf' , \ assignfeedback_editpdf \ document_services :: FINAL_PDF_FILEAREA , 'grade' , null , $ data -> gradeid ) ; $ this -> add_related_files ( 'assignfeedback_editpdf' , \ a... | Processes one feedback_editpdf_files element |
35,154 | public static function arraySort ( array & $ array , $ key = null , $ dir = 0 , $ assoc = true ) { if ( empty ( $ array ) ) { return ; } if ( is_null ( $ key ) ) { $ keys = array_keys ( reset ( $ array ) ) ; $ key = array_shift ( $ keys ) ; } $ helper = new Horde_Array_Sort_Helper ( ) ; $ helper -> key = $ key ; $ func... | Sorts an array on a specified key . If the key does not exist defaults to the first key of the array . |
35,155 | public static function getElement ( & $ array , array & $ keys , $ value = null ) { if ( count ( $ keys ) ) { $ key = array_shift ( $ keys ) ; return isset ( $ array [ $ key ] ) ? self :: getElement ( $ array [ $ key ] , $ keys , $ value ) : false ; } if ( ! is_null ( $ value ) ) { $ array = $ value ; } return $ array ... | Using an array of keys iterate through the array following the keys to find the final key value . If a value is passed then set that value . |
35,156 | public static function getRectangle ( array $ array , $ row , $ col , $ height , $ width ) { $ rec = array ( ) ; for ( $ y = $ row ; $ y < $ row + $ height ; $ y ++ ) { $ rec [ ] = array_slice ( $ array [ $ y ] , $ col , $ width ) ; } return $ rec ; } | Returns a rectangle of a two - dimensional array . |
35,157 | final public function process ( $ data ) { if ( ! array_key_exists ( $ data [ 'path' ] , $ this -> pathelements ) ) { throw new restore_step_exception ( 'restore_structure_step_missing_path' , $ data [ 'path' ] ) ; } $ element = $ this -> pathelements [ $ data [ 'path' ] ] ; $ object = $ element -> get_processing_objec... | Receive one chunk of information form the xml parser processor and dispatch it following the naming rules |
35,158 | protected function add_plugin_structure ( $ plugintype , $ element ) { global $ CFG ; if ( ! array_key_exists ( $ plugintype , core_component :: get_plugin_types ( $ plugintype ) ) ) { throw new restore_step_exception ( 'incorrect_plugin_type' , $ plugintype ) ; } $ pluginsdirs = core_component :: get_plugin_list ( $ p... | Add plugin structure to any element in the structure restore tree |
35,159 | protected function add_subplugin_structure ( $ subplugintype , $ element , $ plugintype = null , $ pluginname = null ) { global $ CFG ; if ( $ plugintype === null and $ pluginname === null ) { $ plugintype = 'mod' ; $ pluginname = $ this -> task -> get_modulename ( ) ; } if ( ! array_key_exists ( $ plugintype , core_co... | Add subplugin structure for a given plugin to any element in the structure restore tree |
35,160 | protected function launch_after_execute_methods ( ) { $ alreadylaunched = array ( ) ; foreach ( $ this -> pathelements as $ key => $ pathelement ) { $ pobject = $ pathelement -> get_processing_object ( ) ; if ( is_null ( $ pobject ) ) { continue ; } if ( $ pobject instanceof restore_structure_step ) { continue ; } if (... | Launch all the after_execute methods present in all the processing objects |
35,161 | public function launch_after_restore_methods ( ) { $ alreadylaunched = array ( ) ; foreach ( $ this -> pathelements as $ pathelement ) { $ pobject = $ pathelement -> get_processing_object ( ) ; if ( is_null ( $ pobject ) ) { continue ; } if ( $ pobject instanceof restore_structure_step ) { continue ; } if ( in_array ( ... | Launch all the after_restore methods present in all the processing objects |
35,162 | protected function prepare_pathelements ( $ elementsarr ) { $ names = array ( ) ; $ paths = array ( ) ; foreach ( $ elementsarr as $ element ) { if ( ! $ element instanceof restore_path_element ) { throw new restore_step_exception ( 'restore_path_element_wrong_class' , get_class ( $ element ) ) ; } if ( array_key_exist... | Prepare the pathelements for processing looking for duplicates applying processing objects and other adjustments |
35,163 | protected function grouped_parent_exists ( $ pelement , $ elements ) { foreach ( $ elements as $ element ) { if ( $ pelement -> get_path ( ) == $ element -> get_path ( ) ) { continue ; } if ( $ element -> is_grouped ( ) and strpos ( $ pelement -> get_path ( ) . '/' , $ element -> get_path ( ) ) === 0 ) { return true ; ... | Given one pathelement return true if grouped parent was found |
35,164 | public function doToolProxyService ( ) { $ toolProxyService = $ this -> findService ( 'application/vnd.ims.lti.v2.toolproxy+json' , array ( 'POST' ) ) ; $ secret = DataConnector :: getRandomString ( 12 ) ; $ toolProxy = new MediaType \ ToolProxy ( $ this , $ toolProxyService , $ secret ) ; $ http = $ this -> consumer -... | Send the tool proxy to the Tool Consumer |
35,165 | private function checkValue ( $ value , $ values , $ reason ) { $ ok = in_array ( $ value , $ values ) ; if ( ! $ ok && ! empty ( $ reason ) ) { $ this -> reason = sprintf ( $ reason , $ value ) ; } return $ ok ; } | Validate a parameter value from an array of permitted values . |
35,166 | public function get_content ( ) { if ( isset ( $ this -> config ) ) { $ config = $ this -> config ; } else { $ config = get_config ( 'block_section_links' ) ; } if ( $ this -> content !== null ) { return $ this -> content ; } $ this -> content = new stdClass ; $ this -> content -> footer = '' ; $ this -> content -> tex... | Generates the content of the block and returns it . |
35,167 | public static function create_from_field ( $ field ) { $ event = self :: create ( array ( 'objectid' => $ field -> id , 'context' => \ context_system :: instance ( ) , 'other' => array ( 'shortname' => $ field -> shortname , 'name' => $ field -> name , 'datatype' => $ field -> datatype , ) ) ) ; $ event -> add_record_s... | Creates an event from a profile field . |
35,168 | public function setMacrosCode ( $ MacrosCode = null ) { $ this -> macrosCode = $ MacrosCode ; $ this -> setHasMacros ( ! is_null ( $ MacrosCode ) ) ; } | Set the macros code |
35,169 | public function getIndex ( PHPExcel_Worksheet $ pSheet ) { foreach ( $ this -> workSheetCollection as $ key => $ value ) { if ( $ value -> getHashCode ( ) == $ pSheet -> getHashCode ( ) ) { return $ key ; } } throw new PHPExcel_Exception ( "Sheet does not exist." ) ; } | Get index for sheet |
35,170 | public function setIndexByName ( $ sheetName , $ newIndex ) { $ oldIndex = $ this -> getIndex ( $ this -> getSheetByName ( $ sheetName ) ) ; $ pSheet = array_splice ( $ this -> workSheetCollection , $ oldIndex , 1 ) ; array_splice ( $ this -> workSheetCollection , $ newIndex , 0 , $ pSheet ) ; return $ newIndex ; } | Set index for sheet by sheet name . |
35,171 | public function setActiveSheetIndexByName ( $ pValue = '' ) { if ( ( $ worksheet = $ this -> getSheetByName ( $ pValue ) ) instanceof PHPExcel_Worksheet ) { $ this -> setActiveSheetIndex ( $ this -> getIndex ( $ worksheet ) ) ; return $ worksheet ; } throw new PHPExcel_Exception ( 'Workbook does not contain sheet:' . $... | Set active sheet index by name |
35,172 | public function getSheetNames ( ) { $ returnValue = array ( ) ; $ worksheetCount = $ this -> getSheetCount ( ) ; for ( $ i = 0 ; $ i < $ worksheetCount ; ++ $ i ) { $ returnValue [ ] = $ this -> getSheet ( $ i ) -> getTitle ( ) ; } return $ returnValue ; } | Get sheet names |
35,173 | public function addExternalSheet ( PHPExcel_Worksheet $ pSheet , $ iSheetIndex = null ) { if ( $ this -> sheetNameExists ( $ pSheet -> getTitle ( ) ) ) { throw new PHPExcel_Exception ( "Workbook already contains a worksheet named '{$pSheet->getTitle()}'. Rename the external sheet first." ) ; } $ countCellXfs = count ( ... | Add external sheet |
35,174 | public function export_for_template ( \ renderer_base $ output ) { global $ PAGE ; $ step = $ this -> step ; $ result = ( object ) [ 'stepid' => $ step -> get_id ( ) , 'title' => external_format_text ( stepsource :: get_string_from_input ( $ step -> get_title ( ) ) , FORMAT_HTML , $ PAGE -> context -> id , 'tool_userto... | Export the step configuration . |
35,175 | public function options ( ) { $ options = array ( ) ; foreach ( $ this -> items as $ userid => $ user ) { $ options [ $ userid ] = fullname ( $ user ) ; } return $ options ; } | Convert this list of items into an options list |
35,176 | public function init ( $ selfitemisempty = false ) { $ this -> items = $ this -> load_users ( ) ; $ this -> totalitemcount = count ( $ this -> items ) ; if ( $ selfitemisempty ) { return ; } $ params = array ( 'id' => $ this -> itemid , 'courseid' => $ this -> courseid ) ; $ this -> item = grade_item :: fetch ( $ param... | Init this page |
35,177 | public function format_line ( $ item ) { global $ OUTPUT ; $ grade = $ this -> fetch_grade_or_default ( $ this -> item , $ item -> id ) ; $ lockicon = '' ; $ lockedgrade = $ lockedgradeitem = 0 ; if ( ! empty ( $ grade -> locked ) ) { $ lockedgrade = 1 ; } if ( ! empty ( $ grade -> grade_item -> locked ) ) { $ lockedgr... | Format a row in the table |
35,178 | public function item_range ( ) { if ( empty ( $ this -> range ) ) { $ this -> range = new range ( $ this -> item ) ; } return $ this -> range ; } | Get the range ui element for this grade_item |
35,179 | public function pager ( ) { global $ OUTPUT ; return $ OUTPUT -> paging_bar ( $ this -> totalitemcount , $ this -> page , $ this -> perpage , new moodle_url ( '/grade/report/singleview/index.php' , array ( 'perpage' => $ this -> perpage , 'id' => $ this -> courseid , 'group' => $ this -> groupid , 'itemid' => $ this ->... | Get the pager for this page . |
35,180 | private function get_request ( $ response , $ item , $ typeid ) { $ response -> set_content_type ( $ this -> formats [ 0 ] ) ; $ lineitem = gradebookservices :: item_for_json ( $ item , substr ( parent :: get_endpoint ( ) , 0 , strrpos ( parent :: get_endpoint ( ) , "/" , - 10 ) ) , $ typeid ) ; $ response -> set_body ... | Process a GET request . |
35,181 | private function process_delete_request ( $ item ) { global $ DB ; $ gradeitem = \ grade_item :: fetch ( array ( 'id' => $ item -> id ) ) ; if ( ( $ gbs = gradebookservices :: find_ltiservice_gradebookservice_for_lineitem ( $ item -> id ) ) == false ) { throw new \ Exception ( null , 403 ) ; } if ( ! $ gradeitem -> del... | Process a DELETE request . |
35,182 | public function enrol_self ( stdClass $ instance , $ data = null ) { global $ DB , $ USER , $ CFG ; if ( $ instance -> password && ! isset ( $ data -> enrolpassword ) ) { return ; } $ timestart = time ( ) ; if ( $ instance -> enrolperiod ) { $ timeend = $ timestart + $ instance -> enrolperiod ; } else { $ timeend = 0 ;... | Self enrol user to course |
35,183 | public function can_self_enrol ( stdClass $ instance , $ checkuserenrolment = true ) { global $ CFG , $ DB , $ OUTPUT , $ USER ; if ( $ checkuserenrolment ) { if ( isguestuser ( ) ) { return get_string ( 'noguestaccess' , 'enrol' ) . $ OUTPUT -> continue_button ( get_login_url ( ) ) ; } if ( $ DB -> get_record ( 'user_... | Checks if user can self enrol . |
35,184 | public function get_instance_defaults ( ) { $ expirynotify = $ this -> get_config ( 'expirynotify' ) ; if ( $ expirynotify == 2 ) { $ expirynotify = 1 ; $ notifyall = 1 ; } else { $ notifyall = 0 ; } $ fields = array ( ) ; $ fields [ 'status' ] = $ this -> get_config ( 'status' ) ; $ fields [ 'roleid' ] = $ this -> get... | Returns defaults for new instances . |
35,185 | protected function email_welcome_message ( $ instance , $ user ) { global $ CFG , $ DB ; $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ instance -> courseid ) , '*' , MUST_EXIST ) ; $ context = context_course :: instance ( $ course -> id ) ; $ a = new stdClass ( ) ; $ a -> coursename = format_string ( $ c... | Send welcome email to specified user . |
35,186 | protected function get_enroller ( $ instanceid ) { global $ DB ; if ( $ this -> lasternollerinstanceid == $ instanceid and $ this -> lasternoller ) { return $ this -> lasternoller ; } $ instance = $ DB -> get_record ( 'enrol' , array ( 'id' => $ instanceid , 'enrol' => $ this -> get_name ( ) ) , '*' , MUST_EXIST ) ; $ ... | Returns the user who is responsible for self enrolments in given instance . |
35,187 | protected function get_longtimenosee_options ( ) { $ options = array ( 0 => get_string ( 'never' ) , 1800 * 3600 * 24 => get_string ( 'numdays' , '' , 1800 ) , 1000 * 3600 * 24 => get_string ( 'numdays' , '' , 1000 ) , 365 * 3600 * 24 => get_string ( 'numdays' , '' , 365 ) , 180 * 3600 * 24 => get_string ( 'numdays' , ... | Return an array of valid options for the longtimenosee property . |
35,188 | public function get_bulk_operations ( course_enrolment_manager $ manager ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/enrol/self/locallib.php' ) ; $ context = $ manager -> get_context ( ) ; $ bulkoperations = array ( ) ; if ( has_capability ( "enrol/self:manage" , $ context ) ) { $ bulkoperations [ 'editselec... | The self enrollment plugin has several bulk operations that can be performed . |
35,189 | public function extend_assignable_roles ( $ context , $ defaultrole ) { global $ DB ; $ roles = get_assignable_roles ( $ context , ROLENAME_BOTH ) ; if ( ! isset ( $ roles [ $ defaultrole ] ) ) { if ( $ role = $ DB -> get_record ( 'role' , array ( 'id' => $ defaultrole ) ) ) { $ roles [ $ defaultrole ] = role_get_name ... | Gets a list of roles that this user can assign for the course as the default for self - enrolment . |
35,190 | public function get_welcome_email_contact ( $ sendoption , $ context ) { global $ CFG ; $ contact = null ; if ( $ sendoption == ENROL_SEND_EMAIL_FROM_COURSE_CONTACT ) { $ rusers = array ( ) ; if ( ! empty ( $ CFG -> coursecontact ) ) { $ croles = explode ( ',' , $ CFG -> coursecontact ) ; list ( $ sort , $ sortparams )... | Get the from contact which the email will be sent from . |
35,191 | public function password_expire ( $ username ) { $ result = 0 ; if ( ! empty ( $ this -> config -> expirationtime ) ) { $ user = core_user :: get_user_by_username ( $ username , 'id,timecreated' ) ; $ lastpasswordupdatetime = get_user_preferences ( 'auth_manual_passwordupdatetime' , $ user -> timecreated , $ user -> id... | Return number of days to user password expires . |
35,192 | function user_confirm ( $ username , $ confirmsecret = null ) { global $ DB ; $ user = get_complete_user_data ( 'username' , $ username ) ; if ( ! empty ( $ user ) ) { if ( $ user -> confirmed ) { return AUTH_CONFIRM_ALREADY ; } else { $ DB -> set_field ( "user" , "confirmed" , 1 , array ( "id" => $ user -> id ) ) ; re... | Confirm the new user as registered . This should normally not be used but it may be necessary if the user auth_method is changed to manual before the user is confirmed . |
35,193 | protected function init ( $ mode , $ formclass , $ quiz , $ cm , $ course ) { $ this -> mode = $ mode ; $ this -> context = context_module :: instance ( $ cm -> id ) ; list ( $ currentgroup , $ studentsjoins , $ groupstudentsjoins , $ allowedjoins ) = $ this -> get_students_joins ( $ cm , $ course ) ; $ this -> qmsubse... | Initialise various aspects of this report . |
35,194 | protected function print_standard_header_and_messages ( $ cm , $ course , $ quiz , $ options , $ currentgroup , $ hasquestions , $ hasstudents ) { global $ OUTPUT ; $ this -> print_header_and_tabs ( $ cm , $ course , $ quiz , $ this -> mode ) ; if ( groups_get_activity_groupmode ( $ cm ) ) { groups_print_activity_menu ... | Outputs the things you commonly want at the top of a quiz report . |
35,195 | protected function configure_user_columns ( $ table ) { $ table -> column_suppress ( 'picture' ) ; $ table -> column_suppress ( 'fullname' ) ; $ extrafields = get_extra_user_fields ( $ this -> context ) ; foreach ( $ extrafields as $ field ) { $ table -> column_suppress ( $ field ) ; } $ table -> column_class ( 'pictur... | Set the display options for the user - related columns in the table . |
35,196 | protected function set_up_table_columns ( $ table , $ columns , $ headers , $ reporturl , mod_quiz_attempts_report_options $ options , $ collapsible ) { $ table -> define_columns ( $ columns ) ; $ table -> define_headers ( $ headers ) ; $ table -> sortable ( true , 'uniqueid' ) ; $ table -> define_baseurl ( $ options -... | Set up the table . |
35,197 | protected function process_actions ( $ quiz , $ cm , $ currentgroup , \ core \ dml \ sql_join $ groupstudentsjoins , \ core \ dml \ sql_join $ allowedjoins , $ redirecturl ) { if ( empty ( $ currentgroup ) || $ this -> hasgroupstudents ) { if ( optional_param ( 'delete' , 0 , PARAM_BOOL ) && confirm_sesskey ( ) ) { if ... | Process any submitted actions . |
35,198 | protected function delete_selected_attempts ( $ quiz , $ cm , $ attemptids , \ core \ dml \ sql_join $ allowedjoins ) { global $ DB ; foreach ( $ attemptids as $ attemptid ) { if ( empty ( $ allowedjoins -> joins ) ) { $ sql = "SELECT quiza.* FROM {quiz_attempts} quiza ... | Delete the quiz attempts |
35,199 | public function col_classname ( $ row ) : string { $ output = '' ; if ( class_exists ( $ row -> classname ) ) { $ task = new $ row -> classname ; if ( $ task instanceof \ core \ task \ scheduled_task ) { $ output = $ task -> get_name ( ) ; } } $ output .= \ html_writer :: tag ( 'div' , "\\{$row->classname}" , [ 'class'... | Format the name cell . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.