idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
28,600
protected function print_badge_related ( badge $ badge ) { $ output = '' ; $ relatedbadges = $ badge -> get_related_badges ( ) ; $ output .= $ this -> heading ( get_string ( 'relatedbages' , 'badges' ) , 3 ) ; if ( ! empty ( $ relatedbadges ) ) { $ items = array ( ) ; foreach ( $ relatedbadges as $ related ) { $ relate...
Print list badges related .
28,601
protected function print_badge_alignments ( badge $ badge ) { $ output = '' ; $ output .= $ this -> heading ( get_string ( 'alignment' , 'badges' ) , 3 ) ; $ alignments = $ badge -> get_alignments ( ) ; if ( ! empty ( $ alignments ) ) { $ items = array ( ) ; foreach ( $ alignments as $ alignment ) { $ urlaligment = new...
Print list badge alignments .
28,602
protected function render_badge_related ( badge_related $ related ) { $ currentbadge = new badge ( $ related -> currentbadgeid ) ; $ languages = get_string_manager ( ) -> get_list_of_languages ( ) ; $ paging = new paging_bar ( $ related -> totalcount , $ related -> page , $ related -> perpage , $ this -> page -> url , ...
Renders a table for related badges .
28,603
protected function render_badge_alignments ( badge_alignments $ alignments ) { $ currentbadge = new badge ( $ alignments -> currentbadgeid ) ; $ paging = new paging_bar ( $ alignments -> totalcount , $ alignments -> page , $ alignments -> perpage , $ this -> page -> url , 'page' ) ; $ htmlpagingbar = $ this -> render (...
Renders a table with alignment .
28,604
public function get_quickgrading_html ( $ userid , $ grade ) { $ commenttext = '' ; if ( $ grade ) { $ feedbackcomments = $ this -> get_feedback_comments ( $ grade -> id ) ; if ( $ feedbackcomments ) { $ commenttext = $ feedbackcomments -> commenttext ; } } $ pluginname = get_string ( 'pluginname' , 'assignfeedback_com...
Get quickgrading form elements as html .
28,605
public function is_quickgrading_modified ( $ userid , $ grade ) { $ commenttext = '' ; if ( $ grade ) { $ feedbackcomments = $ this -> get_feedback_comments ( $ grade -> id ) ; if ( $ feedbackcomments ) { $ commenttext = $ feedbackcomments -> commenttext ; } } $ newvalue = optional_param ( 'quickgrade_comments_' . $ us...
Has the plugin quickgrading form element been modified in the current form submission?
28,606
public function is_feedback_modified ( stdClass $ grade , stdClass $ data ) { $ commenttext = '' ; if ( $ grade ) { $ feedbackcomments = $ this -> get_feedback_comments ( $ grade -> id ) ; if ( $ feedbackcomments ) { $ commenttext = $ feedbackcomments -> commenttext ; } } $ formtext = $ data -> assignfeedbackcomments_e...
Has the comment feedback been modified?
28,607
public function save_quickgrading_changes ( $ userid , $ grade ) { global $ DB ; $ feedbackcomment = $ this -> get_feedback_comments ( $ grade -> id ) ; $ quickgradecomments = optional_param ( 'quickgrade_comments_' . $ userid , null , PARAM_RAW ) ; if ( ! $ quickgradecomments && $ quickgradecomments !== '' ) { return ...
Save quickgrading changes .
28,608
public function get_settings ( MoodleQuickForm $ mform ) { $ default = $ this -> get_config ( 'commentinline' ) ; if ( $ default === false ) { $ default = get_config ( 'assignfeedback_comments' , 'inline' ) ; } $ mform -> addElement ( 'selectyesno' , 'assignfeedback_comments_commentinline' , get_string ( 'commentinline...
Get the default setting for feedback comments plugin
28,609
protected function convert_submission_text_to_feedback ( $ submission , $ data , $ grade ) { global $ DB ; $ format = false ; $ text = '' ; foreach ( $ this -> assignment -> get_submission_plugins ( ) as $ plugin ) { $ fields = $ plugin -> get_editor_fields ( ) ; if ( $ plugin -> is_enabled ( ) && $ plugin -> is_visibl...
Convert the text from any submission plugin that has an editor field to a format suitable for inserting in the feedback text field .
28,610
public function get_form_elements_for_user ( $ grade , MoodleQuickForm $ mform , stdClass $ data , $ userid ) { $ commentinlinenabled = $ this -> get_config ( 'commentinline' ) ; $ submission = $ this -> assignment -> get_user_submission ( $ userid , false ) ; $ feedbackcomments = false ; if ( $ grade ) { $ feedbackcom...
Get form elements for the grading page
28,611
public function save ( stdClass $ grade , stdClass $ data ) { global $ DB ; $ data = file_postupdate_standard_editor ( $ data , 'assignfeedbackcomments' , $ this -> get_editor_options ( ) , $ this -> assignment -> get_context ( ) , ASSIGNFEEDBACK_COMMENTS_COMPONENT , ASSIGNFEEDBACK_COMMENTS_FILEAREA , $ grade -> id ) ;...
Saving the comment content into database .
28,612
public function upgrade ( context $ oldcontext , stdClass $ oldassignment , stdClass $ oldsubmission , stdClass $ grade , & $ log ) { global $ DB ; $ feedbackcomments = new stdClass ( ) ; $ feedbackcomments -> commenttext = $ oldsubmission -> submissioncomment ; $ feedbackcomments -> commentformat = FORMAT_HTML ; $ fee...
Upgrade the feedback from the old assignment to the new one
28,613
public function format_for_gradebook ( stdClass $ grade ) { $ feedbackcomments = $ this -> get_feedback_comments ( $ grade -> id ) ; if ( $ feedbackcomments ) { return $ feedbackcomments -> commentformat ; } return FORMAT_MOODLE ; }
If this plugin adds to the gradebook comments field it must specify the format of the text of the comment
28,614
public function text_for_gradebook ( stdClass $ grade ) { $ feedbackcomments = $ this -> get_feedback_comments ( $ grade -> id ) ; if ( $ feedbackcomments ) { return $ feedbackcomments -> commenttext ; } return '' ; }
If this plugin adds to the gradebook comments field it must format the text of the comment
28,615
public function files_for_gradebook ( stdClass $ grade ) : array { return [ 'contextid' => $ this -> assignment -> get_context ( ) -> id , 'component' => ASSIGNFEEDBACK_COMMENTS_COMPONENT , 'filearea' => ASSIGNFEEDBACK_COMMENTS_FILEAREA , 'itemid' => $ grade -> id ] ; }
Return any files this plugin wishes to save to the gradebook .
28,616
public function get_external_parameters ( ) { $ editorparams = array ( 'text' => new external_value ( PARAM_RAW , 'The text for this feedback.' ) , 'format' => new external_value ( PARAM_INT , 'The format for this feedback' ) ) ; $ editorstructure = new external_single_structure ( $ editorparams , 'Editor structure' , ...
Return a description of external params suitable for uploading an feedback comment from a webservice .
28,617
private function get_default_tree_structure ( ) { $ frontpage = \ context_course :: instance ( SITEID ) ; $ categorybranches = $ this -> get_all_category_branches ( ) ; $ elements = [ 'text' => get_string ( 'contextlevelname' . CONTEXT_SYSTEM , 'tool_dataprivacy' ) , 'contextlevel' => CONTEXT_SYSTEM , 'branches' => [ [...
Returns the tree default structure .
28,618
private function get_all_category_branches ( ) { $ categories = data_registry :: get_site_categories ( ) ; $ categoriesbranch = [ ] ; while ( count ( $ categories ) > 0 ) { foreach ( $ categories as $ key => $ category ) { $ context = \ context_coursecat :: instance ( $ category -> id ) ; $ newnode = [ 'text' => shorte...
Returns the hierarchy of system course categories .
28,619
public static function get_courses_branch ( \ context $ catcontext ) { if ( $ catcontext -> contextlevel !== CONTEXT_COURSECAT ) { throw new \ coding_exception ( 'A course category context should be provided' ) ; } $ coursecat = \ core_course_category :: get ( $ catcontext -> instanceid ) ; $ courses = $ coursecat -> g...
Gets the courses branch for the provided category .
28,620
public static function get_modules_branch ( \ context $ coursecontext ) { if ( $ coursecontext -> contextlevel !== CONTEXT_COURSE ) { throw new \ coding_exception ( 'A course context should be provided' ) ; } $ branches = [ ] ; $ modinfo = get_fast_modinfo ( $ coursecontext -> instanceid ) ; foreach ( $ modinfo -> get_...
Gets the modules branch for the provided course .
28,621
public static function get_blocks_branch ( \ context $ coursecontext ) { global $ DB ; if ( $ coursecontext -> contextlevel !== CONTEXT_COURSE ) { throw new \ coding_exception ( 'A course context should be provided' ) ; } $ branches = [ ] ; $ children = $ coursecontext -> get_child_contexts ( ) ; foreach ( $ children a...
Gets the blocks branch for the provided course .
28,622
private function add_to_parent_category_branch ( $ category , $ newnode , & $ categoriesbranch ) { foreach ( $ categoriesbranch as $ key => $ branch ) { if ( ! empty ( $ branch [ 'categoryid' ] ) && $ branch [ 'categoryid' ] == $ category -> parent ) { if ( ! isset ( $ categoriesbranch [ $ key ] [ 'branches' ] ) ) { $ ...
Adds the provided category to the categories branch .
28,623
private static function complete ( $ node , $ currentcontextlevel = false , $ currentcontextid = false ) { if ( ! isset ( $ node [ 'active' ] ) ) { if ( $ currentcontextlevel && ! empty ( $ node [ 'contextlevel' ] ) && $ currentcontextlevel == $ node [ 'contextlevel' ] && empty ( $ currentcontextid ) ) { $ node [ 'acti...
Completes tree nodes with default values .
28,624
public static function purpose_options ( $ purposes , $ includenotset = true , $ includeinherit = true ) { $ options = self :: base_options ( $ includenotset , $ includeinherit ) ; foreach ( $ purposes as $ purpose ) { $ options [ $ purpose -> get ( 'id' ) ] = $ purpose -> get ( 'name' ) ; } return $ options ; }
From a list of purpose persistents to a list of id = > name purposes .
28,625
public static function category_options ( $ categories , $ includenotset = true , $ includeinherit = true ) { $ options = self :: base_options ( $ includenotset , $ includeinherit ) ; foreach ( $ categories as $ category ) { $ options [ $ category -> get ( 'id' ) ] = $ category -> get ( 'name' ) ; } return $ options ; ...
From a list of category persistents to a list of id = > name categories .
28,626
private static function base_options ( $ includenotset = true , $ includeinherit = true ) { $ options = [ ] ; if ( $ includenotset ) { $ options [ \ tool_dataprivacy \ context_instance :: NOTSET ] = get_string ( 'notset' , 'tool_dataprivacy' ) ; } if ( $ includeinherit ) { $ options [ \ tool_dataprivacy \ context_insta...
Base not set and inherit options .
28,627
public static function reset_database ( ) { global $ DB ; if ( ! is_null ( self :: $ lastdbwrites ) and self :: $ lastdbwrites == $ DB -> perf_get_writes ( ) ) { return false ; } if ( ! parent :: reset_database ( ) ) { return false ; } self :: $ lastdbwrites = $ DB -> perf_get_writes ( ) ; return true ; }
Reset all database tables to default values .
28,628
public static function bootstrap_init ( ) { global $ CFG , $ SITE , $ DB , $ FULLME ; self :: $ globals [ '_SERVER' ] = $ _SERVER ; self :: $ globals [ 'CFG' ] = clone ( $ CFG ) ; self :: $ globals [ 'SITE' ] = clone ( $ SITE ) ; self :: $ globals [ 'DB' ] = $ DB ; self :: $ globals [ 'FULLME' ] = $ FULLME ; self :: re...
Called during bootstrap only!
28,629
public static function get_global_backup ( $ name ) { if ( $ name === 'DB' ) { return self :: $ globals [ 'DB' ] ; } if ( isset ( self :: $ globals [ $ name ] ) ) { if ( is_object ( self :: $ globals [ $ name ] ) ) { $ return = clone ( self :: $ globals [ $ name ] ) ; return $ return ; } else { return self :: $ globals...
Returns original state of global variable .
28,630
public static function drop_site ( $ displayprogress = false ) { global $ DB , $ CFG ; if ( ! self :: is_test_site ( ) ) { phpunit_bootstrap_error ( PHPUNIT_EXITCODE_CONFIGERROR , 'Can not drop non-test site!!' ) ; } if ( $ displayprogress ) { echo "Purging dataroot:\n" ; } self :: reset_dataroot ( ) ; testing_initdata...
Drop all test site data .
28,631
public static function install_site ( ) { global $ DB , $ CFG ; if ( ! self :: is_test_site ( ) ) { phpunit_bootstrap_error ( PHPUNIT_EXITCODE_CONFIGERROR , 'Can not install on non-test site!!' ) ; } if ( $ DB -> get_tables ( ) ) { list ( $ errorcode , $ message ) = self :: testing_ready_problem ( ) ; if ( $ errorcode ...
Perform a fresh test site installation
28,632
public static function display_debugging_messages ( $ return = false ) { if ( empty ( self :: $ debuggings ) ) { return false ; } $ debugstring = '' ; foreach ( self :: $ debuggings as $ debug ) { $ debugstring .= 'Debugging: ' . $ debug -> message . "\n" . trim ( $ debug -> from ) . "\n" ; } if ( $ return ) { return $...
Prints out any debug messages accumulated during test execution .
28,633
public static function start_message_redirection ( ) { if ( self :: $ messagesink ) { self :: stop_message_redirection ( ) ; } self :: $ messagesink = new phpunit_message_sink ( ) ; return self :: $ messagesink ; }
Start message redirection .
28,634
public static function start_phpmailer_redirection ( ) { if ( self :: $ phpmailersink ) { self :: $ phpmailersink -> clear ( ) ; } else { self :: $ phpmailersink = new phpunit_phpmailer_sink ( ) ; } return self :: $ phpmailersink ; }
Start phpmailer redirection .
28,635
public static function start_event_redirection ( ) { if ( self :: $ eventsink ) { self :: stop_event_redirection ( ) ; } self :: $ eventsink = new phpunit_event_sink ( ) ; return self :: $ eventsink ; }
Start event redirection .
28,636
public static function event_triggered ( \ core \ event \ base $ event ) { if ( self :: $ eventsink ) { self :: $ eventsink -> add_event ( $ event ) ; } }
To be called from \ core \ event \ base only!
28,637
public static function run_all_adhoc_tasks ( ) { $ now = time ( ) ; while ( ( $ task = \ core \ task \ manager :: get_next_adhoc_task ( $ now ) ) !== null ) { try { $ task -> execute ( ) ; \ core \ task \ manager :: adhoc_task_complete ( $ task ) ; } catch ( Exception $ e ) { \ core \ task \ manager :: adhoc_task_faile...
Executes all adhoc tasks in the queue . Useful for testing asynchronous behaviour .
28,638
protected static function get_filter_config ( array $ whitelists , array $ excludelists ) : string { $ filters = '' ; if ( ! empty ( $ whitelists ) ) { $ filters .= self :: pad ( "<whitelist>" , 2 ) ; foreach ( $ whitelists as $ line ) { $ filters .= self :: pad ( $ line , 3 ) ; } if ( ! empty ( $ excludelists ) ) { $ ...
Get the filter config for the supplied whitelist and excludelist configuration .
28,639
protected static function get_coverage_info ( string $ fulldir ) : ? phpunit_coverage_info { $ coverageconfig = "{$fulldir}/tests/coverage.php" ; if ( file_exists ( $ coverageconfig ) ) { $ coverageinfo = require ( $ coverageconfig ) ; if ( ! $ coverageinfo instanceof phpunit_coverage_info ) { throw new \ coding_except...
Get the phpunit_coverage_info for the specified plugin or subsystem directory .
28,640
public function charset ( $ charset , $ convert = true ) { $ oldcharset = $ this -> _charset ; $ this -> _charset = Horde_String :: upper ( $ charset ) ; if ( ! $ convert || ( $ oldcharset == $ this -> _charset ) ) { return ; } foreach ( array ( 'and' , 'or' ) as $ item ) { if ( isset ( $ this -> _search [ $ item ] ) )...
Sets the charset of the search text .
28,641
protected function _addFuzzy ( $ add , & $ temp ) { if ( $ add ) { if ( ! $ temp [ 'exts' ] -> query ( 'SEARCH' , 'FUZZY' ) ) { throw new Horde_Imap_Client_Exception_NoSupportExtension ( 'SEARCH=FUZZY' ) ; } $ temp [ 'cmds' ] -> add ( 'FUZZY' ) ; $ temp [ 'exts_used' ] [ ] = 'SEARCH=FUZZY' ; } }
Adds fuzzy modifier to search keys .
28,642
public function headerText ( $ header , $ text , $ not = false , array $ opts = array ( ) ) { if ( ! isset ( $ this -> _search [ 'header' ] ) ) { $ this -> _search [ 'header' ] = array ( ) ; } $ this -> _search [ 'header' ] [ ] = array_filter ( array ( 'fuzzy' => ! empty ( $ opts [ 'fuzzy' ] ) , 'header' => Horde_Strin...
Search for text in the header of a message .
28,643
public function text ( $ text , $ bodyonly = true , $ not = false , array $ opts = array ( ) ) { if ( ! isset ( $ this -> _search [ 'text' ] ) ) { $ this -> _search [ 'text' ] = array ( ) ; } $ this -> _search [ 'text' ] [ ] = array_filter ( array ( 'fuzzy' => ! empty ( $ opts [ 'fuzzy' ] ) , 'not' => $ not , 'text' =>...
Search for text in either the entire message or just the body .
28,644
public function ids ( Horde_Imap_Client_Ids $ ids , $ not = false , array $ opts = array ( ) ) { $ this -> _search [ 'ids' ] = array_filter ( array ( 'fuzzy' => ! empty ( $ opts [ 'fuzzy' ] ) , 'ids' => $ ids , 'not' => $ not ) ) ; }
Search for messages within a given UID range . Only one message range can be specified per query .
28,645
public function dateSearch ( $ date , $ range , $ header = true , $ not = false , array $ opts = array ( ) ) { if ( ! isset ( $ this -> _search [ 'date' ] ) ) { $ this -> _search [ 'date' ] = array ( ) ; } $ ob = new Horde_Imap_Client_Data_Format_Date ( $ date ) ; $ this -> _search [ 'date' ] [ ] = array_filter ( array...
Search for messages within a date range .
28,646
public static function start_logging ( task_base $ task ) { global $ DB ; if ( ! self :: should_log ( ) ) { return ; } if ( ! self :: $ tasklogregistered ) { \ core_shutdown_manager :: register_function ( function ( ) { \ core \ task \ logmanager :: finalise_log ( true ) ; } ) ; get_request_storage_directory ( true , t...
Create a new task logger for the specified task and prepare for logging .
28,647
protected static function should_log ( ) : bool { global $ CFG ; if ( isset ( $ CFG -> task_logmode ) && empty ( $ CFG -> task_logmode ) ) { return false ; } $ loggerclass = self :: get_logger_classname ( ) ; if ( empty ( $ loggerclass ) ) { return false ; } return $ loggerclass :: is_configured ( ) ; }
Whether logging is possible and should be happening .
28,648
public static function uses_standard_settings ( ) : bool { $ classname = self :: get_logger_classname ( ) ; if ( ! class_exists ( $ classname ) ) { return false ; } if ( is_a ( $ classname , database_logger :: class , true ) ) { return true ; } return false ; }
Whether to use the standard settings form .
28,649
public static function get_url_for_task_class ( string $ classname ) : \ moodle_url { $ loggerclass = self :: get_logger_classname ( ) ; return $ loggerclass :: get_url_for_task_class ( $ classname ) ; }
Get any URL available for viewing relevant task log reports .
28,650
protected static function is_current_output_buffer ( ) : bool { if ( empty ( self :: $ taskloginfo ) ) { return false ; } if ( $ ob = ob_get_status ( ) ) { return 'core\\task\\logmanager::add_line' == $ ob [ 'name' ] ; } return false ; }
Whether we are the current log collector .
28,651
protected static function is_capturing ( ) : bool { $ buffers = ob_get_status ( true ) ; foreach ( $ buffers as $ ob ) { if ( 'core\\task\\logmanager::add_line' == $ ob [ 'name' ] ) { return true ; } } return false ; }
Whether we are capturing at all .
28,652
public static function finalise_log ( bool $ failed = false ) { global $ CFG , $ DB , $ PERF ; if ( ! self :: should_log ( ) ) { return ; } if ( ! self :: is_capturing ( ) ) { return ; } $ buffers = ob_get_status ( true ) ; foreach ( array_reverse ( $ buffers ) as $ ob ) { if ( null !== self :: $ oblevel ) { if ( $ ob ...
Finish writing for the current task .
28,653
public static function add_line ( string $ log ) : string { if ( empty ( self :: $ taskloginfo ) ) { return $ log ; } if ( empty ( self :: $ fh ) ) { return $ log ; } if ( self :: is_current_output_buffer ( ) ) { fwrite ( self :: $ fh , $ log ) ; } return $ log ; }
Add a log record to the task log .
28,654
public function generateChildDef ( & $ def , $ module ) { if ( ! empty ( $ def -> child ) ) { return ; } $ content_model = $ def -> content_model ; if ( is_string ( $ content_model ) ) { $ def -> content_model = preg_replace_callback ( '/\b(' . implode ( '|' , $ this -> keys ) . ')\b/' , array ( $ this , 'generateChild...
Accepts a definition ; generates and assigns a ChildDef for it
28,655
private function createUpdateOptions ( ) { $ updateOptions = [ 'multi' => $ this -> options [ 'multi' ] , 'upsert' => $ this -> options [ 'upsert' ] , ] ; if ( isset ( $ this -> options [ 'arrayFilters' ] ) ) { $ updateOptions [ 'arrayFilters' ] = $ this -> options [ 'arrayFilters' ] ; } if ( isset ( $ this -> options ...
Create options for the update command .
28,656
public function guess_antelope_row_size ( array $ columns ) { if ( empty ( $ columns ) ) { return 0 ; } $ size = 0 ; $ first = reset ( $ columns ) ; if ( count ( $ columns ) > 1 ) { $ size += 1000 ; } if ( $ first instanceof xmldb_field ) { foreach ( $ columns as $ field ) { switch ( $ field -> getType ( ) ) { case XML...
Calculate proximate row size when using InnoDB tables in Antelope row format .
28,657
protected function set_parent ( $ element ) { parent :: set_parent ( $ element ) ; foreach ( $ this -> get_children ( ) as $ child ) { $ child -> set_condition ( $ child -> get_condition_param ( ) , $ child -> get_condition_value ( ) ) ; } }
Set the parent of the optigroup and at the same time process all the condition params in all the childs
28,658
protected function add_used ( $ element ) { $ newused = array ( ) ; foreach ( $ element -> get_used ( ) as $ used ) { if ( ! in_array ( $ used , $ this -> get_used ( ) ) ) { $ newused [ ] = $ used ; $ this -> set_used ( array_merge ( $ this -> get_used ( ) , array ( $ used ) ) ) ; } else { if ( $ this -> multiple ) { t...
Recalculate all the used elements in the optigroup observing restrictions and passing the new used to outer level
28,659
public static function update_date ( $ courseid , $ timeshift ) { if ( $ criteria = self :: fetch ( array ( 'course' => $ courseid ) ) ) { $ criteria -> timeend = $ criteria -> timeend + $ timeshift ; $ criteria -> update ( ) ; } }
Shift the date when resetting course .
28,660
public function initialize ( ) { $ this -> title = '' ; $ this -> settings = array ( ) ; $ this -> created = null ; $ this -> updated = null ; }
Initialise the context .
28,661
public function save ( ) { $ ok = $ this -> getDataConnector ( ) -> saveContext ( $ this ) ; if ( $ ok ) { $ this -> settingsChanged = false ; } return $ ok ; }
Save the context to the database .
28,662
public function getSetting ( $ name , $ default = '' ) { if ( array_key_exists ( $ name , $ this -> settings ) ) { $ value = $ this -> settings [ $ name ] ; } else { $ value = $ default ; } return $ value ; }
Get a setting value .
28,663
public function getToolSettings ( $ mode = Service \ ToolSettings :: MODE_CURRENT_LEVEL , $ simple = true ) { $ url = $ this -> getSetting ( 'custom_context_setting_url' ) ; $ service = new Service \ ToolSettings ( $ this , $ url , $ simple ) ; $ response = $ service -> get ( $ mode ) ; return $ response ; }
Get Tool Settings .
28,664
public static function create_from_userlist ( userlist $ userlist ) : approved_userlist { $ newlist = new static ( $ userlist -> get_context ( ) , $ userlist -> get_component ( ) , $ userlist -> get_userids ( ) ) ; return $ newlist ; }
Create an approved userlist from a userlist .
28,665
protected function get_all_concepts ( ) { global $ USER ; if ( $ this -> cache === null ) { $ this -> cache = cache :: make_from_params ( cache_store :: MODE_REQUEST , 'filter' , 'glossary' ) ; } $ coursectx = $ this -> context -> get_course_context ( false ) ; if ( ! $ coursectx ) { $ courseid = 0 ; } else { $ coursei...
Get all the concepts for this context .
28,666
public function cache ( $ key , $ value ) { $ this -> log ( Mustache_Logger :: WARNING , 'Template cache disabled, evaluating "{className}" class at runtime' , array ( 'className' => $ key ) ) ; eval ( '?>' . $ value ) ; }
Loads the compiled Mustache Template class without caching .
28,667
public function is_any_expired ( ) : bool { if ( $ this -> is_fully_expired ( ) ) { return true ; } if ( ! empty ( $ this -> get_expired_roles ( ) ) ) { return true ; } if ( $ this -> is_default_expired ( ) ) { return true ; } return false ; }
Whether any part of this context has expired .
28,668
public function get_unprotected_overridden_roles ( ) : array { $ allroles = array_merge ( $ this -> expired , $ this -> unexpired ) ; return array_diff ( $ allroles , $ this -> protectedroles ) ; }
Get a list of all overridden roles which are unprotected .
28,669
public function merge_with_child ( expiry_info $ child ) : expiry_info { if ( $ child -> is_fully_expired ( ) ) { return $ this ; } $ this -> fullyexpired = false ; foreach ( $ this -> expired as $ key => $ roleid ) { if ( ! $ child -> is_role_expired ( $ roleid ) ) { unset ( $ this -> expired [ $ key ] ) ; } } array_m...
Merge this expiry_info object with another belonging to a child context in order to set the safest heritage .
28,670
public function getL ( ) { $ L = [ ] ; for ( $ i = 0 ; $ i < $ this -> m ; ++ $ i ) { for ( $ j = 0 ; $ j < $ this -> n ; ++ $ j ) { if ( $ i > $ j ) { $ L [ $ i ] [ $ j ] = $ this -> LU [ $ i ] [ $ j ] ; } elseif ( $ i == $ j ) { $ L [ $ i ] [ $ j ] = 1.0 ; } else { $ L [ $ i ] [ $ j ] = 0.0 ; } } } return new Matrix ...
Get lower triangular factor .
28,671
public function display_options ( ) { global $ OUTPUT ; $ tags = \ core_tag_tag :: get_tags_by_area_in_contexts ( 'core_question' , 'question' , $ this -> contexts ) ; $ tagoptions = array_map ( function ( $ tag ) { return [ 'id' => $ tag -> id , 'name' => $ tag -> name , 'selected' => in_array ( $ tag -> id , $ this -...
Print HTML to display the list of tags to filter by .
28,672
protected function parse_query ( $ sql ) { $ stmt = oci_parse ( $ this -> oci , $ sql ) ; if ( $ stmt == false ) { throw new dml_connection_exception ( 'Can not parse sql query' ) ; } return $ stmt ; }
Prepare the statement for execution
28,673
protected function tweak_param_names ( $ sql , array $ params ) { if ( empty ( $ params ) ) { return array ( $ sql , $ params ) ; } $ newparams = array ( ) ; $ searcharr = array ( ) ; foreach ( $ params as $ name => $ value ) { if ( strlen ( $ name ) <= 28 ) { $ newname = 'o_' . $ name ; } else { $ newname = 'o_' . sub...
Make sure there are no reserved words in param names ...
28,674
private function get_limit_sql ( $ sql , array $ params = null , $ limitfrom = 0 , $ limitnum = 0 ) { list ( $ limitfrom , $ limitnum ) = $ this -> normalise_limit_from_num ( $ limitfrom , $ limitnum ) ; if ( $ limitfrom and $ limitnum ) { $ sql = "SELECT oracle_o.* FROM (SELECT oracle_i.*, rownum ...
Transforms the sql and params in order to emulate the LIMIT clause available in other DBs
28,675
public function insert_record ( $ table , $ dataobject , $ returnid = true , $ bulk = false ) { $ dataobject = ( array ) $ dataobject ; $ columns = $ this -> get_columns ( $ table ) ; if ( empty ( $ columns ) ) { throw new dml_exception ( 'ddltablenotexist' , $ table ) ; } $ cleaned = array ( ) ; foreach ( $ dataobject...
Insert a record into a table and return the id field if required .
28,676
protected function recursive_concat ( array $ args ) { $ count = count ( $ args ) ; if ( $ count == 1 ) { $ arg = reset ( $ args ) ; return $ arg ; } if ( $ count == 2 ) { $ args [ ] = "' '" ; } $ first = array_shift ( $ args ) ; $ second = array_shift ( $ args ) ; $ third = $ this -> recursive_concat ( $ args ) ; retu...
Mega hacky magic to work around crazy Oracle NULL concats .
28,677
protected function oci_package_installed ( ) { $ sql = "SELECT 1 FROM user_objects WHERE object_type = 'PACKAGE BODY' AND object_name = 'MOODLELIB' AND status = 'VALID'" ; $ this -> query_start ( $ sql , null , SQL_QUERY_AUX ) ; $ stmt = $ this -> parse_qu...
Is the required OCI server package installed?
28,678
protected function attempt_oci_package_install ( ) { $ sqls = file_get_contents ( __DIR__ . '/oci_native_moodle_package.sql' ) ; $ sqls = preg_split ( '/^\/$/sm' , $ sqls ) ; foreach ( $ sqls as $ sql ) { $ sql = trim ( $ sql ) ; if ( $ sql === '' or $ sql === 'SHOW ERRORS' ) { continue ; } $ this -> change_database_st...
Try to add required moodle package into oracle server .
28,679
protected function transform_db_records_to_entities ( array $ records ) { $ preprocessors = $ this -> get_preprocessors ( ) ; $ result = array_map ( function ( $ record ) { return [ 'record' => $ record ] ; } , $ records ) ; $ result = array_reduce ( array_keys ( $ preprocessors ) , function ( $ carry , $ preprocessor ...
Execute the defined preprocessors on the DB record results and then convert them into entities .
28,680
public function get_from_id ( int $ id ) { $ records = $ this -> get_from_ids ( [ $ id ] ) ; return count ( $ records ) ? array_shift ( $ records ) : null ; }
Get the entity for the given id .
28,681
public function get_from_ids ( array $ ids ) { $ alias = $ this -> get_table_alias ( ) ; list ( $ insql , $ params ) = $ this -> get_db ( ) -> get_in_or_equal ( $ ids ) ; $ wheresql = $ alias . '.id ' . $ insql ; $ sql = $ this -> generate_get_records_sql ( $ wheresql ) ; $ records = $ this -> get_db ( ) -> get_records...
Get the list of entities for the given ids .
28,682
public static function classloader ( $ classname ) { self :: init ( ) ; if ( isset ( self :: $ classmap [ $ classname ] ) ) { global $ CFG ; include_once ( self :: $ classmap [ $ classname ] ) ; return ; } if ( isset ( self :: $ classmaprenames [ $ classname ] ) && isset ( self :: $ classmap [ self :: $ classmaprenames...
Class loader for Frankenstyle named classes in standard locations . Frankenstyle namespaces are supported .
28,683
protected static function psr_classloader ( $ class ) { foreach ( self :: $ psr4namespaces as $ prefix => $ path ) { $ file = self :: get_class_file ( $ class , $ prefix , $ path , array ( '\\' ) ) ; if ( ! empty ( $ file ) && file_exists ( $ file ) ) { return $ file ; } } foreach ( self :: $ psr0namespaces as $ prefix...
Return the path to a class from our defined PSR - 0 or PSR - 4 standard namespaces on demand . Only returns paths to files that exist .
28,684
protected static function get_class_file ( $ class , $ prefix , $ path , $ separators ) { global $ CFG ; $ len = strlen ( $ prefix ) ; if ( strncmp ( $ prefix , $ class , $ len ) !== 0 ) { return false ; } $ path = $ CFG -> dirroot . '/' . $ path ; $ relativeclass = substr ( $ class , $ len ) ; $ file = $ path . str_re...
Return the path to the class based on the given namespace prefix and path it corresponds to .
28,685
protected static function is_developer ( ) { global $ CFG ; if ( isset ( $ CFG -> config_php_settings [ 'debug' ] ) ) { $ debug = ( int ) $ CFG -> config_php_settings [ 'debug' ] ; } else { return false ; } if ( $ debug & E_ALL and $ debug & E_STRICT ) { return true ; } return false ; }
Are we in developer debug mode?
28,686
public static function get_cache_content ( ) { if ( ! isset ( self :: $ plugintypes ) ) { self :: fill_all_caches ( ) ; } $ cache = array ( 'subsystems' => self :: $ subsystems , 'plugintypes' => self :: $ plugintypes , 'plugins' => self :: $ plugins , 'parents' => self :: $ parents , 'subplugins' => self :: $ subplugi...
Create cache file content .
28,687
protected static function fill_all_caches ( ) { self :: $ subsystems = self :: fetch_subsystems ( ) ; list ( self :: $ plugintypes , self :: $ parents , self :: $ subplugins ) = self :: fetch_plugintypes ( ) ; self :: $ plugins = array ( ) ; foreach ( self :: $ plugintypes as $ type => $ fulldir ) { self :: $ plugins [...
Fill all caches .
28,688
protected static function fetch_core_version ( ) { global $ CFG ; if ( self :: $ version === null ) { $ version = null ; require ( $ CFG -> dirroot . '/version.php' ) ; self :: $ version = $ version ; } return self :: $ version ; }
Get the core version .
28,689
protected static function fetch_subtypes ( $ ownerdir ) { global $ CFG ; $ types = array ( ) ; if ( file_exists ( "$ownerdir/db/subplugins.php" ) ) { $ subplugins = array ( ) ; include ( "$ownerdir/db/subplugins.php" ) ; foreach ( $ subplugins as $ subtype => $ dir ) { if ( ! preg_match ( '/^[a-z][a-z0-9]*$/' , $ subty...
Returns list of subtypes .
28,690
protected static function fetch_plugins ( $ plugintype , $ fulldir ) { global $ CFG ; $ fulldirs = ( array ) $ fulldir ; if ( $ plugintype === 'theme' ) { if ( realpath ( $ fulldir ) !== realpath ( $ CFG -> dirroot . '/theme' ) ) { array_unshift ( $ fulldirs , $ CFG -> dirroot . '/theme' ) ; } } $ result = array ( ) ; ...
Returns list of plugins of given type in given directory .
28,691
protected static function fill_classmap_cache ( ) { global $ CFG ; self :: $ classmap = array ( ) ; self :: load_classes ( 'core' , "$CFG->dirroot/lib/classes" ) ; foreach ( self :: $ subsystems as $ subsystem => $ fulldir ) { if ( ! $ fulldir ) { continue ; } self :: load_classes ( 'core_' . $ subsystem , "$fulldir/cl...
Find all classes that can be autoloaded including frankenstyle namespaces .
28,692
protected static function fill_filemap_cache ( ) { global $ CFG ; self :: $ filemap = array ( ) ; foreach ( self :: $ filestomap as $ file ) { if ( ! isset ( self :: $ filemap [ $ file ] ) ) { self :: $ filemap [ $ file ] = array ( ) ; } foreach ( self :: $ plugins as $ plugintype => $ plugins ) { if ( ! isset ( self :...
Fills up the cache defining what plugins have certain files .
28,693
protected static function load_classes ( $ component , $ fulldir , $ namespace = '' ) { if ( ! is_dir ( $ fulldir ) ) { return ; } if ( ! is_readable ( $ fulldir ) ) { return ; } $ items = new \ DirectoryIterator ( $ fulldir ) ; foreach ( $ items as $ item ) { if ( $ item -> isDot ( ) ) { continue ; } if ( $ item -> is...
Find classes in directory and recurse to subdirs .
28,694
public static function get_plugin_list ( $ plugintype ) { self :: init ( ) ; if ( ! isset ( self :: $ plugins [ $ plugintype ] ) ) { return array ( ) ; } return self :: $ plugins [ $ plugintype ] ; }
Get list of plugins of given type .
28,695
public static function get_plugin_list_with_class ( $ plugintype , $ class , $ file = null ) { global $ CFG ; if ( $ class ) { $ suffix = '_' . $ class ; } else { $ suffix = '' ; } $ pluginclasses = array ( ) ; $ plugins = self :: get_plugin_list ( $ plugintype ) ; foreach ( $ plugins as $ plugin => $ fulldir ) { if ( ...
Get a list of all the plugins of a given type that define a certain class in a certain file . The plugin component names and class names are returned .
28,696
public static function get_plugin_list_with_file ( $ plugintype , $ file , $ include = false ) { global $ CFG ; $ pluginfiles = array ( ) ; if ( isset ( self :: $ filemap [ $ file ] ) ) { if ( isset ( self :: $ filemap [ $ file ] [ $ plugintype ] ) ) { $ pluginfiles = self :: $ filemap [ $ file ] [ $ plugintype ] ; } }...
Get a list of all the plugins of a given type that contain a particular file .
28,697
public static function get_component_classes_in_namespace ( $ component = null , $ namespace = '' ) { $ classes = array ( ) ; if ( isset ( $ component ) || ! empty ( $ namespace ) ) { $ component = ( isset ( $ component ) ) ? self :: normalize_componentname ( $ component ) : '\w+' ; if ( $ namespace ) { $ namespace = t...
Returns all classes in a component matching the provided namespace .
28,698
public static function is_valid_plugin_name ( $ plugintype , $ pluginname ) { if ( $ plugintype === 'mod' ) { if ( ! isset ( self :: $ subsystems ) ) { self :: init ( ) ; } if ( isset ( self :: $ subsystems [ $ pluginname ] ) ) { return false ; } return ( bool ) preg_match ( '/^[a-z][a-z0-9]*$/' , $ pluginname ) ; } el...
This method validates a plug name . It is much faster than calling clean_param .
28,699
public static function normalize_componentname ( $ componentname ) { list ( $ plugintype , $ pluginname ) = self :: normalize_component ( $ componentname ) ; if ( $ plugintype === 'core' && is_null ( $ pluginname ) ) { return $ plugintype ; } return $ plugintype . '_' . $ pluginname ; }
Normalize the component name .