idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
28,300
public function get_link ( $ key = 0 , $ rel = 'alternate' ) { $ links = $ this -> get_links ( $ rel ) ; if ( $ links [ $ key ] !== null ) { return $ links [ $ key ] ; } else { return null ; } }
Get a single link for the item
28,301
public function get_enclosure ( $ key = 0 , $ prefer = null ) { $ enclosures = $ this -> get_enclosures ( ) ; if ( isset ( $ enclosures [ $ key ] ) ) { return $ enclosures [ $ key ] ; } else { return null ; } }
Get an enclosure from the item
28,302
public function is_discussion_time_locked ( discussion_entity $ discussion ) : bool { if ( ! $ this -> has_lock_discussions_after ( ) ) { return false ; } if ( $ this -> get_type ( ) === 'single' ) { return false ; } return ( ( $ discussion -> get_time_modified ( ) + $ this -> get_lock_discussions_after ( ) ) < time ( ...
Check whether the discussion is locked based on forum s time based locking criteria
28,303
public function is_discussion_locked ( discussion_entity $ discussion ) : bool { if ( $ discussion -> is_locked ( ) ) { return true ; } return $ this -> is_discussion_time_locked ( $ discussion ) ; }
Is the discussion locked? - Takes into account both discussion settings AND forum s criteria
28,304
private function get_system_oauth_client ( ) { if ( $ this -> systemoauthclient === false ) { try { $ this -> systemoauthclient = \ core \ oauth2 \ api :: get_system_oauth_client ( $ this -> issuer ) ; } catch ( \ moodle_exception $ e ) { $ this -> systemoauthclient = false ; } } return $ this -> systemoauthclient ; }
Get or initialise an oauth client for the system account .
28,305
private function get_system_ocs_client ( ) { if ( $ this -> systemocsclient === null ) { try { $ systemoauth = $ this -> get_system_oauth_client ( ) ; if ( ! $ systemoauth ) { return null ; } $ this -> systemocsclient = new ocs_client ( $ systemoauth ) ; } catch ( \ moodle_exception $ e ) { $ this -> systemocsclient = ...
Get or initialise an ocs client for the system account .
28,306
private function initiate_webdavclient ( ) { if ( $ this -> dav !== null ) { return $ this -> dav ; } $ webdavendpoint = issuer_management :: parse_endpoint_url ( 'webdav' , $ this -> issuer ) ; $ server = $ webdavendpoint [ 'host' ] ; if ( $ webdavendpoint [ 'scheme' ] === 'https' ) { $ webdavtype = 'ssl://' ; $ webda...
Initiates the webdav client .
28,307
public function get_link ( $ url ) { $ ocsparams = [ 'path' => $ url , 'shareType' => ocs_client :: SHARE_TYPE_PUBLIC , 'publicUpload' => false , 'permissions' => ocs_client :: SHARE_PERMISSION_READ ] ; $ response = $ this -> ocsclient -> call ( 'create_share' , $ ocsparams ) ; $ xml = simplexml_load_string ( $ respons...
Use OCS to generate a public share to the requested file . This method derives a download link from the public share URL .
28,308
protected function get_user_oauth_client ( $ overrideurl = false ) { if ( $ this -> client ) { return $ this -> client ; } if ( $ overrideurl ) { $ returnurl = $ overrideurl ; } else { $ returnurl = new moodle_url ( '/repository/repository_callback.php' ) ; $ returnurl -> param ( 'callback' , 'yes' ) ; $ returnurl -> p...
Get a cached user authenticated oauth client .
28,309
public function print_login ( ) { $ client = $ this -> get_user_oauth_client ( ) ; $ loginurl = $ client -> get_login_url ( ) ; if ( $ this -> options [ 'ajax' ] ) { $ ret = array ( ) ; $ btn = new \ stdClass ( ) ; $ btn -> type = 'popup' ; $ btn -> url = $ loginurl -> out ( false ) ; $ ret [ 'login' ] = array ( $ btn ...
Prints a simple Login Button which redirects to an authorization window from Nextcloud .
28,310
public static function instance_config_form ( $ mform ) { if ( ! has_capability ( 'moodle/site:config' , context_system :: instance ( ) ) ) { $ mform -> addElement ( 'static' , null , '' , get_string ( 'nopermissions' , 'error' , get_string ( 'configplugin' , 'repository_nextcloud' ) ) ) ; return false ; } $ issuers = ...
This method adds a select form and additional information to the settings form ..
28,311
private function get_listing_prepare_response ( $ path ) { $ ret = [ 'dynload' => true , 'nosearch' => true , 'nologin' => false , 'path' => array ( [ 'name' => $ this -> get_meta ( ) -> name , 'path' => '' , ] ) , 'defaultreturntype' => $ this -> default_returntype ( ) , 'manage' => $ this -> issuer -> get ( 'baseurl'...
Prepare response of get_listing ; namely - defining setting elements - filling in the parent path of the currently - viewed directory .
28,312
public function get_reference_details ( $ reference , $ filestatus = 0 ) { if ( $ this -> disabled ) { throw new repository_exception ( 'cannotdownload' , 'repository' ) ; } if ( empty ( $ reference ) ) { return get_string ( 'unknownsource' , 'repository' ) ; } $ source = json_decode ( $ reference ) ; $ path = '' ; if ...
When a controlled link is clicked in the file picker get the human readable info about this file .
28,313
public function force_archetype ( $ archetype , array $ options ) { $ archetypes = get_role_archetypes ( ) ; if ( ! isset ( $ archetypes [ $ archetype ] ) ) { throw new coding_exception ( 'Unknown archetype: ' . $ archetype ) ; } if ( $ options [ 'shortname' ] ) { $ this -> role -> shortname = '' ; } if ( $ options [ '...
Change the role definition to match given archetype .
28,314
public function force_preset ( $ xml , array $ options ) { if ( ! $ info = core_role_preset :: parse_preset ( $ xml ) ) { throw new coding_exception ( 'Invalid role preset' ) ; } if ( $ options [ 'shortname' ] ) { if ( isset ( $ info [ 'shortname' ] ) ) { $ this -> role -> shortname = $ info [ 'shortname' ] ; } } if ( ...
Change the role definition to match given preset .
28,315
protected function get_allow_roles_list ( $ type , $ roleid = null ) { global $ DB ; if ( $ type !== 'assign' and $ type !== 'switch' and $ type !== 'override' and $ type !== 'view' ) { debugging ( 'Invalid role allowed type specified' , DEBUG_DEVELOPER ) ; return array ( ) ; } if ( $ roleid === null ) { $ roleid = $ t...
Returns an array of roles of the allowed type .
28,316
protected function get_allow_role_control ( $ type ) { if ( $ type !== 'assign' and $ type !== 'switch' and $ type !== 'override' and $ type !== 'view' ) { debugging ( 'Invalid role allowed type specified' , DEBUG_DEVELOPER ) ; return '' ; } $ property = 'allow' . $ type ; $ selected = $ this -> $ property ; $ options ...
Returns an array of roles with the allowed type .
28,317
protected function print_field ( $ name , $ caption , $ field , $ helpicon = null ) { global $ OUTPUT ; echo '<div class="fitem row form-group">' ; echo '<div class="fitemtitle col-md-3">' ; if ( $ name ) { echo '<label for="' . $ name . '">' ; } echo $ caption ; if ( $ name ) { echo "</label>\n" ; } if ( $ helpicon ) ...
Print labels fields and help icon on role administration page .
28,318
public static function get_filetypes_browser_data_parameters ( ) { return new external_function_parameters ( [ 'onlytypes' => new external_value ( PARAM_RAW , 'Limit the browser to the given groups and extensions' , VALUE_DEFAULT , '' ) , 'allowall' => new external_value ( PARAM_BOOL , 'Allows to select All file types,...
Describes the input paramaters of the get_filetypes_browser_data external function .
28,319
public static function get_filetypes_browser_data ( $ onlytypes , $ allowall , $ current ) { $ params = self :: validate_parameters ( self :: get_filetypes_browser_data_parameters ( ) , compact ( 'onlytypes' , 'allowall' , 'current' ) ) ; $ util = new filetypes_util ( ) ; return [ 'groups' => $ util -> data_for_browser...
Implements the get_filetypes_browser_data external function .
28,320
public static function get_filetypes_browser_data_returns ( ) { $ type = new external_single_structure ( [ 'key' => new external_value ( PARAM_RAW , 'The file type identifier' ) , 'name' => new external_value ( PARAM_RAW , 'The file type name' ) , 'selected' => new external_value ( PARAM_BOOL , 'Should it be marked as ...
Describes the output of the get_filetypes_browser_data external function .
28,321
protected function isSelfExtend ( $ target , $ origin ) { foreach ( $ origin as $ sel ) { if ( in_array ( $ target , $ sel ) ) { return true ; } } return false ; }
Is self extend?
28,322
protected function makeOutputBlock ( $ type , $ selectors = null ) { $ out = new OutputBlock ; $ out -> type = $ type ; $ out -> lines = [ ] ; $ out -> children = [ ] ; $ out -> parent = $ this -> scope ; $ out -> selectors = $ selectors ; $ out -> depth = $ this -> env -> depth ; $ out -> sourceName = $ this -> env ->...
Make output block
28,323
protected function missingSelectors ( ) { foreach ( $ this -> extends as $ extend ) { if ( isset ( $ extend [ 3 ] ) ) { continue ; } list ( $ target , $ origin , $ block ) = $ extend ; if ( $ block [ 2 ] ) { continue ; } $ target = implode ( ' ' , $ target ) ; $ origin = $ this -> collapseSelectors ( $ origin ) ; $ thi...
Report missing selectors
28,324
protected function matchExtendsSingle ( $ rawSingle , & $ outOrigin ) { $ counts = [ ] ; $ single = [ ] ; foreach ( $ rawSingle as $ part ) { if ( ! is_string ( $ part ) ) { return false ; } if ( ! preg_match ( '/^[\[.:#%]/' , $ part ) && count ( $ single ) ) { $ single [ count ( $ single ) - 1 ] .= $ part ; } else { $...
Match extends single
28,325
protected function extractRelationshipFromFragment ( array $ fragment ) { $ parents = [ ] ; $ children = [ ] ; $ j = $ i = count ( $ fragment ) ; for ( ; ; ) { $ children = $ j != $ i ? array_slice ( $ fragment , $ j , $ i - $ j ) : [ ] ; $ parents = array_slice ( $ fragment , 0 , $ j ) ; $ slice = end ( $ parents ) ; ...
Extract a relationship from the fragment .
28,326
protected function combineSelectorSingle ( $ base , $ other ) { $ tag = [ ] ; $ out = [ ] ; $ wasTag = true ; foreach ( [ $ base , $ other ] as $ single ) { foreach ( $ single as $ part ) { if ( preg_match ( '/^[\[.:#]/' , $ part ) ) { $ out [ ] = $ part ; $ wasTag = false ; } elseif ( preg_match ( '/^[^_-]/' , $ part ...
Combine selector single
28,327
private function spliceTree ( $ envs , Block $ block , $ without ) { $ newBlock = null ; foreach ( $ envs as $ e ) { if ( ! isset ( $ e -> block ) ) { continue ; } if ( $ e -> block === $ block ) { continue ; } if ( isset ( $ e -> block -> type ) && $ e -> block -> type === Type :: T_AT_ROOT ) { continue ; } if ( $ e -...
Splice parse tree
28,328
private function filterWithout ( $ envs , $ without ) { $ filtered = [ ] ; foreach ( $ envs as $ e ) { if ( $ e -> block && $ this -> isWithout ( $ without , $ e -> block ) ) { continue ; } $ filtered [ ] = $ e ; } return $ this -> extractEnv ( $ filtered ) ; }
Filter env stack
28,329
protected function compileKeyframeBlock ( Block $ block , $ selectors ) { $ env = $ this -> pushEnv ( $ block ) ; $ envs = $ this -> compactEnv ( $ env ) ; $ this -> env = $ this -> extractEnv ( array_filter ( $ envs , function ( Environment $ e ) { return ! isset ( $ e -> block -> selectors ) ; } ) ) ; $ this -> scope...
Compile keyframe block
28,330
protected function compileComment ( $ block ) { $ out = $ this -> makeOutputBlock ( Type :: T_COMMENT ) ; $ out -> lines [ ] = $ block [ 1 ] ; $ this -> scope -> children [ ] = $ out ; }
Compile root level comment
28,331
protected function evalSelectorPart ( $ part ) { foreach ( $ part as & $ p ) { if ( is_array ( $ p ) && ( $ p [ 0 ] === Type :: T_INTERPOLATE || $ p [ 0 ] === Type :: T_STRING ) ) { $ p = $ this -> compileValue ( $ p ) ; if ( strpos ( $ p , '&' ) !== false || strpos ( $ p , ',' ) !== false ) { $ this -> shouldEvaluate ...
Evaluate selector part ; replaces all the interpolates stripping quotes
28,332
protected function compileMediaQuery ( $ queryList ) { $ out = '@media' ; $ first = true ; foreach ( $ queryList as $ query ) { $ type = null ; $ parts = [ ] ; foreach ( $ query as $ q ) { switch ( $ q [ 0 ] ) { case Type :: T_MEDIA_TYPE : if ( $ type ) { $ type = $ this -> mergeMediaTypes ( $ type , array_map ( [ $ th...
Compile media query
28,333
protected function mergeMediaTypes ( $ type1 , $ type2 ) { if ( empty ( $ type1 ) ) { return $ type2 ; } if ( empty ( $ type2 ) ) { return $ type1 ; } $ m1 = '' ; $ t1 = '' ; if ( count ( $ type1 ) > 1 ) { $ m1 = strtolower ( $ type1 [ 0 ] ) ; $ t1 = strtolower ( $ type1 [ 1 ] ) ; } else { $ t1 = strtolower ( $ type1 [...
Merge media types
28,334
protected function compileImport ( $ rawPath , $ out , $ once = false ) { if ( $ rawPath [ 0 ] === Type :: T_STRING ) { $ path = $ this -> compileStringContent ( $ rawPath ) ; if ( $ path = $ this -> findImport ( $ path ) ) { if ( ! $ once || ! in_array ( $ path , $ this -> importedFiles ) ) { $ this -> importFile ( $ ...
Compile import ; returns true if the value was something that could be imported
28,335
protected function expToString ( $ exp ) { list ( , $ op , $ left , $ right , , $ whiteLeft , $ whiteRight ) = $ exp ; $ content = [ $ this -> reduce ( $ left ) ] ; if ( $ whiteLeft ) { $ content [ ] = ' ' ; } $ content [ ] = $ op ; if ( $ whiteRight ) { $ content [ ] = ' ' ; } $ content [ ] = $ this -> reduce ( $ righ...
Reduce expression to string
28,336
protected function opNumberColor ( $ op , $ left , $ right ) { $ value = $ left [ 1 ] ; return $ this -> opColorColor ( $ op , [ Type :: T_COLOR , $ value , $ value , $ value ] , $ right ) ; }
Compare number and color
28,337
protected function opEq ( $ left , $ right ) { if ( ( $ lStr = $ this -> coerceString ( $ left ) ) && ( $ rStr = $ this -> coerceString ( $ right ) ) ) { $ lStr [ 1 ] = '' ; $ rStr [ 1 ] = '' ; $ left = $ this -> compileValue ( $ lStr ) ; $ right = $ this -> compileValue ( $ rStr ) ; } return $ this -> toBool ( $ left ...
Compare number1 == number2
28,338
protected function opCmpNumberNumber ( $ left , $ right ) { $ n = $ left [ 1 ] - $ right [ 1 ] ; return new Node \ Number ( $ n ? $ n / abs ( $ n ) : 0 , '' ) ; }
Three - way comparison aka spaceship operator
28,339
protected function extractInterpolation ( $ list ) { $ items = $ list [ 2 ] ; foreach ( $ items as $ i => $ item ) { if ( $ item [ 0 ] === Type :: T_INTERPOLATE ) { $ before = [ Type :: T_LIST , $ list [ 1 ] , array_slice ( $ items , 0 , $ i ) ] ; $ after = [ Type :: T_LIST , $ list [ 1 ] , array_slice ( $ items , $ i ...
Extract interpolation ; it doesn t need to be recursive compileValue will handle that
28,340
private function compactEnv ( Environment $ env ) { for ( $ envs = [ ] ; $ env ; $ env = $ env -> parent ) { $ envs [ ] = $ env ; } return $ envs ; }
Convert env linked list to stack
28,341
public function addParsedFile ( $ path ) { if ( isset ( $ path ) && file_exists ( $ path ) ) { $ this -> parsedFiles [ realpath ( $ path ) ] = filemtime ( $ path ) ; } }
Adds to list of parsed files
28,342
protected function handleImportLoop ( $ name ) { for ( $ env = $ this -> env ; $ env ; $ env = $ env -> parent ) { $ file = $ this -> sourceNames [ $ env -> block -> sourceIndex ] ; if ( realpath ( $ file ) === $ name ) { $ this -> throwError ( 'An @import loop has been found: %s imports %s' , $ file , basename ( $ fil...
Handle import loop
28,343
protected function getBuiltinFunction ( $ name ) { $ libName = 'lib' . preg_replace_callback ( '/_(.)/' , function ( $ m ) { return ucfirst ( $ m [ 1 ] ) ; } , ucfirst ( $ name ) ) ; return [ $ this , $ libName ] ; }
Get built - in function
28,344
protected function coerceMap ( $ item ) { if ( $ item [ 0 ] === Type :: T_MAP ) { return $ item ; } if ( $ item === static :: $ emptyList ) { return static :: $ emptyMap ; } return [ Type :: T_MAP , [ $ item ] , [ static :: $ null ] ] ; }
Coerce something to map
28,345
protected function coerceList ( $ item , $ delim = ',' ) { if ( isset ( $ item ) && $ item [ 0 ] === Type :: T_LIST ) { return $ item ; } if ( isset ( $ item ) && $ item [ 0 ] === Type :: T_MAP ) { $ keys = $ item [ 1 ] ; $ values = $ item [ 2 ] ; $ list = [ ] ; for ( $ i = 0 , $ s = count ( $ keys ) ; $ i < $ s ; $ i ...
Coerce something to list
28,346
protected function coerceColor ( $ value ) { switch ( $ value [ 0 ] ) { case Type :: T_COLOR : return $ value ; case Type :: T_KEYWORD : $ name = strtolower ( $ value [ 1 ] ) ; if ( isset ( Colors :: $ cssColors [ $ name ] ) ) { $ rgba = explode ( ',' , Colors :: $ cssColors [ $ name ] ) ; return isset ( $ rgba [ 3 ] )...
Coerce value to color
28,347
protected function coerceString ( $ value ) { if ( $ value [ 0 ] === Type :: T_STRING ) { return $ value ; } return [ Type :: T_STRING , '' , [ $ this -> compileValue ( $ value ) ] ] ; }
Coerce value to string
28,348
protected function fixColor ( $ c ) { foreach ( [ 1 , 2 , 3 ] as $ i ) { if ( $ c [ $ i ] < 0 ) { $ c [ $ i ] = 0 ; } if ( $ c [ $ i ] > 255 ) { $ c [ $ i ] = 255 ; } } return $ c ; }
Make sure a color s components don t go out of bounds
28,349
public function toHSL ( $ red , $ green , $ blue ) { $ min = min ( $ red , $ green , $ blue ) ; $ max = max ( $ red , $ green , $ blue ) ; $ l = $ min + $ max ; $ d = $ max - $ min ; if ( ( int ) $ d === 0 ) { $ h = $ s = 0 ; } else { if ( $ l < 255 ) { $ s = $ d / $ l ; } else { $ s = $ d / ( 510 - $ l ) ; } if ( $ re...
Convert RGB to HSL
28,350
protected function getNormalizedNumbers ( $ args ) { $ unit = null ; $ originalUnit = null ; $ numbers = [ ] ; foreach ( $ args as $ key => $ item ) { if ( $ item [ 0 ] !== Type :: T_NUMBER ) { $ this -> throwError ( '%s is not a number' , $ item [ 0 ] ) ; break ; } $ number = $ item -> normalize ( ) ; if ( null === $ ...
Helper to normalize args containing numbers
28,351
protected function libCounter ( $ args ) { $ list = array_map ( [ $ this , 'compileValue' ] , $ args ) ; return [ Type :: T_STRING , '' , [ 'counter(' . implode ( ',' , $ list ) . ')' ] ] ; }
Workaround IE7 s content counter bug .
28,352
public function get_instance_name ( $ instance ) { global $ DB ; if ( empty ( $ instance ) ) { $ enrol = $ this -> get_name ( ) ; return get_string ( 'pluginname' , 'enrol_' . $ enrol ) ; } else if ( empty ( $ instance -> name ) ) { $ enrol = $ this -> get_name ( ) ; $ cohort = $ DB -> get_record ( 'cohort' , array ( '...
Returns localised name of enrol instance .
28,353
public function can_add_instance ( $ courseid ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ coursecontext = context_course :: instance ( $ courseid ) ; if ( ! has_capability ( 'moodle/course:enrolconfig' , $ coursecontext ) or ! has_capability ( 'enrol/cohort:config' , $ coursecontext ) )...
Given a courseid this function returns true if the user is able to enrol or configure cohorts . AND there are cohorts that the user can view .
28,354
protected function get_cohort_options ( $ instance , $ context ) { global $ DB , $ CFG ; require_once ( $ CFG -> dirroot . '/cohort/lib.php' ) ; $ cohorts = array ( ) ; if ( $ instance -> id ) { if ( $ cohort = $ DB -> get_record ( 'cohort' , array ( 'id' => $ instance -> customint1 ) ) ) { $ name = format_string ( $ c...
Return an array of valid options for the cohorts .
28,355
protected function get_role_options ( $ instance , $ coursecontext ) { global $ DB ; $ roles = get_assignable_roles ( $ coursecontext ) ; $ roles [ 0 ] = get_string ( 'none' ) ; $ roles = array_reverse ( $ roles , true ) ; if ( $ instance -> id and ! isset ( $ roles [ $ instance -> roleid ] ) ) { if ( $ role = $ DB -> ...
Return an array of valid options for the roles .
28,356
protected function get_group_options ( $ coursecontext ) { $ groups = array ( 0 => get_string ( 'none' ) ) ; if ( has_capability ( 'moodle/course:managegroups' , $ coursecontext ) ) { $ groups [ COHORT_CREATE_GROUP ] = get_string ( 'creategroup' , 'enrol_cohort' ) ; } foreach ( groups_get_all_groups ( $ coursecontext -...
Return an array of valid options for the groups .
28,357
public static function supports ( $ from , $ to ) { $ imports = self :: $ imports ; $ exports = self :: $ exports ; return isset ( $ imports [ $ from ] ) && isset ( $ exports [ $ to ] ) ; }
Whether a file conversion can be completed using this converter .
28,358
protected function get_day_names ( renderer_base $ output ) { $ weekdays = $ this -> related [ 'type' ] -> get_weekdays ( ) ; $ daysinweek = count ( $ weekdays ) ; $ daynames = [ ] ; for ( $ i = 0 ; $ i < $ daysinweek ; $ i ++ ) { $ dayno = ( $ i + $ this -> firstdayofweek + $ daysinweek ) % $ daysinweek ; $ dayname = ...
Get the list of day names for display re - ordered from the first day of the week .
28,359
protected function get_weeks ( renderer_base $ output ) { $ weeks = [ ] ; $ alldays = $ this -> get_days ( ) ; $ daysinweek = count ( $ this -> related [ 'type' ] -> get_weekdays ( ) ) ; $ firstdayofweek = $ this -> firstdayofweek ; $ day = reset ( $ alldays ) ; $ firstdayno = $ day [ 'wday' ] ; $ prepadding = ( $ firs...
Get the list of week days ordered into weeks and padded according to the value of the first day of the week .
28,360
protected function get_days ( ) { $ date = $ this -> related [ 'type' ] -> timestamp_to_date_array ( $ this -> calendar -> time ) ; $ monthdays = $ this -> related [ 'type' ] -> get_num_days_in_month ( $ date [ 'year' ] , $ date [ 'mon' ] ) ; $ days = [ ] ; for ( $ dayno = 1 ; $ dayno <= $ monthdays ; $ dayno ++ ) { $ ...
Get the list of days with the matching date array .
28,361
protected function get_month_data ( ) { $ date = $ this -> related [ 'type' ] -> timestamp_to_date_array ( $ this -> calendar -> time ) ; $ monthtime = $ this -> related [ 'type' ] -> convert_to_gregorian ( $ date [ 'year' ] , $ date [ 'month' ] , 1 ) ; return make_timestamp ( $ monthtime [ 'year' ] , $ monthtime [ 'mo...
Get the current month timestamp .
28,362
protected function get_previous_month_data ( ) { $ type = $ this -> related [ 'type' ] ; $ date = $ type -> timestamp_to_date_array ( $ this -> calendar -> time ) ; list ( $ date [ 'mon' ] , $ date [ 'year' ] ) = $ type -> get_prev_month ( $ date [ 'year' ] , $ date [ 'mon' ] ) ; $ time = $ type -> convert_to_timestamp...
Get the previous month timestamp .
28,363
protected function get_next_month_data ( ) { $ type = $ this -> related [ 'type' ] ; $ date = $ type -> timestamp_to_date_array ( $ this -> calendar -> time ) ; list ( $ date [ 'mon' ] , $ date [ 'year' ] ) = $ type -> get_next_month ( $ date [ 'year' ] , $ date [ 'mon' ] ) ; $ time = $ type -> convert_to_timestamp ( $...
Get the next month timestamp .
28,364
protected function get_default_add_context ( ) { if ( calendar_user_can_add_event ( $ this -> calendar -> course ) ) { return \ context_course :: instance ( $ this -> calendar -> course -> id ) ; } return null ; }
Get the default context for use when adding a new event .
28,365
protected function timefield_pagination_from ( $ field , $ timefrom , $ lastseentime = null , $ lastseenid = null , $ withduration = true ) { $ where = '' ; $ params = [ ] ; if ( $ lastseentime && $ lastseentime >= $ timefrom ) { $ where = '((timesort = :timefrom1 AND e.id > :timefromid) OR timesort > :timefrom2)' ; if...
Generates SQL subquery and parameters for from pagination .
28,366
protected function timefield_pagination_to ( $ field , $ timeto , $ lastseentime = null , $ lastseenid = null ) { $ where = [ ] ; $ params = [ ] ; if ( $ lastseentime && $ lastseentime > $ timeto ) { return false ; } else if ( $ lastseentime && $ lastseentime == $ timeto ) { $ where [ ] = '((timesort = :timeto1 AND e.i...
Generates SQL subquery and parameters for to pagination .
28,367
protected function get_from_db ( $ userid , $ whereconditions , $ whereparams , $ ordersql , $ offset , $ limitnum ) { return array_values ( $ this -> retrievalstrategy -> get_raw_events ( [ $ userid ] , null , null , null , $ whereconditions , $ whereparams , $ ordersql , $ offset , $ limitnum ) ) ; }
Fetches records from DB .
28,368
public static function store ( \ core \ event \ base $ event ) { $ logmanager = get_log_manager ( ) ; if ( get_class ( $ logmanager ) === 'tool_log\log\manager' ) { $ logmanager -> process ( $ event ) ; } }
Redirect all events to this log manager but only if this log manager is actually used .
28,369
public function process_question ( array $ data , array $ raw ) { $ this -> write_xml ( 'essay' , array ( 'id' => $ this -> converter -> get_nextid ( ) , 'responseformat' => 'editor' , 'responserequired' => 1 , 'responsefieldlines' => 15 , 'attachments' => 0 , 'attachmentsrequired' => 0 , 'graderinfo' => '' , 'graderin...
Appends the essay specific information to the question
28,370
public function pop ( ) { $ etime = microtime ( true ) ; if ( ! ( $ this -> _idx > 0 ) ) { throw new Exception ( 'No timers have been started' ) ; } return $ etime - $ this -> _start [ -- $ this -> _idx ] ; }
Pop the latest timer start and return the difference with the current time .
28,371
public static function export_user_data ( approved_contextlist $ contextlist ) { global $ DB ; $ contexts = $ contextlist -> get_contexts ( ) ; if ( count ( $ contexts ) == 0 ) { return ; } $ context = reset ( $ contexts ) ; if ( $ context -> contextlevel !== CONTEXT_USER ) { return ; } $ userid = $ context -> instance...
Export all user data for the specified user using the User context level .
28,372
public function get_all_samples ( \ core_analytics \ analysable $ site ) { global $ DB ; $ select = 'id != 1' ; $ courses = get_courses ( 'all' , 'c.sortorder ASC' ) ; unset ( $ courses [ SITEID ] ) ; $ courseids = array_keys ( $ courses ) ; $ sampleids = array_combine ( $ courseids , $ courseids ) ; $ courses = array_...
Returns all site courses .
28,373
public function get_samples ( $ sampleids ) { global $ DB ; list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( $ sampleids , SQL_PARAMS_NAMED ) ; $ courses = $ DB -> get_records_select ( 'course' , "id $sql" , $ params ) ; $ courseids = array_keys ( $ courses ) ; $ sampleids = array_combine ( $ courseids , $ coursei...
Return all complete samples data from sample ids .
28,374
protected function restoreExtractedData ( $ content ) { $ content = parent :: restoreExtractedData ( $ content ) ; $ content = strtr ( $ content , $ this -> nestedExtracted ) ; return $ content ; }
In addition to the regular restore routine we also need to restore a few more things that have been extracted as part of the regex extraction ...
28,375
protected function getOperatorsForRegex ( array $ operators , $ delimiter = '/' ) { $ delimiters = array_fill ( 0 , count ( $ operators ) , $ delimiter ) ; $ escaped = array_map ( 'preg_quote' , $ operators , $ delimiters ) ; $ operators = array_combine ( $ operators , $ escaped ) ; unset ( $ operators [ '+' ] , $ oper...
We ll strip whitespace around certain operators with regular expressions . This will prepare the given array by escaping all characters .
28,376
protected function getKeywordsForRegex ( array $ keywords , $ delimiter = '/' ) { $ delimiter = array_fill ( 0 , count ( $ keywords ) , $ delimiter ) ; $ escaped = array_map ( 'preg_quote' , $ keywords , $ delimiter ) ; array_walk ( $ keywords , function ( $ value ) { return '\b' . $ value . '\b' ; } ) ; $ keywords = a...
We ll strip whitespace around certain keywords with regular expressions . This will prepare the given array by escaping all characters .
28,377
protected function shortenBools ( $ content ) { $ callback = function ( $ match ) { if ( trim ( $ match [ 1 ] ) === '.' ) { return $ match [ 0 ] ; } return $ match [ 1 ] . ( $ match [ 2 ] === 'true' ? '!0' : '!1' ) ; } ; $ content = preg_replace_callback ( '/(^|.\s*)\b(true|false)\b(?!:)/' , $ callback , $ content ) ; ...
Replaces true & false by !0 and !1 .
28,378
public function set_attributes ( $ type , $ precision = null , $ unsigned = null , $ notnull = null , $ sequence = null , $ default = null , $ previous = null ) { $ this -> type = $ type ; $ precisionarr = explode ( ',' , $ precision ) ; if ( isset ( $ precisionarr [ 0 ] ) ) { $ this -> length = trim ( $ precisionarr [...
Set all the attributes of one xmldb_field
28,379
public function setDefault ( $ default ) { if ( $ this -> type == XMLDB_TYPE_CHAR && $ this -> notnull && $ default === '' ) { $ this -> errormsg = 'XMLDB has detected one CHAR NOT NULL column (' . $ this -> name . ") with '' (empty string) as DEFAULT value. This type of columns must have one meaningful DEFAULT declare...
Set the field default
28,380
public function getXMLDBFieldType ( $ type ) { $ result = XMLDB_TYPE_INCORRECT ; switch ( strtolower ( $ type ) ) { case 'int' : $ result = XMLDB_TYPE_INTEGER ; break ; case 'number' : $ result = XMLDB_TYPE_NUMBER ; break ; case 'float' : $ result = XMLDB_TYPE_FLOAT ; break ; case 'char' : $ result = XMLDB_TYPE_CHAR ; ...
This function returns the correct XMLDB_TYPE_XXX value for the string passed as argument
28,381
public function getXMLDBTypeName ( $ type ) { $ result = "" ; switch ( strtolower ( $ type ) ) { case XMLDB_TYPE_INTEGER : $ result = 'int' ; break ; case XMLDB_TYPE_NUMBER : $ result = 'number' ; break ; case XMLDB_TYPE_FLOAT : $ result = 'float' ; break ; case XMLDB_TYPE_CHAR : $ result = 'char' ; break ; case XMLDB_...
This function returns the correct name value for the XMLDB_TYPE_XXX passed as argument
28,382
public function calculateHash ( $ recursive = false ) { if ( ! $ this -> loaded ) { $ this -> hash = null ; } else { $ defaulthash = is_null ( $ this -> default ) ? '' : sha1 ( $ this -> default ) ; $ key = $ this -> name . $ this -> type . $ this -> length . $ this -> notnull . $ this -> sequence . $ this -> decimals ...
This function calculate and set the hash of one xmldb_field
28,383
public function xmlOutput ( ) { $ o = '' ; $ o .= ' <FIELD NAME="' . $ this -> name . '"' ; $ o .= ' TYPE="' . $ this -> getXMLDBTypeName ( $ this -> type ) . '"' ; if ( $ this -> length ) { $ o .= ' LENGTH="' . $ this -> length . '"' ; } if ( $ this -> notnull ) { $ notnull = 'true' ; } else { $ notnull = 'fals...
This function will output the XML text for one field
28,384
public function setFromADOField ( $ adofield ) { switch ( strtolower ( $ adofield -> type ) ) { case 'int' : case 'tinyint' : case 'smallint' : case 'bigint' : case 'integer' : $ this -> type = XMLDB_TYPE_INTEGER ; break ; case 'number' : case 'decimal' : case 'dec' : case 'numeric' : $ this -> type = XMLDB_TYPE_NUMBER...
This function will set all the attributes of the xmldb_field object based on information passed in one ADOField
28,385
public function getPHP ( $ includeprevious = true ) { $ result = '' ; switch ( $ this -> getType ( ) ) { case XMLDB_TYPE_INTEGER : $ result .= 'XMLDB_TYPE_INTEGER' . ', ' ; break ; case XMLDB_TYPE_NUMBER : $ result .= 'XMLDB_TYPE_NUMBER' . ', ' ; break ; case XMLDB_TYPE_FLOAT : $ result .= 'XMLDB_TYPE_FLOAT' . ', ' ; b...
Returns the PHP code needed to define one xmldb_field
28,386
public static function register ( $ baseDir = null ) { $ key = $ baseDir ? $ baseDir : 0 ; if ( ! isset ( self :: $ instances [ $ key ] ) ) { self :: $ instances [ $ key ] = new self ( $ baseDir ) ; } $ loader = self :: $ instances [ $ key ] ; spl_autoload_register ( array ( $ loader , 'autoload' ) ) ; return $ loader ...
Register a new instance as an SPL autoloader .
28,387
public function matchDomain ( $ domain ) { $ host = $ this -> host ; if ( is_null ( $ host ) ) { return false ; } $ match_domain = explode ( '.' , $ domain ) ; $ match_host = array_slice ( explode ( '.' , $ host ) , count ( $ match_domain ) * - 1 ) ; return ( strcasecmp ( $ domain , implode ( '.' , $ match_host ) ) ===...
Do a case - insensitive match on the address for a given domain . Matches as many parts of the subdomain in the address as is given in the input .
28,388
public function loadToolProxy ( $ toolProxy ) { $ now = time ( ) ; $ toolProxy -> created = $ now ; $ toolProxy -> updated = $ now ; return true ; }
Load tool proxy object .
28,389
protected static function getConsumerKey ( $ key ) { $ len = strlen ( $ key ) ; if ( $ len > 255 ) { $ key = 'sha512:' . hash ( 'sha512' , $ key ) ; } return $ key ; }
Return a hash of a consumer key for values longer than 255 characters .
28,390
public function refreshToken ( $ refreshToken ) { $ this -> refreshTokenRequest ( array ( 'client_id' => $ this -> client -> getClassConfig ( $ this , 'client_id' ) , 'client_secret' => $ this -> client -> getClassConfig ( $ this , 'client_secret' ) , 'refresh_token' => $ refreshToken , 'grant_type' => 'refresh_token' ...
Fetches a fresh access token with the given refresh token .
28,391
private function maybeAddParam ( $ params , $ name ) { $ param = $ this -> client -> getClassConfig ( $ this , $ name ) ; if ( $ param != '' ) { $ params [ $ name ] = $ param ; } return $ params ; }
Add a parameter to the auth params if not empty string .
28,392
protected function set_url ( $ url ) { if ( $ url instanceof \ moodle_url ) { $ url = $ url -> out ( false ) ; } $ this -> raw_set ( 'url' , $ url ) ; }
Convenience method handling moodle_urls .
28,393
protected function validate_descidentifier ( $ value ) { if ( ! $ this -> get ( 'id' ) && ! get_string_manager ( ) -> string_exists ( $ value , $ this -> get ( 'desccomponent' ) ) ) { return new lang_string ( 'invalidevidencedesc' , 'core_competency' ) ; } return true ; }
Validate the description identifier .
28,394
public static function get_records_for_usercompetency ( $ usercompetencyid , \ context $ context , $ sort = '' , $ order = 'ASC' , $ skip = 0 , $ limit = 0 ) { global $ DB ; $ params = array ( 'usercompid' => $ usercompetencyid , 'path' => $ context -> path . '/%' , 'contextid' => $ context -> id ) ; if ( ! empty ( $ s...
Load a list of records in a context for a user competency .
28,395
public static function get_name ( ) { $ parts = explode ( '\\' , get_called_class ( ) ) ; if ( count ( $ parts ) !== 3 ) { return get_string ( 'unknownevent' , 'error' ) ; } return $ parts [ 0 ] . ': ' . str_replace ( '_' , ' ' , $ parts [ 2 ] ) ; }
Returns localised general event name .
28,396
public static final function restore ( array $ data , array $ logextra ) { $ classname = $ data [ 'eventname' ] ; $ component = $ data [ 'component' ] ; $ action = $ data [ 'action' ] ; $ target = $ data [ 'target' ] ; if ( $ classname !== "\\{$component}\\event\\{$target}_{$action}" ) { return false ; } if ( ! class_e...
Restore event from existing historic data .
28,397
protected static final function restore_unknown ( array $ data , array $ logextra ) { $ classname = '\core\event\unknown_logged' ; $ event = new $ classname ( ) ; $ event -> restored = true ; $ event -> triggered = true ; $ event -> dispatched = true ; $ event -> data = $ data ; $ event -> logextra = $ logextra ; retur...
Restore unknown event .
28,398
public static final function get_static_info ( ) { $ event = new static ( ) ; $ event -> init ( ) ; return array ( 'eventname' => $ event -> data [ 'eventname' ] , 'component' => $ event -> data [ 'component' ] , 'target' => $ event -> data [ 'target' ] , 'action' => $ event -> data [ 'action' ] , 'crud' => $ event -> ...
Get static information about an event . This is used in reports and is not for general use .
28,399
public function get_context ( ) { if ( isset ( $ this -> context ) ) { return $ this -> context ; } $ this -> context = \ context :: instance_by_id ( $ this -> data [ 'contextid' ] , IGNORE_MISSING ) ; return $ this -> context ; }
Returns event context .