idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
29,700
public function prepare_response_files_draft_itemid_with_text ( $ name , $ contextid , $ text ) { $ draftid = 0 ; $ newtext = file_prepare_draft_area ( $ draftid , $ contextid , 'question' , 'response_' . $ name , $ this -> id , null , $ text ) ; return array ( $ draftid , $ newtext ) ; }
Prepare a draft file are for the files belonging the a response variable of this step while rewriting the URLs in some text .
29,701
public function get_qt_data ( ) { $ result = array ( ) ; foreach ( $ this -> data as $ name => $ value ) { if ( $ name [ 0 ] != '-' && $ name [ 0 ] != ':' ) { $ result [ $ name ] = $ value ; } } return $ result ; }
Get all the question type variables .
29,702
public function set_behaviour_var ( $ name , $ value ) { if ( $ name [ 0 ] != '_' ) { throw new coding_exception ( 'Cannot set question type data ' . $ name . ' on an attempt step. You can only set variables with names begining with _.' ) ; } return $ this -> data [ '-' . $ name ] = $ value ; }
Set a cached behaviour variable .
29,703
public function get_behaviour_data ( ) { $ result = array ( ) ; foreach ( $ this -> data as $ name => $ value ) { if ( $ name [ 0 ] == '-' ) { $ result [ substr ( $ name , 1 ) ] = $ value ; } } return $ result ; }
Get all the behaviour variables .
29,704
public function add_prefix ( $ field ) { if ( substr ( $ field , 0 , 2 ) === '!_' ) { return '-_' . $ this -> extraprefix . substr ( $ field , 2 ) ; } else if ( substr ( $ field , 0 , 1 ) === '-' ) { return '-' . $ this -> extraprefix . substr ( $ field , 1 ) ; } else if ( substr ( $ field , 0 , 1 ) === '_' ) { return ...
Add the extra prefix to a field name .
29,705
public function remove_prefix ( $ field ) { if ( preg_match ( '~^(-?_?)' . preg_quote ( $ this -> extraprefix , '~' ) . '(.*)$~' , $ field , $ matches ) ) { return $ matches [ 1 ] . $ matches [ 2 ] ; } else { return null ; } }
Remove the extra prefix from a field name if it is present .
29,706
public function filter_array ( $ data ) { $ result = array ( ) ; foreach ( $ data as $ fullname => $ value ) { if ( $ name = $ this -> remove_prefix ( $ fullname ) ) { $ result [ $ name ] = $ value ; } } return $ result ; }
Filter some data to keep only those entries where the key contains extraprefix and remove the extra prefix from the reutrned arrary .
29,707
private function init_youtube_service ( ) { global $ CFG ; if ( ! isset ( $ this -> service ) ) { require_once ( $ CFG -> libdir . '/google/lib.php' ) ; $ this -> client = get_google_client ( ) ; $ this -> client -> setDeveloperKey ( $ this -> apikey ) ; $ this -> client -> setScopes ( array ( Google_Service_YouTube ::...
Init all the youtube client service stuff .
29,708
public function set_option ( $ options = array ( ) ) { if ( ! empty ( $ options [ 'apikey' ] ) ) { set_config ( 'apikey' , trim ( $ options [ 'apikey' ] ) , 'youtube' ) ; } unset ( $ options [ 'apikey' ] ) ; return parent :: set_option ( $ options ) ; }
Save apikey in config table .
29,709
public function get_option ( $ config = '' ) { if ( $ config === 'apikey' ) { return trim ( get_config ( 'youtube' , 'apikey' ) ) ; } else { $ options [ 'apikey' ] = trim ( get_config ( 'youtube' , 'apikey' ) ) ; } return parent :: get_option ( $ config ) ; }
Get apikey from config table .
29,710
public function search ( $ search_text , $ page = 0 ) { global $ SESSION ; $ sort = optional_param ( 'youtube_sort' , '' , PARAM_TEXT ) ; $ sess_keyword = 'youtube_' . $ this -> id . '_keyword' ; $ sess_sort = 'youtube_' . $ this -> id . '_sort' ; if ( $ page && ! $ search_text && isset ( $ SESSION -> { $ sess_keyword ...
Return search results
29,711
private function _get_collection ( $ keyword , $ start , $ max , $ sort ) { global $ SESSION ; $ sesspagetoken = 'youtube_' . $ this -> id . '_nextpagetoken' ; $ pagetoken = '' ; if ( $ start > 1 && isset ( $ SESSION -> { $ sesspagetoken } ) ) { $ pagetoken = $ SESSION -> { $ sesspagetoken } ; } $ list = array ( ) ; $ ...
Private method to get youtube search results
29,712
public function print_login ( $ ajax = true ) { $ ret = array ( ) ; $ search = new stdClass ( ) ; $ search -> type = 'text' ; $ search -> id = 'youtube_search' ; $ search -> name = 's' ; $ search -> label = get_string ( 'search' , 'repository_youtube' ) . ': ' ; $ sort = new stdClass ( ) ; $ sort -> type = 'select' ; $...
Generate search form
29,713
public static function type_config_form ( $ mform , $ classname = 'repository' ) { parent :: type_config_form ( $ mform , $ classname ) ; $ apikey = get_config ( 'youtube' , 'apikey' ) ; if ( empty ( $ apikey ) ) { $ apikey = '' ; } $ mform -> addElement ( 'text' , 'apikey' , get_string ( 'apikey' , 'repository_youtube...
Add plugin settings input to Moodle form .
29,714
protected function _pop3Cache ( $ type , $ index = self :: MBOX_CACHE , $ data = null ) { if ( isset ( $ this -> _temp [ 'pop3cache' ] [ $ index ] [ $ type ] ) ) { if ( $ type == 'msg' ) { rewind ( $ this -> _temp [ 'pop3cache' ] [ $ index ] [ $ type ] ) ; } return $ this -> _temp [ 'pop3cache' ] [ $ index ] [ $ type ]...
Retrieve locally cached message data .
29,715
protected function _processString ( $ str , $ opts ) { if ( ! empty ( $ opts [ 'length' ] ) ) { return substr ( $ str , empty ( $ opts [ 'start' ] ) ? 0 : $ opts [ 'start' ] , $ opts [ 'length' ] ) ; } elseif ( ! empty ( $ opts [ 'start' ] ) ) { return substr ( $ str , $ opts [ 'start' ] ) ; } return $ str ; }
Process a string response based on criteria options .
29,716
protected function _sendLine ( $ cmd , $ options = array ( ) ) { if ( ! empty ( $ options [ 'debug' ] ) ) { $ this -> _debug -> client ( $ options [ 'debug' ] ) ; } if ( $ this -> _debug -> debug ) { $ timer = new Horde_Support_Timer ( ) ; $ timer -> push ( ) ; } try { $ this -> _connection -> write ( $ cmd , empty ( $...
Perform a command on the server . A connection to the server must have already been made .
29,717
protected function _getSeqIds ( Horde_Imap_Client_Ids $ ids ) { if ( ! count ( $ ids ) ) { $ status = $ this -> status ( $ this -> _selected , Horde_Imap_Client :: STATUS_MESSAGES ) ; return range ( 1 , $ status [ 'messages' ] ) ; } elseif ( $ ids -> sequence ) { return $ ids -> ids ; } return array_keys ( array_inters...
Returns a list of sequence IDs .
29,718
protected static function queue_conversion ( $ event ) { global $ DB ; $ submissionid = $ event -> other [ 'submissionid' ] ; $ submissionattempt = $ event -> other [ 'submissionattempt' ] ; $ fields = array ( 'submissionid' => $ submissionid , 'submissionattempt' => $ submissionattempt ) ; $ record = ( object ) $ fiel...
Queue the submission for processing .
29,719
function export_class_instance ( $ exportclass = null ) { if ( ! is_null ( $ exportclass ) ) { $ this -> started_output = true ; $ this -> exportclass = $ exportclass ; $ this -> exportclass -> table = $ this ; } else if ( is_null ( $ this -> exportclass ) && ! empty ( $ this -> download ) ) { $ this -> exportclass = n...
Get and optionally set the export class .
29,720
function is_downloadable ( $ downloadable = null ) { if ( $ downloadable !== null ) { $ this -> downloadable = $ downloadable ; } return $ this -> downloadable ; }
Probably don t need to call this directly . Calling is_downloading with a param automatically sets table as downloadable .
29,721
function sortable ( $ bool , $ defaultcolumn = NULL , $ defaultorder = SORT_ASC ) { $ this -> is_sortable = $ bool ; $ this -> sort_default_column = $ defaultcolumn ; $ this -> sort_default_order = $ defaultorder ; }
Sets the is_sortable variable to the given boolean sort_default_column to the given string and the sort_default_order to the given integer .
29,722
function is_sortable ( $ column = null ) { if ( empty ( $ column ) ) { return $ this -> is_sortable ; } if ( ! $ this -> is_sortable ) { return false ; } return ! in_array ( $ column , $ this -> column_nosort ) ; }
Is the column sortable?
29,723
function pagesize ( $ perpage , $ total ) { $ this -> pagesize = $ perpage ; $ this -> totalrows = $ total ; $ this -> use_pages = true ; }
Sets the pagesize variable to the given integer the totalrows variable to the given integer and the use_pages variable to true .
29,724
function set_control_variables ( $ variables ) { foreach ( $ variables as $ what => $ variable ) { if ( isset ( $ this -> request [ $ what ] ) ) { $ this -> request [ $ what ] = $ variable ; } } }
Assigns each given variable in the array to the corresponding index in the request class variable .
29,725
function column_suppress ( $ column ) { if ( isset ( $ this -> column_suppress [ $ column ] ) ) { $ this -> column_suppress [ $ column ] = true ; } }
What this method does is set the column so that if the same data appears in consecutive rows then it is not repeated .
29,726
public static function construct_order_by ( $ cols , $ textsortcols = array ( ) ) { global $ DB ; $ bits = array ( ) ; foreach ( $ cols as $ column => $ order ) { if ( in_array ( $ column , $ textsortcols ) ) { $ column = $ DB -> sql_order_by_text ( $ column ) ; } if ( $ order == SORT_ASC ) { $ bits [ ] = $ column . ' ...
Prepare an an order by clause from the list of columns to be sorted .
29,727
public function format_and_add_array_of_rows ( $ rowstoadd , $ finish = true ) { foreach ( $ rowstoadd as $ row ) { if ( is_null ( $ row ) ) { $ this -> add_separator ( ) ; } else { $ this -> add_data_keyed ( $ this -> format_row ( $ row ) ) ; } } if ( $ finish ) { $ this -> finish_output ( ! $ this -> is_downloading (...
Add a number of rows to the table at once . And optionally finish output after they have been added .
29,728
function add_data ( $ row , $ classname = '' ) { if ( ! $ this -> setup ) { return false ; } if ( ! $ this -> started_output ) { $ this -> start_output ( ) ; } if ( $ this -> exportclass !== null ) { if ( $ row === null ) { $ this -> exportclass -> add_seperator ( ) ; } else { $ this -> exportclass -> add_data ( $ row ...
This method actually directly echoes the row passed to it now or adds it to the download . If this is the first row and start_output has not already been called this method also calls start_output to open the table or send headers for the downloaded . Can be used as before . print_html now calls finish_html to close ta...
29,729
function finish_output ( $ closeexportclassdoc = true ) { if ( $ this -> exportclass !== null ) { $ this -> exportclass -> finish_table ( ) ; if ( $ closeexportclassdoc ) { $ this -> exportclass -> finish_document ( ) ; } } else { $ this -> finish_html ( ) ; } }
You should call this to finish outputting the table data after adding data to the table with add_data or add_data_keyed .
29,730
public function download_buttons ( ) { global $ OUTPUT ; if ( $ this -> is_downloadable ( ) && ! $ this -> is_downloading ( ) ) { return $ OUTPUT -> download_dataformat_selector ( get_string ( 'downloadas' , 'table' ) , $ this -> baseurl -> out_omit_querystring ( ) , 'download' , $ this -> baseurl -> params ( ) ) ; } e...
Get the html for the download buttons
29,731
function start_output ( ) { $ this -> started_output = true ; if ( $ this -> exportclass !== null ) { $ this -> exportclass -> start_table ( $ this -> sheettitle ) ; $ this -> exportclass -> output_headers ( $ this -> headers ) ; } else { $ this -> start_html ( ) ; $ this -> print_headers ( ) ; echo html_writer :: star...
This function is not part of the public api . You don t normally need to call this . It is called automatically when needed when you start adding data to the table .
29,732
public function get_row_html ( $ row , $ classname = '' ) { static $ suppress_lastrow = NULL ; $ rowclasses = array ( ) ; if ( $ classname ) { $ rowclasses [ ] = $ classname ; } $ rowid = $ this -> uniqueid . '_r' . $ this -> currentrow ; $ html = '' ; $ html .= html_writer :: start_tag ( 'tr' , array ( 'class' => impl...
Generate html code for the passed row .
29,733
protected function render_reset_button ( ) { if ( ! $ this -> can_be_reset ( ) ) { return '' ; } $ url = $ this -> baseurl -> out ( false , array ( $ this -> request [ TABLE_VAR_RESET ] => 1 ) ) ; $ html = html_writer :: start_div ( 'resettable mdl-right' ) ; $ html .= html_writer :: link ( $ url , get_string ( 'resett...
Generate the HTML for the table preferences reset button .
29,734
protected function can_be_reset ( ) { foreach ( $ this -> prefs as $ prefname => $ prefval ) { if ( $ prefname === 'sortby' and ! empty ( $ this -> sort_default_column ) ) { if ( empty ( $ prefval ) or $ prefval !== array ( $ this -> sort_default_column => $ this -> sort_default_order ) ) { return true ; } } else if ( ...
Are there some table preferences that can be reset?
29,735
function set_count_sql ( $ sql , array $ params = NULL ) { $ this -> countsql = $ sql ; $ this -> countparams = $ params ; }
This is only needed if you want to use different sql to count rows . Used for example when perhaps all db JOINS are not needed when counting records . You don t need to call this function the count_sql will be generated automatically .
29,736
function format_text ( $ text , $ format = FORMAT_MOODLE , $ options = NULL , $ courseid = NULL ) { $ text = str_replace ( array ( '</p>' , "\n" , "\r" ) , ' ' , $ text ) ; return strip_tags ( $ text ) ; }
Given text in a variety of format codings this function returns the text as safe HTML or as plain text dependent on what is appropriate for the download format . The default removes all tags .
29,737
public function getThread ( $ index ) { foreach ( $ this -> _thread as $ v ) { if ( isset ( $ v [ $ index ] ) ) { reset ( $ v ) ; $ ob = new stdClass ; $ ob -> base = ( count ( $ v ) > 1 ) ? key ( $ v ) : null ; $ ob -> last = false ; $ levels = $ out = array ( ) ; $ last = 0 ; while ( ( $ v2 = current ( $ v ) ) !== fa...
Returns the list of messages in a thread .
29,738
protected function _getAllIndices ( ) { $ out = array ( ) ; foreach ( $ this -> _thread as $ val ) { $ out += $ val ; } return array_keys ( $ out ) ; }
Return all indices .
29,739
public static function calculate_all_expressions ( qtype_calculated_question_with_expressions $ question ) { $ question -> questiontext = $ question -> vs -> replace_expressions_in_text ( $ question -> questiontext ) ; $ question -> generalfeedback = $ question -> vs -> replace_expressions_in_text ( $ question -> gener...
Calculate all the exressions in a qtype_calculatedmulti_single_question or qtype_calculatedmulti_multi_question .
29,740
public function set_status ( $ status = self :: STATUS_ACTIVE ) { $ this -> statusactive = $ status == static :: STATUS_ACTIVE ; $ this -> statussuspended = $ status == static :: STATUS_SUSPENDED ; $ this -> statusnotcurrent = $ status == static :: STATUS_NOT_CURRENT ; return $ this ; }
Status setter .
29,741
protected static function define_properties ( ) { return array ( 'sourcefileid' => [ 'type' => PARAM_INT , ] , 'targetformat' => [ 'type' => PARAM_ALPHANUMEXT , ] , 'status' => [ 'type' => PARAM_INT , 'choices' => [ self :: STATUS_PENDING , self :: STATUS_IN_PROGRESS , self :: STATUS_COMPLETE , self :: STATUS_FAILED , ...
Define properties .
29,742
public static function get_conversions_for_file ( stored_file $ file , $ format ) { global $ DB ; $ instances = [ ] ; $ sqlfields = self :: get_sql_fields ( 'c' , 'conversion' ) ; $ sql = "SELECT {$sqlfields} FROM {" . self :: TABLE . "} c INNER JOIN {files} conversionsourcefile ON convers...
Fetch all conversions relating to the specified file .
29,743
public static function remove_orphan_records ( ) { global $ DB ; $ sql = " SELECT c.id FROM {" . self :: TABLE . "} c LEFT JOIN {files} f ON f.id = c.sourcefileid WHERE f.id IS NULL" ; $ ids = $ DB -> get_fieldset_sql ( $ sql , [ ] ) ; if ( empty ( $ ids ) ) { ...
Remove orphan records .
29,744
protected function get_file_record ( ) { $ file = $ this -> get_sourcefile ( ) ; if ( ! $ file ) { return false ; } return [ 'contextid' => \ context_system :: instance ( ) -> id , 'component' => 'core' , 'filearea' => 'documentconversion' , 'itemid' => 0 , 'filepath' => "/" . $ this -> get ( 'targetformat' ) . "/" , '...
Return the file record base for use in the files table .
29,745
static function get_as_strings ( $ lines ) { $ strings = array ( ) ; foreach ( $ lines as $ key => $ value ) { $ strings [ $ key ] = $ value -> get_as_string ( ) ; } return $ strings ; }
Static function converts lines to strings .
29,746
public static function delete_feedback_for_grade ( assign_plugin_request_data $ requestdata ) { $ requestdata -> set_userids ( [ $ requestdata -> get_user ( ) -> id ] ) ; $ requestdata -> populate_submissions_and_grades ( ) ; self :: delete_feedback_for_grades ( $ requestdata ) ; }
Calling this function should delete all user data associated with this grade .
29,747
public static function get_behat_selector ( $ selectortype , $ element , Behat \ Mink \ Session $ session ) { if ( $ selectortype == 'css_element' || $ selectortype == 'xpath_element' ) { $ selector = str_replace ( '_element' , '' , $ selectortype ) ; $ locator = $ element ; } else { $ allowedselectors = self :: get_al...
Returns the behat selector and locator for a given moodle selector and locator
29,748
public static function available_numofreviews_list ( ) { $ options = array ( ) ; $ options [ 30 ] = 30 ; $ options [ 20 ] = 20 ; $ options [ 15 ] = 15 ; for ( $ i = 10 ; $ i >= 0 ; $ i -- ) { $ options [ $ i ] = $ i ; } return $ options ; }
Return an array of possible numbers of reviews to be done
29,749
protected function self_allocation ( $ authors = array ( ) , $ reviewers = array ( ) , $ assessments = array ( ) ) { if ( ! isset ( $ authors [ 0 ] ) || ! isset ( $ reviewers [ 0 ] ) ) { return array ( ) ; } $ alreadyallocated = array ( ) ; foreach ( $ assessments as $ assessment ) { if ( $ assessment -> authorid == $ ...
Allocates submissions to their authors for review
29,750
protected function add_new_allocations ( array $ newallocations , array $ dataauthors , array $ datareviewers ) { global $ DB ; $ newallocations = $ this -> get_unique_allocations ( $ newallocations ) ; $ authorids = $ this -> get_author_ids ( $ newallocations ) ; $ submissions = $ this -> workshop -> get_submissions (...
Creates new assessment records
29,751
protected function index_submissions_by_authors ( $ submissions ) { $ byauthor = array ( ) ; if ( is_array ( $ submissions ) ) { foreach ( $ submissions as $ submissionid => $ submission ) { if ( isset ( $ byauthor [ $ submission -> authorid ] ) ) { throw new moodle_exception ( 'moresubmissionsbyauthor' , 'workshop' ) ...
Flips the structure of submission so it is indexed by authorid attribute
29,752
protected function get_author_ids ( $ newallocations ) { $ authors = array ( ) ; foreach ( $ newallocations as $ newallocation ) { $ authorid = reset ( $ newallocation ) ; if ( ! in_array ( $ authorid , $ authors ) ) { $ authors [ ] = $ authorid ; } } return $ authors ; }
Extracts unique list of authors IDs from the structure of new allocations
29,753
protected function get_unkept_assessments ( $ assessments , $ newallocations , $ keepselfassessments ) { $ keepids = array ( ) ; foreach ( $ assessments as $ assessmentid => $ assessment ) { $ aaid = $ assessment -> authorid ; $ arid = $ assessment -> reviewerid ; if ( ( $ keepselfassessments ) && ( $ aaid == $ arid ) ...
Returns the list of assessments to remove
29,754
protected function convert_assessments_to_links ( $ assessments ) { $ authorlinks = array ( ) ; $ reviewerlinks = array ( ) ; foreach ( $ assessments as $ assessment ) { if ( ! isset ( $ authorlinks [ $ assessment -> authorid ] ) ) { $ authorlinks [ $ assessment -> authorid ] = array ( ) ; } if ( ! isset ( $ reviewerli...
Extracts the information about reviews from the authors and reviewers perspectives
29,755
protected function get_element_with_lowest_workload ( $ workload ) { $ precision = 10 ; if ( empty ( $ workload ) ) { return false ; } $ minload = round ( min ( $ workload ) , $ precision ) ; $ minkeys = array ( ) ; foreach ( $ workload as $ key => $ val ) { if ( round ( $ val , $ precision ) == $ minload ) { $ minkeys...
Selects an element with the lowest workload
29,756
protected function shuffle_assoc ( & $ array ) { if ( count ( $ array ) > 1 ) { $ keys = array_keys ( $ array ) ; shuffle ( $ keys ) ; foreach ( $ keys as $ key ) { $ new [ $ key ] = $ array [ $ key ] ; } $ array = $ new ; } return true ; }
Shuffle the order of array elements preserving the key = > values
29,757
protected function filter_current_assessments ( & $ newallocations , $ assessments ) { foreach ( $ assessments as $ assessment ) { $ allocation = array ( $ assessment -> reviewerid => $ assessment -> authorid ) ; $ foundat = array_keys ( $ newallocations , $ allocation ) ; $ newallocations = array_diff_key ( $ newalloc...
Filter new allocations so that they do not contain an already existing assessment
29,758
public static function instance_from_object ( stdClass $ data ) { $ i = new self ( ) ; if ( ! isset ( $ data -> numofreviews ) ) { throw new coding_exception ( 'Missing value of the numofreviews property' ) ; } else { $ i -> numofreviews = ( int ) $ data -> numofreviews ; } if ( ! isset ( $ data -> numper ) ) { throw n...
Factory method making the instance from data in the passed object
29,759
public static function get_popup_notifications ( $ useridto = 0 , $ sort = 'DESC' , $ limit = 0 , $ offset = 0 ) { global $ DB , $ USER ; $ sort = strtoupper ( $ sort ) ; if ( $ sort != 'DESC' && $ sort != 'ASC' ) { throw new \ moodle_exception ( 'invalid parameter: sort: must be "DESC" or "ASC"' ) ; } if ( empty ( $ u...
Get popup notifications for the specified users . Nothing is returned if notifications are disabled .
29,760
public static function count_unread_popup_notifications ( $ useridto = 0 ) { global $ USER , $ DB ; if ( empty ( $ useridto ) ) { $ useridto = $ USER -> id ; } return $ DB -> count_records_sql ( "SELECT count(id) FROM {notifications} WHERE id IN (SELECT notificationid FROM {message_popup_noti...
Count the unread notifications for a user .
29,761
public function parse ( array $ tokens = array ( ) ) { $ this -> lineNum = - 1 ; $ this -> lineTokens = 0 ; $ this -> pragmas = $ this -> defaultPragmas ; $ this -> pragmaFilters = isset ( $ this -> pragmas [ Mustache_Engine :: PRAGMA_FILTERS ] ) ; $ this -> pragmaBlocks = isset ( $ this -> pragmas [ Mustache_Engine ::...
Process an array of Mustache tokens and convert them into a parse tree .
29,762
private function clearStandaloneLines ( array & $ nodes , array & $ tokens ) { if ( $ this -> lineTokens > 1 ) { return ; } $ prev = null ; if ( $ this -> lineTokens === 1 ) { if ( $ prev = end ( $ nodes ) ) { if ( ! $ this -> tokenIsWhitespace ( $ prev ) ) { return ; } } } if ( $ next = reset ( $ tokens ) ) { if ( $ n...
Clear standalone line tokens .
29,763
private function tokenIsWhitespace ( array $ token ) { if ( $ token [ Mustache_Tokenizer :: TYPE ] === Mustache_Tokenizer :: T_TEXT ) { return preg_match ( '/^\s*$/' , $ token [ Mustache_Tokenizer :: VALUE ] ) ; } return false ; }
Check whether token is a whitespace token .
29,764
private function checkIfTokenIsAllowedInParent ( $ parent , array $ token ) { if ( $ parent [ Mustache_Tokenizer :: TYPE ] === Mustache_Tokenizer :: T_PARENT ) { throw new Mustache_Exception_SyntaxException ( 'Illegal content in < parent tag' , $ token ) ; } }
Check whether a token is allowed inside a parent tag .
29,765
private function getNameAndFilters ( $ name ) { $ filters = array_map ( 'trim' , explode ( '|' , $ name ) ) ; $ name = array_shift ( $ filters ) ; return array ( $ name , $ filters ) ; }
Split a tag name into name and filters .
29,766
private function enablePragma ( $ name ) { $ this -> pragmas [ $ name ] = true ; switch ( $ name ) { case Mustache_Engine :: PRAGMA_BLOCKS : $ this -> pragmaBlocks = true ; break ; case Mustache_Engine :: PRAGMA_FILTERS : $ this -> pragmaFilters = true ; break ; } }
Enable a pragma .
29,767
public function get ( $ mode = self :: MODE_CURRENT_LEVEL ) { $ parameter = array ( ) ; if ( $ mode === self :: MODE_ALL_LEVELS ) { $ parameter [ 'bubble' ] = 'all' ; } else if ( $ mode === self :: MODE_DISTINCT_NAMES ) { $ parameter [ 'bubble' ] = 'distinct' ; } $ http = $ this -> send ( 'GET' , $ parameter ) ; if ( !...
Get the tool settings .
29,768
public function set ( $ settings ) { if ( ! $ this -> simple ) { if ( is_a ( $ this -> source , 'ToolConsumer' ) ) { $ type = 'ToolProxy' ; } else if ( is_a ( $ this -> source , 'ToolConsumer' ) ) { $ type = 'ToolProxyBinding' ; } else { $ type = 'LtiLink' ; } $ obj = new \ stdClass ( ) ; $ obj -> { '@context' } = 'htt...
Set the tool settings .
29,769
public function get_capability_manager ( forum_entity $ forum ) { return new capability_manager ( $ forum , $ this -> legacydatamapperfactory -> get_forum_data_mapper ( ) , $ this -> legacydatamapperfactory -> get_discussion_data_mapper ( ) , $ this -> legacydatamapperfactory -> get_post_data_mapper ( ) ) ; }
Create a capability manager for the given forum .
29,770
public function execute ( ) { global $ DB ; if ( is_enabled_auth ( 'ldap' ) ) { $ auth = get_auth_plugin ( 'ldap' ) ; $ users = $ DB -> get_records ( 'user' , array ( 'auth' => 'ldap' ) ) ; foreach ( $ users as $ user ) { $ auth -> sync_roles ( $ user ) ; } } }
Synchronise role assignments from LDAP .
29,771
public function write ( $ key , $ message ) { $ message = strval ( $ message ) ; return ( strlen ( $ key ) && strlen ( $ message ) ) ? $ this -> _getCipherOb ( $ key ) -> encrypt ( $ message ) : '' ; }
Take a small piece of data and encrypt it with a key .
29,772
protected function _getCipherOb ( $ key ) { if ( ! is_string ( $ key ) ) { throw new Horde_Secret_Exception ( 'Key must be a string' , Horde_Secret_Exception :: KEY_NOT_STRING ) ; } if ( ! strlen ( $ key ) ) { throw new Horde_Secret_Exception ( 'Key must be non-zero.' , Horde_Secret_Exception :: KEY_ZERO_LENGTH ) ; } $...
Returns the cached crypt object .
29,773
public function getKey ( $ keyname = self :: DEFAULT_KEY ) { if ( ! isset ( $ this -> _keyCache [ $ keyname ] ) ) { if ( isset ( $ _COOKIE [ $ keyname . '_key' ] ) ) { $ key = $ _COOKIE [ $ keyname . '_key' ] ; } else { $ key = session_id ( ) ; $ this -> _setCookie ( $ keyname , $ key ) ; } $ this -> _keyCache [ $ keyn...
Return a secret key either from a cookie or if the cookie isn t there assume we are using a munged version of a known base value .
29,774
public function clearKey ( $ keyname = self :: DEFAULT_KEY ) { if ( isset ( $ _COOKIE [ $ this -> _params [ 'session_name' ] ] ) && isset ( $ _COOKIE [ $ keyname . '_key' ] ) ) { $ this -> _setCookie ( $ keyname , false ) ; return true ; } return false ; }
Clears a secret key entry from the current cookie .
29,775
public static function delete_comments_for_users ( \ core_privacy \ local \ request \ approved_userlist $ userlist , string $ component , string $ commentarea = null , int $ itemid = null ) { global $ DB ; $ context = $ userlist -> get_context ( ) ; $ params = [ 'contextid' => $ context -> id , 'component' => $ compone...
Deletes all records for a context from a list of approved users .
29,776
public static function get_users_in_context_from_sql ( userlist $ userlist , string $ alias , string $ component , string $ area , int $ contextid = null , string $ insql = '' , array $ params = [ ] ) { if ( $ insql != '' ) { $ insql = "AND {$alias}.itemid {$insql}" ; } $ contextsql = '' ; if ( isset ( $ contextid ) ) ...
Add the list of users who have commented in the specified constraints .
29,777
public static function get_calculation_display ( \ core_analytics \ calculable $ calculable , $ value , $ output , $ subtype = false ) { $ outcome = $ calculable -> get_calculation_outcome ( $ value , $ subtype ) ; switch ( $ outcome ) { case \ core_analytics \ calculable :: OUTCOME_NEUTRAL : $ style = '' ; $ text = ge...
Returns display info for the calculated value outcome .
29,778
public function validation ( $ data , $ files ) { global $ CFG , $ DB , $ USER ; $ errors = parent :: validation ( $ data , $ files ) ; if ( ! empty ( $ data [ 'courseassoc' ] ) ) { $ coursecontext = context :: instance_by_id ( $ data [ 'courseassoc' ] ) ; if ( $ coursecontext -> contextlevel != CONTEXT_COURSE ) { $ er...
Validate the blog form data .
29,779
public function rollback ( $ e ) { if ( $ this -> is_disposed ( ) ) { throw new dml_transaction_exception ( 'Transactions already disposed' , $ this ) ; } $ this -> database -> rollback_delegated_transaction ( $ this , $ e ) ; }
Rollback all current delegated transactions .
29,780
public function get_description ( ) { $ retstring = "The user with id '$this->userid' restored the course with id '$this->courseid'." ; if ( isset ( $ this -> other [ 'originalcourseid' ] ) ) { $ originalcourseid = $ this -> other [ 'originalcourseid' ] ; $ retstring = "The user with id '$this->userid' restored old cou...
Returns non - localised description of what happened .
29,781
function SuspiciousSQL ( $ numsql = 10 ) { $ sql = "select substr(to_char(s.pct, '99.00'), 2) || '%' load, s.executions executes, p.sql_textfrom ( select address, buffer_gets, executions, pct, rank() over (order by buffer_gets desc) ranking from ( select address, buffer_ge...
requires oracle 8 . 1 . 7 or later
29,782
function name ( ) { static $ myname ; if ( $ myname === NULL ) { $ myname = strtolower ( get_class ( $ this ) ) ; $ myname = substr ( $ myname , strpos ( $ myname , '_' ) + 1 ) ; } return $ myname ; }
Returns the block name as present in the class name the database the block directory etc etc .
29,783
function is_empty ( ) { if ( ! has_capability ( 'moodle/block:view' , $ this -> context ) ) { return true ; } $ this -> get_content ( ) ; return ( empty ( $ this -> content -> text ) && empty ( $ this -> content -> footer ) ) ; }
Returns true or false depending on whether this block has any content to display and whether the user has permission to view the block
29,784
public function get_content_for_output ( $ output ) { global $ CFG ; $ bc = new block_contents ( $ this -> html_attributes ( ) ) ; $ bc -> attributes [ 'data-block' ] = $ this -> name ( ) ; $ bc -> blockinstanceid = $ this -> instance -> id ; $ bc -> blockpositionid = $ this -> instance -> blockpositionid ; if ( $ this...
Return a block_contents object representing the full contents of this block .
29,785
public function get_content_for_external ( $ output ) { $ bc = new stdClass ; $ bc -> title = null ; $ bc -> content = null ; $ bc -> contentformat = FORMAT_HTML ; $ bc -> footer = null ; $ bc -> files = [ ] ; if ( $ this -> instance -> visible ) { $ bc -> content = $ this -> formatted_contents ( $ output ) ; if ( ! em...
Return an object containing all the block content to be returned by external functions .
29,786
protected function formatted_contents ( $ output ) { $ this -> get_content ( ) ; $ this -> get_required_javascript ( ) ; if ( ! empty ( $ this -> content -> text ) ) { return $ this -> content -> text ; } else { return '' ; } }
Convert the contents of the block to HTML .
29,787
private function has_add_block_capability ( $ page , $ capability ) { if ( ! get_capability_info ( $ capability ) ) { static $ warned = array ( ) ; if ( ! isset ( $ warned [ $ this -> name ( ) ] ) ) { debugging ( 'The block ' . $ this -> name ( ) . ' does not define the standard capability ' . $ capability , DEBUG_DEVE...
Returns true if the user can add a block to a page .
29,788
protected function formatted_contents ( $ output ) { global $ PAGE ; static $ eventattached ; if ( $ eventattached === null ) { $ eventattached = true ; } if ( ! $ this -> content ) { $ this -> content = new stdClass ; $ this -> content -> items = array ( ) ; } $ this -> get_required_javascript ( ) ; $ this -> get_cont...
Make the formatted HTML ouput .
29,789
protected static function validate_prediction ( $ predictionid ) { list ( $ model , $ prediction , $ context ) = \ core_analytics \ manager :: get_prediction ( $ predictionid ) ; self :: validate_context ( $ context ) ; return array ( $ model , $ prediction , $ context ) ; }
Validates access to the prediction and returns it .
29,790
public function get_availability_tree ( ) { if ( is_null ( $ this -> availabilitytree ) ) { if ( is_null ( $ this -> availability ) ) { throw new \ coding_exception ( 'Cannot call get_availability_tree with null availability' ) ; } $ this -> availabilitytree = $ this -> decode_availability ( $ this -> availability , tr...
Gets the availability tree decoding it if not already done .
29,791
protected function decode_availability ( $ availability , $ lax ) { $ structure = json_decode ( $ availability ) ; if ( is_null ( $ structure ) ) { throw new \ coding_exception ( 'Invalid availability text' , $ availability ) ; } return new tree ( $ structure , $ lax ) ; }
Decodes availability data from JSON format .
29,792
public function is_available ( & $ information , $ grabthelot = false , $ userid = 0 , \ course_modinfo $ modinfo = null ) { global $ USER ; $ information = '' ; if ( is_null ( $ this -> availability ) ) { return true ; } if ( ! $ userid ) { $ userid = $ USER -> id ; } if ( ! $ modinfo ) { $ modinfo = get_fast_modinfo ...
Determines whether this particular item is currently available according to the availability criteria .
29,793
public function is_available_for_all ( ) { if ( is_null ( $ this -> availability ) ) { return true ; } else { try { return $ this -> get_availability_tree ( ) -> is_available_for_all ( ) ; } catch ( \ coding_exception $ e ) { $ this -> warn_about_invalid_availability ( $ e ) ; return false ; } } }
Checks whether this activity is going to be available for all users .
29,794
protected function warn_about_invalid_availability ( \ coding_exception $ e ) { $ name = $ this -> get_thing_name ( ) ; $ htmlname = @ $ this -> format_info ( $ name , $ this -> course ) ; if ( $ htmlname === '' ) { $ htmlname = preg_replace ( '~[^0-9]~' , '' , $ name ) ; } $ info = 'Error processing availability data ...
In some places we catch coding_exception because if a bug happens it would be fatal for the course page GUI ; instead we just show a developer debug message .
29,795
protected function update_dependency_id ( $ table , $ oldid , $ newid ) { if ( is_null ( $ this -> availability ) ) { return false ; } $ tree = $ this -> get_availability_tree ( ) ; $ changed = $ tree -> update_dependency_id ( $ table , $ oldid , $ newid ) ; if ( $ changed ) { $ structure = $ tree -> save ( ) ; $ this ...
Called on a single item . If necessary updates availability data where it has a dependency on an item with a particular id .
29,796
public static function add_legacy_availability_condition ( $ availability , $ rec , $ show ) { if ( ! empty ( $ rec -> sourcecmid ) ) { $ condition = '{"type":"completion","cm":' . $ rec -> sourcecmid . ',"e":' . $ rec -> requiredcompletion . '}' ; } else { $ minmax = '' ; if ( ! empty ( $ rec -> grademin ) ) { $ minma...
Adds a condition from the legacy availability condition .
29,797
public static function add_legacy_availability_field_condition ( $ availability , $ rec , $ show ) { if ( isset ( $ rec -> userfield ) ) { $ fieldbit = ',"sf":' . json_encode ( $ rec -> userfield ) ; } else { $ fieldbit = ',"cf":' . json_encode ( $ rec -> shortname ) ; } switch ( $ rec -> operator ) { case 'isempty' : ...
Adds a condition from the legacy availability field condition .
29,798
protected static function add_legacy_condition ( $ availability , $ condition , $ show ) { $ showtext = ( $ show ? 'true' : 'false' ) ; if ( is_null ( $ availability ) ) { $ availability = '{"op":"&","showc":[' . $ showtext . '],"c":[' . $ condition . ']}' ; } else { $ matches = array ( ) ; if ( ! preg_match ( '~^({"op...
Adds a condition to an AND group .
29,799
public function register_return_link ( $ action , $ params ) { global $ PAGE ; $ params [ 'action' ] = $ action ; $ cm = $ this -> get_course_module ( ) ; if ( $ cm ) { $ currenturl = new moodle_url ( '/mod/assign/view.php' , array ( 'id' => $ cm -> id ) ) ; } else { $ currenturl = new moodle_url ( '/mod/assign/index.p...
Set the action and parameters that can be used to return to the current page .