idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
32,800 | protected function get_javascript_code ( $ ondomready ) { $ where = $ ondomready ? 'ondomready' : 'normal' ; $ output = '' ; if ( $ this -> jscalls [ $ where ] ) { foreach ( $ this -> jscalls [ $ where ] as $ data ) { $ output .= js_writer :: function_call ( $ data [ 0 ] , $ data [ 1 ] , $ data [ 2 ] ) ; } if ( ! empty... | Get the inline JavaScript code that need to appear in a particular place . |
32,801 | protected function get_yui3lib_headcss ( ) { global $ CFG ; $ yuiformat = '-min' ; if ( $ this -> yui3loader -> filter === 'RAW' ) { $ yuiformat = '' ; } $ code = '' ; if ( $ this -> yui3loader -> combine ) { if ( ! empty ( $ this -> yuicssmodules ) ) { $ modules = array ( ) ; foreach ( $ this -> yuicssmodules as $ mod... | Returns basic YUI3 CSS code . |
32,802 | protected function get_yui3lib_headcode ( ) { global $ CFG ; $ jsrev = $ this -> get_jsrev ( ) ; $ yuiformat = '-min' ; if ( $ this -> yui3loader -> filter === 'RAW' ) { $ yuiformat = '' ; } $ format = '-min' ; if ( $ this -> YUI_config -> groups [ 'moodle' ] [ 'filter' ] === 'DEBUG' ) { $ format = '-debug' ; } $ rollu... | Returns basic YUI3 JS loading code . |
32,803 | protected function get_css_code ( ) { $ attributes = array ( 'rel' => 'stylesheet' , 'type' => 'text/css' ) ; $ code = $ this -> get_yui3lib_headcss ( ) ; $ code .= html_writer :: tag ( 'script' , '/** Required in order to fix style inclusion problems in IE with YUI **/' , array ( 'id' => 'firstthemesheet' , 'type' => ... | Returns html tags needed for inclusion of theme CSS . |
32,804 | protected function get_extra_modules_code ( ) { if ( empty ( $ this -> extramodules ) ) { return '' ; } return html_writer :: script ( js_writer :: function_call ( 'M.yui.add_module' , array ( $ this -> extramodules ) ) ) ; } | Adds extra modules specified after printing of page header . |
32,805 | public function get_end_code ( ) { global $ CFG ; $ output = '' ; $ logconfig = new stdClass ( ) ; $ logconfig -> level = 'warn' ; if ( $ CFG -> debugdeveloper ) { $ logconfig -> level = 'trace' ; } $ this -> js_call_amd ( 'core/log' , 'setConfig' , array ( $ logconfig ) ) ; $ this -> js_call_amd ( 'core/page_global' ,... | Generate any HTML that needs to go at the end of the page . |
32,806 | public function add_group ( $ name , $ config ) { if ( isset ( $ this -> groups [ $ name ] ) ) { throw new coding_exception ( "A YUI configuration group for '{$name}' already exists. To make changes to this group use YUI_config->update_group()." ) ; } $ this -> groups [ $ name ] = $ config ; } | Create a new group within the YUI_config system . |
32,807 | public function update_group ( $ name , $ config ) { if ( ! isset ( $ this -> groups [ $ name ] ) ) { throw new coding_exception ( 'The Moodle YUI module does not exist. You must define the moodle module config using YUI_config->add_module_config first.' ) ; } $ this -> groups [ $ name ] = $ config ; } | Update an existing group configuration |
32,808 | public function set_config_function ( $ function ) { $ configname = 'yui' . ( count ( $ this -> jsconfigfunctions ) + 1 ) . 'ConfigFn' ; if ( isset ( $ this -> jsconfigfunctions [ $ configname ] ) ) { throw new coding_exception ( "A YUI config function with this name already exists. Config function names must be unique... | Set the value of a configuration function used by the YUI Loader s pattern testing . |
32,809 | public function get_config_functions ( ) { $ configfunctions = '' ; foreach ( $ this -> jsconfigfunctions as $ functionname => $ function ) { $ configfunctions .= "var {$functionname} = function(me) {" ; $ configfunctions .= $ function ; $ configfunctions .= "};\n" ; } return $ configfunctions ; } | Retrieve the list of JavaScript functions for YUI_config groups . |
32,810 | public function update_header_js ( $ js ) { foreach ( $ this -> jsconfigfunctions as $ functionname => $ function ) { $ js = str_replace ( '"@' . $ functionname . '@"' , $ functionname , $ js ) ; } return $ js ; } | Update the header JavaScript with any required modification for the YUI Loader . |
32,811 | public function add_module_config ( $ name , $ config , $ group = null ) { if ( $ group ) { if ( ! isset ( $ this -> groups [ $ name ] ) ) { throw new coding_exception ( 'The Moodle YUI module does not exist. You must define the moodle module config using YUI_config->add_module_config first.' ) ; } if ( ! isset ( $ thi... | Add configuration for a specific module . |
32,812 | public function add_moodle_metadata ( ) { global $ CFG ; if ( ! isset ( $ this -> groups [ 'moodle' ] ) ) { throw new coding_exception ( 'The Moodle YUI module does not exist. You must define the moodle module config using YUI_config->add_module_config first.' ) ; } if ( ! isset ( $ this -> groups [ 'moodle' ] [ 'modul... | Add the moodle YUI module metadata for the moodle group to the YUI_config instance . |
32,813 | private function get_moodle_metadata ( ) { $ moodlemodules = array ( ) ; if ( $ module = $ this -> get_moodle_path_metadata ( core_component :: get_component_directory ( 'core' ) ) ) { $ moodlemodules = array_merge ( $ moodlemodules , $ module ) ; } $ subsystems = core_component :: get_core_subsystems ( ) ; foreach ( $... | Determine the module metadata for all moodle YUI modules . |
32,814 | private function get_moodle_path_metadata ( $ path ) { $ baseyui = $ path . '/yui/src' ; $ modules = array ( ) ; if ( is_dir ( $ baseyui ) ) { $ items = new DirectoryIterator ( $ baseyui ) ; foreach ( $ items as $ item ) { if ( $ item -> isDot ( ) or ! $ item -> isDir ( ) ) { continue ; } $ metafile = realpath ( $ base... | Helper function process and return the YUI metadata for all of the modules under the specified path . |
32,815 | public function define_patched_core_modules ( $ combobase , $ yuiversion , $ patchlevel , $ patchedmodules ) { $ subversion = $ yuiversion . '_' . $ patchlevel ; if ( $ this -> comboBase == $ combobase ) { $ patterns = array ( ) ; $ modules = array ( ) ; foreach ( $ patchedmodules as $ modulename ) { $ patterns [ $ mod... | Define YUI modules which we have been required to patch between releases . |
32,816 | public static function data_for_report ( $ courseid , $ userid , $ moduleid ) { global $ PAGE ; $ params = self :: validate_parameters ( self :: data_for_report_parameters ( ) , array ( 'courseid' => $ courseid , 'userid' => $ userid , 'moduleid' => $ moduleid ) ) ; $ context = context_course :: instance ( $ params [ '... | Loads the data required to render the report . |
32,817 | public function decrypt ( $ value ) { if ( ! function_exists ( 'openssl_encrypt' ) ) { return null ; } if ( ! function_exists ( 'hash_hmac' ) ) { return null ; } if ( ! in_array ( backup :: CIPHER , openssl_get_cipher_methods ( ) ) ) { return null ; } $ key = get_config ( 'backup' , 'backup_encryptkey' ) ; if ( $ key =... | Returns symmetric - key AES - 256 decryption of base64 encoded contents . |
32,818 | protected function get_unique_db_instance_id ( ) { global $ CFG ; $ strkey = $ CFG -> dbname . ':' . $ CFG -> prefix ; $ intkey = crc32 ( $ strkey ) ; if ( PHP_INT_SIZE == 8 ) { if ( $ intkey > 0x7FFFFFFF ) { $ intkey -= 0x100000000 ; } } return $ intkey ; } | Calculate a unique instance id based on the database name and prefix . |
32,819 | protected function get_index_from_key ( $ key ) { if ( isset ( self :: $ lockidcache [ $ key ] ) ) { return self :: $ lockidcache [ $ key ] ; } $ index = 0 ; $ record = $ this -> db -> get_record ( 'lock_db' , array ( 'resourcekey' => $ key ) ) ; if ( $ record ) { $ index = $ record -> id ; } if ( ! $ index ) { $ recor... | This function generates the unique index for a specific lock key . Once an index is assigned to a key it never changes - so this is statically cached . |
32,820 | public function auto_release ( ) { foreach ( $ this -> openlocks as $ key => $ unused ) { $ lock = new lock ( $ key , $ this ) ; $ lock -> release ( ) ; } } | Auto release any open locks on shutdown . This is required because we may be using persistent DB connections . |
32,821 | public function update_stats ( ) { $ temptables = $ this -> get_temptables ( ) ; foreach ( $ temptables as $ temptablename ) { $ this -> mdb -> execute ( "ANALYZE {" . $ temptablename . "}" ) ; } } | Analyze the data in temporary tables to force statistics collection after bulk data loads . PostgreSQL does not natively support automatic temporary table stats collection so we do it . |
32,822 | public function register ( $ doctype , $ xml = true , $ modules = array ( ) , $ tidy_modules = array ( ) , $ aliases = array ( ) , $ dtd_public = null , $ dtd_system = null ) { if ( ! is_array ( $ modules ) ) { $ modules = array ( $ modules ) ; } if ( ! is_array ( $ tidy_modules ) ) { $ tidy_modules = array ( $ tidy_mo... | Registers a doctype to the registry |
32,823 | public function get ( $ doctype ) { if ( isset ( $ this -> aliases [ $ doctype ] ) ) { $ doctype = $ this -> aliases [ $ doctype ] ; } if ( ! isset ( $ this -> doctypes [ $ doctype ] ) ) { trigger_error ( 'Doctype ' . htmlspecialchars ( $ doctype ) . ' does not exist' , E_USER_ERROR ) ; $ anon = new HTMLPurifier_Doctyp... | Retrieves reference to a doctype of a certain name |
32,824 | public function getDoctypeFromConfig ( $ config ) { $ doctype = $ config -> get ( 'HTML.Doctype' ) ; if ( ! empty ( $ doctype ) ) { return $ doctype ; } $ doctype = $ config -> get ( 'HTML.CustomDoctype' ) ; if ( ! empty ( $ doctype ) ) { return $ doctype ; } if ( $ config -> get ( 'HTML.XHTML' ) ) { $ doctype = 'XHTML... | Retrieves the doctype from the configuration object |
32,825 | public function manage_messageoutput_settings ( $ allprocessors , $ processors , $ providers , $ preferences ) { $ output = html_writer :: start_tag ( 'form' , array ( 'id' => 'defaultmessageoutputs' , 'method' => 'post' ) ) ; $ output .= html_writer :: empty_tag ( 'input' , array ( 'type' => 'hidden' , 'name' => 'sess... | Display the interface to manage both message outputs and default message outputs |
32,826 | public function manage_messageoutputs ( $ processors ) { $ table = new html_table ( ) ; $ table -> attributes [ 'class' ] = 'admintable generaltable' ; $ table -> data = array ( ) ; $ table -> head = array ( get_string ( 'name' ) , get_string ( 'enable' ) , get_string ( 'settings' ) , ) ; $ table -> colclasses = array ... | Display the interface to manage message outputs |
32,827 | public function render_user_notification_preferences ( $ user ) { $ processors = get_message_processors ( ) ; $ providers = message_get_providers_for_user ( $ user -> id ) ; $ preferences = \ core_message \ api :: get_all_message_preferences ( $ processors , $ providers , $ user ) ; $ notificationlistoutput = new \ cor... | Display the interface for notification preferences |
32,828 | public function render_user_message_preferences ( $ user ) { global $ CFG ; $ readyprocessors = array_filter ( get_message_processors ( ) , function ( $ processor ) { return $ processor -> enabled && $ processor -> configured && $ processor -> object -> is_user_configured ( ) && $ processor -> object -> has_message_pre... | Display the interface for message preferences |
32,829 | static function pathGet ( $ values , $ path , $ default = NULL ) { foreach ( $ path as $ key ) { if ( ! is_array ( $ values ) || ! isset ( $ values [ $ key ] ) ) { return $ default ; } $ values = $ values [ $ key ] ; } return $ values ; } | Get a single value from an array - tree . |
32,830 | static function pathIsset ( $ values , $ path ) { foreach ( $ path as $ key ) { if ( ! is_array ( $ values ) || ! isset ( $ values [ $ key ] ) ) { return FALSE ; } $ values = $ values [ $ key ] ; } return TRUE ; } | Check if a key isset which may be several layers deep . |
32,831 | static function pathSet ( & $ values , $ pathParts , $ value ) { $ r = & $ values ; $ last = array_pop ( $ pathParts ) ; foreach ( $ pathParts as $ part ) { if ( ! isset ( $ r [ $ part ] ) ) { $ r [ $ part ] = array ( ) ; } $ r = & $ r [ $ part ] ; } $ r [ $ last ] = $ value ; } | Set a single value in an array tree . |
32,832 | static function recursiveBuild ( $ path , $ value , $ source = array ( ) ) { self :: pathSet ( $ source , $ path , $ value ) ; return $ source ; } | Append the value to the array using the key provided . |
32,833 | public static function submit_choice_response ( $ choiceid , $ responses ) { global $ USER ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: submit_choice_response_parameters ( ) , array ( 'choiceid' => $ choiceid , 'responses' => $ responses ) ) ; if ( ! $ choice = choice_get_choice ( $ param... | Submit choice responses |
32,834 | public static function submit_choice_response_returns ( ) { return new external_single_structure ( array ( 'answers' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'answer id' ) , 'choiceid' => new external_value ( PARAM_INT , 'choiceid' ) , 'userid... | Describes the submit_choice_response return value . |
32,835 | public static function get_choices_by_courses_returns ( ) { return new external_single_structure ( array ( 'choices' => new external_multiple_structure ( new external_single_structure ( array ( 'id' => new external_value ( PARAM_INT , 'Choice instance id' ) , 'coursemodule' => new external_value ( PARAM_INT , 'Course m... | Describes the mod_choice_get_choices_by_courses return value . |
32,836 | public static function delete_choice_responses ( $ choiceid , $ responses = array ( ) ) { $ status = false ; $ warnings = array ( ) ; $ params = self :: validate_parameters ( self :: delete_choice_responses_parameters ( ) , array ( 'choiceid' => $ choiceid , 'responses' => $ responses ) ) ; if ( ! $ choice = choice_get... | Delete the given submitted responses in a choice |
32,837 | private static function get_enabled ( ) { global $ CFG ; $ active = array ( ) ; if ( empty ( $ CFG -> antiviruses ) ) { return $ active ; } foreach ( explode ( ',' , $ CFG -> antiviruses ) as $ e ) { if ( $ antivirus = self :: get_antivirus ( $ e ) ) { if ( $ antivirus -> is_configured ( ) ) { $ active [ $ e ] = $ anti... | Returns list of enabled antiviruses . |
32,838 | public static function scan_file ( $ file , $ filename , $ deleteinfected ) { $ antiviruses = self :: get_enabled ( ) ; foreach ( $ antiviruses as $ antivirus ) { $ result = $ antivirus -> scan_file ( $ file , $ filename ) ; if ( $ result === $ antivirus :: SCAN_RESULT_FOUND ) { if ( $ deleteinfected ) { unlink ( $ fil... | Scan file using all enabled antiviruses throws exception in case of infected file . |
32,839 | public static function scan_data ( $ data ) { $ antiviruses = self :: get_enabled ( ) ; foreach ( $ antiviruses as $ antivirus ) { $ result = $ antivirus -> scan_data ( $ data ) ; if ( $ result === $ antivirus :: SCAN_RESULT_FOUND ) { throw new \ core \ antivirus \ scanner_exception ( 'virusfound' , '' , array ( 'item'... | Scan data steam using all enabled antiviruses throws exception in case of infected data . |
32,840 | public static function get_available ( ) { $ antiviruses = array ( ) ; foreach ( \ core_component :: get_plugin_list ( 'antivirus' ) as $ antivirusname => $ dir ) { $ antiviruses [ $ antivirusname ] = get_string ( 'pluginname' , 'antivirus_' . $ antivirusname ) ; } return $ antiviruses ; } | Get the list of available antiviruses . |
32,841 | protected function register_type ( $ identifier , $ datatransfertypes , $ addmessage , $ namemessage , $ handlermessage , $ priority = 100 ) { if ( $ this -> is_known_type ( $ identifier ) ) { throw new coding_exception ( "Type $identifier is already registered" ) ; } $ add = new stdClass ; $ add -> identifier = $ iden... | Used to add a new mime type that can be drag and dropped onto a course displayed in a browser window |
32,842 | protected function register_type_handler ( $ type , $ module , $ message , $ noname ) { if ( ! $ this -> is_known_type ( $ type ) ) { throw new coding_exception ( "Trying to add handler for unknown type $type" ) ; } $ add = new stdClass ; $ add -> type = $ type ; $ add -> module = $ module ; $ add -> message = $ messag... | Used to declare that a particular module will handle a particular type of dropped data |
32,843 | protected function register_file_handler ( $ extension , $ module , $ message ) { $ extension = strtolower ( $ extension ) ; $ add = new stdClass ; $ add -> extension = $ extension ; $ add -> module = $ module ; $ add -> message = $ message ; $ this -> filehandlers [ ] = $ add ; } | Used to declare that a particular module will handle a particular type of dropped file |
32,844 | public function has_type_handler ( $ module , $ type ) { if ( ! $ this -> is_known_type ( $ type ) ) { throw new coding_exception ( "Checking for handler for unknown type $type" ) ; } foreach ( $ this -> types [ $ type ] -> handlers as $ handler ) { if ( $ handler -> module == $ module ) { return true ; } } return fals... | Check to see if the module in question has registered to handle the type given |
32,845 | public function get_handled_file_types ( $ module ) { $ types = array ( ) ; foreach ( $ this -> filehandlers as $ handler ) { if ( $ handler -> module == $ module ) { if ( $ handler -> extension == '*' ) { return '*' ; } else { $ types [ ] = '.' . $ handler -> extension ; } } } return $ types ; } | Gets a list of the file types that are handled by a particular module |
32,846 | protected function type_compare ( $ type1 , $ type2 ) { if ( $ type1 -> priority < $ type2 -> priority ) { return - 1 ; } if ( $ type1 -> priority > $ type2 -> priority ) { return 1 ; } return 0 ; } | Comparison function used when sorting types by priority |
32,847 | public function process ( $ displayname = null , $ content = null ) { require_capability ( 'moodle/course:manageactivities' , $ this -> context ) ; if ( $ this -> is_file_upload ( ) ) { require_capability ( 'moodle/course:managefiles' , $ this -> context ) ; if ( $ content != null ) { throw new moodle_exception ( 'file... | Process the upload - creating the module in the course and returning the result to the browser |
32,848 | protected function handle_file_upload ( ) { global $ CFG ; $ draftitemid = file_get_unused_draft_itemid ( ) ; $ maxbytes = get_user_max_upload_file_size ( $ this -> context , $ CFG -> maxbytes , $ this -> course -> maxbytes ) ; $ types = $ this -> dnduploadhandler -> get_handled_file_types ( $ this -> module -> name ) ... | Handle uploads containing files - create the course module ask the upload repository to process the file ask the mod to set itself up then return the result to the browser |
32,849 | protected function handle_other_upload ( $ content ) { if ( ! $ this -> dnduploadhandler -> has_type_handler ( $ this -> module -> name , $ this -> type ) ) { $ info = ( object ) array ( 'modname' => $ this -> module -> name , 'type' => $ this -> type ) ; throw new moodle_exception ( 'moddoesnotsupporttype' , 'moodle' ... | Handle uploads not containing file - create the course module ask the mod to set itself up then return the result to the browser |
32,850 | protected function display_name_from_file ( $ filename ) { $ pos = core_text :: strrpos ( $ filename , '.' ) ; if ( $ pos ) { $ filename = core_text :: substr ( $ filename , 0 , $ pos ) ; } return str_replace ( '_' , ' ' , $ filename ) ; } | Generate the name of the mod instance from the name of the file ( remove the extension and convert underscore = > space |
32,851 | protected function prepare_module_data ( $ draftitemid = null , $ content = null ) { $ data = new stdClass ( ) ; $ data -> type = $ this -> type ; $ data -> course = $ this -> course ; if ( $ draftitemid ) { $ data -> draftitemid = $ draftitemid ; } else if ( $ content ) { $ data -> content = $ content ; } $ data -> co... | Gather together all the details to pass on to the mod so that it can initialise it s own database tables |
32,852 | protected function send_response ( $ mod ) { global $ OUTPUT , $ PAGE ; $ resp = new stdClass ( ) ; $ resp -> error = self :: ERROR_OK ; $ resp -> elementid = 'module-' . $ mod -> id ; $ courserenderer = $ PAGE -> get_renderer ( 'core' , 'course' ) ; $ completioninfo = new completion_info ( $ this -> course ) ; $ info ... | Send the details of the newly created activity back to the client browser |
32,853 | public function html ( ) { global $ OUTPUT ; $ text = new text_attribute ( $ this -> insertname , "0" , 'bulk' ) ; $ context = ( object ) [ 'label' => get_string ( 'bulklegend' , 'gradereport_singleview' ) , 'applylabel' => get_string ( 'bulkperform' , 'gradereport_singleview' ) , 'applyname' => $ this -> applyname , '... | Generate the html for this form element . |
32,854 | function getPluginName ( ) { if ( $ this -> plugin ) { $ manager = core_plugin_manager :: instance ( ) ; list ( $ plugintype , $ pluginname ) = core_component :: normalize_component ( $ this -> plugin ) ; return $ manager -> plugintype_name ( $ plugintype ) . ' / ' . $ manager -> plugin_name ( $ this -> plugin ) ; } el... | Get plugin name . |
32,855 | public function render ( stdClass $ user , \ cm_info $ cm , ? int $ groupid , ? int $ sortorder , ? int $ pageno , ? int $ pagesize ) : string { global $ PAGE ; $ forum = $ this -> forum ; $ forumexporter = $ this -> exporterfactory -> get_forum_exporter ( $ user , $ this -> forum , $ groupid ) ; $ pagesize = $ this ->... | Render for the specified user . |
32,856 | private function get_page_size ( ? int $ pagesize ) : int { if ( null === $ pagesize || $ pagesize <= 0 ) { $ pagesize = discussion_list_vault :: PAGESIZE_DEFAULT ; } return $ pagesize ; } | Fetch the page size to use when displaying the page . |
32,857 | protected function get_all_groups ( $ courseid ) { global $ CFG ; require_once ( $ CFG -> libdir . '/grouplib.php' ) ; if ( $ courseid != $ this -> allgroupscourseid ) { $ this -> allgroups = groups_get_all_groups ( $ courseid , 0 , 0 , 'g.id, g.name' ) ; $ this -> allgroupscourseid = $ courseid ; } return $ this -> al... | Gets all groups for the given course . |
32,858 | public function get_analysables_iterator ( ? string $ action = null ) { global $ DB ; list ( $ sql , $ params ) = $ this -> get_iterator_sql ( 'course' , CONTEXT_COURSE , $ action , 'c' ) ; if ( ! empty ( $ this -> options [ 'filter' ] ) ) { $ courses = array ( ) ; foreach ( $ this -> options [ 'filter' ] as $ courseid... | Return the list of courses to analyse . |
32,859 | public function push ( ) { $ start = $ this -> _start [ $ this -> _idx ++ ] = array ( memory_get_usage ( ) , memory_get_peak_usage ( ) , memory_get_usage ( true ) , memory_get_peak_usage ( true ) ) ; return $ start ; } | Push a new tracker on the stack . |
32,860 | public function pop ( ) { if ( ! ( $ this -> _idx > 0 ) ) { throw new Exception ( 'No timers have been started' ) ; } $ start = $ this -> _start [ -- $ this -> _idx ] ; return array ( memory_get_usage ( ) - $ start [ 0 ] , memory_get_peak_usage ( ) - $ start [ 1 ] , memory_get_usage ( true ) - $ start [ 2 ] , memory_ge... | Pop the latest tracker and return the difference with the current memory situation . |
32,861 | public static function get_user_by_email ( $ email , $ fields = '*' , $ mnethostid = null , $ strictness = IGNORE_MISSING ) { global $ DB , $ CFG ; if ( empty ( $ mnethostid ) ) { $ mnethostid = $ CFG -> mnet_localhost_id ; } return $ DB -> get_record ( 'user' , array ( 'email' => $ email , 'mnethostid' => $ mnethostid... | Return user object from db based on their email . |
32,862 | public static function get_user_by_username ( $ username , $ fields = '*' , $ mnethostid = null , $ strictness = IGNORE_MISSING ) { global $ DB , $ CFG ; if ( empty ( $ mnethostid ) ) { $ mnethostid = $ CFG -> mnet_localhost_id ; } return $ DB -> get_record ( 'user' , array ( 'username' => $ username , 'mnethostid' => ... | Return user object from db based on their username . |
32,863 | protected static function get_enrolled_sql_on_courses_with_capability ( $ capability ) { $ courses = get_user_capability_course ( $ capability , null , true , implode ( ',' , array_values ( context_helper :: get_preload_record_columns ( 'ctx' ) ) ) ) ; if ( ! $ courses ) { return [ null , null ] ; } $ unionsql = '' ; $... | Gets an SQL query that lists all enrolled user ids on any course where the current user has the specified capability . Helper function used for searching users . |
32,864 | protected static function get_dummy_user_record ( ) { global $ CFG ; $ dummyuser = new stdClass ( ) ; $ dummyuser -> id = self :: NOREPLY_USER ; $ dummyuser -> email = $ CFG -> noreplyaddress ; $ dummyuser -> firstname = get_string ( 'noreplyname' ) ; $ dummyuser -> username = 'noreply' ; $ dummyuser -> lastname = '' ;... | Helper function to return dummy noreply user record . |
32,865 | public static function is_real_user ( $ userid , $ checkdb = false ) { global $ DB ; if ( $ userid <= 0 ) { return false ; } if ( $ checkdb ) { return $ DB -> record_exists ( 'user' , array ( 'id' => $ userid ) ) ; } else { return true ; } } | Return true if user id is greater than 0 and alternatively check db . |
32,866 | public static function require_active_user ( $ user , $ checksuspended = false , $ checknologin = false ) { if ( ! self :: is_real_user ( $ user -> id ) ) { throw new moodle_exception ( 'invaliduser' , 'error' ) ; } if ( $ user -> deleted ) { throw new moodle_exception ( 'userdeleted' ) ; } if ( empty ( $ user -> confi... | Check if the given user is an active user in the site . |
32,867 | public static function update_picture ( stdClass $ usernew , $ filemanageroptions = array ( ) ) { global $ CFG , $ DB ; require_once ( "$CFG->libdir/gdlib.php" ) ; $ context = context_user :: instance ( $ usernew -> id , MUST_EXIST ) ; $ user = core_user :: get_user ( $ usernew -> id , 'id, picture' , MUST_EXIST ) ; $ ... | Updates the provided users profile picture based upon the expected fields returned from the edit or edit_advanced forms . |
32,868 | public static function get_property_definition ( $ property ) { self :: fill_properties_cache ( ) ; if ( ! array_key_exists ( $ property , self :: $ propertiescache ) ) { throw new coding_exception ( 'Invalid property requested.' ) ; } return self :: $ propertiescache [ $ property ] ; } | Get properties of a user field . |
32,869 | public static function validate ( $ data ) { self :: fill_properties_cache ( ) ; foreach ( $ data as $ property => $ value ) { try { if ( isset ( self :: $ propertiescache [ $ property ] ) ) { validate_param ( $ value , self :: $ propertiescache [ $ property ] [ 'type' ] , self :: $ propertiescache [ $ property ] [ 'nu... | Validate user data . |
32,870 | public static function clean_data ( $ user ) { if ( empty ( $ user ) ) { return $ user ; } foreach ( $ user as $ field => $ value ) { try { $ user -> $ field = core_user :: clean_field ( $ value , $ field ) ; } catch ( coding_exception $ e ) { debugging ( "The property '$field' could not be cleaned." , DEBUG_DEVELOPER ... | Clean the user data . |
32,871 | public static function clean_field ( $ data , $ field ) { if ( empty ( $ data ) || empty ( $ field ) ) { return $ data ; } try { $ type = core_user :: get_property_type ( $ field ) ; if ( isset ( self :: $ propertiescache [ $ field ] [ 'choices' ] ) ) { if ( ! array_key_exists ( $ data , self :: $ propertiescache [ $ f... | Clean a specific user field . |
32,872 | public static function get_property_type ( $ property ) { self :: fill_properties_cache ( ) ; if ( ! array_key_exists ( $ property , self :: $ propertiescache ) ) { throw new coding_exception ( 'Invalid property requested: ' . $ property ) ; } return self :: $ propertiescache [ $ property ] [ 'type' ] ; } | Get the parameter type of the property . |
32,873 | public static function get_property_null ( $ property ) { self :: fill_properties_cache ( ) ; if ( ! array_key_exists ( $ property , self :: $ propertiescache ) ) { throw new coding_exception ( 'Invalid property requested: ' . $ property ) ; } return self :: $ propertiescache [ $ property ] [ 'null' ] ; } | Discover if the property is NULL_ALLOWED or NULL_NOT_ALLOWED . |
32,874 | public static function get_property_choices ( $ property ) { self :: fill_properties_cache ( ) ; if ( ! array_key_exists ( $ property , self :: $ propertiescache ) && ! array_key_exists ( 'choices' , self :: $ propertiescache [ $ property ] ) ) { throw new coding_exception ( 'Invalid property requested, or the property... | Get the choices of the property . |
32,875 | public static function get_property_default ( $ property ) { self :: fill_properties_cache ( ) ; if ( ! array_key_exists ( $ property , self :: $ propertiescache ) || ! isset ( self :: $ propertiescache [ $ property ] [ 'default' ] ) ) { throw new coding_exception ( 'Invalid property requested, or the property does not... | Get the property default . |
32,876 | protected static function fill_preferences_cache ( ) { if ( self :: $ preferencescache !== null ) { return ; } $ preferences = array ( ) ; $ preferences [ 'auth_forcepasswordchange' ] = array ( 'type' => PARAM_INT , 'null' => NULL_NOT_ALLOWED , 'choices' => array ( 0 , 1 ) , 'permissioncallback' => function ( $ user , ... | Definition of updateable user preferences and rules for data and access validation . |
32,877 | protected static function get_preference_definition ( $ preferencename ) { self :: fill_preferences_cache ( ) ; foreach ( self :: $ preferencescache as $ key => $ preference ) { if ( empty ( $ preference [ 'isregex' ] ) ) { if ( $ key === $ preferencename ) { return $ preference ; } } else { if ( preg_match ( $ key , $... | Retrieves the preference definition |
32,878 | public static function clean_preference ( $ value , $ preferencename ) { $ definition = self :: get_preference_definition ( $ preferencename ) ; if ( isset ( $ definition [ 'type' ] ) && $ value !== null ) { $ value = clean_param ( $ value , $ definition [ 'type' ] ) ; } if ( isset ( $ definition [ 'cleancallback' ] ) ... | Clean value of a user preference |
32,879 | protected function to_features ( $ calculatedvalues ) { $ classes = static :: get_classes ( ) ; foreach ( $ calculatedvalues as $ sampleid => $ calculatedvalue ) { $ classindex = array_search ( intval ( $ calculatedvalue ) , $ classes , true ) ; if ( $ classindex === false && ! is_null ( $ calculatedvalue ) ) { throw n... | From calculated values to dataset features . |
32,880 | private function _checkNeedsP ( $ current ) { if ( $ current instanceof HTMLPurifier_Token_Start ) { if ( ! $ this -> _isInline ( $ current ) ) { return false ; } } elseif ( $ current instanceof HTMLPurifier_Token_Text ) { if ( strpos ( $ current -> data , "\n\n" ) !== false ) { return true ; } else { } } return null ;... | Determines if a particular token requires an earlier inline token to get a paragraph . This should be used with _forwardUntilEndToken |
32,881 | public function getHTML ( $ columnNames = null ) { if ( $ this -> isTerminal ) { $ value = "<b>$this->classValue</b>" ; } else { $ value = $ this -> value ; if ( $ columnNames !== null ) { $ col = $ columnNames [ $ this -> columnIndex ] ; } else { $ col = "col_$this->columnIndex" ; } if ( ! preg_match ( "/^[<>=]{1,2}/"... | Returns HTML representation of the node including children nodes |
32,882 | public function validation ( $ data , $ files = array ( ) ) { global $ DB ; $ errors = array ( ) ; $ field = $ this -> _customdata [ 'field' ] ; $ handler = $ field -> get_handler ( ) ; if ( ! preg_match ( '/^[a-z0-9_]+$/' , $ data [ 'shortname' ] ) ) { $ errors [ 'shortname' ] = get_string ( 'invalidshortnameerror' , ... | Field data validation |
32,883 | public function is_empty_area ( ) { if ( $ child = $ this -> get_area_backup ( 0 , '/' , '.' ) ) { if ( ! $ child -> is_empty_area ( ) ) { return false ; } } if ( $ child = $ this -> get_area_intro ( 0 , '/' , '.' ) ) { if ( ! $ child -> is_empty_area ( ) ) { return false ; } } foreach ( $ this -> areas as $ area => $ ... | Whether or not this is an emtpy area |
32,884 | public function handle_component_failure ( $ e , $ component , $ interface , $ methodname , array $ params ) { $ dpos = api :: get_site_dpos ( ) ; $ messagesubject = get_string ( 'exceptionnotificationsubject' , 'tool_dataprivacy' ) ; $ a = ( object ) [ 'fullmethodname' => \ core_privacy \ manager :: get_provider_class... | Notifies all DPOs that an exception occurred . |
32,885 | function _seek ( $ row ) { $ rs = $ this -> _queryID ; if ( $ this -> _currentRow > $ row ) return false ; @ $ rs -> Move ( ( integer ) $ row - $ this -> _currentRow - 1 ) ; return true ; } | should only be used to move forward as we normally use forward - only cursors |
32,886 | public static function role_assigned ( \ core \ event \ role_assigned $ event ) { global $ DB ; if ( ! enrol_is_enabled ( 'category' ) ) { return ; } $ ra = new stdClass ( ) ; $ ra -> roleid = $ event -> objectid ; $ ra -> userid = $ event -> relateduserid ; $ ra -> contextid = $ event -> contextid ; $ parentcontext = ... | Triggered when user is assigned a new role . |
32,887 | public static function role_unassigned ( \ core \ event \ role_unassigned $ event ) { global $ DB ; if ( ! enrol_is_enabled ( 'category' ) ) { return ; } $ ra = new stdClass ( ) ; $ ra -> userid = $ event -> relateduserid ; $ ra -> contextid = $ event -> contextid ; $ parentcontext = context :: instance_by_id ( $ ra ->... | Triggered when user role is unassigned . |
32,888 | protected function get_row_attributes ( $ capability ) { $ rowattributes = parent :: get_row_attributes ( $ capability ) ; if ( $ this -> permissions [ $ capability -> name ] !== 0 ) { if ( empty ( $ rowattributes [ 'class' ] ) ) { $ rowattributes [ 'class' ] = "overriddenpermission" ; } else { $ rowattributes [ 'class... | This method adds an additional class to a row if capability is other than inherited . |
32,889 | protected function formatStringCellValue ( $ node ) { $ pNodeValues = [ ] ; $ pNodes = $ node -> getElementsByTagName ( self :: XML_NODE_P ) ; foreach ( $ pNodes as $ pNode ) { $ currentPValue = '' ; foreach ( $ pNode -> childNodes as $ childNode ) { if ( $ childNode instanceof \ DOMText ) { $ currentPValue .= $ childN... | Returns the cell String value . |
32,890 | protected function formatFloatCellValue ( $ node ) { $ nodeValue = $ node -> getAttribute ( self :: XML_ATTRIBUTE_VALUE ) ; $ nodeIntValue = intval ( $ nodeValue ) ; $ cellValue = ( $ nodeIntValue == $ nodeValue ) ? $ nodeIntValue : floatval ( $ nodeValue ) ; return $ cellValue ; } | Returns the cell Numeric value from the given node . |
32,891 | protected function formatBooleanCellValue ( $ node ) { $ nodeValue = $ node -> getAttribute ( self :: XML_ATTRIBUTE_BOOLEAN_VALUE ) ; $ cellValue = ! ! $ nodeValue ; return $ cellValue ; } | Returns the cell Boolean value from the given node . |
32,892 | protected function formatDateCellValue ( $ node ) { if ( $ this -> shouldFormatDates ) { $ nodeWithValueAlreadyFormatted = $ node -> getElementsByTagName ( self :: XML_NODE_P ) -> item ( 0 ) ; return $ nodeWithValueAlreadyFormatted -> nodeValue ; } else { try { $ nodeValue = $ node -> getAttribute ( self :: XML_ATTRIBU... | Returns the cell Date value from the given node . |
32,893 | protected function formatTimeCellValue ( $ node ) { if ( $ this -> shouldFormatDates ) { $ nodeWithValueAlreadyFormatted = $ node -> getElementsByTagName ( self :: XML_NODE_P ) -> item ( 0 ) ; return $ nodeWithValueAlreadyFormatted -> nodeValue ; } else { try { $ nodeValue = $ node -> getAttribute ( self :: XML_ATTRIBU... | Returns the cell Time value from the given node . |
32,894 | protected function formatCurrencyCellValue ( $ node ) { $ value = $ node -> getAttribute ( self :: XML_ATTRIBUTE_VALUE ) ; $ currency = $ node -> getAttribute ( self :: XML_ATTRIBUTE_CURRENCY ) ; return "$value $currency" ; } | Returns the cell Currency value from the given node . |
32,895 | protected function rewindAndSkipBom ( ) { $ byteOffsetToSkipBom = $ this -> encodingHelper -> getBytesOffsetToSkipBOM ( $ this -> filePointer , $ this -> encoding ) ; $ this -> globalFunctionsHelper -> fseek ( $ this -> filePointer , $ byteOffsetToSkipBom ) ; } | This rewinds and skips the BOM if inserted at the beginning of the file by moving the file pointer after it so that it is not read . |
32,896 | protected function getEncodedEOLDelimiter ( ) { if ( ! isset ( $ this -> encodedEOLDelimiter ) ) { $ this -> encodedEOLDelimiter = $ this -> encodingHelper -> attemptConversionFromUTF8 ( $ this -> inputEOLDelimiter , $ this -> encoding ) ; } return $ this -> encodedEOLDelimiter ; } | Returns the end of line delimiter encoded using the same encoding as the CSV . The return value is cached . |
32,897 | protected function add_filter ( $ key , $ value , $ allowmultiple = false ) { if ( $ allowmultiple || empty ( $ this -> get_filter_values ( $ key ) ) ) { $ this -> filtersapplied [ ] = [ $ key , $ value ] ; } } | Adds an applied filter |
32,898 | protected function get_filter_values ( $ filtername ) { $ values = [ ] ; foreach ( $ this -> filtersapplied as $ filter ) { if ( $ filter [ 0 ] == $ filtername ) { $ values [ ] = $ filter [ 1 ] ; } } return $ values ; } | Get all values of the applied filter |
32,899 | protected function get_filter_value ( $ filtername , $ default = null ) { if ( $ values = $ this -> get_filter_values ( $ filtername ) ) { $ value = reset ( $ values ) ; return $ value ; } return $ default ; } | Get one value of the applied filter |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.