idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
27,300
public function has_actual_responses ( ) { $ actualresponses = $ this -> get_responses ( ) ; if ( count ( $ actualresponses ) > 1 ) { return true ; } else if ( count ( $ actualresponses ) === 1 ) { $ singleactualresponse = reset ( $ actualresponses ) ; return ( string ) $ singleactualresponse !== ( string ) $ this -> m...
Are there actual responses to sub parts that where classified into this class?
27,301
public function data_for_question_response_table ( $ responseclasscolumn , $ partid ) { $ return = array ( ) ; if ( count ( $ this -> get_responses ( ) ) == 0 ) { $ rowdata = new \ stdClass ( ) ; $ rowdata -> part = $ partid ; $ rowdata -> responseclass = $ this -> modelresponse ; if ( ! $ responseclasscolumn ) { $ row...
Return the data to display in the response analysis table .
27,302
public function get_maximum_tries ( ) { $ max = 1 ; foreach ( $ this -> get_responses ( ) as $ actualresponse ) { $ max = max ( $ max , $ this -> get_response ( $ actualresponse ) -> get_maximum_tries ( ) ) ; } return $ max ; }
What is the highest try number that an actual response of this response class has been seen?
27,303
function ServerInfo ( ) { global $ ADODB_FETCH_MODE ; $ save = $ ADODB_FETCH_MODE ; $ ADODB_FETCH_MODE = ADODB_FETCH_NUM ; $ row = $ this -> GetRow ( "execute sp_server_info 2" ) ; $ ADODB_FETCH_MODE = $ save ; if ( ! is_array ( $ row ) ) return false ; $ arr [ 'description' ] = $ row [ 2 ] ; $ arr [ 'version' ] = ADOC...
crashes php ...
27,304
public function get_normalized_value ( ) { $ value = $ this -> get_value ( ) ; if ( $ value === false && $ this -> get_ui ( ) instanceof backup_setting_ui_defaultcustom ) { $ attributes = $ this -> get_ui ( ) -> get_attributes ( ) ; return $ attributes [ 'defaultvalue' ] ; } return $ value ; }
Special method for this element only . When value is false returns the default value .
27,305
public function messagePrintf ( array $ args = array ( ) ) { $ this -> raw_msg = vsprintf ( $ this -> raw_msg , $ args ) ; $ this -> message = vsprintf ( $ this -> message , $ args ) ; }
Perform substitution of variables in the error message .
27,306
public static function client ( $ server_version , $ server_hostname , $ server_port , $ server_uri , $ changeSessionID = true ) { phpCAS :: traceBegin ( ) ; if ( is_object ( self :: $ _PHPCAS_CLIENT ) ) { phpCAS :: error ( self :: $ _PHPCAS_INIT_CALL [ 'method' ] . '() has already been called (at ' . self :: $ _PHPCAS...
phpCAS client initializer .
27,307
public static function setVerbose ( $ verbose ) { if ( $ verbose === true ) { self :: $ _PHPCAS_VERBOSE = true ; } else { self :: $ _PHPCAS_VERBOSE = false ; } }
Enable verbose errors messages in the website output This is a security relevant since internal status info may leak an may help an attacker . Default is therefore false
27,308
public static function log ( $ str ) { $ indent_str = "." ; if ( ! empty ( self :: $ _PHPCAS_DEBUG [ 'filename' ] ) ) { if ( ! file_exists ( self :: $ _PHPCAS_DEBUG [ 'filename' ] ) ) { touch ( self :: $ _PHPCAS_DEBUG [ 'filename' ] ) ; @ chmod ( self :: $ _PHPCAS_DEBUG [ 'filename' ] , 0600 ) ; } for ( $ i = 0 ; $ i <...
Logs a string in debug mode .
27,309
public static function error ( $ msg ) { phpCAS :: traceBegin ( ) ; $ dbg = debug_backtrace ( ) ; $ function = '?' ; $ file = '?' ; $ line = '?' ; if ( is_array ( $ dbg ) ) { for ( $ i = 1 ; $ i < sizeof ( $ dbg ) ; $ i ++ ) { if ( is_array ( $ dbg [ $ i ] ) && isset ( $ dbg [ $ i ] [ 'class' ] ) ) { if ( $ dbg [ $ i ]...
This method is used by interface methods to print an error and where the function was originally called from .
27,310
public static function trace ( $ str ) { $ dbg = debug_backtrace ( ) ; phpCAS :: log ( $ str . ' [' . basename ( $ dbg [ 0 ] [ 'file' ] ) . ':' . $ dbg [ 0 ] [ 'line' ] . ']' ) ; }
This method is used to log something in debug mode .
27,311
public static function traceBegin ( ) { $ dbg = debug_backtrace ( ) ; $ str = '=> ' ; if ( ! empty ( $ dbg [ 1 ] [ 'class' ] ) ) { $ str .= $ dbg [ 1 ] [ 'class' ] . '::' ; } $ str .= $ dbg [ 1 ] [ 'function' ] . '(' ; if ( is_array ( $ dbg [ 1 ] [ 'args' ] ) ) { foreach ( $ dbg [ 1 ] [ 'args' ] as $ index => $ arg ) {...
This method is used to indicate the start of the execution of a function in debug mode .
27,312
public static function traceEnd ( $ res = '' ) { if ( empty ( self :: $ _PHPCAS_DEBUG [ 'indent' ] ) ) { self :: $ _PHPCAS_DEBUG [ 'indent' ] = 0 ; } else { self :: $ _PHPCAS_DEBUG [ 'indent' ] -- ; } $ dbg = debug_backtrace ( ) ; $ str = '' ; if ( is_object ( $ res ) ) { $ str .= '<= ' . get_class ( $ res ) ; } else {...
This method is used to indicate the end of the execution of a function in debug mode .
27,313
public static function setHTMLHeader ( $ header ) { phpCAS :: _validateClientExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setHTMLHeader ( $ header ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } }
This method sets the HTML header used for all outputs .
27,314
public static function setHTMLFooter ( $ footer ) { phpCAS :: _validateClientExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setHTMLFooter ( $ footer ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } }
This method sets the HTML footer used for all outputs .
27,315
public static function hasAttribute ( $ key ) { phpCAS :: _validateClientExists ( ) ; try { return self :: $ _PHPCAS_CLIENT -> hasAttribute ( $ key ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } }
Answer true if an attribute exists for the authenticated user .
27,316
public static function handleLogoutRequests ( $ check_client = true , $ allowed_clients = false ) { phpCAS :: _validateClientExists ( ) ; return ( self :: $ _PHPCAS_CLIENT -> handleLogoutRequests ( $ check_client , $ allowed_clients ) ) ; }
Handle logout requests .
27,317
public static function setServerLoginURL ( $ url = '' ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateClientExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setServerLoginURL ( $ url ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } phpCAS :: traceEnd ( ) ; }
Set the login URL of the CAS server .
27,318
public static function setFixedCallbackURL ( $ url = '' ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateProxyExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setCallbackURL ( $ url ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } phpCAS :: traceEnd ( ) ; }
Set the fixed URL that will be used by the CAS server to transmit the PGT . When this method is not called a phpCAS script uses its own URL for the callback .
27,319
public static function setFixedServiceURL ( $ url ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateProxyExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setURL ( $ url ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ) ; } phpCAS :: traceEnd ( ) ; }
Set the fixed URL that will be set as the CAS service parameter . When this method is not called a phpCAS script uses its own URL .
27,320
public static function retrievePT ( $ target_service , & $ err_code , & $ err_msg ) { phpCAS :: _validateProxyExists ( ) ; try { return ( self :: $ _PHPCAS_CLIENT -> retrievePT ( $ target_service , $ err_code , $ err_msg ) ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ...
Retrieve a Proxy Ticket from the CAS server .
27,321
public static function setCasServerCACert ( $ cert , $ validate_cn = true ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateClientExists ( ) ; try { self :: $ _PHPCAS_CLIENT -> setCasServerCACert ( $ cert , $ validate_cn ) ; } catch ( Exception $ e ) { phpCAS :: error ( get_class ( $ e ) . ': ' . $ e -> getMessage ( ) ...
Set the certificate of the CAS server CA and if the CN should be properly verified .
27,322
public static function setNoCasServerValidation ( ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateClientExists ( ) ; phpCAS :: trace ( 'You have configured no validation of the legitimacy of the cas server. This is not recommended for production use.' ) ; self :: $ _PHPCAS_CLIENT -> setNoCasServerValidation ( ) ; php...
Set no SSL validation for the CAS server .
27,323
public static function setExtraCurlOption ( $ key , $ value ) { phpCAS :: traceBegin ( ) ; phpCAS :: _validateClientExists ( ) ; self :: $ _PHPCAS_CLIENT -> setExtraCurlOption ( $ key , $ value ) ; phpCAS :: traceEnd ( ) ; }
Change CURL options . CURL is used to connect through HTTPS to CAS server
27,324
public function check_chunks ( $ type , $ check ) { if ( array_key_exists ( $ type , $ this -> _chunks ) ) { foreach ( array_keys ( $ this -> _chunks [ $ type ] ) as $ typekey ) { list ( $ key , $ data ) = explode ( "\0" , $ this -> _chunks [ $ type ] [ $ typekey ] ) ; if ( strcmp ( $ key , $ check ) == 0 ) { debugging...
Checks if a key already exists in the chunk of said type . We need to avoid writing same keyword into file chunks .
27,325
public function add_chunks ( $ type , $ key , $ value ) { if ( strlen ( $ key ) > 79 ) { debugging ( 'Key is too big' ) ; } $ data = $ key . "\0" . $ value ; $ crc = pack ( "N" , crc32 ( $ type . $ data ) ) ; $ len = pack ( "N" , strlen ( $ data ) ) ; $ newchunk = $ len . $ type . $ data . $ crc ; $ result = substr ( $...
Adds a chunk with keyword and data to the file content . Chunk is added to the end of the file before IEND image trailer .
27,326
private function get_non_empty_children ( file_info $ fileinfo , $ extensions ) { $ nonemptychildren = $ fileinfo -> get_non_empty_children ( $ extensions ) ; $ list = array ( ) ; foreach ( $ nonemptychildren as $ child ) { if ( $ this -> can_skip ( $ child , $ extensions , $ fileinfo ) ) { $ list = array_merge ( $ lis...
Returns all children elements that have one of the specified extensions
27,327
private function can_skip ( file_info $ fileinfo , $ extensions , $ parent = - 1 ) { global $ CFG ; if ( ! $ fileinfo -> is_directory ( ) ) { return false ; } if ( $ fileinfo instanceof file_info_context_course || $ fileinfo instanceof file_info_context_user || $ fileinfo instanceof file_info_area_course_legacy || $ fi...
Whether this folder may be skipped in folder hierarchy
27,328
private function get_node ( file_info $ fileinfo ) { global $ OUTPUT ; $ encodedpath = base64_encode ( json_encode ( $ fileinfo -> get_params ( ) ) ) ; $ node = array ( 'title' => $ fileinfo -> get_visible_name ( ) , 'datemodified' => $ fileinfo -> get_timemodified ( ) , 'datecreated' => $ fileinfo -> get_timecreated (...
Converts file_info object to element of repository return list
27,329
private function get_node_path ( file_info $ fileinfo ) { $ encodedpath = base64_encode ( json_encode ( $ fileinfo -> get_params ( ) ) ) ; return array ( 'path' => $ encodedpath , 'name' => $ fileinfo -> get_visible_name ( ) ) ; }
Converts file_info object to element of repository return path
27,330
public function search ( $ q , $ page = 1 ) { global $ DB , $ SESSION ; if ( ! $ page ) { $ page = 1 ; } if ( ! isset ( $ SESSION -> repository_local_search ) ) { $ SESSION -> repository_local_search = array ( ) ; } $ fs = get_file_storage ( ) ; $ fb = get_file_browser ( ) ; $ max = 50 ; $ limit = 100 ; if ( $ page <= ...
Search through all the files .
27,331
public function fill_per_analysable_caches ( \ core_analytics \ analysable $ analysable ) { if ( $ analysable instanceof \ core_analytics \ course ) { $ this -> fetch_student_grades ( $ analysable ) ; } }
Fetch the course grades of this activity type instances .
27,332
public final function get_activity_type ( ) { $ class = get_class ( $ this ) ; $ package = stristr ( $ class , "\\" , true ) ; $ type = str_replace ( "mod_" , "" , $ package ) ; if ( $ type === $ package ) { throw new \ coding_exception ( "$class does not belong to any module specific namespace" ) ; } return $ type ; }
Returns the activity type . No point in changing this class in children classes .
27,333
protected final function any_log ( $ contextid , $ user ) { if ( empty ( $ this -> activitylogs [ $ contextid ] ) ) { return false ; } if ( empty ( $ user ) || ( ! empty ( $ user ) && ! empty ( $ this -> activitylogs [ $ contextid ] [ $ user -> id ] ) ) ) { return true ; } return false ; }
Do activity logs contain any log of user in this context?
27,334
protected final function any_write_log ( $ contextid , $ user ) { if ( empty ( $ this -> activitylogs [ $ contextid ] ) ) { return false ; } $ it = $ this -> activitylogs [ $ contextid ] ; if ( $ user ) { if ( empty ( $ this -> activitylogs [ $ contextid ] [ $ user -> id ] ) ) { return false ; } $ it = array ( $ user -...
Do activity logs contain any write log of user in this context?
27,335
protected function any_feedback ( $ action , \ cm_info $ cm , $ contextid , $ user ) { if ( ! in_array ( $ action , [ 'submitted' , 'replied' , 'viewed' ] ) ) { throw new \ coding_exception ( 'Provided action "' . $ action . '" is not valid.' ) ; } if ( empty ( $ this -> activitylogs [ $ contextid ] ) ) { return false ...
Is there any feedback activity log for this user in this context?
27,336
protected function get_graded_date ( $ contextid , $ userid , $ checkfeedback = false ) { if ( empty ( $ this -> grades [ $ contextid ] [ $ userid ] ) ) { return false ; } foreach ( $ this -> grades [ $ contextid ] [ $ userid ] as $ gradeitemid => $ gradeitem ) { if ( ( $ checkfeedback && $ gradeitem -> feedback ) || $...
Returns the date a user was graded .
27,337
protected function get_student_activities ( $ sampleid , $ tablename , $ starttime , $ endtime ) { $ user = $ this -> retrieve ( 'user' , $ sampleid ) ; if ( $ this -> course === null ) { $ this -> course = \ core_analytics \ course :: instance ( $ this -> retrieve ( 'course' , $ sampleid ) ) ; } if ( $ this -> activit...
Returns the activities the user had access to between a time period .
27,338
protected function fetch_activity_logs ( $ activities , $ starttime = false , $ endtime = false ) { global $ DB ; list ( $ contextsql , $ contextparams ) = $ DB -> get_in_or_equal ( array_keys ( $ activities ) , SQL_PARAMS_NAMED ) ; $ select = "contextid $contextsql AND timecreated > :starttime AND timecreated <= :endt...
Fetch acitivity logs from database
27,339
protected function cognitive_calculate_sample ( $ sampleid , $ tablename , $ starttime = false , $ endtime = false ) { $ user = $ this -> retrieve ( 'user' , $ sampleid ) ; if ( ! $ useractivities = $ this -> get_student_activities ( $ sampleid , $ tablename , $ starttime , $ endtime ) ) { return null ; } $ scoreperact...
Calculates the cognitive depth of a sample .
27,340
protected function social_calculate_sample ( $ sampleid , $ tablename , $ starttime = false , $ endtime = false ) { $ user = $ this -> retrieve ( 'user' , $ sampleid ) ; if ( ! $ useractivities = $ this -> get_student_activities ( $ sampleid , $ tablename , $ starttime , $ endtime ) ) { return null ; } $ scoreperactivi...
Calculates the social breadth of a sample .
27,341
protected function fetch_student_grades ( \ core_analytics \ course $ course ) { $ courseactivities = $ course -> get_all_activities ( $ this -> get_activity_type ( ) ) ; $ this -> grades = $ course -> get_student_grades ( $ courseactivities ) ; }
Gets the course student grades .
27,342
protected function get_activities ( $ starttime , $ endtime , $ student = false ) { $ activitytype = $ this -> get_activity_type ( ) ; $ studentid = - 1 ; if ( $ student ) { $ studentid = $ student -> id ; } $ modinfo = get_fast_modinfo ( $ this -> course -> get_course_data ( ) , $ studentid ) ; $ activities = $ modinf...
Guesses all activities that were available during a period of time .
27,343
protected function activity_type_completed_by ( \ cm_info $ activity , $ starttime , $ endtime , $ student = false ) { $ fieldname = $ this -> get_timeclose_field ( ) ; if ( ! $ fieldname ) { return null ; } $ this -> fill_instance_data ( $ activity ) ; $ instance = $ this -> instancedata [ $ activity -> instance ] ; i...
True if the activity is due or it has been closed during this period false if during another period null if no due time .
27,344
protected function fill_instance_data ( \ cm_info $ cm ) { global $ DB ; if ( ! isset ( $ this -> instancedata [ $ cm -> instance ] ) ) { $ this -> instancedata [ $ cm -> instance ] = $ DB -> get_record ( $ this -> get_activity_type ( ) , array ( 'id' => $ cm -> instance ) , '*' , MUST_EXIST ) ; } }
Fills in activity instance data .
27,345
protected function get_ratings_on_subcontext ( \ context $ context , array $ subcontext ) { $ writer = \ core_privacy \ local \ request \ writer :: with_context ( $ context ) ; return $ writer -> get_related_data ( $ subcontext , 'rating' ) ; }
Fetch all ratings on a subcontext .
27,346
protected function assert_all_own_ratings_on_context ( int $ userid , \ context $ context , array $ subcontext , $ component , $ ratingarea , $ itemid ) { $ writer = \ core_privacy \ local \ request \ writer :: with_context ( $ context ) ; $ rm = new \ rating_manager ( ) ; $ dbratings = $ rm -> get_all_ratings_for_item...
Check that all included ratings belong to the specified user .
27,347
protected function assert_rating_matches ( $ expected , $ stored ) { $ this -> assertEquals ( $ expected -> rating , $ stored -> rating ) ; $ this -> assertEquals ( $ expected -> userid , $ stored -> author ) ; }
Assert that the rating matches .
27,348
protected static function restore_event_from_standard_record ( $ data ) { $ extra = [ 'origin' => $ data -> origin , 'ip' => $ data -> ip , 'realuserid' => $ data -> realuserid ] ; $ data = ( array ) $ data ; $ id = $ data [ 'id' ] ; $ data [ 'other' ] = self :: decode_other ( $ data [ 'other' ] ) ; if ( $ data [ 'othe...
Returns an event from a standard record .
27,349
public static function transform_standard_log_record_for_userid ( $ record , $ userid ) { $ restoredevent = static :: restore_event_from_standard_record ( $ record ) ; if ( $ restoredevent ) { $ name = $ restoredevent -> get_name ( ) ; $ description = $ restoredevent -> get_description ( ) ; $ other = $ restoredevent -...
Transform a standard log record for a user .
27,350
protected function _getMx ( $ host ) { $ mx = array ( ) ; if ( $ this -> params [ 'netdns' ] ) { $ this -> _loadNetDns ( ) ; try { $ response = $ this -> _resolver -> query ( $ host , 'MX' ) ; if ( ! $ response ) { return false ; } } catch ( Exception $ e ) { throw new Horde_Mail_Exception ( $ e ) ; } foreach ( $ respo...
Recieve MX records for a host .
27,351
protected function _error ( $ id , $ info = array ( ) ) { $ msg = $ this -> _errorCode [ $ id ] [ 'msg' ] ; if ( ! empty ( $ info ) ) { $ replace = $ search = array ( ) ; foreach ( $ info as $ key => $ value ) { $ search [ ] = '{' . Horde_String :: upper ( $ key ) . '}' ; $ replace [ ] = $ value ; } $ msg = str_replace...
Format error message .
27,352
protected function validate_and_get_users ( $ versionids , $ userids , $ action ) { global $ DB ; $ usernames = [ ] ; list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( $ userids , SQL_PARAMS_NAMED ) ; $ params [ 'usercontextlevel' ] = CONTEXT_USER ; $ users = $ DB -> get_records_sql ( "SELECT u.id, " . get_all_user...
Validate userids and return usernames
27,353
protected function validate_and_get_versions ( $ versionids ) { $ versionnames = [ ] ; $ policies = api :: list_policies ( ) ; foreach ( $ versionids as $ versionid ) { $ version = api :: get_policy_version ( $ versionid , $ policies ) ; if ( $ version -> audience == policy_version :: AUDIENCE_GUESTS ) { throw new \ mo...
Validate versionids and return their names
27,354
public function process ( ) { if ( $ data = $ this -> get_data ( ) ) { foreach ( $ data -> userids as $ userid ) { if ( $ data -> action === 'revoke' ) { foreach ( $ data -> versionids as $ versionid ) { \ tool_policy \ api :: revoke_acceptance ( $ versionid , $ userid , $ data -> note ) ; } } else if ( $ data -> actio...
Process form submission
27,355
public function data_preprocessing ( & $ defaultvalues ) { if ( $ this -> current -> instance ) { $ draftitemid = file_get_submitted_draft_itemid ( 'page' ) ; $ defaultvalues [ 'page' ] [ 'format' ] = $ defaultvalues [ 'contentformat' ] ; $ defaultvalues [ 'page' ] [ 'text' ] = file_prepare_draft_area ( $ draftitemid ,...
Enforce defaults here .
27,356
public function writeAddress ( $ opts = array ( ) ) { if ( $ opts === true ) { $ opts = array ( 'encode' => 'UTF-8' , 'idn' => true ) ; } elseif ( ! empty ( $ opts [ 'encode' ] ) && ( $ opts [ 'encode' ] === true ) ) { $ opts [ 'encode' ] = 'UTF-8' ; } return $ this -> _writeAddress ( $ opts ) ; }
Write an address given information in this part .
27,357
public function can_edit ( field_controller $ field , int $ instanceid = 0 ) : bool { if ( $ instanceid ) { $ context = $ this -> get_instance_context ( $ instanceid ) ; return ( ! $ field -> get_configdata_property ( 'locked' ) || has_capability ( 'moodle/course:changelockedcustomfields' , $ context ) ) ; } else { $ c...
The current user can edit custom fields on the given course .
27,358
public function can_view ( field_controller $ field , int $ instanceid ) : bool { $ visibility = $ field -> get_configdata_property ( 'visibility' ) ; if ( $ visibility == self :: NOTVISIBLE ) { return false ; } else if ( $ visibility == self :: VISIBLETOTEACHERS ) { return has_capability ( 'moodle/course:update' , $ t...
The current user can view custom fields on the given course .
27,359
protected function get_parent_context ( ) : \ context { global $ PAGE ; if ( $ this -> parentcontext ) { return $ this -> parentcontext ; } else if ( $ PAGE -> context && $ PAGE -> context instanceof \ context_coursecat ) { return $ PAGE -> context ; } return \ context_system :: instance ( ) ; }
Returns the parent context for the course
27,360
public function get_instance_context ( int $ instanceid = 0 ) : \ context { if ( $ instanceid > 0 ) { return \ context_course :: instance ( $ instanceid ) ; } else { return \ context_system :: instance ( ) ; } }
Returns the context for the data associated with the given instanceid .
27,361
public function config_form_definition ( \ MoodleQuickForm $ mform ) { $ mform -> addElement ( 'header' , 'course_handler_header' , get_string ( 'customfieldsettings' , 'core_course' ) ) ; $ mform -> setExpanded ( 'course_handler_header' , true ) ; $ mform -> addElement ( 'selectyesno' , 'configdata[locked]' , get_stri...
Allows to add custom controls to the field configuration form that will be saved in configdata
27,362
public function restore_instance_data_from_backup ( \ restore_task $ task , array $ data ) { $ courseid = $ task -> get_courseid ( ) ; $ context = $ this -> get_instance_context ( $ courseid ) ; $ editablefields = $ this -> get_editable_fields ( $ courseid ) ; $ records = api :: get_instance_fields_data ( $ editablefie...
Creates or updates custom field data .
27,363
public function send ( $ method , $ parameters = array ( ) , $ body = null ) { $ url = $ this -> endpoint ; if ( ! empty ( $ parameters ) ) { if ( strpos ( $ url , '?' ) === false ) { $ sep = '?' ; } else { $ sep = '&' ; } foreach ( $ parameters as $ name => $ value ) { $ url .= $ sep . urlencode ( $ name ) . '=' . url...
Send a service request .
27,364
function iso8601totime ( $ iso8601 ) { $ regs = array ( ) ; if ( preg_match ( '/^([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})Z$/' , $ iso8601 , $ regs ) ) { return mktime ( $ regs [ 4 ] , $ regs [ 5 ] , $ regs [ 6 ] , $ regs [ 2 ] , $ regs [ 3 ] , $ regs [ 1 ] ) ; } return false ; }
Convert ISO 8601 Date and Time Profile used in RFC 2518 to an unix timestamp .
27,365
function open ( ) { $ this -> _error_log ( 'open a socket connection' ) ; $ this -> sock = fsockopen ( $ this -> _socket . $ this -> _server , $ this -> _port , $ this -> _errno , $ this -> _errstr , $ this -> _socket_timeout ) ; core_php_time_limit :: raise ( 30 ) ; if ( is_resource ( $ this -> sock ) ) { socket_set_b...
Open s a socket to a webdav server
27,366
function close ( ) { $ this -> _error_log ( 'closing socket ' . $ this -> sock ) ; $ this -> _connection_closed = true ; fclose ( $ this -> sock ) ; }
Closes an open socket .
27,367
function check_webdav ( ) { $ resp = $ this -> options ( ) ; if ( ! $ resp ) { return false ; } $ this -> _error_log ( $ resp [ 'header' ] [ 'DAV' ] ) ; if ( preg_match ( '/1,2/' , $ resp [ 'header' ] [ 'DAV' ] ) ) { return true ; } return false ; }
Check s if server is a webdav compliant server . True if server returns a DAV Element in Header and when schema 1 2 is supported .
27,368
function options ( ) { $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'OPTIONS' ) ; $ this -> send_request ( ) ; $ this -> get_respond ( ) ; $ response = $ this -> process_respond ( ) ; if ( $ response [ 'status' ] [ 'http-version' ] == 'HTTP/1.1' || $ response [ 'status' ] [ 'http-version' ] == 'HTTP/1....
Get options from webdav server .
27,369
function mkcol ( $ path ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'MKCOL' ) ; $ this -> send_request ( ) ; $ this -> get_respond ( ) ; $ response = $ this -> process_respond ( ) ; $ http_version = $ response [ 'status' ] [ 'http-version' ] ;...
Public method mkcol
27,370
function get ( $ path , & $ buffer , $ fp = null ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'GET' ) ; $ this -> send_request ( ) ; $ this -> get_respond ( $ fp ) ; $ response = $ this -> process_respond ( ) ; $ http_version = $ response [ 'st...
Public method get
27,371
function put ( $ path , $ data ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'PUT' ) ; $ this -> header_add ( 'Content-length: ' . strlen ( $ data ) ) ; $ this -> header_add ( 'Content-type: application/octet-stream' ) ; $ this -> send_request (...
Public method put
27,372
function put_file ( $ path , $ filename ) { $ handle = @ fopen ( $ filename , 'r' ) ; if ( $ handle ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'PUT' ) ; $ this -> header_add ( 'Content-length: ' . filesize ( $ filename ) ) ; $ this -> header_...
Public method put_file
27,373
function get_file ( $ srcpath , $ localpath ) { $ localpath = $ this -> utf_decode_path ( $ localpath ) ; $ handle = fopen ( $ localpath , 'wb' ) ; if ( $ handle ) { $ unused = '' ; $ ret = $ this -> get ( $ srcpath , $ unused , $ handle ) ; fclose ( $ handle ) ; if ( $ ret ) { return true ; } } return false ; }
Public method get_file
27,374
function copy_file ( $ src_path , $ dst_path , $ overwrite ) { $ this -> _path = $ this -> translate_uri ( $ src_path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'COPY' ) ; $ this -> header_add ( sprintf ( 'Destination: http://%s%s' , $ this -> _server , $ this -> translate_uri ( $ dst_path ) ) ) ...
Public method copy_file
27,375
function copy_coll ( $ src_path , $ dst_path , $ overwrite ) { $ this -> _path = $ this -> translate_uri ( $ src_path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'COPY' ) ; $ this -> header_add ( sprintf ( 'Destination: http://%s%s' , $ this -> _server , $ this -> translate_uri ( $ dst_path ) ) ) ...
Public method copy_coll
27,376
function lock ( $ path ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'LOCK' ) ; $ this -> header_add ( 'Timeout: Infinite' ) ; $ this -> header_add ( 'Content-type: text/xml' ) ; $ xml = "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\r\n" ; $ xml ...
Public method lock
27,377
function unlock ( $ path , $ locktoken ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'UNLOCK' ) ; $ this -> header_add ( sprintf ( 'Lock-Token: <%s>' , $ locktoken ) ) ; $ this -> send_request ( ) ; $ this -> get_respond ( ) ; $ response = $ thi...
Public method unlock
27,378
function delete ( $ path ) { $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'DELETE' ) ; $ this -> header_add ( '' ) ; $ this -> send_request ( ) ; $ this -> get_respond ( ) ; $ response = $ this -> process_respond ( ) ; if ( $ response [ 'status' ] ...
Public method delete
27,379
function ls ( $ path ) { if ( trim ( $ path ) == '' ) { $ this -> _error_log ( 'Missing a path in method ls' ) ; return false ; } $ this -> _path = $ this -> translate_uri ( $ path ) ; $ this -> header_unset ( ) ; $ this -> create_basic_request ( 'PROPFIND' ) ; $ this -> header_add ( 'Depth: 1' ) ; $ this -> header_add...
Public method ls
27,380
function gpi ( $ path ) { $ path = rtrim ( $ path , "/" ) ; $ item = basename ( $ path ) ; $ dir = dirname ( $ path ) ; $ list = $ this -> ls ( $ dir ) ; if ( is_array ( $ list ) ) { foreach ( $ list as $ e ) { $ fullpath = urldecode ( $ e [ 'href' ] ) ; $ filename = basename ( $ fullpath ) ; if ( $ filename == $ item ...
Public method gpi
27,381
function is_file ( $ path ) { $ item = $ this -> gpi ( $ path ) ; if ( $ item === false ) { return false ; } else { return ( $ item [ 'resourcetype' ] != 'collection' ) ; } }
Public method is_file
27,382
function is_dir ( $ path ) { $ item = $ this -> gpi ( $ path ) ; if ( $ item === false ) { return false ; } else { return ( $ item [ 'resourcetype' ] == 'collection' ) ; } }
Public method is_dir
27,383
function mput ( $ filelist ) { $ result = true ; foreach ( $ filelist as $ localpath => $ destpath ) { $ localpath = rtrim ( $ localpath , "/" ) ; $ destpath = rtrim ( $ destpath , "/" ) ; if ( is_dir ( $ localpath ) ) { $ pathparts = explode ( "/" , $ destpath . "/ " ) ; } else { $ pathparts = explode ( "/" , $ destpa...
Public method mput
27,384
function mget ( $ filelist ) { $ result = true ; foreach ( $ filelist as $ remotepath => $ localpath ) { $ localpath = rtrim ( $ localpath , "/" ) ; $ remotepath = rtrim ( $ remotepath , "/" ) ; if ( $ this -> is_dir ( $ remotepath ) ) { $ pathparts = explode ( "/" , $ localpath . "/ " ) ; } else { $ pathparts = explod...
Public method mget
27,385
private function _endElement ( $ parser , $ name ) { $ parserid = ( int ) $ parser ; $ this -> _xmltree [ $ parserid ] = substr ( $ this -> _xmltree [ $ parserid ] , 0 , strlen ( $ this -> _xmltree [ $ parserid ] ) - ( strlen ( $ name ) + 1 ) ) ; }
Private method _endelement
27,386
private function _propfind_startElement ( $ parser , $ name , $ attrs ) { $ parserid = ( int ) $ parser ; $ propname = strtolower ( $ name ) ; if ( ! empty ( $ this -> _xmltree [ $ parserid ] ) ) { $ this -> _xmltree [ $ parserid ] .= $ propname . '_' ; } else { $ this -> _xmltree [ $ parserid ] = $ propname . '_' ; } ...
Private method _propfind_startElement
27,387
private function _delete_startElement ( $ parser , $ name , $ attrs ) { $ parserid = ( int ) $ parser ; $ propname = strtolower ( $ name ) ; $ this -> _xmltree [ $ parserid ] .= $ propname . '_' ; switch ( $ this -> _xmltree [ $ parserid ] ) { case 'dav::multistatus_dav::response_' : $ this -> _delete_ref = & $ this ->...
Private method _delete_startElement
27,388
private function _lock_startElement ( $ parser , $ name , $ attrs ) { $ parserid = ( int ) $ parser ; $ propname = strtolower ( $ name ) ; $ this -> _xmltree [ $ parserid ] .= $ propname . '_' ; switch ( $ this -> _xmltree [ $ parserid ] ) { case 'dav::prop_dav::lockdiscovery_dav::activelock_' : $ this -> _lock_ref = &...
Private method _lock_startElement
27,389
private function _lock_cData ( $ parser , $ cdata ) { $ parserid = ( int ) $ parser ; if ( trim ( $ cdata ) <> '' ) { $ this -> _lock_ref_cdata .= $ cdata ; } else { } }
Private method _lock_cData
27,390
private function create_basic_request ( $ method ) { $ this -> header_add ( sprintf ( '%s %s %s' , $ method , $ this -> _path , $ this -> _protocol ) ) ; $ this -> header_add ( sprintf ( 'Host: %s:%s' , $ this -> _server , $ this -> _port ) ) ; $ this -> header_add ( sprintf ( 'User-Agent: %s' , $ this -> _user_agent )...
Private method create_basic_request
27,391
private function digest_auth ( ) { $ headers = array ( ) ; $ headers [ ] = sprintf ( '%s %s %s' , 'HEAD' , $ this -> _path , $ this -> _protocol ) ; $ headers [ ] = sprintf ( 'Host: %s:%s' , $ this -> _server , $ this -> _port ) ; $ headers [ ] = sprintf ( 'User-Agent: %s' , $ this -> _user_agent ) ; $ headers = implod...
Reads the header stores the challenge information
27,392
private function digest_signature ( $ method ) { if ( ! $ this -> _digestchallenge ) { $ this -> digest_auth ( ) ; } $ signature = array ( ) ; $ signature [ 'username' ] = '"' . $ this -> _user . '"' ; $ signature [ 'realm' ] = '"' . $ this -> _digestchallenge [ 'realm' ] . '"' ; $ signature [ 'nonce' ] = '"' . $ this ...
Generates the digest signature
27,393
private function send_request ( ) { if ( $ this -> _connection_closed ) { $ this -> close ( ) ; $ this -> reopen ( ) ; } $ buffer = implode ( "\r\n" , $ this -> _req ) ; $ buffer .= "\r\n\r\n" ; $ this -> _error_log ( $ buffer ) ; fputs ( $ this -> sock , $ buffer ) ; }
Private method send_request
27,394
private function process_respond ( ) { $ lines = explode ( "\r\n" , $ this -> _header ) ; $ header_done = false ; list ( $ ret_struct [ 'status' ] [ 'http-version' ] , $ ret_struct [ 'status' ] [ 'status-code' ] , $ ret_struct [ 'status' ] [ 'reason-phrase' ] ) = explode ( ' ' , $ lines [ 0 ] , 3 ) ; for ( $ i = 1 ; $ ...
Private method process_respond
27,395
private function translate_uri ( $ uri ) { $ native_path = html_entity_decode ( $ uri ) ; $ parts = explode ( '/' , $ native_path ) ; for ( $ i = 0 ; $ i < count ( $ parts ) ; $ i ++ ) { if ( iconv ( 'UTF-8' , 'UTF-8' , $ parts [ $ i ] ) == $ parts [ $ i ] ) { $ parts [ $ i ] = rawurlencode ( $ parts [ $ i ] ) ; } else...
Private method translate_uri
27,396
private function utf_decode_path ( $ path ) { $ fullpath = $ path ; if ( iconv ( 'UTF-8' , 'UTF-8' , $ fullpath ) == $ fullpath ) { $ this -> _error_log ( "filename is utf-8. Needs conversion..." ) ; $ fullpath = utf8_decode ( $ fullpath ) ; } return $ fullpath ; }
Private method utf_decode_path
27,397
public function transaction_starts ( ) { if ( $ this -> buffer !== null ) { $ this -> unregister ( ) ; return ; } if ( ! $ this -> rsrc ) { $ this -> unregister ( ) ; return ; } raise_memory_limit ( '2G' ) ; $ this -> buffer = array ( ) ; while ( $ next = $ this -> fetch_next ( ) ) { $ this -> buffer [ ] = $ next ; } }
Inform existing open recordsets that transaction is starting this works around MARS problem described in MDL - 37734 .
27,398
private function unregister ( ) { if ( $ this -> db ) { $ this -> db -> recordset_closed ( $ this ) ; $ this -> db = null ; } }
Unregister recordset from the global list of open recordsets .
27,399
public static function workshop_viewed ( $ event ) { global $ DB , $ CFG ; require_once ( $ CFG -> dirroot . '/mod/workshop/locallib.php' ) ; $ workshop = $ event -> get_record_snapshot ( 'workshop' , $ event -> objectid ) ; $ course = $ event -> get_record_snapshot ( 'course' , $ event -> courseid ) ; $ cm = $ event -...
Triggered when the \ mod_workshop \ event \ course_module_viewed event is triggered .