idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
32,600
public function get_description ( ) { $ allhelp = array ( ) ; if ( $ this -> aggregation != GRADE_AGGREGATE_SUM ) { $ aggrstrings = grade_helper :: get_aggregation_strings ( ) ; $ allhelp [ ] = $ aggrstrings [ $ this -> aggregation ] ; } if ( $ this -> droplow && $ this -> can_apply_limit_rules ( ) ) { $ allhelp [ ] = ...
Describe the aggregation settings for this category so the reports make more sense .
32,601
public function set_parent ( $ parentid , $ source = null ) { if ( $ this -> parent == $ parentid ) { return true ; } if ( $ parentid == $ this -> id ) { print_error ( 'cannotassignselfasparent' ) ; } if ( empty ( $ this -> parent ) and $ this -> is_course_category ( ) ) { print_error ( 'cannothaveparentcate' ) ; } if ...
Sets this category s parent id
32,602
public static function fetch_course_category ( $ courseid ) { if ( empty ( $ courseid ) ) { debugging ( 'Missing course id!' ) ; return false ; } if ( $ course_category = grade_category :: fetch ( array ( 'courseid' => $ courseid , 'parent' => null ) ) ) { return $ course_category ; } $ course_category = new grade_cate...
Return the course level grade_category object
32,603
public function set_locked ( $ lockedstate , $ cascade = false , $ refresh = true ) { $ this -> load_grade_item ( ) ; $ result = $ this -> grade_item -> set_locked ( $ lockedstate , $ cascade , true ) ; if ( $ cascade ) { if ( $ children = grade_item :: fetch_all ( array ( 'categoryid' => $ this -> id ) ) ) { foreach (...
Sets the grade_item s locked variable and updates the grade_item .
32,604
public function set_hidden ( $ hidden , $ cascade = false ) { $ this -> load_grade_item ( ) ; $ this -> grade_item -> set_hidden ( $ hidden , $ cascade ) ; parent :: set_hidden ( $ hidden , $ cascade ) ; if ( $ cascade ) { if ( $ children = grade_item :: fetch_all ( array ( 'categoryid' => $ this -> id ) ) ) { foreach ...
Sets the grade_item s hidden variable and updates the grade_item .
32,605
public function apply_default_settings ( ) { global $ CFG ; foreach ( $ this -> forceable as $ property ) { if ( isset ( $ CFG -> { "grade_$property" } ) ) { if ( $ CFG -> { "grade_$property" } == - 1 ) { continue ; } $ this -> $ property = $ CFG -> { "grade_$property" } ; } } }
Applies default settings on this category
32,606
public function apply_forced_settings ( ) { global $ CFG ; $ updated = false ; foreach ( $ this -> forceable as $ property ) { if ( isset ( $ CFG -> { "grade_$property" } ) and isset ( $ CFG -> { "grade_{$property}_flag" } ) and ( ( int ) $ CFG -> { "grade_{$property}_flag" } & 1 ) ) { if ( $ CFG -> { "grade_$property"...
Applies forced settings on this category
32,607
protected static function retrieve_record_set ( $ params ) { $ cache = cache :: make ( 'core' , 'grade_categories' ) ; return $ cache -> get ( self :: generate_record_set_key ( $ params ) ) ; }
Tries to retrieve a record set from the cache .
32,608
protected static function set_record_set ( $ params , $ records ) { $ cache = cache :: make ( 'core' , 'grade_categories' ) ; return $ cache -> set ( self :: generate_record_set_key ( $ params ) , $ records ) ; }
Sets a result to the records cache even if there were no results .
32,609
protected function make_rules ( $ quizobj , $ timenow , $ canignoretimelimits ) { $ rules = array ( ) ; foreach ( self :: get_rule_classes ( ) as $ ruleclass ) { $ rule = $ ruleclass :: make ( $ quizobj , $ timenow , $ canignoretimelimits ) ; if ( $ rule ) { $ rules [ $ ruleclass ] = $ rule ; } } $ superceededrules = a...
Make all the rules relevant to a particular quiz .
32,610
public static function add_settings_form_fields ( mod_quiz_mod_form $ quizform , MoodleQuickForm $ mform ) { foreach ( self :: get_rule_classes ( ) as $ rule ) { $ rule :: add_settings_form_fields ( $ quizform , $ mform ) ; } }
Add any form fields that the access rules require to the settings form .
32,611
public static function get_browser_security_choices ( ) { $ options = array ( '-' => get_string ( 'none' , 'quiz' ) ) ; foreach ( self :: get_rule_classes ( ) as $ rule ) { $ options += $ rule :: get_browser_security_choices ( ) ; } return $ options ; }
The the options for the Browser security settings menu .
32,612
protected static function get_load_sql ( $ quizid , $ rules , $ basefields ) { $ allfields = $ basefields ; $ alljoins = '{quiz} quiz' ; $ allparams = array ( 'quizid' => $ quizid ) ; foreach ( $ rules as $ rule ) { list ( $ fields , $ joins , $ params ) = $ rule :: get_settings_sql ( $ quizid ) ; if ( $ fields ) { if ...
Build the SQL for loading all the access settings in one go .
32,613
public static function load_settings ( $ quizid ) { global $ DB ; $ rules = self :: get_rule_classes ( ) ; list ( $ sql , $ params ) = self :: get_load_sql ( $ quizid , $ rules , '' ) ; if ( $ sql ) { $ data = ( array ) $ DB -> get_record_sql ( $ sql , $ params ) ; } else { $ data = array ( ) ; } foreach ( $ rules as $...
Load any settings required by the access rules . We try to do this with a single DB query .
32,614
public static function load_quiz_and_settings ( $ quizid ) { global $ DB ; $ rules = self :: get_rule_classes ( ) ; list ( $ sql , $ params ) = self :: get_load_sql ( $ quizid , $ rules , 'quiz.*' ) ; $ quiz = $ DB -> get_record_sql ( $ sql , $ params , MUST_EXIST ) ; foreach ( $ rules as $ rule ) { foreach ( $ rule ::...
Load the quiz settings and any settings required by the access rules . We try to do this with a single DB query .
32,615
public function describe_rules ( ) { $ result = array ( ) ; foreach ( $ this -> rules as $ rule ) { $ result = $ this -> accumulate_messages ( $ result , $ rule -> description ( ) ) ; } return $ result ; }
Provide a description of the rules that apply to this quiz such as is shown at the top of the quiz view page . Note that not all rules consider themselves important enough to output a description .
32,616
public function prevent_new_attempt ( $ numprevattempts , $ lastattempt ) { $ reasons = array ( ) ; foreach ( $ this -> rules as $ rule ) { $ reasons = $ this -> accumulate_messages ( $ reasons , $ rule -> prevent_new_attempt ( $ numprevattempts , $ lastattempt ) ) ; } return $ reasons ; }
Whether or not a user should be allowed to start a new attempt at this quiz now . If there are any restrictions in force now return an array of reasons why access should be blocked . If access is OK return false .
32,617
public function prevent_access ( ) { $ reasons = array ( ) ; foreach ( $ this -> rules as $ rule ) { $ reasons = $ this -> accumulate_messages ( $ reasons , $ rule -> prevent_access ( ) ) ; } return $ reasons ; }
Whether the user should be blocked from starting a new attempt or continuing an attempt now . If there are any restrictions in force now return an array of reasons why access should be blocked . If access is OK return false .
32,618
public function get_preflight_check_form ( moodle_url $ url , $ attemptid ) { $ method = 'post' ; if ( ! empty ( $ _GET [ '_qf__mod_quiz_preflight_check_form' ] ) ) { $ method = 'get' ; } return new mod_quiz_preflight_check_form ( $ url -> out_omit_querystring ( ) , array ( 'rules' => $ this -> rules , 'quizobj' => $ t...
Build the form required to do the pre - flight checks .
32,619
public function is_finished ( $ numprevattempts , $ lastattempt ) { foreach ( $ this -> rules as $ rule ) { if ( $ rule -> is_finished ( $ numprevattempts , $ lastattempt ) ) { return true ; } } return false ; }
Do any of the rules mean that this student will no be allowed any further attempts at this quiz . Used for example to change the label by the grade displayed on the view page from your current grade is to your final grade is .
32,620
public function get_end_time ( $ attempt ) { $ timeclose = false ; foreach ( $ this -> rules as $ rule ) { $ ruletimeclose = $ rule -> end_time ( $ attempt ) ; if ( $ ruletimeclose !== false && ( $ timeclose === false || $ ruletimeclose < $ timeclose ) ) { $ timeclose = $ ruletimeclose ; } } return $ timeclose ; }
Compute when the attempt must be submitted .
32,621
public function get_time_left_display ( $ attempt , $ timenow ) { $ timeleft = false ; foreach ( $ this -> rules as $ rule ) { $ ruletimeleft = $ rule -> time_left_display ( $ attempt , $ timenow ) ; if ( $ ruletimeleft !== false && ( $ timeleft === false || $ ruletimeleft < $ timeleft ) ) { $ timeleft = $ ruletimeleft...
Compute what should be displayed to the user for time remaining in this attempt .
32,622
public function back_to_view_page ( $ output , $ message = '' ) { if ( $ this -> attempt_must_be_in_popup ( ) ) { echo $ output -> close_attempt_popup ( $ this -> quizobj -> view_url ( ) , $ message ) ; die ( ) ; } else { redirect ( $ this -> quizobj -> view_url ( ) , $ message ) ; } }
Send the user back to the quiz view page . Normally this is just a redirect but If we were in a secure window we close this window and reload the view window we came from .
32,623
public function make_review_link ( $ attempt , $ reviewoptions , $ output ) { if ( in_array ( $ attempt -> state , array ( quiz_attempt :: IN_PROGRESS , quiz_attempt :: OVERDUE ) ) ) { return $ output -> no_review_message ( '' ) ; } $ when = quiz_attempt_state ( $ this -> quizobj -> get_quiz ( ) , $ attempt ) ; $ revie...
Make some text into a link to review the quiz if that is appropriate .
32,624
public function validate_preflight_check ( $ data , $ files , $ attemptid ) { $ errors = array ( ) ; foreach ( $ this -> rules as $ rule ) { if ( $ rule -> is_preflight_check_required ( $ attemptid ) ) { $ errors = $ rule -> validate_preflight_check ( $ data , $ files , $ errors , $ attemptid ) ; } } return $ errors ; ...
Run the preflight checks using the given data in all the rules supporting them .
32,625
public static function instance ( $ prototype = null ) { static $ instance ; if ( $ prototype !== null ) { $ instance = $ prototype ; } elseif ( $ instance === null || $ prototype === true ) { $ instance = new HTMLPurifier_DefinitionCacheFactory ( ) ; $ instance -> setup ( ) ; } return $ instance ; }
Retrieves an instance of global definition cache factory .
32,626
public function create ( $ type , $ config ) { $ method = $ config -> get ( 'Cache.DefinitionImpl' ) ; if ( $ method === null ) { return new HTMLPurifier_DefinitionCache_Null ( $ type ) ; } if ( ! empty ( $ this -> caches [ $ method ] [ $ type ] ) ) { return $ this -> caches [ $ method ] [ $ type ] ; } if ( isset ( $ t...
Factory method that creates a cache object based on configuration
32,627
public function addDecorator ( $ decorator ) { if ( is_string ( $ decorator ) ) { $ class = "HTMLPurifier_DefinitionCache_Decorator_$decorator" ; $ decorator = new $ class ; } $ this -> decorators [ $ decorator -> name ] = $ decorator ; }
Registers a decorator to add to all new cache objects
32,628
public function shorten ( $ args , Mustache_LambdaHelper $ helper ) { list ( $ length , $ text ) = explode ( ',' , $ args , 2 ) ; $ length = trim ( $ length ) ; $ text = trim ( $ text ) ; $ text = $ helper -> render ( $ text ) ; return shorten_text ( $ text , $ length ) ; }
Read a length and text component from the string .
32,629
public function generateScriptFromToken ( $ token ) { if ( ! $ token instanceof HTMLPurifier_Token_Text ) { return $ this -> generateFromToken ( $ token ) ; } $ data = preg_replace ( '#//\s*$#' , '' , $ token -> data ) ; return '<!--// . "\n" . trim ( $ data ) . "\n" . '// ; }
Special case processor for the contents of script tags
32,630
public function generateAttributes ( $ assoc_array_of_attributes , $ element = '' ) { $ html = '' ; if ( $ this -> _sortAttr ) { ksort ( $ assoc_array_of_attributes ) ; } foreach ( $ assoc_array_of_attributes as $ key => $ value ) { if ( ! $ this -> _xhtml ) { if ( strpos ( $ key , ':' ) !== false ) { continue ; } if (...
Generates attribute declarations from attribute array .
32,631
public function escape ( $ string , $ quote = null ) { if ( $ quote === null ) { $ quote = ENT_COMPAT ; } return htmlspecialchars ( $ string , $ quote , 'UTF-8' ) ; }
Escapes raw text data .
32,632
public function setDispositionParameter ( $ label , $ data ) { $ cd = $ this -> _headers [ 'content-disposition' ] ; if ( is_null ( $ data ) ) { unset ( $ cd [ $ label ] ) ; } elseif ( strlen ( $ data ) ) { $ cd [ $ label ] = $ data ; if ( strcasecmp ( $ label , 'size' ) === 0 ) { $ this -> _bytes = $ cd [ $ label ] ; ...
Add a disposition parameter to this part .
32,633
public function getName ( $ default = false ) { if ( ! ( $ name = $ this -> getDispositionParameter ( 'filename' ) ) && ! ( $ name = $ this -> getContentTypeParameter ( 'name' ) ) && $ default ) { $ name = preg_replace ( '|\W|' , '_' , $ this -> getDescription ( false ) ) ; } return $ name ; }
Get the name of this part .
32,634
public function setContents ( $ contents , $ options = array ( ) ) { if ( is_resource ( $ contents ) && ( $ contents === $ this -> _contents ) ) { return ; } if ( empty ( $ options [ 'encoding' ] ) ) { $ options [ 'encoding' ] = $ this -> _transferEncoding ; } $ fp = ( empty ( $ options [ 'usestream' ] ) || ! is_resour...
Set the body contents of this part .
32,635
public function appendContents ( $ contents , $ options = array ( ) ) { if ( empty ( $ this -> _contents ) ) { $ this -> setContents ( $ contents , $ options ) ; } else { $ fp = ( empty ( $ options [ 'usestream' ] ) || ! is_resource ( $ contents ) ) ? $ this -> _writeStream ( $ contents ) : $ contents ; $ this -> _writ...
Add to the body contents of this part .
32,636
public function clearContents ( ) { if ( ! empty ( $ this -> _contents ) ) { fclose ( $ this -> _contents ) ; $ this -> _contents = null ; unset ( $ this -> _temp [ 'sendTransferEncoding' ] ) ; } }
Clears the body contents of this part .
32,637
public function getContents ( $ options = array ( ) ) { return empty ( $ options [ 'canonical' ] ) ? ( empty ( $ options [ 'stream' ] ) ? $ this -> _readStream ( $ this -> _contents ) : $ this -> _contents ) : $ this -> replaceEOL ( $ this -> _contents , self :: RFC_EOL , ! empty ( $ options [ 'stream' ] ) ) ; }
Return the body of the part .
32,638
protected function _transferDecode ( $ fp , $ encoding ) { fseek ( $ fp , 0 , SEEK_END ) ; if ( ftell ( $ fp ) ) { switch ( $ encoding ) { case 'base64' : try { return $ this -> _writeStream ( $ fp , array ( 'error' => true , 'filter' => array ( 'convert.base64-decode' => array ( ) ) ) ) ; } catch ( ErrorException $ e ...
Decodes the contents of the part to binary encoding .
32,639
protected function _transferEncode ( $ fp , $ encoding ) { $ this -> _temp [ 'transferEncodeClose' ] = true ; switch ( $ encoding ) { case 'base64' : return $ this -> _writeStream ( $ fp , array ( 'filter' => array ( 'convert.base64-encode' => array ( 'line-break-chars' => $ this -> getEOL ( ) , 'line-length' => 76 ) )...
Encodes the contents of the part as necessary for transport .
32,640
public function getType ( $ charset = false ) { $ ct = $ this -> _headers [ 'content-type' ] ; return $ charset ? $ ct -> type_charset : $ ct -> value ; }
Get the full MIME Content - Type of this part .
32,641
public function setDescription ( $ description ) { if ( is_null ( $ description ) ) { unset ( $ this -> _headers [ 'content-description' ] ) ; } else { if ( ! ( $ hdr = $ this -> _headers [ 'content-description' ] ) ) { $ hdr = new Horde_Mime_Headers_ContentDescription ( null , '' ) ; $ this -> _headers -> addHeaderOb ...
Set the description of this part .
32,642
public function getDescription ( $ default = false ) { if ( ( $ ob = $ this -> _headers [ 'content-description' ] ) && strlen ( $ ob -> value ) ) { return $ ob -> value ; } return $ default ? $ this -> getName ( ) : '' ; }
Get the description of this part .
32,643
public function setTransferEncoding ( $ encoding , $ options = array ( ) ) { if ( empty ( $ encoding ) || ( empty ( $ options [ 'send' ] ) && ! empty ( $ this -> _contents ) ) ) { return ; } switch ( $ encoding = Horde_String :: lower ( $ encoding ) ) { case '7bit' : case '8bit' : case 'base64' : case 'binary' : case '...
Set the transfer encoding to use for this part .
32,644
public function addMimeHeaders ( $ options = array ( ) ) { if ( empty ( $ options [ 'headers' ] ) ) { $ headers = new Horde_Mime_Headers ( ) ; } else { $ headers = $ options [ 'headers' ] ; $ headers -> removeHeader ( 'Content-Disposition' ) ; $ headers -> removeHeader ( 'Content-Transfer-Encoding' ) ; } $ ct = $ this ...
Returns a Horde_Mime_Header object containing all MIME headers needed for the part .
32,645
protected function _getTransferEncoding ( $ encode = self :: ENCODE_7BIT ) { if ( ! empty ( $ this -> _temp [ 'sendEncoding' ] ) ) { return $ this -> _temp [ 'sendEncoding' ] ; } elseif ( ! empty ( $ this -> _temp [ 'sendTransferEncoding' ] [ $ encode ] ) ) { return $ this -> _temp [ 'sendTransferEncoding' ] [ $ encode...
Get the transfer encoding for the part based on the user requested transfer encoding and the current contents of the part .
32,646
public function replaceEOL ( $ text , $ eol = null , $ stream = false ) { if ( is_null ( $ eol ) ) { $ eol = $ this -> getEOL ( ) ; } stream_filter_register ( 'horde_eol' , 'Horde_Stream_Filter_Eol' ) ; $ fp = $ this -> _writeStream ( $ text , array ( 'filter' => array ( 'horde_eol' => array ( 'eol' => $ eol ) ) ) ) ; ...
Replace newlines in this part s contents with those specified by either the given newline sequence or the part s current EOL setting .
32,647
public function getBytes ( $ approx = false ) { if ( $ this -> getPrimaryType ( ) == 'multipart' ) { if ( isset ( $ this -> _bytes ) ) { return $ this -> _bytes ; } $ bytes = 0 ; foreach ( $ this as $ part ) { $ bytes += $ part -> getBytes ( $ approx ) ; } return $ bytes ; } if ( $ this -> _contents ) { fseek ( $ this ...
Determine the size of this MIME part and its child members .
32,648
public function getSize ( $ approx = false ) { if ( ! ( $ bytes = $ this -> getBytes ( $ approx ) ) ) { return 0 ; } $ localeinfo = Horde_Nls :: getLocaleInfo ( ) ; return str_replace ( array ( 'X' , 'Y' ) , array ( $ localeinfo [ 'decimal_point' ] , $ localeinfo [ 'thousands_sep' ] ) , number_format ( ceil ( $ bytes /...
Output the size of this MIME part in KB .
32,649
public function setContentId ( $ cid = null ) { if ( ! is_null ( $ id = $ this -> getContentId ( ) ) ) { return $ id ; } $ this -> _headers -> addHeaderOb ( is_null ( $ cid ) ? Horde_Mime_Headers_ContentId :: create ( ) : new Horde_Mime_Headers_ContentId ( null , $ cid ) ) ; return $ this -> getContentId ( ) ; }
Sets the Content - ID header for this part .
32,650
public function buildMimeIds ( $ id = null , $ rfc822 = false ) { $ this -> _status &= ~ self :: STATUS_REINDEX ; if ( is_null ( $ id ) ) { $ rfc822 = true ; $ id = '' ; } if ( $ rfc822 ) { if ( empty ( $ this -> _parts ) && ( $ this -> getPrimaryType ( ) != 'multipart' ) ) { $ this -> setMimeId ( $ id . '1' ) ; } else...
Build the MIME IDs for this part and all subparts .
32,651
public function isBasePart ( $ base ) { if ( empty ( $ base ) ) { $ this -> _status &= ~ self :: STATUS_BASEPART ; } else { $ this -> _status |= self :: STATUS_BASEPART ; } }
Is this the base MIME part?
32,652
public function isAttachment ( ) { $ type = $ this -> getType ( ) ; switch ( $ type ) { case 'application/ms-tnef' : case 'application/pgp-keys' : case 'application/vnd.ms-tnef' : return false ; } if ( $ this -> parent ) { switch ( $ this -> parent -> getType ( ) ) { case 'multipart/encrypted' : switch ( $ type ) { cas...
Determines if this MIME part is an attachment for display purposes .
32,653
public function setMetadata ( $ key , $ data = null ) { if ( is_null ( $ data ) ) { unset ( $ this -> _metadata [ $ key ] ) ; } else { $ this -> _metadata [ $ key ] = $ data ; } }
Set a piece of metadata on this object .
32,654
public function getMetadata ( $ key ) { return isset ( $ this -> _metadata [ $ key ] ) ? $ this -> _metadata [ $ key ] : null ; }
Retrieves metadata from this object .
32,655
public function getPartByIndex ( $ index ) { if ( ! isset ( $ this -> _parts [ $ index ] ) ) { return null ; } $ part = $ this -> _parts [ $ index ] ; $ part -> parent = $ this ; return $ part ; }
Returns a subpart by index .
32,656
protected function _reindex ( $ force = false ) { $ id = $ this -> getMimeId ( ) ; if ( ( $ this -> _status & self :: STATUS_REINDEX ) || ( $ force && is_null ( $ id ) ) ) { $ this -> buildMimeIds ( is_null ( $ id ) ? ( ( $ this -> getPrimaryType ( ) === 'multipart' ) ? '0' : '1' ) : $ id ) ; } }
Reindexes the MIME IDs if necessary .
32,657
protected function _writeStream ( $ data , $ options = array ( ) ) { if ( empty ( $ options [ 'fp' ] ) ) { $ fp = fopen ( 'php://temp/maxmemory:' . self :: $ memoryLimit , 'r+' ) ; } else { $ fp = $ options [ 'fp' ] ; fseek ( $ fp , 0 , SEEK_END ) ; } if ( ! is_array ( $ data ) ) { $ data = array ( $ data ) ; } $ appen...
Write data to a stream .
32,658
protected function _readStream ( $ fp , $ close = false ) { $ out = '' ; if ( ! is_resource ( $ fp ) ) { return $ out ; } rewind ( $ fp ) ; while ( ! feof ( $ fp ) ) { $ out .= fread ( $ fp , 8192 ) ; } if ( $ close ) { fclose ( $ fp ) ; } return $ out ; }
Read data from a stream .
32,659
protected function _scanStream ( $ fp ) { rewind ( $ fp ) ; stream_filter_register ( 'horde_mime_scan_stream' , 'Horde_Mime_Filter_Encoding' ) ; $ filter_params = new stdClass ; $ filter = stream_filter_append ( $ fp , 'horde_mime_scan_stream' , STREAM_FILTER_READ , $ filter_params ) ; while ( ! feof ( $ fp ) ) { fread...
Scans a stream for content type .
32,660
public static function parseMessage ( $ text , array $ opts = array ( ) ) { $ part = new Horde_Mime_Part ( ) ; $ rawtext = $ part -> replaceEOL ( $ text , self :: EOL ) ; $ hdr_pos = self :: _findHeader ( $ rawtext , self :: EOL ) ; unset ( $ opts [ 'ctype' ] ) ; $ ob = self :: _getStructure ( substr ( $ rawtext , 0 , ...
Attempts to build a Horde_Mime_Part object from message text .
32,661
public static function getRawPartText ( $ text , $ type , $ id ) { $ part = new Horde_Mime_Part ( ) ; $ rawtext = $ part -> replaceEOL ( $ text , self :: RFC_EOL ) ; $ hdr_pos = self :: _findHeader ( $ rawtext , self :: RFC_EOL ) ; $ curr_pos = $ hdr_pos + 3 ; if ( $ id == 0 ) { switch ( $ type ) { case 'body' : return...
Attempts to obtain the raw text of a MIME part .
32,662
protected static function _findHeader ( $ text , $ eol ) { $ hdr_pos = strpos ( $ text , $ eol . $ eol ) ; return ( $ hdr_pos === false ) ? strlen ( $ text ) : $ hdr_pos ; }
Find the location of the end of the header text .
32,663
protected static function _findBoundary ( $ text , $ pos , $ boundary , $ end = null ) { $ i = 0 ; $ out = array ( ) ; $ search = "--" . $ boundary ; $ search_len = strlen ( $ search ) ; while ( ( $ pos = strpos ( $ text , $ search , $ pos ) ) !== false ) { if ( ( $ pos != 0 ) && ( $ text [ $ pos - 1 ] != "\n" ) ) { co...
Find the location of the next boundary string .
32,664
protected function get_legacy_eventdata ( ) { $ data = new \ stdClass ( ) ; $ data -> cohortid = $ this -> objectid ; $ data -> userid = $ this -> relateduserid ; return $ data ; }
Return legacy event data .
32,665
public function logout ( ) { set_user_preference ( 'repository_flickr_access_token' , null ) ; set_user_preference ( 'repository_flickr_access_token_secret' , null ) ; $ this -> accesstoken = null ; $ this -> accesstokensecret = null ; return $ this -> print_login ( ) ; }
Purge the stored access token and related user data .
32,666
public function print_login ( ) { $ reqtoken = $ this -> flickr -> request_token ( ) ; $ this -> flickr -> set_request_token_secret ( [ 'caller' => 'repository_flickr' ] , $ reqtoken [ 'oauth_token_secret' ] ) ; $ authurl = new moodle_url ( $ reqtoken [ 'authorize_url' ] , array ( 'perms' => 'read' ) ) ; if ( $ this ->...
Show the interface to log in to Flickr ..
32,667
public function search ( $ searchtext , $ page = 0 ) { $ response = $ this -> flickr -> call ( 'photos.search' , [ 'user_id' => 'me' , 'per_page' => 24 , 'extras' => 'original_format,url_sq,url_o,date_upload,owner_name' , 'page' => $ page , 'text' => $ searchtext , ] ) ; if ( $ response === false ) { $ this -> logout (...
Search for the user s photos at Flickr
32,668
public function callback ( ) { $ token = required_param ( 'oauth_token' , PARAM_RAW ) ; $ verifier = required_param ( 'oauth_verifier' , PARAM_RAW ) ; $ secret = $ this -> flickr -> get_request_token_secret ( [ 'caller' => 'repository_flickr' ] ) ; $ accesstoken = $ this -> flickr -> get_access_token ( $ token , $ secr...
Handle the oauth authorize callback
32,669
public function execute ( ) { global $ CFG ; if ( ! empty ( $ CFG -> skiplangupgrade ) ) { mtrace ( 'Langpack update skipped. ($CFG->skiplangupgrade set)' ) ; return ; } $ controller = new \ tool_langimport \ controller ( ) ; if ( $ controller -> update_all_installed_languages ( ) ) { foreach ( $ controller -> info as ...
Run langpack update
32,670
public function instance_can_be_docked ( ) { return parent :: instance_can_be_docked ( ) && isset ( $ this -> config -> title ) && ! empty ( $ this -> config -> title ) ; }
Returns true if the block can be docked . The mentees block can only be docked if it has a non - empty title .
32,671
public function get_used_module_names ( $ plural = false ) { $ modnames = get_module_types_names ( $ plural ) ; $ modnamesused = array ( ) ; foreach ( $ this -> get_cms ( ) as $ cmid => $ mod ) { if ( ! isset ( $ modnamesused [ $ mod -> modname ] ) && isset ( $ modnames [ $ mod -> modname ] ) && $ mod -> uservisible ) ...
Returns array of localised human - readable module names used in this course
32,672
private function get_groups_all ( ) { if ( is_null ( $ this -> groups ) ) { $ this -> groups = groups_get_user_groups ( $ this -> course -> id , $ this -> userid ) ; } return $ this -> groups ; }
Groups that the current user belongs to organised by grouping id . Calculated on the first request .
32,673
public function get_section_info ( $ sectionnumber , $ strictness = IGNORE_MISSING ) { if ( ! array_key_exists ( $ sectionnumber , $ this -> sectioninfo ) ) { if ( $ strictness === MUST_EXIST ) { throw new moodle_exception ( 'sectionnotexist' ) ; } else { return null ; } } return $ this -> sectioninfo [ $ sectionnumber...
Gets data about specific numbered section .
32,674
public static function instance ( $ courseorid , $ userid = 0 ) { global $ USER ; if ( is_object ( $ courseorid ) ) { $ course = $ courseorid ; } else { $ course = ( object ) array ( 'id' => $ courseorid ) ; } if ( empty ( $ userid ) ) { $ userid = $ USER -> id ; } if ( ! empty ( self :: $ instancecache [ $ course -> i...
Returns the instance of course_modinfo for the specified course and specified user
32,675
protected static function get_course_cache_lock ( $ courseid ) { $ lockfactory = \ core \ lock \ lock_config :: get_lock_factory ( 'core_modinfo' ) ; $ lock = $ lockfactory -> get_lock ( 'build_course_cache_' . $ courseid , self :: COURSE_CACHE_LOCK_WAIT , self :: COURSE_CACHE_LOCK_EXPIRY ) ; if ( ! $ lock ) { throw ne...
Gets a lock for rebuilding the cache of a single course .
32,676
public static function build_course_cache ( $ course ) { if ( empty ( $ course -> id ) ) { throw new coding_exception ( 'Object $course is missing required property \id\'' ) ; } $ lock = self :: get_course_cache_lock ( $ course -> id ) ; try { return self :: inner_build_course_cache ( $ course , $ lock ) ; } finally { ...
Builds and stores in MUC object containing information about course modules and sections together with cached fields from table course .
32,677
protected static function inner_build_course_cache ( $ course , \ core \ lock \ lock $ lock ) { global $ DB , $ CFG ; require_once ( "{$CFG->dirroot}/course/lib.php" ) ; foreach ( self :: $ cachedfields as $ key ) { if ( ! isset ( $ course -> $ key ) ) { $ course = $ DB -> get_record ( 'course' , array ( 'id' => $ cour...
Called to build course cache when there is already a lock obtained .
32,678
public function get_module_type_name ( $ plural = false ) { $ modnames = get_module_types_names ( $ plural ) ; if ( isset ( $ modnames [ $ this -> modname ] ) ) { return $ modnames [ $ this -> modname ] ; } else { return null ; } }
Returns a localised human - readable name of the module type
32,679
private function get_effective_groupmode ( ) { $ groupmode = $ this -> groupmode ; if ( $ this -> modinfo -> get_course ( ) -> groupmodeforce ) { $ groupmode = $ this -> modinfo -> get_course ( ) -> groupmode ; if ( $ groupmode != NOGROUPS && ! plugin_supports ( 'mod' , $ this -> modname , FEATURE_GROUPS , false ) ) { ...
Returns effective groupmode of the module that may be overwritten by forced course groupmode .
32,680
public function get_course_module_record ( $ additionalfields = false ) { $ cmrecord = new stdClass ( ) ; static $ cmfields = array ( 'id' , 'course' , 'module' , 'instance' , 'section' , 'idnumber' , 'added' , 'score' , 'indent' , 'visible' , 'visibleoncoursepage' , 'visibleold' , 'groupmode' , 'groupingid' , 'complet...
Returns itself in the form of stdClass .
32,681
private function obtain_dynamic_data ( ) { global $ CFG ; $ userid = $ this -> modinfo -> get_user_id ( ) ; if ( $ this -> state >= self :: STATE_BUILDING_DYNAMIC || $ userid == - 1 ) { return ; } $ this -> state = self :: STATE_BUILDING_DYNAMIC ; if ( ! empty ( $ CFG -> enableavailability ) ) { $ ci = new \ core_avail...
If dynamic data for this course - module is not yet available gets it .
32,682
public function is_stealth ( ) { return ! $ this -> visibleoncoursepage || ( $ this -> visible && ( $ section = $ this -> get_section_info ( ) ) && ! $ section -> visible ) ; }
Whether this module is available but hidden from course page
32,683
private function update_user_visible ( ) { $ userid = $ this -> modinfo -> get_user_id ( ) ; if ( $ userid == - 1 ) { return null ; } $ this -> uservisible = true ; if ( $ this -> deletioninprogress ) { $ this -> uservisible = false ; return null ; } if ( ( ! $ this -> visible && ! has_capability ( 'moodle/course:viewh...
Works out whether activity is available to the current user
32,684
private function obtain_view_data ( ) { if ( $ this -> state >= self :: STATE_BUILDING_VIEW || $ this -> modinfo -> get_user_id ( ) == - 1 ) { return ; } $ this -> obtain_dynamic_data ( ) ; $ this -> state = self :: STATE_BUILDING_VIEW ; $ this -> call_mod_function ( 'cm_info_view' ) ; $ this -> state = self :: STATE_V...
If view data for this course - module is not yet available obtains it .
32,685
public function __isset ( $ name ) { if ( method_exists ( $ this , 'get_' . $ name ) || property_exists ( $ this , '_' . $ name ) || array_key_exists ( $ name , self :: $ sectionformatoptions [ $ this -> modinfo -> get_course ( ) -> format ] ) ) { $ value = $ this -> __get ( $ name ) ; return isset ( $ value ) ; } retu...
Magic method to check if the property is set
32,686
public function __empty ( $ name ) { if ( method_exists ( $ this , 'get_' . $ name ) || property_exists ( $ this , '_' . $ name ) || array_key_exists ( $ name , self :: $ sectionformatoptions [ $ this -> modinfo -> get_course ( ) -> format ] ) ) { $ value = $ this -> __get ( $ name ) ; return empty ( $ value ) ; } retu...
Magic method to check if the property is empty
32,687
private function get_available ( ) { global $ CFG ; $ userid = $ this -> modinfo -> get_user_id ( ) ; if ( $ this -> _available !== null || $ userid == - 1 ) { return $ this -> _available ; } $ this -> _available = true ; $ this -> _availableinfo = '' ; if ( ! empty ( $ CFG -> enableavailability ) ) { $ ci = new \ core...
Finds whether this section is available at the moment for the current user .
32,688
private function get_sequence ( ) { if ( ! empty ( $ this -> modinfo -> sections [ $ this -> _section ] ) ) { return implode ( ',' , $ this -> modinfo -> sections [ $ this -> _section ] ) ; } else { return '' ; } }
Restores the course_sections . sequence value
32,689
public static function convert_for_section_cache ( $ section ) { global $ CFG ; unset ( $ section -> course ) ; unset ( $ section -> section ) ; unset ( $ section -> sequence ) ; foreach ( self :: $ sectioncachedefaults as $ field => $ value ) { if ( isset ( $ section -> { $ field } ) && $ section -> { $ field } === $ ...
Prepares section data for inclusion in sectioncache cache removing items that are set to defaults and adding availability data if required .
32,690
public function get_taskbasepath ( ) { $ basepath = $ this -> get_basepath ( ) ; if ( ! empty ( $ this -> moduleid ) ) { $ basepath .= '/activities/' . $ this -> modulename . '_' . $ this -> moduleid . '/blocks/' . $ this -> blockname . '_' . $ this -> blockid ; } else { $ basepath .= '/course/blocks/' . $ this -> bloc...
Block tasks have their own directory to write files
32,691
public static function load_from_record ( $ record , $ clean = false ) { $ tour = new self ( ) ; return $ tour -> reload_from_record ( $ record , $ clean ) ; }
Create an instance of tour from its provided DB record .
32,692
protected function reload_from_record ( $ record , $ clean = false ) { $ this -> id = $ record -> id ; if ( ! property_exists ( $ record , 'description' ) ) { if ( property_exists ( $ record , 'comment' ) ) { $ record -> description = $ record -> comment ; unset ( $ record -> comment ) ; } } if ( $ clean ) { $ this -> ...
Reload the tour into the current object .
32,693
public function get_steps ( ) { if ( empty ( $ this -> steps ) ) { $ this -> steps = helper :: get_steps ( $ this -> id ) ; } return $ this -> steps ; }
Fetch all steps in the tour .
32,694
public function set_name ( $ value ) { $ this -> name = clean_param ( $ value , PARAM_TEXT ) ; $ this -> dirty = true ; return $ this ; }
Set the name of the tour to the specified value .
32,695
public function set_description ( $ value ) { $ this -> description = clean_text ( $ value ) ; $ this -> dirty = true ; return $ this ; }
Set the description of the tour to the specified value .
32,696
public function to_record ( ) { return ( object ) array ( 'id' => $ this -> id , 'name' => $ this -> name , 'description' => $ this -> description , 'pathmatch' => $ this -> pathmatch , 'enabled' => $ this -> enabled , 'sortorder' => $ this -> sortorder , 'configdata' => json_encode ( $ this -> config ) , ) ; }
Prepare this tour for saving to the database .
32,697
public function is_last_tour ( $ tourcount = null ) { if ( $ tourcount === null ) { $ tourcount = helper :: count_tours ( ) ; } return ( $ this -> get_sortorder ( ) === ( $ tourcount - 1 ) ) ; }
Whether this tour is the last tour .
32,698
public function set_config ( $ key , $ value ) { if ( $ this -> config === null ) { $ this -> config = ( object ) array ( ) ; } $ this -> config -> $ key = $ value ; $ this -> dirty = true ; return $ this ; }
Set the configuration item as specified .
32,699
public function reset_step_sortorder ( ) { global $ DB ; $ steps = $ DB -> get_records ( 'tool_usertours_steps' , array ( 'tourid' => $ this -> id ) , 'sortorder ASC' , 'id' ) ; $ index = 0 ; foreach ( $ steps as $ step ) { $ DB -> set_field ( 'tool_usertours_steps' , 'sortorder' , $ index , array ( 'id' => $ step -> i...
Reset the sortorder for all steps in the tour .