idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
34,800
public static function logout_db_session ( $ spsessionid ) { global $ CFG , $ DB ; $ sessions = $ DB -> get_records_sql ( 'SELECT userid, sessdata FROM {sessions} WHERE timemodified > ?' , array ( time ( ) - $ CFG -> sessiontimeout ) ) ; foreach ( $ sessions as $ session ) { if ( session_decode ( base64_decode ( $ sess...
Delete session of user using DB sessions .
34,801
private static function unserializesession ( $ serializedstring ) { $ variables = array ( ) ; $ a = preg_split ( "/(\w+)\|/" , $ serializedstring , - 1 , PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE ) ; $ counta = count ( $ a ) ; for ( $ i = 0 ; $ i < $ counta ; $ i = $ i + 2 ) { $ variables [ $ a [ $ i ] ] = unseria...
Unserialize a session string .
34,802
public function write ( $ content ) { if ( ! $ this -> running ) { throw new xml_output_exception ( 'xml_output_not_started' ) ; } $ lenc = strlen ( $ content ) ; if ( $ lenc == 0 ) { return ; } $ tooutput = true ; if ( $ this -> usebuffer ) { $ this -> currentbuffer .= $ content ; $ this -> currentbuffersize += $ lenc...
Get contents from
34,803
public function search ( $ searchtext , $ page = 0 ) { $ path = $ this -> build_node_path ( 'root' , get_string ( 'pluginname' , 'repository_googledocs' ) ) ; $ str = get_string ( 'searchfor' , 'repository_googledocs' , $ searchtext ) ; $ path = $ this -> build_node_path ( 'search' , $ str , $ path ) ; $ q = "fullText ...
Search throughout the Google Drive .
34,804
public function supported_returntypes ( ) { if ( ! empty ( $ this -> issuer ) && $ this -> issuer -> is_system_account_connected ( ) ) { $ setting = get_config ( 'googledocs' , 'supportedreturntypes' ) ; if ( $ setting == 'internal' ) { return FILE_INTERNAL ; } else if ( $ setting == 'external' ) { return FILE_CONTROLL...
Tells how the file can be picked from this repository .
34,805
protected function copy_file ( \ repository_googledocs \ rest $ client , $ fileid , $ name ) { $ fields = "id,name,mimeType,webContentLink,webViewLink,size,thumbnailLink,iconLink" ; $ params = [ 'fileid' => $ fileid , 'fields' => $ fields , ] ; $ copyinfo = [ ] ; if ( ! empty ( $ name ) ) { $ copyinfo = [ 'name' => $ n...
Copy a file and return the new file details . A side effect of the copy is that the owner will be the account authenticated with this oauth client .
34,806
protected function add_writer_to_file ( \ repository_googledocs \ rest $ client , $ fileid , $ email ) { $ updateeditor = [ 'emailAddress' => $ email , 'role' => 'writer' , 'type' => 'user' ] ; $ params = [ 'fileid' => $ fileid , 'sendNotificationEmail' => 'false' ] ; $ response = $ client -> call ( 'create_permission'...
Add a writer to the permissions on the file .
34,807
protected function move_file_from_root_to_folder ( \ repository_googledocs \ rest $ client , $ fileid , $ folderid ) { $ params = [ 'fileid' => $ fileid , 'addParents' => $ folderid , 'removeParents' => 'root' ] ; $ response = $ client -> call ( 'update' , $ params , ' ' ) ; if ( empty ( $ response -> id ) ) { $ detail...
Move from root to folder
34,808
protected function prevent_writers_from_sharing_file ( \ repository_googledocs \ rest $ client , $ fileid ) { $ params = [ 'fileid' => $ fileid ] ; $ update = [ 'writersCanShare' => false ] ; $ response = $ client -> call ( 'update' , $ params , json_encode ( $ update ) ) ; if ( empty ( $ response -> id ) ) { $ details...
Prevent writers from sharing .
34,809
public function validation ( $ data , $ files ) { $ errors = parent :: validation ( $ data , $ files ) ; if ( signup_captcha_enabled ( ) ) { $ recaptchaelement = $ this -> _form -> getElement ( 'recaptcha_element' ) ; if ( ! empty ( $ this -> _form -> _submitValues [ 'g-recaptcha-response' ] ) ) { $ response = $ this -...
Validate user supplied data on the signup form .
34,810
protected function check_combined_feedback_file_access ( $ qa , $ options , $ filearea , $ args = null ) { $ state = $ qa -> get_state ( ) ; if ( $ args === null ) { debugging ( 'You must pass $args as the fourth argument to check_combined_feedback_file_access.' , DEBUG_DEVELOPER ) ; $ args = array ( $ this -> id ) ; }...
Check a request for access to a file belonging to a combined feedback field .
34,811
protected function check_hint_file_access ( $ qa , $ options , $ args ) { if ( ! $ options -> feedback ) { return false ; } $ hint = $ qa -> get_applicable_hint ( ) ; $ hintid = reset ( $ args ) ; return $ hintid == $ hint -> id ; }
Check a request for access to a file belonging to a hint .
34,812
public function render ( stdClass $ user , array $ forums , array $ discussions , array $ posts ) : string { $ forums = array_reduce ( $ forums , function ( $ carry , $ forum ) { $ carry [ $ forum -> get_id ( ) ] = $ forum ; return $ carry ; } , [ ] ) ; $ discussions = array_reduce ( $ discussions , function ( $ carry ...
Render the given posts for the forums and discussions .
34,813
public static function create_multiple_from_competencyids ( $ competencyids , $ contextid ) { $ events = array ( ) ; foreach ( $ competencyids as $ id ) { $ events [ $ id ] = static :: create ( array ( 'contextid' => $ contextid , 'objectid' => $ id ) ) ; } return $ events ; }
Instantiate events from competency ids .
34,814
public function export_for_template ( \ renderer_base $ output ) { $ data = array ( 'feeds' => array ( ) ) ; foreach ( $ this -> feeds as $ feed ) { $ data [ 'feeds' ] [ ] = $ feed -> export_for_template ( $ output ) ; } return $ data ; }
Prepare data for use in a template
34,815
public function html ( ) { global $ OUTPUT ; $ options = $ this -> options ; $ selected = $ this -> selected ; $ context = array ( 'name' => $ this -> name , 'value' => $ this -> selected , 'tabindex' => 1 , 'disabled' => ! empty ( $ this -> isdisabled ) , 'options' => array_map ( function ( $ option ) use ( $ options ...
Render this element as html .
34,816
public function install_languagepacks ( $ langs , $ updating = false ) { global $ CFG ; $ this -> installer -> set_queue ( $ langs ) ; $ results = $ this -> installer -> run ( ) ; $ updatedpacks = 0 ; foreach ( $ results as $ langcode => $ langstatus ) { switch ( $ langstatus ) { case \ lang_installer :: RESULT_DOWNLOA...
Install language packs provided
34,817
public function uninstall_language ( $ lang ) { global $ CFG ; $ dest1 = $ CFG -> dataroot . '/lang/' . $ lang ; $ dest2 = $ CFG -> dirroot . '/lang/' . $ lang ; $ rm1 = false ; $ rm2 = false ; if ( file_exists ( $ dest1 ) ) { $ rm1 = remove_dir ( $ dest1 ) ; } if ( file_exists ( $ dest2 ) ) { $ rm2 = remove_dir ( $ de...
Uninstall language pack
34,818
public function update_all_installed_languages ( ) { global $ CFG ; if ( ! $ availablelangs = $ this -> installer -> get_remote_list_of_languages ( ) ) { $ this -> errors [ ] = get_string ( 'cannotdownloadlanguageupdatelist' , 'error' ) ; return false ; } $ md5array = array ( ) ; foreach ( $ availablelangs as $ alang )...
Updated all install language packs with the latest found on servre
34,819
public function is_installed_lang ( $ lang , $ md5check ) { global $ CFG ; $ md5file = $ CFG -> dataroot . '/lang/' . $ lang . '/' . $ lang . '.md5' ; if ( file_exists ( $ md5file ) ) { return ( file_get_contents ( $ md5file ) == $ md5check ) ; } return false ; }
checks the md5 of the zip file grabbed from download . moodle . org against the md5 of the local language file from last update
34,820
private static function get_cached_grade_name ( $ courseid , $ gradeitemid ) { global $ DB , $ CFG ; require_once ( $ CFG -> libdir . '/gradelib.php' ) ; $ cache = \ cache :: make ( 'availability_grade' , 'items' ) ; if ( ( $ cacheditems = $ cache -> get ( $ courseid ) ) === false ) { $ cacheditems = $ DB -> get_record...
Obtains the name of a grade item also checking that it exists . Uses a cache . The name returned is suitable for display .
34,821
protected static function get_cached_grade_score ( $ gradeitemid , $ courseid , $ grabthelot = false , $ userid = 0 ) { global $ USER , $ DB ; if ( ! $ userid ) { $ userid = $ USER -> id ; } $ cache = \ cache :: make ( 'availability_grade' , 'scores' ) ; if ( ( $ cachedgrades = $ cache -> get ( $ userid ) ) === false )...
Obtains a grade score . Note that this score should not be displayed to the user because gradebook rules might prohibit that . It may be a non - final score subject to adjustment later .
34,822
public function addServer ( $ servername = 'localhost' , $ port = 0 , $ sharedSecret = 'testing123' , $ timeout = 3 , $ maxtries = 3 ) { $ this -> _servers [ ] = array ( $ servername , $ port , $ sharedSecret , $ timeout , $ maxtries ) ; }
Adds a RADIUS server to the list of servers for requests .
34,823
public function putAttribute ( $ attrib , $ value , $ type = null ) { if ( $ type == null ) { $ type = gettype ( $ value ) ; } switch ( $ type ) { case 'integer' : case 'double' : return radius_put_int ( $ this -> res , $ attrib , $ value ) ; case 'addr' : return radius_put_addr ( $ this -> res , $ attrib , $ value ) ;...
Puts an attribute .
34,824
public function putVendorAttribute ( $ vendor , $ attrib , $ value , $ type = null ) { if ( $ type == null ) { $ type = gettype ( $ value ) ; } switch ( $ type ) { case 'integer' : case 'double' : return radius_put_vendor_int ( $ this -> res , $ vendor , $ attrib , $ value ) ; case 'addr' : return radius_put_vendor_add...
Puts a vendor - specific attribute .
34,825
public function putStandardAttributes ( ) { if ( ! $ this -> useStandardAttributes ) { return ; } if ( isset ( $ _SERVER ) ) { $ var = $ _SERVER ; } else { $ var = $ GLOBALS [ 'HTTP_SERVER_VARS' ] ; } $ this -> putAttribute ( RADIUS_NAS_IDENTIFIER , isset ( $ var [ 'HTTP_HOST' ] ) ? $ var [ 'HTTP_HOST' ] : 'localhost' ...
Puts standard attributes .
34,826
public function putServer ( $ servername , $ port = 0 , $ sharedsecret = 'testing123' , $ timeout = 3 , $ maxtries = 3 ) { if ( ! radius_add_server ( $ this -> res , $ servername , $ port , $ sharedsecret , $ timeout , $ maxtries ) ) { return false ; } return true ; }
Configures the radius library .
34,827
public function start ( ) { if ( ! $ this -> open ( ) ) { return false ; } foreach ( $ this -> _servers as $ s ) { if ( ! $ this -> putServer ( $ s [ 0 ] , $ s [ 1 ] , $ s [ 2 ] , $ s [ 3 ] , $ s [ 4 ] ) ) { return false ; } } if ( ! empty ( $ this -> _configfile ) ) { if ( ! $ this -> putConfigfile ( $ this -> _config...
Initiates a RADIUS request .
34,828
public function send ( ) { $ req = radius_send_request ( $ this -> res ) ; if ( ! $ req ) { throw new Auth_RADIUS_Exception ( 'Error sending request: ' . $ this -> getError ( ) ) ; } switch ( $ req ) { case RADIUS_ACCESS_ACCEPT : if ( is_subclass_of ( $ this , 'auth_radius_acct' ) ) { throw new Auth_RADIUS_Exception ( ...
Sends a prepared RADIUS request and waits for a response
34,829
function putAuthAttributes ( ) { if ( isset ( $ this -> username ) ) { $ this -> putAttribute ( RADIUS_USER_NAME , $ this -> username ) ; } if ( isset ( $ this -> password ) ) { $ this -> putAttribute ( RADIUS_USER_PASSWORD , $ this -> password ) ; } }
Put authentication specific attributes
34,830
function putAuthAttributes ( ) { if ( isset ( $ this -> username ) ) { $ this -> putAttribute ( RADIUS_USER_NAME , $ this -> username ) ; } if ( isset ( $ this -> response ) ) { $ response = pack ( 'C' , $ this -> chapid ) . $ this -> response ; $ this -> putAttribute ( RADIUS_CHAP_PASSWORD , $ response ) ; } if ( isse...
Put CHAP - MD5 specific attributes
34,831
function putAuthAttributes ( ) { if ( isset ( $ this -> username ) ) { $ this -> putAttribute ( RADIUS_USER_NAME , $ this -> username ) ; } if ( isset ( $ this -> response ) || isset ( $ this -> lmResponse ) ) { $ lmResp = isset ( $ this -> lmResponse ) ? $ this -> lmResponse : str_repeat ( "\0" , 24 ) ; $ ntResp = iss...
Put MS - CHAPv1 specific attributes
34,832
function putAuthAttributes ( ) { if ( isset ( $ this -> username ) ) { $ this -> putAttribute ( RADIUS_USER_NAME , $ this -> username ) ; } if ( isset ( $ this -> response ) && isset ( $ this -> peerChallenge ) ) { $ resp = pack ( 'CCa16a8a24' , $ this -> chapid , 1 , $ this -> peerChallenge , str_repeat ( "\0" , 8 ) ,...
Put MS - CHAPv2 specific attributes
34,833
function putAuthAttributes ( ) { $ this -> putAttribute ( RADIUS_ACCT_SESSION_ID , $ this -> session_id ) ; $ this -> putAttribute ( RADIUS_ACCT_STATUS_TYPE , $ this -> status_type ) ; if ( isset ( $ this -> session_time ) && $ this -> status_type == RADIUS_STOP ) { $ this -> putAttribute ( RADIUS_ACCT_SESSION_TIME , $...
Put attributes for accounting .
34,834
protected function get_popover_title ( ) { $ title = null ; $ userdate = userdate ( $ this -> data [ 0 ] , get_string ( 'strftimedayshort' ) ) ; if ( count ( $ this -> related [ 'events' ] ) ) { $ title = get_string ( 'eventsfor' , 'calendar' , $ userdate ) ; } else if ( $ this -> data [ 'istoday' ] ) { $ title = $ use...
Get the title for this popover .
34,835
protected static function call_subplugins_method_with_args ( $ method , array $ args = [ ] , string $ interface = null ) { if ( ! isset ( $ interface ) ) { $ interface = \ tool_log \ local \ privacy \ logstore_provider :: class ; } \ core_privacy \ manager :: plugintype_class_callback ( 'logstore' , $ interface , $ met...
Invoke the subplugins method with arguments .
34,836
private function createZip ( $ pFilename ) { $ zipClass = PHPExcel_Settings :: getZipClass ( ) ; $ objZip = new $ zipClass ( ) ; $ ro = new ReflectionObject ( $ objZip ) ; $ zipOverWrite = $ ro -> getConstant ( 'OVERWRITE' ) ; $ zipCreate = $ ro -> getConstant ( 'CREATE' ) ; if ( file_exists ( $ pFilename ) ) { unlink ...
Create zip object
34,837
protected function _toSequenceString ( $ sort = true ) { return implode ( ' ' , count ( $ this -> _ids ) > 25000 ? array_unique ( $ this -> _ids ) : array_keys ( array_flip ( $ this -> _ids ) ) ) ; }
Create a POP3 message sequence string .
34,838
protected function get_filters_as_booleans ( ) { $ filters = [ BLOCK_TIMELINE_FILTER_BY_NONE => false , BLOCK_TIMELINE_FILTER_BY_OVERDUE => false , BLOCK_TIMELINE_FILTER_BY_7_DAYS => false , BLOCK_TIMELINE_FILTER_BY_30_DAYS => false , BLOCK_TIMELINE_FILTER_BY_3_MONTHS => false , BLOCK_TIMELINE_FILTER_BY_6_MONTHS => fal...
Test the available filters with the current user preference and return an array with bool flags corresponding to which is active
34,839
protected function notify_admins ( \ core \ oauth2 \ issuer $ issuer ) { global $ CFG ; $ admins = get_admins ( ) ; if ( empty ( $ admins ) ) { return ; } foreach ( $ admins as $ admin ) { $ strparams = [ 'siteurl' => $ CFG -> wwwroot , 'issuer' => $ issuer -> get ( 'name' ) ] ; $ long = get_string ( 'oauthrefreshtoken...
Notify admins when an OAuth refresh token expires . Should not happen if cron is running regularly .
34,840
function setMaxbytes ( $ maxbytes ) { global $ CFG , $ PAGE ; $ this -> _options [ 'maxbytes' ] = get_user_max_upload_file_size ( $ PAGE -> context , $ CFG -> maxbytes , $ maxbytes ) ; }
Sets maximum file size which can be uploaded
34,841
function toHtml ( ) { global $ CFG , $ USER , $ COURSE , $ PAGE , $ OUTPUT ; require_once ( "$CFG->dirroot/repository/lib.php" ) ; if ( isguestuser ( ) or ! isloggedin ( ) ) { print_error ( 'noguest' ) ; } if ( $ this -> _flagFrozen ) { return $ this -> getFrozenHtml ( ) ; } $ id = $ this -> _attributes [ 'id' ] ; $ el...
Returns HTML for filemanager form element .
34,842
public function validateSubmitValue ( $ value ) { if ( empty ( $ value ) ) { return ; } $ filetypesutil = new \ core_form \ filetypes_util ( ) ; $ whitelist = $ filetypesutil -> normalize_file_types ( $ this -> _options [ 'accepted_types' ] ) ; if ( empty ( $ whitelist ) || $ whitelist === [ '*' ] ) { return ; } $ draf...
Check that all files have the allowed type .
34,843
protected function tokenizeDOM ( $ node , & $ tokens , $ config ) { $ level = 0 ; $ nodes = array ( $ level => new HTMLPurifier_Queue ( array ( $ node ) ) ) ; $ closingNodes = array ( ) ; do { while ( ! $ nodes [ $ level ] -> isEmpty ( ) ) { $ node = $ nodes [ $ level ] -> shift ( ) ; $ collect = $ level > 0 ? true : f...
Iterative function that tokenizes a node putting it into an accumulator . To iterate is human to recurse divine - L . Peter Deutsch
34,844
public function process_question ( array $ data , array $ raw ) { if ( isset ( $ data [ 'answers' ] ) ) { $ this -> write_answers ( $ data [ 'answers' ] , $ this -> pluginname ) ; } foreach ( $ data [ 'multianswers' ] as $ multianswers ) { foreach ( $ multianswers as $ multianswer ) { $ this -> write_xml ( 'multianswer...
Appends the multianswer specific information to the question
34,845
protected static function ensure_collator_available ( ) { $ locale = get_string ( 'locale' , 'langconfig' ) ; if ( is_null ( self :: $ collator ) || $ locale != self :: $ locale ) { self :: $ collator = false ; self :: $ locale = $ locale ; if ( class_exists ( 'Collator' , false ) ) { $ collator = new Collator ( $ loca...
Ensures that a collator is available and created
34,846
protected static function restore_array ( array & $ arr , array & $ original ) { foreach ( $ arr as $ key => $ ignored ) { $ arr [ $ key ] = $ original [ $ key ] ; } }
Restore array contents keeping new keys .
34,847
public static function asort ( array & $ arr , $ sortflag = core_collator :: SORT_STRING ) { if ( empty ( $ arr ) ) { return true ; } $ original = null ; $ casesensitive = ( bool ) ( $ sortflag & core_collator :: CASE_SENSITIVE ) ; $ sortflag = ( $ sortflag & ~ core_collator :: CASE_SENSITIVE ) ; if ( $ sortflag != cor...
Locale aware sorting the key associations are kept values are sorted alphabetically .
34,848
public static function asort_objects_by_property ( array & $ objects , $ property , $ sortflag = core_collator :: SORT_STRING ) { $ original = $ objects ; foreach ( $ objects as $ key => $ object ) { $ objects [ $ key ] = $ object -> $ property ; } $ result = self :: asort ( $ objects , $ sortflag ) ; self :: restore_a...
Locale aware sort of objects by a property in common to all objects
34,849
public static function asort_objects_by_method ( array & $ objects , $ method , $ sortflag = core_collator :: SORT_STRING ) { $ original = $ objects ; foreach ( $ objects as $ key => $ object ) { $ objects [ $ key ] = $ object -> { $ method } ( ) ; } $ result = self :: asort ( $ objects , $ sortflag ) ; self :: restore...
Locale aware sort of objects by a method in common to all objects
34,850
public static function asort_array_of_arrays_by_key ( array & $ array , $ key , $ sortflag = core_collator :: SORT_STRING ) { $ original = $ array ; foreach ( $ array as $ initkey => $ item ) { $ array [ $ initkey ] = $ item [ $ key ] ; } $ result = self :: asort ( $ array , $ sortflag ) ; self :: restore_array ( $ arr...
Locale aware sort of array of arrays .
34,851
public static function ksort ( array & $ arr , $ sortflag = core_collator :: SORT_STRING ) { $ keys = array_keys ( $ arr ) ; if ( ! self :: asort ( $ keys , $ sortflag ) ) { return false ; } $ original = $ arr ; $ arr = array ( ) ; foreach ( $ keys as $ key ) { $ arr [ $ key ] = $ original [ $ key ] ; } return true ; }
Locale aware sorting the key associations are kept keys are sorted alphabetically .
34,852
private static function check_contexts ( context $ context , $ values ) { if ( $ context -> contextlevel > CONTEXT_COURSECAT ) { return self :: check_contexts ( $ context -> get_parent_context ( ) , $ values ) ; } else if ( $ context -> contextlevel == CONTEXT_COURSECAT ) { if ( in_array ( $ context -> instanceid , $ v...
Recursive function allows checking of parent categories .
34,853
public final function get_export_config ( $ key ) { $ allowed = array_merge ( array ( 'hidewait' , 'wait' , 'format' , 'hideformat' ) , $ this -> get_allowed_export_config ( ) ) ; if ( ! in_array ( $ key , $ allowed ) ) { $ a = ( object ) array ( 'property' => $ key , 'class' => get_class ( $ this ) ) ; throw new portf...
Gets an export time config value . Subclasses should not override this .
34,854
public static function create_instance ( $ plugin , $ name , $ config ) { global $ DB , $ CFG ; $ new = ( object ) array ( 'plugin' => $ plugin , 'name' => $ name , ) ; if ( ! portfolio_static_function ( $ plugin , 'allows_multiple_instances' ) ) { if ( $ DB -> record_exists ( 'portfolio_instance' , array ( 'plugin' =>...
This function creates a new instance of a plugin saves it in the database saves the config and returns it . You shouldn t need to override it unless you re doing something really funky
34,855
public final function get_config ( $ key ) { if ( ! in_array ( $ key , $ this -> get_allowed_config ( ) ) ) { $ a = ( object ) array ( 'property' => $ key , 'class' => get_class ( $ this ) ) ; throw new portfolio_export_exception ( $ this -> get ( 'exporter' ) , 'invalidconfigproperty' , 'portfolio' , null , $ a ) ; } ...
Gets the value of a particular config item
34,856
public final function get_user_config ( $ key , $ userid = 0 ) { global $ DB ; if ( empty ( $ userid ) ) { $ userid = $ this -> user -> id ; } if ( $ key != 'visible' ) { if ( ! in_array ( $ key , $ this -> get_allowed_user_config ( ) ) ) { $ a = ( object ) array ( 'property' => $ key , 'class' => get_class ( $ this ) ...
Get the value of a config item for a particular user .
34,857
public final function set_user_config ( $ config , $ userid = 0 ) { global $ DB ; if ( empty ( $ userid ) ) { $ userid = $ this -> user -> id ; } foreach ( $ config as $ key => $ value ) { if ( $ key != 'visible' && ! in_array ( $ key , $ this -> get_allowed_user_config ( ) ) ) { $ a = ( object ) array ( 'property' => ...
Sets config options for a given user .
34,858
public function addElement ( $ element , $ type , $ contents , $ attr_includes = array ( ) , $ attr = array ( ) ) { $ this -> elements [ ] = $ element ; list ( $ content_model_type , $ content_model ) = $ this -> parseContents ( $ contents ) ; $ this -> mergeInAttrIncludes ( $ attr , $ attr_includes ) ; if ( $ type ) {...
Convenience function that sets up a new element
34,859
public function addBlankElement ( $ element ) { if ( ! isset ( $ this -> info [ $ element ] ) ) { $ this -> elements [ ] = $ element ; $ this -> info [ $ element ] = new HTMLPurifier_ElementDef ( ) ; $ this -> info [ $ element ] -> standalone = false ; } else { trigger_error ( "Definition for $element already exists in...
Convenience function that creates a totally blank non - standalone element .
34,860
public function addElementToContentSet ( $ element , $ type ) { if ( ! isset ( $ this -> content_sets [ $ type ] ) ) { $ this -> content_sets [ $ type ] = '' ; } else { $ this -> content_sets [ $ type ] .= ' | ' ; } $ this -> content_sets [ $ type ] .= $ element ; }
Convenience function that registers an element to a content set
34,861
private function executeCommand ( Server $ server ) { $ cmd = [ 'createIndexes' => $ this -> collectionName , 'indexes' => $ this -> indexes , ] ; if ( isset ( $ this -> options [ 'maxTimeMS' ] ) ) { $ cmd [ 'maxTimeMS' ] = $ this -> options [ 'maxTimeMS' ] ; } $ server -> executeWriteCommand ( $ this -> databaseName ,...
Create one or more indexes for the collection using the createIndexes command .
34,862
protected function createMetaInfoFolderAndFile ( ) { $ this -> metaInfFolder = $ this -> createFolder ( $ this -> rootFolder , self :: META_INF_FOLDER_NAME ) ; $ this -> createManifestFile ( ) ; return $ this ; }
Creates the META - INF folder under the root folder as well as the manifest . xml file in it
34,863
protected function createSheetsContentTempFolder ( ) { $ this -> sheetsContentTempFolder = $ this -> createFolder ( $ this -> rootFolder , self :: SHEETS_CONTENT_TEMP_FOLDER_NAME ) ; return $ this ; }
Creates the temp folder where specific sheets content will be written to . This folder is not part of the final ODS file and is only used to be able to jump between sheets .
34,864
protected function createMetaFile ( ) { $ appName = self :: APP_NAME ; $ createdDate = ( new \ DateTime ( ) ) -> format ( \ DateTime :: W3C ) ; $ metaXmlFileContents = <<<EOD<?xml version="1.0" encoding="UTF-8" standalone="yes"?><office:document-meta office:version="1.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xml...
Creates the meta . xml file under the root folder
34,865
protected function createMimetypeFile ( ) { $ this -> createFileWithContents ( $ this -> rootFolder , self :: MIMETYPE_FILE_NAME , self :: MIMETYPE ) ; return $ this ; }
Creates the mimetype file under the root folder
34,866
public function createContentFile ( $ worksheets , $ styleHelper ) { $ contentXmlFileContents = <<<EOD<?xml version="1.0" encoding="UTF-8" standalone="yes"?><office:document-content office:version="1.2" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:...
Creates the content . xml file under the root folder
34,867
protected function copyFileContentsToTarget ( $ sourceFilePath , $ targetResource ) { $ sourceHandle = fopen ( $ sourceFilePath , 'r' ) ; stream_copy_to_stream ( $ sourceHandle , $ targetResource ) ; fclose ( $ sourceHandle ) ; }
Streams the content of the file at the given path into the target resource . Depending on which mode the target resource was created with it will truncate then copy or append the content to the target file .
34,868
public function createStylesFile ( $ styleHelper , $ numWorksheets ) { $ stylesXmlFileContents = $ styleHelper -> getStylesXMLFileContent ( $ numWorksheets ) ; $ this -> createFileWithContents ( $ this -> rootFolder , self :: STYLES_XML_FILE_NAME , $ stylesXmlFileContents ) ; return $ this ; }
Creates the styles . xml file under the root folder
34,869
public function definition ( ) { $ mform = $ this -> _form ; $ mform -> addElement ( 'select' , 'size' , get_string ( 'size' , 'tool_generator' ) , tool_generator_course_backend :: get_size_choices ( ) ) ; $ mform -> setDefault ( 'size' , tool_generator_course_backend :: DEFAULT_SIZE ) ; $ mform -> addElement ( 'text' ...
Course generation tool form definition .
34,870
public static function get_sorted_subjects ( ) { $ subjects = get_string_manager ( ) -> load_component_strings ( 'edufields' , current_language ( ) ) ; $ return = [ ] ; asort ( $ subjects ) ; foreach ( $ subjects as $ key => $ option ) { $ keylength = strlen ( $ key ) ; if ( $ keylength == 12 ) { $ return [ $ key ] = $...
Retrieve all the sorted course subjects
34,871
public static function get_course_publications ( $ courseid ) { global $ DB ; $ sql = 'SELECT cp.id, cp.status, cp.timechecked, cp.timepublished, rh.hubname, rh.huburl, cp.courseid, cp.enrollable, cp.hubcourseid FROM {course_published} cp, {registration_hubs} rh WHERE...
Get all publication for a course
34,872
public static function get_publication ( $ id , $ courseid = 0 , $ strictness = IGNORE_MISSING ) { global $ DB ; if ( ! $ id && $ strictness != MUST_EXIST ) { return false ; } $ params = [ 'id' => $ id , 'huburl' => HUB_MOODLEORGHUBURL ] ; if ( $ courseid ) { $ params [ 'courseid' ] = $ courseid ; } return $ DB -> get_...
Load publication information from local db
34,873
public static function request_status_update ( ) { global $ DB ; list ( $ sitecourses , $ coursetotal ) = api :: get_courses ( '' , 1 , 1 , [ 'allsitecourses' => 1 ] ) ; foreach ( $ sitecourses as $ sitecourse ) { $ publication = $ DB -> get_record ( 'course_published' , [ 'hubcourseid' => $ sitecourse [ 'id' ] ] ) ; i...
Check all courses published from this site if they have been approved
34,874
public static function unpublish ( $ publication ) { global $ DB ; api :: unregister_courses ( $ publication -> hubcourseid ) ; $ DB -> delete_records ( 'course_published' , array ( 'id' => $ publication -> id ) ) ; $ course = get_course ( $ publication -> courseid ) ; $ context = \ context_course :: instance ( $ cours...
Unpublish a course
34,875
public static function publish_course ( $ courseinfo , $ files ) { global $ DB ; $ courseid = $ courseinfo -> sitecourseid ; try { $ hubcourseid = api :: register_course ( $ courseinfo ) ; } catch ( Exception $ e ) { throw new moodle_exception ( 'errorcoursepublish' , 'hub' , new moodle_url ( '/course/view.php' , array...
Publish a course
34,876
public static function delete_all_publications ( $ advertised = true , $ shared = true ) { global $ DB ; if ( ! $ advertised && ! $ shared ) { return true ; } $ params = [ 'huburl' => HUB_MOODLEORGHUBURL ] ; if ( ! $ advertised || ! $ shared ) { $ params [ 'enrollable' ] = $ advertised ? 1 : 0 ; } if ( ! $ publications...
Delete all publications
34,877
public static function educational_level_options ( $ any = false ) { $ options = array ( ) ; if ( $ any ) { $ options [ 'all' ] = get_string ( 'any' ) ; } $ options [ self :: HUB_EDULEVEL_PRIMARY ] = get_string ( 'edulevelprimary' , 'hub' ) ; $ options [ self :: HUB_EDULEVEL_SECONDARY ] = get_string ( 'edulevelsecondar...
List of available educational levels
34,878
public static function audience_options ( $ any = false ) { $ options = array ( ) ; if ( $ any ) { $ options [ 'all' ] = get_string ( 'any' ) ; } $ options [ self :: HUB_AUDIENCE_EDUCATORS ] = get_string ( 'audienceeducators' , 'hub' ) ; $ options [ self :: HUB_AUDIENCE_STUDENTS ] = get_string ( 'audiencestudents' , 'h...
List of available audience options
34,879
public static function search ( $ search , $ downloadable , $ options ) { try { return api :: get_courses ( $ search , $ downloadable , ! $ downloadable , $ options ) ; } catch ( moodle_exception $ e ) { \ core \ notification :: add ( get_string ( 'errorcourselisting' , 'block_community' , $ e -> getMessage ( ) ) , \ c...
Search for courses
34,880
public static function get_published_course ( $ publication ) { try { list ( $ courses , $ unused ) = api :: get_courses ( '' , ! $ publication -> enrollable , $ publication -> enrollable , [ 'ids' => [ $ publication -> hubcourseid ] , 'allsitecourses' => 1 ] ) ; return reset ( $ courses ) ; } catch ( \ Exception $ e )...
Retrieves information about published course
34,881
public static function download_course_backup ( $ hubcourseid , $ coursename ) { global $ CFG , $ USER ; require_once ( $ CFG -> libdir . "/filelib.php" ) ; $ backuptempdir = make_backup_temp_directory ( '' ) ; $ filename = md5 ( time ( ) . '-' . $ hubcourseid . '-' . $ USER -> id . '-' . random_string ( 20 ) ) ; $ pat...
Downloads course backup and stores it in the user private files
34,882
public function build ( stdClass $ user , array $ forums , array $ discussions , array $ posts ) : array { $ forums = array_reduce ( $ forums , function ( $ carry , $ forum ) { $ carry [ $ forum -> get_id ( ) ] = $ forum ; return $ carry ; } , [ ] ) ; $ discussions = array_reduce ( $ discussions , function ( $ carry , ...
Build the exported posts for a given set of forums discussions and posts .
34,883
private function group_posts_by_discussion ( array $ forums , array $ discussions , array $ posts ) : array { return array_reduce ( $ posts , function ( $ carry , $ post ) use ( $ forums , $ discussions ) { $ discussionid = $ post -> get_discussion_id ( ) ; if ( ! isset ( $ discussions [ $ discussionid ] ) ) { throw ne...
Group the posts by which discussion they belong to in order for them to be processed in chunks by the exporting .
34,884
private function get_attachments_for_posts ( array $ groupedposts ) : array { $ attachmentsbypostid = [ ] ; $ postattachmentvault = $ this -> vaultfactory -> get_post_attachment_vault ( ) ; $ postsbyforum = array_reduce ( $ groupedposts , function ( $ carry , $ grouping ) { [ 'forum' => $ forum , 'posts' => $ posts ] =...
Load the list of all attachments for the posts . The list of attachments will be indexed by the post id .
34,885
private function get_author_groups_from_posts ( array $ groupedposts ) : array { $ groupsbyauthorid = [ ] ; $ authoridsbycourseid = [ ] ; foreach ( $ groupedposts as $ grouping ) { [ 'forum' => $ forum , 'posts' => $ posts ] = $ grouping ; $ course = $ forum -> get_course_record ( ) ; $ courseid = $ course -> id ; if (...
Get the groups for each author of the given posts .
34,886
private function get_tags_from_posts ( array $ posts ) : array { $ postids = array_map ( function ( $ post ) { return $ post -> get_id ( ) ; } , $ posts ) ; return core_tag_tag :: get_items_tags ( 'mod_forum' , 'forum_posts' , $ postids ) ; }
Get the list of tags for each of the posts . The tags will be returned in an array indexed by the post id .
34,887
private function get_ratings_from_posts ( stdClass $ user , array $ groupedposts ) { $ ratingsbypostid = [ ] ; $ postsdatamapper = $ this -> legacydatamapperfactory -> get_post_data_mapper ( ) ; $ postsbyforum = array_reduce ( $ groupedposts , function ( $ carry , $ grouping ) { [ 'forum' => $ forum , 'posts' => $ post...
Get the list of ratings for each post . The ratings are returned in an array indexed by the post id .
34,888
private function get_read_receipts_from_posts ( stdClass $ user , array $ groupedposts ) { $ forumdatamapper = $ this -> legacydatamapperfactory -> get_forum_data_mapper ( ) ; $ trackedforums = [ ] ; $ trackedpostids = [ ] ; foreach ( $ groupedposts as $ group ) { [ 'forum' => $ forum , 'posts' => $ posts ] = $ group ;...
Get the read receipt collections for the given viewing user and each forum . The receipt collections will only be loaded for posts in forums that the user is tracking .
34,889
private function sort_exported_posts ( array $ posts , array $ exportedposts ) { $ postindexes = [ ] ; foreach ( array_values ( $ posts ) as $ index => $ post ) { $ postindexes [ $ post -> get_id ( ) ] = $ index ; } $ sortedexportedposts = [ ] ; foreach ( $ exportedposts as $ exportedpost ) { $ index = $ postindexes [ ...
Sort the list of exported posts back into the same order as the given posts . The ordering of the exported posts can often deviate from the given posts due to the process of exporting them so we need to sort them back into the order that the calling code expected .
34,890
private function readSplitMenuColors ( ) { $ length = PHPExcel_Reader_Excel5 :: getInt4d ( $ this -> data , $ this -> pos + 4 ) ; $ recordData = substr ( $ this -> data , $ this -> pos + 8 , $ length ) ; $ this -> pos += 8 + $ length ; }
Read SplitMenuColors record
34,891
private function get_new_scale_definition ( $ oldscaleid ) { $ data = array ( 'userid' => 0 , 'courseid' => 0 , 'description' => '' , 'descriptionformat' => FORMAT_HTML , ) ; switch ( $ oldscaleid ) { case 0 : $ data [ 'name' ] = get_string ( 'scalename0' , 'workshopform_accumulative' ) ; $ data [ 'scale' ] = implode (...
Returns a definition of a legacy workshop scale
34,892
public static function delete_field ( $ id ) { $ params = self :: validate_parameters ( self :: delete_field_parameters ( ) , [ 'id' => $ id ] ) ; $ record = \ core_customfield \ field_controller :: create ( $ params [ 'id' ] ) ; $ handler = $ record -> get_handler ( ) ; if ( ! $ handler -> can_configure ( ) ) { throw ...
Delete custom field function
34,893
public static function reload_template_parameters ( ) { return new external_function_parameters ( array ( 'component' => new external_value ( PARAM_COMPONENT , 'component' , VALUE_REQUIRED ) , 'area' => new external_value ( PARAM_ALPHANUMEXT , 'area' , VALUE_REQUIRED ) , 'itemid' => new external_value ( PARAM_INT , 'it...
Parameters for reload template function
34,894
public static function reload_template ( $ component , $ area , $ itemid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: reload_template_parameters ( ) , [ 'component' => $ component , 'area' => $ area , 'itemid' => $ itemid ] ) ; $ PAGE -> set_context ( context_system :: instance ( ) ) ; $ handler...
Reload template function
34,895
public static function reload_template_returns ( ) { return new external_single_structure ( array ( 'component' => new external_value ( PARAM_COMPONENT , 'component' ) , 'area' => new external_value ( PARAM_ALPHANUMEXT , 'area' ) , 'itemid' => new external_value ( PARAM_INT , 'itemid' ) , 'usescategories' => new extern...
Ajax returns on reload template .
34,896
public static function delete_category ( $ id ) { $ category = core_customfield \ category_controller :: create ( $ id ) ; $ handler = $ category -> get_handler ( ) ; self :: validate_context ( $ handler -> get_configuration_context ( ) ) ; if ( ! $ handler -> can_configure ( ) ) { throw new moodle_exception ( 'nopermi...
Delete category function
34,897
public static function create_category_parameters ( ) { return new external_function_parameters ( array ( 'component' => new external_value ( PARAM_COMPONENT , 'component' , VALUE_REQUIRED ) , 'area' => new external_value ( PARAM_ALPHANUMEXT , 'area' , VALUE_REQUIRED ) , 'itemid' => new external_value ( PARAM_INT , 'it...
Parameters for create category
34,898
public static function create_category ( $ component , $ area , $ itemid ) { $ params = self :: validate_parameters ( self :: create_category_parameters ( ) , [ 'component' => $ component , 'area' => $ area , 'itemid' => $ itemid ] ) ; $ handler = \ core_customfield \ handler :: get_handler ( $ params [ 'component' ] ,...
Create category function
34,899
public static function move_field_parameters ( ) { return new external_function_parameters ( [ 'id' => new external_value ( PARAM_INT , 'Id of the field to move' , VALUE_REQUIRED ) , 'categoryid' => new external_value ( PARAM_INT , 'New parent category id' , VALUE_REQUIRED ) , 'beforeid' => new external_value ( PARAM_I...
Parameters for move field .