idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
29,200
public function process ( ) { $ backuptempdir = make_backup_temp_directory ( '' ) ; if ( $ this -> filename ) { $ archivepath = $ backuptempdir . '/' . $ this -> filename ; if ( ! file_exists ( $ archivepath ) ) { throw new restore_ui_exception ( 'invalidrestorefile' ) ; } $ outcome = $ this -> extract_file_to_dir ( $ ...
Processes this restore stage
29,201
protected function extract_file_to_dir ( $ source ) { global $ USER ; $ this -> filepath = restore_controller :: get_tempdir_name ( $ this -> contextid , $ USER -> id ) ; $ backuptempdir = make_backup_temp_directory ( '' , false ) ; $ fb = get_file_packer ( 'application/vnd.moodle.backup' ) ; $ result = $ fb -> extract...
Extracts the file .
29,202
public function display ( core_backup_renderer $ renderer ) { $ prevstageurl = new moodle_url ( '/backup/restorefile.php' , array ( 'contextid' => $ this -> contextid ) ) ; $ nextstageurl = new moodle_url ( '/backup/restore.php' , array ( 'contextid' => $ this -> contextid , 'filepath' => $ this -> filepath , 'stage' =...
Renders the confirmation stage screen
29,203
public function process ( ) { global $ DB ; $ filepathdir = make_backup_temp_directory ( $ this -> filepath , false ) ; if ( ! file_exists ( $ filepathdir ) || ! is_dir ( $ filepathdir ) ) { throw new restore_ui_exception ( 'invalidrestorepath' ) ; } if ( optional_param ( 'searchcourses' , false , PARAM_BOOL ) ) { retu...
Processes the destination stage .
29,204
public function display ( core_backup_renderer $ renderer ) { $ format = backup_general_helper :: detect_backup_format ( $ this -> filepath ) ; if ( $ format === backup :: FORMAT_MOODLE ) { $ details = backup_general_helper :: get_backup_information ( $ this -> filepath ) ; if ( $ details -> type === backup :: TYPE_1CO...
Renders the destination stage screen
29,205
public function process ( base_moodleform $ form = null ) { $ form = $ this -> initialise_stage_form ( ) ; if ( $ form -> is_cancelled ( ) ) { $ this -> ui -> cancel_process ( ) ; } $ data = $ form -> get_data ( ) ; if ( $ data && confirm_sesskey ( ) ) { $ tasks = $ this -> ui -> get_tasks ( ) ; $ changes = 0 ; foreach...
Process the settings stage .
29,206
protected function initialise_stage_form ( ) { global $ PAGE ; if ( $ this -> stageform === null ) { $ form = new restore_settings_form ( $ this , $ PAGE -> url ) ; $ tasks = $ this -> ui -> get_tasks ( ) ; $ headingprinted = false ; foreach ( $ tasks as & $ task ) { if ( $ task instanceof restore_root_task ) { if ( ! ...
Initialise the stage form .
29,207
public function process ( base_moodleform $ form = null ) { $ form = $ this -> initialise_stage_form ( ) ; if ( $ form -> is_cancelled ( ) ) { $ this -> ui -> cancel_process ( ) ; } $ data = $ form -> get_data ( ) ; if ( $ data && confirm_sesskey ( ) ) { return 0 ; } else { return false ; } }
Processes the confirmation stage
29,208
public function process ( base_moodleform $ form = null ) { if ( optional_param ( 'cancel' , false , PARAM_BOOL ) ) { redirect ( new moodle_url ( '/course/view.php' , array ( 'id' => $ this -> get_ui ( ) -> get_controller ( ) -> get_courseid ( ) ) ) ) ; } $ rc = $ this -> ui -> get_controller ( ) ; if ( $ rc -> get_sta...
Processes the final stage .
29,209
public function display ( core_backup_renderer $ renderer ) { global $ PAGE ; $ html = '' ; $ haserrors = false ; $ url = new moodle_url ( $ PAGE -> url , array ( 'restore' => $ this -> get_uniqueid ( ) , 'stage' => restore_ui :: STAGE_PROCESS , 'substage' => $ this -> substage , 'sesskey' => sesskey ( ) ) ) ; $ html ....
Renders the process stage screen
29,210
public function fetch ( ) { $ response = $ this -> get_response ( ) ; $ this -> validate_response ( $ response ) ; $ this -> store_response ( $ response ) ; \ core_plugin_manager :: reset_caches ( ) ; }
Fetches the available update status from the remote site
29,211
public function get_update_info ( $ component , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'minmaturity' ] ) ) { $ options [ 'minmaturity' ] = 0 ; } if ( ! isset ( $ options [ 'notifybuilds' ] ) ) { $ options [ 'notifybuilds' ] = false ; } if ( $ component === 'core' ) { $ this -> load_current_environme...
Returns the available update information for the given component
29,212
public function cron ( ) { global $ CFG ; if ( ! $ this -> enabled ( ) or ! $ this -> cron_autocheck_enabled ( ) ) { $ this -> cron_mtrace ( 'Automatic check for available updates not enabled, skipping.' ) ; return ; } $ now = $ this -> cron_current_timestamp ( ) ; if ( $ this -> cron_has_fresh_fetch ( $ now ) ) { $ th...
The method being run via cron . php
29,213
protected function get_response ( ) { global $ CFG ; require_once ( $ CFG -> libdir . '/filelib.php' ) ; $ curl = new \ curl ( array ( 'proxy' => true ) ) ; $ response = $ curl -> post ( $ this -> prepare_request_url ( ) , $ this -> prepare_request_params ( ) , $ this -> prepare_request_options ( ) ) ; $ curlerrno = $ ...
Makes cURL request to get data from the remote site
29,214
protected function validate_response ( $ response ) { $ response = $ this -> decode_response ( $ response ) ; if ( empty ( $ response ) ) { throw new checker_exception ( 'err_response_empty' ) ; } if ( empty ( $ response [ 'status' ] ) or $ response [ 'status' ] !== 'OK' ) { throw new checker_exception ( 'err_response_...
Makes sure the response is valid has correct API format etc .
29,215
protected function store_response ( $ response ) { set_config ( 'recentfetch' , time ( ) , 'core_plugin' ) ; set_config ( 'recentresponse' , $ response , 'core_plugin' ) ; if ( defined ( 'CACHE_DISABLE_ALL' ) and CACHE_DISABLE_ALL ) { \ cache_helper :: purge_all ( true ) ; } $ this -> restore_response ( true ) ; }
Stores the valid fetched response for later usage
29,216
protected function restore_response ( $ forcereload = false ) { if ( ! $ forcereload and ! is_null ( $ this -> recentresponse ) ) { return ; } $ config = get_config ( 'core_plugin' ) ; if ( ! empty ( $ config -> recentresponse ) and ! empty ( $ config -> recentfetch ) ) { try { $ this -> validate_response ( $ config ->...
Loads the most recent raw response record we have fetched
29,217
protected function load_current_environment ( $ forcereload = false ) { global $ CFG ; if ( ! is_null ( $ this -> currentversion ) and ! $ forcereload ) { return ; } $ version = null ; $ release = null ; require ( $ CFG -> dirroot . '/version.php' ) ; $ this -> currentversion = $ version ; $ this -> currentrelease = $ ...
Sets the properties currentversion currentrelease currentbranch and currentplugins
29,218
protected function prepare_request_params ( ) { global $ CFG ; $ this -> load_current_environment ( ) ; $ this -> restore_response ( ) ; $ params = array ( ) ; $ params [ 'format' ] = 'json' ; if ( isset ( $ this -> recentresponse [ 'ticket' ] ) ) { $ params [ 'ticket' ] = $ this -> recentresponse [ 'ticket' ] ; } if (...
Returns the list of HTTP params to be sent to the updates provider URL
29,219
protected function cron_has_fresh_fetch ( $ now ) { $ recent = $ this -> get_last_timefetched ( ) ; if ( empty ( $ recent ) ) { return false ; } if ( $ now < $ recent ) { $ this -> cron_mtrace ( 'The most recent fetch is reported to be in the future, this is weird!' ) ; return true ; } if ( $ now - $ recent > 24 * HOUR...
Decide if the recently fetched data are still fresh enough
29,220
protected function cron_execution_offset ( ) { global $ CFG ; if ( empty ( $ CFG -> updatecronoffset ) ) { set_config ( 'updatecronoffset' , rand ( 1 , 5 * HOURSECS ) ) ; } return $ CFG -> updatecronoffset ; }
Returns the cron execution offset for this site
29,221
protected function cron_execute ( ) { try { $ this -> restore_response ( ) ; $ previous = $ this -> recentresponse ; $ this -> fetch ( ) ; $ this -> restore_response ( true ) ; $ current = $ this -> recentresponse ; $ changes = $ this -> compare_responses ( $ previous , $ current ) ; $ notifications = $ this -> cron_no...
Fetch available updates info and eventually send notification to site admins
29,222
protected function cron_notifications ( array $ changes ) { global $ CFG ; if ( empty ( $ changes ) ) { return array ( ) ; } $ notifications = array ( ) ; $ pluginman = \ core_plugin_manager :: instance ( ) ; $ plugins = $ pluginman -> get_plugins ( ) ; foreach ( $ changes as $ component => $ componentchanges ) { if ( ...
Given the list of changes in available updates pick those to send to site admins
29,223
protected function is_same_release ( $ remote , $ local = null ) { if ( is_null ( $ local ) ) { $ this -> load_current_environment ( ) ; $ local = $ this -> currentrelease ; } $ pattern = '/^([0-9\.\+]+)([^(]*)/' ; preg_match ( $ pattern , $ remote , $ remotematches ) ; preg_match ( $ pattern , $ local , $ localmatches...
Compare two release labels and decide if they are the same
29,224
protected function get_manage_subscriptions_button ( ) { if ( calendar_user_can_add_event ( $ this -> calendar -> course ) ) { $ managesubscriptionurl = new moodle_url ( '/calendar/managesubscriptions.php' , $ this -> get_link_params ( ) ) ; return new \ single_button ( $ managesubscriptionurl , get_string ( 'managesub...
Get manage subscription button .
29,225
protected function get_link_params ( ) { $ params = [ ] ; if ( SITEID !== $ this -> calendar -> course -> id ) { $ params [ 'course' ] = $ this -> calendar -> course -> id ; } else if ( null !== $ this -> calendar -> categoryid && $ this -> calendar -> categoryid > 0 ) { $ params [ 'category' ] = $ this -> calendar -> ...
Get the list of URL parameters for calendar links .
29,226
private function createCommand ( Server $ server ) { $ cmd = [ 'mapReduce' => $ this -> collectionName , 'map' => $ this -> map , 'reduce' => $ this -> reduce , 'out' => $ this -> out , ] ; foreach ( [ 'finalize' , 'jsMode' , 'limit' , 'maxTimeMS' , 'verbose' ] as $ option ) { if ( isset ( $ this -> options [ $ option ...
Create the mapReduce command .
29,227
public function compile ( $ source , array $ tree , $ name , $ customEscape = false , $ charset = 'UTF-8' , $ strictCallables = false , $ entityFlags = ENT_COMPAT ) { $ this -> pragmas = $ this -> defaultPragmas ; $ this -> sections = array ( ) ; $ this -> blocks = array ( ) ; $ this -> source = $ source ; $ this -> in...
Compile a Mustache token parse tree into PHP source code .
29,228
private function writeCode ( $ tree , $ name ) { $ code = $ this -> walk ( $ tree ) ; $ sections = implode ( "\n" , $ this -> sections ) ; $ blocks = implode ( "\n" , $ this -> blocks ) ; $ klass = empty ( $ this -> sections ) && empty ( $ this -> blocks ) ? self :: KLASS_NO_LAMBDAS : self :: KLASS ; $ callable = $ thi...
Generate Mustache Template class PHP source .
29,229
private function blockVar ( $ nodes , $ id , $ start , $ end , $ otag , $ ctag , $ level ) { $ id = var_export ( $ id , true ) ; $ else = $ this -> walk ( $ nodes , $ level ) ; if ( $ else !== '' ) { $ else = sprintf ( $ this -> prepare ( self :: BLOCK_VAR_ELSE , $ level + 1 , false , true ) , $ else ) ; } return sprin...
Generate Mustache Template inheritance block variable PHP source .
29,230
private function blockArg ( $ nodes , $ id , $ start , $ end , $ otag , $ ctag , $ level ) { $ key = $ this -> block ( $ nodes ) ; $ keystr = var_export ( $ key , true ) ; $ id = var_export ( $ id , true ) ; return sprintf ( $ this -> prepare ( self :: BLOCK_ARG , $ level ) , $ id , $ key ) ; }
Generate Mustache Template inheritance block argument PHP source .
29,231
private function block ( $ nodes ) { $ code = $ this -> walk ( $ nodes , 0 ) ; $ key = ucfirst ( md5 ( $ code ) ) ; if ( ! isset ( $ this -> blocks [ $ key ] ) ) { $ this -> blocks [ $ key ] = sprintf ( $ this -> prepare ( self :: BLOCK_FUNCTION , 0 ) , $ key , $ code ) ; } return $ key ; }
Generate Mustache Template inheritance block function PHP source .
29,232
private function section ( $ nodes , $ id , $ filters , $ start , $ end , $ otag , $ ctag , $ level ) { $ source = var_export ( substr ( $ this -> source , $ start , $ end - $ start ) , true ) ; $ callable = $ this -> getCallable ( ) ; if ( $ otag !== '{{' || $ ctag !== '}}' ) { $ delimTag = var_export ( sprintf ( '{{=...
Generate Mustache Template section PHP source .
29,233
private function invertedSection ( $ nodes , $ id , $ filters , $ level ) { $ method = $ this -> getFindMethod ( $ id ) ; $ id = var_export ( $ id , true ) ; $ filters = $ this -> getFilters ( $ filters , $ level ) ; return sprintf ( $ this -> prepare ( self :: INVERTED_SECTION , $ level ) , $ id , $ method , $ id , $ ...
Generate Mustache Template inverted section PHP source .
29,234
private function partial ( $ id , $ indent , $ level ) { if ( $ indent !== '' ) { $ indentParam = sprintf ( self :: PARTIAL_INDENT , var_export ( $ indent , true ) ) ; } else { $ indentParam = '' ; } return sprintf ( $ this -> prepare ( self :: PARTIAL , $ level ) , var_export ( $ id , true ) , $ indentParam ) ; }
Generate Mustache Template partial call PHP source .
29,235
private function parent ( $ id , $ indent , array $ children , $ level ) { $ realChildren = array_filter ( $ children , array ( __CLASS__ , 'onlyBlockArgs' ) ) ; if ( empty ( $ realChildren ) ) { return sprintf ( $ this -> prepare ( self :: PARENT_NO_CONTEXT , $ level ) , var_export ( $ id , true ) ) ; } return sprintf...
Generate Mustache Template inheritance parent call PHP source .
29,236
private function variable ( $ id , $ filters , $ escape , $ level ) { $ method = $ this -> getFindMethod ( $ id ) ; $ id = ( $ method !== 'last' ) ? var_export ( $ id , true ) : '' ; $ filters = $ this -> getFilters ( $ filters , $ level ) ; $ value = $ escape ? $ this -> getEscape ( ) : '$value' ; return sprintf ( $ t...
Generate Mustache Template variable interpolation PHP source .
29,237
private function getFilters ( array $ filters , $ level ) { if ( empty ( $ filters ) ) { return '' ; } $ name = array_shift ( $ filters ) ; $ method = $ this -> getFindMethod ( $ name ) ; $ filter = ( $ method !== 'last' ) ? var_export ( $ name , true ) : '' ; $ callable = $ this -> getCallable ( '$filter' ) ; $ msg = ...
Generate Mustache Template variable filtering PHP source .
29,238
private function text ( $ text , $ level ) { $ indentNextLine = ( substr ( $ text , - 1 ) === "\n" ) ; $ code = sprintf ( $ this -> prepare ( self :: TEXT , $ level ) , $ this -> flushIndent ( ) , var_export ( $ text , true ) ) ; $ this -> indentNextLine = $ indentNextLine ; return $ code ; }
Generate Mustache Template output Buffer call PHP source .
29,239
private function prepare ( $ text , $ bonus = 0 , $ prependNewline = true , $ appendNewline = false ) { $ text = ( $ prependNewline ? "\n" : '' ) . trim ( $ text ) ; if ( $ prependNewline ) { $ bonus ++ ; } if ( $ appendNewline ) { $ text .= "\n" ; } return preg_replace ( "/\n( {8})?/" , "\n" . str_repeat ( ' ' , $ bon...
Prepare PHP source code snippet for output .
29,240
private function getEscape ( $ value = '$value' ) { if ( $ this -> customEscape ) { return sprintf ( self :: CUSTOM_ESCAPE , $ value ) ; } return sprintf ( self :: DEFAULT_ESCAPE , $ value , var_export ( $ this -> entityFlags , true ) , var_export ( $ this -> charset , true ) ) ; }
Get the current escaper .
29,241
private function getCallable ( $ variable = '$value' ) { $ tpl = $ this -> strictCallables ? self :: STRICT_IS_CALLABLE : self :: IS_CALLABLE ; return sprintf ( $ tpl , $ variable , $ variable ) ; }
Helper function to compile strict vs lax is callable logic .
29,242
public static function get_config ( $ section = '' ) { $ params = self :: validate_parameters ( self :: get_config_parameters ( ) , array ( 'section' => $ section ) ) ; $ settings = api :: get_config ( $ params [ 'section' ] ) ; $ result [ 'settings' ] = array ( ) ; foreach ( $ settings as $ name => $ value ) { $ resul...
Returns a list of site settings filtering by section .
29,243
public static function get_autologin_key ( $ privatetoken ) { global $ CFG , $ DB , $ USER ; $ params = self :: validate_parameters ( self :: get_autologin_key_parameters ( ) , array ( 'privatetoken' => $ privatetoken ) ) ; $ privatetoken = $ params [ 'privatetoken' ] ; $ context = context_system :: instance ( ) ; try ...
Creates an auto - login key for the current user . Is created only in https sites and is restricted by time and ip address .
29,244
public static function get_content ( $ component , $ method , $ args = array ( ) ) { global $ OUTPUT , $ PAGE , $ USER ; $ params = self :: validate_parameters ( self :: get_content_parameters ( ) , array ( 'component' => $ component , 'method' => $ method , 'args' => $ args ) ) ; $ arguments = array ( ) ; foreach ( $ ...
Returns a piece of content to be displayed in the Mobile app it usually returns a template javascript and other structured data that will be used to render a view in the Mobile app ..
29,245
public static function call_external_functions ( $ requests ) { global $ SESSION ; $ params = self :: validate_parameters ( self :: call_external_functions_parameters ( ) , [ 'requests' => $ requests ] ) ; $ webservicemanager = new \ webservice ; $ token = $ webservicemanager -> get_user_ws_token ( required_param ( 'ws...
Call multiple external functions and return all responses .
29,246
public function get_current_group ( $ cm , $ course , $ context ) { $ groupmode = groups_get_activity_groupmode ( $ cm , $ course ) ; $ currentgroup = groups_get_activity_group ( $ cm , true ) ; if ( $ groupmode == SEPARATEGROUPS && ! $ currentgroup && ! has_capability ( 'moodle/site:accessallgroups' , $ context ) ) { ...
Get the current group for the user user looking at the report .
29,247
public function standard_upload_file_form ( $ course , $ mform ) { $ output = groups_print_course_menu ( $ course , 'index.php?id=' . $ course -> id , true ) ; $ output .= html_writer :: start_tag ( 'div' , array ( 'class' => 'clearer' ) ) ; $ output .= html_writer :: end_tag ( 'div' ) ; ob_start ( ) ; $ mform -> displ...
A renderer for the standard upload file form .
29,248
public function import_preview_page ( $ header , $ data ) { $ html = $ this -> output -> heading ( get_string ( 'importpreview' , 'grades' ) ) ; $ table = new html_table ( ) ; $ table -> head = $ header ; $ table -> data = $ data ; $ html .= html_writer :: table ( $ table ) ; return $ html ; }
A renderer for the CSV file preview .
29,249
public function errors ( $ errors ) { $ html = '' ; foreach ( $ errors as $ error ) { $ html .= $ this -> output -> notification ( $ error ) ; } return $ html ; }
A renderer for errors generated trying to import the CSV file .
29,250
protected function render_report_log ( report_log_renderable $ reportlog ) { if ( empty ( $ reportlog -> selectedlogreader ) ) { echo $ this -> output -> notification ( get_string ( 'nologreaderenabled' , 'report_log' ) , 'notifyproblem' ) ; return ; } if ( $ reportlog -> showselectorform ) { $ this -> report_selector_...
Render log report page .
29,251
protected function get_course_gradetopass ( $ courseid ) { if ( ! isset ( $ this -> coursesgradetopass [ $ courseid ] ) ) { $ courseitem = \ grade_item :: fetch_course_item ( $ courseid ) ; $ ci = array ( ) ; $ ci [ 'courseitemid' ] = $ courseitem -> id ; if ( $ courseitem -> gradetype == GRADE_TYPE_VALUE && grade_floa...
Returns the grade to pass a course .
29,252
protected function get_user_grade ( $ courseitemid , $ userid ) { if ( ! isset ( $ this -> coursesgrades [ $ courseitemid ] ) ) { unset ( $ this -> coursesgrades ) ; $ gg = new \ grade_grade ( null , false ) ; $ usersgrades = $ gg -> fetch_all ( array ( 'itemid' => $ courseitemid ) ) ; if ( $ usersgrades ) { foreach ( ...
Returns the grade of a user in a course .
29,253
protected function calculate_sample ( $ sampleid , \ core_analytics \ analysable $ course , $ starttime = false , $ endtime = false ) { $ userenrol = $ this -> retrieve ( 'user_enrolments' , $ sampleid ) ; $ courseitem = $ this -> get_course_gradetopass ( $ course -> get_id ( ) ) ; $ usergrade = $ this -> get_user_grad...
The user s grade in the course sets the target value .
29,254
public static function get_record_by_contextlevel ( $ contextlevel , $ exception = true ) { global $ DB ; $ cache = \ cache :: make ( 'tool_dataprivacy' , 'contextlevel' ) ; if ( $ data = $ cache -> get ( $ contextlevel ) ) { return new static ( 0 , $ data ) ; } if ( ! $ record = $ DB -> get_record ( self :: TABLE , ar...
Returns an instance by contextlevel .
29,255
public function get_manual_enrol_link ( $ instance ) { $ name = $ this -> get_name ( ) ; if ( $ instance -> enrol !== $ name ) { throw new coding_exception ( 'invalid enrol instance!' ) ; } if ( ! enrol_is_enabled ( $ name ) ) { return NULL ; } $ context = context_course :: instance ( $ instance -> courseid , MUST_EXIS...
Returns link to manual enrol UI if exists . Does the access control tests automatically .
29,256
public function get_action_icons ( stdClass $ instance ) { global $ OUTPUT ; $ context = context_course :: instance ( $ instance -> courseid ) ; $ icons = array ( ) ; if ( has_capability ( 'enrol/manual:enrol' , $ context ) or has_capability ( 'enrol/manual:unenrol' , $ context ) ) { $ managelink = new moodle_url ( "/e...
Returns edit icons for the page with list of instances .
29,257
public function get_manual_enrol_button ( course_enrolment_manager $ manager ) { global $ CFG , $ PAGE ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ instance = null ; $ instances = array ( ) ; foreach ( $ manager -> get_enrolment_instances ( ) as $ tempinstance ) { if ( $ tempinstance -> enrol == 'manual'...
Returns a button to manually enrol users through the manual enrolment plugin .
29,258
public function get_bulk_operations ( course_enrolment_manager $ manager ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/enrol/manual/locallib.php' ) ; $ context = $ manager -> get_context ( ) ; $ bulkoperations = array ( ) ; if ( has_capability ( "enrol/manual:manage" , $ context ) ) { $ bulkoperations [ 'edits...
The manual plugin has several bulk operations that can be performed .
29,259
public function enrol_cohort ( stdClass $ instance , $ cohortid , $ roleid = null , $ timestart = 0 , $ timeend = 0 , $ status = null , $ recovergrades = null ) { global $ DB ; $ context = context_course :: instance ( $ instance -> courseid ) ; list ( $ esql , $ params ) = get_enrolled_sql ( $ context ) ; $ sql = "SELE...
Enrol all not enrolled cohort members into course via enrol instance .
29,260
public function validate ( ) { global $ DB ; $ params = array_keys ( $ this -> params ) ; $ method = ( $ this -> method == BADGE_CRITERIA_AGGREGATION_ALL ) ; $ singleparam = ( count ( $ params ) == 1 ) ; foreach ( $ params as $ param ) { if ( ( $ singleparam || $ method ) && ! $ DB -> record_exists ( 'cohort' , array (...
Checks criteria for any major problems .
29,261
public static function get_group_members_in_context ( userlist $ userlist , string $ component , int $ itemid = 0 ) { $ context = $ userlist -> get_context ( ) ; if ( ! $ context instanceof \ context_course ) { return ; } $ sql = "SELECT gm.userid FROM {groups_members} gm JOIN {groups}...
Add the list of users who are members of some groups in the specified constraints .
29,262
public static function get_contexts_for_group_member ( int $ userid , string $ component , int $ itemid = 0 ) { $ contextlist = new contextlist ( ) ; $ sql = "SELECT ctx.id FROM {groups_members} gm JOIN {groups} g ON gm.groupid = g.id JOIN {context} ctx ON g.courseid =...
Get the list of contexts that contain group membership for the specified user .
29,263
function init ( ) { $ this -> does_generate = ACTION_NONE ; $ this -> title = strtolower ( get_class ( $ this ) ) ; $ this -> str = array ( ) ; $ this -> output = NULL ; $ this -> errormsg = NULL ; $ this -> subaction = NULL ; $ this -> sesskey_protected = true ; }
Init method every subclass will have its own always calling the parent one
29,264
function loadStrings ( $ strings ) { if ( get_string_manager ( ) -> string_exists ( $ this -> title , 'tool_xmldb' ) ) { $ this -> str [ 'title' ] = get_string ( $ this -> title , 'tool_xmldb' ) ; } else { $ this -> str [ 'title' ] = $ this -> title ; } if ( $ strings ) { foreach ( $ strings as $ key => $ module ) { $ ...
loadStrings method loads the required strings specified in the array parameter
29,265
function invoke ( ) { global $ SESSION ; if ( $ this -> sesskey_protected ) { require_sesskey ( ) ; } if ( $ lastused = optional_param ( 'dir' , NULL , PARAM_PATH ) ) { $ SESSION -> lastused = $ lastused ; } $ this -> postaction = optional_param ( 'postaction' , NULL , PARAM_ALPHAEXT ) ; if ( $ this -> title == $ this ...
main invoke method it sets the postaction attribute if possible and checks sesskey_protected if needed
29,266
function launch ( $ action ) { global $ CFG ; $ actionsroot = "$CFG->dirroot/$CFG->admin/tool/xmldb/actions" ; $ actionclass = $ action . '.class.php' ; $ actionpath = "$actionsroot/$action/$actionclass" ; $ result = false ; if ( file_exists ( $ actionpath ) && is_readable ( $ actionpath ) ) { require_once ( $ actionpa...
launch method used to easily call invoke methods between actions
29,267
public function linked_logins_table ( $ linkedlogins ) { global $ CFG ; $ table = new html_table ( ) ; $ table -> head = [ get_string ( 'issuer' , 'auth_oauth2' ) , get_string ( 'info' , 'auth_oauth2' ) , get_string ( 'edit' ) , ] ; $ table -> attributes [ 'class' ] = 'admintable generaltable' ; $ data = [ ] ; $ index ...
This function will render one beautiful table with all the linked_logins .
29,268
function Render_First ( $ anchor = true ) { global $ PHP_SELF ; if ( $ anchor ) { ?> <a href=" <?php echo $ PHP_SELF , '?' , $ this -> id ; ?> _next_page=1"> <?php echo $ this -> first ; ?> </a> &nbsp; <?php } else { print "$this->first &nbsp; " ; } }
Display link to first page
29,269
function render_next ( $ anchor = true ) { global $ PHP_SELF ; if ( $ anchor ) { ?> <a href=" <?php echo $ PHP_SELF , '?' , $ this -> id , '_next_page=' , $ this -> rs -> AbsolutePage ( ) + 1 ?> "> <?php echo $ this -> next ; ?> </a> &nbsp; <?php } else { print "$this->next &nbsp; " ; } }
Display link to next page
29,270
function render_last ( $ anchor = true ) { global $ PHP_SELF ; if ( ! $ this -> db -> pageExecuteCountRows ) return ; if ( $ anchor ) { ?> <a href=" <?php echo $ PHP_SELF , '?' , $ this -> id , '_next_page=' , $ this -> rs -> LastPageNo ( ) ?> "> <?php echo $ this -> last ; ?> </a> &nbsp; <?php } else { print "$this-...
last page counting .
29,271
function render_pagelinks ( ) { global $ PHP_SELF ; $ pages = $ this -> rs -> LastPageNo ( ) ; $ linksperpage = $ this -> linksPerPage ? $ this -> linksPerPage : $ pages ; for ( $ i = 1 ; $ i <= $ pages ; $ i += $ linksperpage ) { if ( $ this -> rs -> AbsolutePage ( ) >= $ i ) { $ start = $ i ; } } $ numbers = '' ; $ e...
original code by Pablo Costa <pablo
29,272
function render_prev ( $ anchor = true ) { global $ PHP_SELF ; if ( $ anchor ) { ?> <a href=" <?php echo $ PHP_SELF , '?' , $ this -> id , '_next_page=' , $ this -> rs -> AbsolutePage ( ) - 1 ?> "> <?php echo $ this -> prev ; ?> </a> &nbsp; <?php } else { print "$this->prev &nbsp; " ; } }
Link to previous page
29,273
function RenderGrid ( ) { global $ gSQLBlockRows ; include_once ( ADODB_DIR . '/tohtml.inc.php' ) ; ob_start ( ) ; $ gSQLBlockRows = $ this -> rows ; rs2html ( $ this -> rs , $ this -> gridAttributes , $ this -> gridHeader , $ this -> htmlSpecialChars ) ; $ s = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ s ; }
We use output buffering to keep code clean and readable .
29,274
function RenderNav ( ) { ob_start ( ) ; if ( ! $ this -> rs -> AtFirstPage ( ) ) { $ this -> Render_First ( ) ; $ this -> Render_Prev ( ) ; } else { $ this -> Render_First ( false ) ; $ this -> Render_Prev ( false ) ; } if ( $ this -> showPageLinks ) { $ this -> Render_PageLinks ( ) ; } if ( ! $ this -> rs -> AtLastPag...
we use output buffering to keep the code easy to read .
29,275
function RenderPageCount ( ) { if ( ! $ this -> db -> pageExecuteCountRows ) return '' ; $ lastPage = $ this -> rs -> LastPageNo ( ) ; if ( $ lastPage == - 1 ) $ lastPage = 1 ; if ( $ this -> curr_page > $ lastPage ) $ this -> curr_page = 1 ; return "<font size=-1>$this->page " . $ this -> curr_page . "/" . $ lastPage ...
This is the footer
29,276
function Render ( $ rows = 10 ) { global $ ADODB_COUNTRECS ; $ this -> rows = $ rows ; if ( $ this -> db -> dataProvider == 'informix' ) $ this -> db -> cursorType = IFX_SCROLL ; $ savec = $ ADODB_COUNTRECS ; if ( $ this -> db -> pageExecuteCountRows ) $ ADODB_COUNTRECS = true ; if ( $ this -> cache ) $ rs = $ this -> ...
Call this class to draw everything .
29,277
public function current ( ) { if ( ! $ this -> recordset -> valid ( ) ) { return false ; } if ( ! $ record = $ this -> recordset -> current ( ) ) { return false ; } if ( ! is_null ( $ this -> callbackextra ) ) { return call_user_func ( $ this -> callback , $ record , $ this -> callbackextra ) ; } else { return call_use...
Returns the current element after applying the callback .
29,278
public function add ( $ chunk , $ fileInfo = null , $ index = 0 , $ mapLines = null ) { $ this -> strs [ ] = $ chunk ; }
Adds a chunk to the stack
29,279
public function render_adaptive_marks ( qbehaviour_adaptive_mark_details $ details , question_display_options $ options ) { if ( $ details -> state == question_state :: $ todo || $ options -> marks < question_display_options :: MARK_AND_MAX ) { return '' ; } $ class = $ details -> state -> get_feedback_class ( ) ; retu...
Display the scoring information about an adaptive attempt .
29,280
protected function grading_details ( qbehaviour_adaptive_mark_details $ details , question_display_options $ options ) { $ mark = $ details -> get_formatted_marks ( $ options -> markdp ) ; if ( $ details -> currentpenalty == 0 && $ details -> totalpenalty == 0 ) { return get_string ( 'gradingdetails' , 'qbehaviour_adap...
Display the information about the penalty calculations .
29,281
private static function tool_type_return_structure ( ) { return new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Tool type id' ) , 'name' => new external_value ( PARAM_NOTAGS , 'Tool type name' ) , 'description' => new external_value ( PARAM_NOTAGS , 'Tool type description' ) , 'urls' =...
Returns structure be used for returning a tool type from a web service .
29,282
private static function tool_proxy_return_structure ( ) { return new external_function_parameters ( array ( 'id' => new external_value ( PARAM_INT , 'Tool proxy id' ) , 'name' => new external_value ( PARAM_TEXT , 'Tool proxy name' ) , 'regurl' => new external_value ( PARAM_URL , 'Tool proxy registration URL' ) , 'state...
Returns description of a tool proxy
29,283
public static function get_tool_launch_data ( $ toolid ) { global $ DB , $ CFG ; require_once ( $ CFG -> dirroot . '/mod/lti/lib.php' ) ; $ params = self :: validate_parameters ( self :: get_tool_launch_data_parameters ( ) , array ( 'toolid' => $ toolid ) ) ; $ warnings = array ( ) ; $ lti = $ DB -> get_record ( 'lti' ...
Return the launch data for a given external tool .
29,284
public static function get_ltis_by_courses ( $ courseids = array ( ) ) { global $ CFG ; $ returnedltis = array ( ) ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: get_ltis_by_courses_parameters ( ) , array ( 'courseids' => $ courseids ) ) ; $ mycourses = array ( ) ; if ( empty ( $ params [ '...
Returns a list of external tools in a provided list of courses if no list is provided all external tools that the user can view will be returned .
29,285
public static function get_ltis_by_courses_returns ( ) { return new external_single_structure ( array ( 'ltis' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'External tool id' ) , 'coursemodule' => new external_value ( PARAM_INT , 'Course module id...
Describes the get_ltis_by_courses return value .
29,286
public static function create_tool_proxy ( $ name , $ registrationurl , $ capabilityoffered , $ serviceoffered ) { $ params = self :: validate_parameters ( self :: create_tool_proxy_parameters ( ) , array ( 'name' => $ name , 'regurl' => $ registrationurl , 'capabilityoffered' => $ capabilityoffered , 'serviceoffered' ...
Creates a new tool proxy
29,287
public static function get_tool_proxy_registration_request ( $ id ) { $ params = self :: validate_parameters ( self :: get_tool_proxy_registration_request_parameters ( ) , array ( 'id' => $ id , ) ) ; $ id = $ params [ 'id' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; requir...
Returns the registration request for a tool proxy .
29,288
public static function create_tool_type ( $ cartridgeurl , $ key , $ secret ) { $ params = self :: validate_parameters ( self :: create_tool_type_parameters ( ) , array ( 'cartridgeurl' => $ cartridgeurl , 'key' => $ key , 'secret' => $ secret ) ) ; $ cartridgeurl = $ params [ 'cartridgeurl' ] ; $ key = $ params [ 'key...
Creates a tool type .
29,289
public static function update_tool_type ( $ id , $ name , $ description , $ state ) { $ params = self :: validate_parameters ( self :: update_tool_type_parameters ( ) , array ( 'id' => $ id , 'name' => $ name , 'description' => $ description , 'state' => $ state , ) ) ; $ id = $ params [ 'id' ] ; $ name = $ params [ 'n...
Update a tool type .
29,290
public static function delete_tool_type ( $ id ) { $ params = self :: validate_parameters ( self :: delete_tool_type_parameters ( ) , array ( 'id' => $ id , ) ) ; $ id = $ params [ 'id' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/site:config' , ...
Delete a tool type .
29,291
public static function is_cartridge ( $ url ) { $ params = self :: validate_parameters ( self :: is_cartridge_parameters ( ) , array ( 'url' => $ url , ) ) ; $ url = $ params [ 'url' ] ; $ context = context_system :: instance ( ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/site:config' , $ c...
Determine if the url to a tool is for a cartridge .
29,292
public function definition ( ) { $ mform = $ this -> _form ; $ mform -> addElement ( 'header' , 'searchheader' , get_string ( 'searchtemplate' , 'core_grading' ) ) ; $ mform -> addHelpButton ( 'searchheader' , 'searchtemplate' , 'core_grading' ) ; $ mform -> addGroup ( array ( $ mform -> createElement ( 'checkbox' , 'm...
Pretty simple search box
29,293
public function render_category ( category $ category ) { $ classes = $ category -> classes ; if ( empty ( $ classes ) ) { $ return = \ html_writer :: start_tag ( 'section' , array ( 'class' => 'node_category' ) ) ; } else { $ return = \ html_writer :: start_tag ( 'section' , array ( 'class' => 'node_category ' . $ cla...
Render a category .
29,294
public function render_node ( node $ node ) { $ return = '' ; if ( is_object ( $ node -> url ) ) { $ header = \ html_writer :: link ( $ node -> url , $ node -> title ) ; } else { $ header = $ node -> title ; } $ icon = $ node -> icon ; if ( ! empty ( $ icon ) ) { $ header .= $ this -> render ( $ icon ) ; } $ content = ...
Render a node .
29,295
public function messageinbound_handlers_table ( array $ handlers ) { global $ CFG ; $ table = new html_table ( ) ; $ handlername = new html_table_cell ( get_string ( 'name' , 'tool_messageinbound' ) . "\n" . html_writer :: tag ( 'span' , get_string ( 'classname' , 'tool_messageinbound' ) , array ( 'class' => 'handler-f...
Render a table listing all of the Inbound Message handlers .
29,296
public static function init ( moodle_page $ page = null ) { global $ PAGE ; if ( empty ( $ page ) ) { $ page = $ PAGE ; } self :: $ nonjs = optional_param ( 'nonjscomment' , '' , PARAM_ALPHANUM ) ; self :: $ comment_itemid = optional_param ( 'comment_itemid' , '' , PARAM_INT ) ; self :: $ comment_component = optional_p...
Receive nonjs comment parameters
29,297
public function set_component ( $ component ) { if ( ! empty ( $ this -> component ) && $ this -> component !== $ component ) { throw new coding_exception ( 'You cannot change the component of a comment once it has been set' ) ; } $ this -> component = $ component ; list ( $ this -> plugintype , $ this -> pluginname ) ...
Sets the component .
29,298
public function get_nojslink ( moodle_page $ page = null ) { if ( $ page === null ) { global $ PAGE ; $ page = $ PAGE ; } $ link = new moodle_url ( $ page -> url , array ( 'nonjscomment' => true , 'comment_itemid' => $ this -> itemid , 'comment_context' => $ this -> context -> id , 'comment_component' => $ this -> get_...
Gets a link for this page that will work with JS disabled .
29,299
public function initialise_javascript ( moodle_page $ page ) { $ options = new stdClass ; $ options -> client_id = $ this -> cid ; $ options -> commentarea = $ this -> commentarea ; $ options -> itemid = $ this -> itemid ; $ options -> page = 0 ; $ options -> courseid = $ this -> courseid ; $ options -> contextid = $ t...
Initialises the JavaScript that enchances the comment API .