idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
32,300
public static function get_sessions ( $ chatid , $ groupid = 0 , $ showall = false ) { global $ DB ; $ params = self :: validate_parameters ( self :: get_sessions_parameters ( ) , array ( 'chatid' => $ chatid , 'groupid' => $ groupid , 'showall' => $ showall , ) ) ; $ sessions = $ warnings = array ( ) ; $ chat = $ DB -...
Retrieves chat sessions for a given chat .
32,301
public static function get_session_messages ( $ chatid , $ sessionstart , $ sessionend , $ groupid = 0 ) { global $ DB , $ PAGE ; $ params = self :: validate_parameters ( self :: get_session_messages_parameters ( ) , array ( 'chatid' => $ chatid , 'sessionstart' => $ sessionstart , 'sessionend' => $ sessionend , 'group...
Retrieves messages of the given chat session .
32,302
public static function fetch_users_grades ( $ grade_item , $ userids , $ include_missing = true ) { global $ DB ; $ limit = 2000 ; $ count = count ( $ userids ) ; if ( $ count > $ limit ) { $ half = ( int ) ( $ count / 2 ) ; $ first = array_slice ( $ userids , 0 , $ half ) ; $ second = array_slice ( $ userids , $ half ...
Returns array of grades for given grade_item + users
32,303
public function is_editable ( ) { if ( $ this -> is_locked ( ) ) { return false ; } $ grade_item = $ this -> load_grade_item ( ) ; if ( $ grade_item -> gradetype == GRADE_TYPE_NONE ) { return false ; } if ( $ grade_item -> is_course_item ( ) or $ grade_item -> is_category_item ( ) ) { return ( bool ) get_config ( 'mood...
Is grading object editable?
32,304
protected function get_grade_min_and_max ( ) { global $ CFG ; $ this -> load_grade_item ( ) ; $ minmaxtouse = grade_get_setting ( $ this -> grade_item -> courseid , 'minmaxtouse' , $ CFG -> grade_minmaxtouse ) ; $ gradebookcalculationsfreeze = 'gradebook_calculations_freeze_' . $ this -> grade_item -> courseid ; if ( i...
Returns the minimum and maximum number of points this grade is graded with respect to .
32,305
public function get_dategraded ( ) { if ( is_null ( $ this -> finalgrade ) and is_null ( $ this -> feedback ) ) { return null ; } else if ( $ this -> overridden ) { return $ this -> overridden ; } else { return $ this -> timemodified ; } }
Returns timestamp when last graded null if no grade present
32,306
public function set_overridden ( $ state , $ refresh = true ) { if ( empty ( $ this -> overridden ) and $ state ) { $ this -> overridden = time ( ) ; $ this -> update ( ) ; return true ; } else if ( ! empty ( $ this -> overridden ) and ! $ state ) { $ this -> overridden = 0 ; $ this -> update ( ) ; if ( $ refresh ) { $...
Set the overridden status of grade
32,307
public function set_excluded ( $ state ) { if ( empty ( $ this -> excluded ) and $ state ) { $ this -> excluded = time ( ) ; $ this -> update ( ) ; return true ; } else if ( ! empty ( $ this -> excluded ) and ! $ state ) { $ this -> excluded = 0 ; $ this -> update ( ) ; return true ; } return false ; }
Set the excluded status of grade
32,308
public function get_locktime ( ) { $ this -> load_grade_item ( ) ; $ item_locktime = $ this -> grade_item -> get_locktime ( ) ; if ( empty ( $ this -> locktime ) or ( $ item_locktime and $ item_locktime < $ this -> locktime ) ) { return $ item_locktime ; } else { return $ this -> locktime ; } }
Get the locktime for this grade .
32,309
public function is_passed ( $ grade_item = null ) { if ( empty ( $ grade_item ) ) { if ( ! isset ( $ this -> grade_item ) ) { $ this -> load_grade_item ( ) ; } } else { $ this -> grade_item = $ grade_item ; $ this -> itemid = $ grade_item -> id ; } if ( is_null ( $ this -> finalgrade ) ) { return null ; } if ( is_null ...
Returns true if the grade s value is superior or equal to the grade item s gradepass value false otherwise .
32,310
protected function add_feedback_files ( int $ historyid = null ) { global $ CFG ; if ( $ this -> grade_item && $ this -> grade_item -> is_external_item ( ) ) { $ context = $ this -> get_context ( ) ; $ this -> copy_feedback_files ( $ context , GRADE_FEEDBACK_FILEAREA , $ this -> id ) ; if ( empty ( $ CFG -> disablegrad...
Handles adding feedback files in the gradebook .
32,311
protected function update_feedback_files ( int $ historyid = null ) { global $ CFG ; if ( $ this -> grade_item && $ this -> grade_item -> is_external_item ( ) ) { $ context = $ this -> get_context ( ) ; $ fs = new file_storage ( ) ; $ fs -> delete_area_files ( $ context -> id , GRADE_FILE_COMPONENT , GRADE_FEEDBACK_FIL...
Handles updating feedback files in the gradebook .
32,312
protected function delete_feedback_files ( ) { if ( $ this -> grade_item && $ this -> grade_item -> is_external_item ( ) ) { $ context = $ this -> get_context ( ) ; $ fs = new file_storage ( ) ; $ fs -> delete_area_files ( $ context -> id , GRADE_FILE_COMPONENT , GRADE_FEEDBACK_FILEAREA , $ this -> id ) ; } return true...
Handles deleting feedback files in the gradebook .
32,313
public function delete ( $ source = null ) { $ success = parent :: delete ( $ source ) ; if ( $ success ) { $ this -> load_grade_item ( ) ; \ core \ event \ grade_deleted :: create_from_grade ( $ this ) -> trigger ( ) ; } return $ success ; }
Deletes the grade_grade instance from the database .
32,314
private function copy_feedback_files ( context $ context , string $ filearea , int $ itemid ) { if ( $ this -> feedbackfiles ) { $ filestocopycontextid = $ this -> feedbackfiles [ 'contextid' ] ; $ filestocopycomponent = $ this -> feedbackfiles [ 'component' ] ; $ filestocopyfilearea = $ this -> feedbackfiles [ 'filear...
Handles copying feedback files to a specified gradebook file area .
32,315
public function getCauseMessage ( & $ causes ) { $ trace = $ this -> getTraceSafe ( ) ; $ cause = array ( 'class' => get_class ( $ this ) , 'message' => $ this -> message , 'file' => 'unknown' , 'line' => 'unknown' ) ; if ( isset ( $ trace [ 0 ] ) ) { if ( isset ( $ trace [ 0 ] [ 'file' ] ) ) { $ cause [ 'file' ] = $ t...
Function must be public to call on caused exceptions
32,316
public final function is_first ( ) { $ order = get_config ( $ this -> get_subtype ( ) . '_' . $ this -> get_type ( ) , 'sortorder' ) ; if ( $ order == 0 ) { return true ; } return false ; }
Is this the first plugin in the list?
32,317
public final function is_last ( ) { $ lastindex = count ( core_component :: get_plugin_list ( $ this -> get_subtype ( ) ) ) - 1 ; $ currentindex = get_config ( $ this -> get_subtype ( ) . '_' . $ this -> get_type ( ) , 'sortorder' ) ; if ( $ lastindex == $ currentindex ) { return true ; } return false ; }
Is this the last plugin in the list?
32,318
public final function is_visible ( ) { if ( $ this -> visiblecache === null ) { $ disabled = get_config ( $ this -> get_subtype ( ) . '_' . $ this -> get_type ( ) , 'disabled' ) ; $ this -> visiblecache = ! $ disabled ; } return $ this -> visiblecache ; }
Is this plugin enaled?
32,319
public final function has_admin_settings ( ) { global $ CFG ; $ pluginroot = $ CFG -> dirroot . '/mod/assign/' . substr ( $ this -> get_subtype ( ) , strlen ( 'assign' ) ) . '/' . $ this -> get_type ( ) ; $ settingsfile = $ pluginroot . '/settings.php' ; return file_exists ( $ settingsfile ) ; }
Has this plugin got a custom settings . php file?
32,320
public final function set_config ( $ name , $ value ) { global $ DB ; $ dbparams = array ( 'assignment' => $ this -> assignment -> get_instance ( ) -> id , 'subtype' => $ this -> get_subtype ( ) , 'plugin' => $ this -> get_type ( ) , 'name' => $ name ) ; $ current = $ DB -> get_record ( 'assign_plugin_config' , $ dbpar...
Set a configuration value for this plugin
32,321
public final function get_config ( $ setting = null ) { global $ DB ; if ( $ setting ) { if ( ! $ this -> assignment -> has_instance ( ) ) { return false ; } $ assignment = $ this -> assignment -> get_instance ( ) ; if ( $ assignment ) { $ dbparams = array ( 'assignment' => $ assignment -> id , 'subtype' => $ this -> g...
Get a configuration value for this plugin
32,322
public function upgrade_settings ( context $ oldcontext , stdClass $ oldassignment , & $ log ) { $ params = array ( 'type' => $ this -> type , 'subtype' => $ this -> get_subtype ( ) ) ; $ log .= ' ' . get_string ( 'upgradenotimplemented' , 'mod_assign' , $ params ) ; return false ; }
Upgrade the settings from the old assignment to the new one
32,323
public function get_file_info ( $ browser , $ filearea , $ itemid , $ filepath , $ filename ) { global $ CFG , $ DB , $ USER ; $ urlbase = $ CFG -> wwwroot . '/pluginfile.php' ; $ writeaccess = false ; $ assignment = $ this -> assignment ; if ( $ this -> get_subtype ( ) == 'assignsubmission' ) { if ( $ itemid ) { $ rec...
Default implementation of file_get_info for plugins . This is used by the filebrowser to browse a plugins file areas .
32,324
public static function reset_caches ( $ phpunitreset = false ) { if ( $ phpunitreset ) { static :: $ singletoninstance = null ; } else { if ( static :: $ singletoninstance ) { static :: $ singletoninstance -> pluginsinfo = null ; static :: $ singletoninstance -> subpluginsinfo = null ; static :: $ singletoninstance -> ...
Reset all caches .
32,325
public function get_installed_plugins ( $ type ) { $ this -> load_installed_plugins ( ) ; if ( isset ( $ this -> installedplugins [ $ type ] ) ) { return $ this -> installedplugins [ $ type ] ; } return array ( ) ; }
Return list of installed plugins of given type .
32,326
public function get_enabled_plugins ( $ type ) { $ this -> load_enabled_plugins ( ) ; if ( isset ( $ this -> enabledplugins [ $ type ] ) ) { return $ this -> enabledplugins [ $ type ] ; } return null ; }
Get list of enabled plugins of given type the result may contain missing plugins .
32,327
public function get_present_plugins ( $ type ) { $ this -> load_present_plugins ( ) ; if ( isset ( $ this -> presentplugins [ $ type ] ) ) { return $ this -> presentplugins [ $ type ] ; } return null ; }
Get list of present plugins of given type .
32,328
public function get_plugins ( ) { $ this -> init_pluginsinfo_property ( ) ; foreach ( $ this -> pluginsinfo as $ plugintype => $ list ) { if ( $ list === null ) { $ this -> get_plugins_of_type ( $ plugintype ) ; } } return $ this -> pluginsinfo ; }
Returns a tree of known plugins and information about them
32,329
public function get_plugins_of_type ( $ type ) { global $ CFG ; $ this -> init_pluginsinfo_property ( ) ; if ( ! array_key_exists ( $ type , $ this -> pluginsinfo ) ) { return array ( ) ; } if ( is_array ( $ this -> pluginsinfo [ $ type ] ) ) { return $ this -> pluginsinfo [ $ type ] ; } $ types = core_component :: get...
Returns list of known plugins of the given type .
32,330
protected function init_pluginsinfo_property ( ) { if ( is_array ( $ this -> pluginsinfo ) ) { return ; } $ this -> pluginsinfo = array ( ) ; $ plugintypes = $ this -> get_plugin_types ( ) ; foreach ( $ plugintypes as $ plugintype => $ plugintyperootdir ) { $ this -> pluginsinfo [ $ plugintype ] = null ; } $ this -> lo...
Init placeholder array for plugin infos .
32,331
public static function resolve_plugininfo_class ( $ type ) { $ plugintypes = core_component :: get_plugin_types ( ) ; if ( ! isset ( $ plugintypes [ $ type ] ) ) { return '\core\plugininfo\orphaned' ; } $ parent = core_component :: get_subtype_parent ( $ type ) ; if ( $ parent ) { $ class = '\\' . $ parent . '\pluginin...
Find the plugin info class for given type .
32,332
public function get_subplugins_of_plugin ( $ component ) { $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { return array ( ) ; } $ subplugins = $ this -> get_subplugins ( ) ; if ( ! isset ( $ subplugins [ $ pluginfo -> component ] ) ) { return array ( ) ; } $ list = array ( ) ; f...
Returns list of all known subplugins of the given plugin .
32,333
public function plugin_name ( $ component ) { $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { throw new moodle_exception ( 'err_unknown_plugin' , 'core_plugin' , '' , array ( 'plugin' => $ component ) ) ; } return $ pluginfo -> displayname ; }
Returns a localized name of a given plugin
32,334
public function plugintype_name ( $ type ) { if ( get_string_manager ( ) -> string_exists ( 'type_' . $ type , 'core_plugin' ) ) { return get_string ( 'type_' . $ type , 'core_plugin' ) ; } else if ( $ parent = $ this -> get_parent_of_subplugin ( $ type ) ) { if ( get_string_manager ( ) -> string_exists ( 'subplugintyp...
Returns a localized name of a plugin typed in singular form
32,335
public function get_plugin_info ( $ component ) { list ( $ type , $ name ) = core_component :: normalize_component ( $ component ) ; $ plugins = $ this -> get_plugins_of_type ( $ type ) ; if ( isset ( $ plugins [ $ name ] ) ) { return $ plugins [ $ name ] ; } else { return null ; } }
Returns information about the known plugin or null
32,336
public function plugin_external_source ( $ component ) { $ plugininfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ plugininfo ) ) { return false ; } $ pluginroot = $ plugininfo -> rootdir ; if ( is_dir ( $ pluginroot . '/.git' ) ) { return 'git' ; } if ( is_file ( $ pluginroot . '/.git' ) ) { return '...
Check to see if the current version of the plugin seems to be a checkout of an external repository .
32,337
public function other_plugins_that_require ( $ component ) { $ others = array ( ) ; foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { $ required = $ plugin -> get_other_required_plugins ( ) ; if ( isset ( $ required [ $ component ] ) ) { $ others [ ] = $ plugin -> compon...
Get a list of any other plugins that require this one .
32,338
public function are_dependencies_satisfied ( $ dependencies ) { foreach ( $ dependencies as $ component => $ requiredversion ) { $ otherplugin = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ otherplugin ) ) { return false ; } if ( $ requiredversion != ANY_VERSION and $ otherplugin -> versiondisk < $ requ...
Check a dependencies list against the list of installed plugins .
32,339
public function all_plugins_ok ( $ moodleversion , & $ failedplugins = array ( ) ) { $ return = true ; foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { if ( ! $ plugin -> is_core_dependency_satisfied ( $ moodleversion ) ) { $ return = false ; $ failedplugins [ ] = $ plu...
Checks all dependencies for all installed plugins
32,340
public function resolve_requirements ( \ core \ plugininfo \ base $ plugin , $ moodleversion = null , $ moodlebranch = null ) { global $ CFG ; if ( $ plugin -> versiondisk === null ) { return array ( ) ; } if ( $ moodleversion === null ) { $ moodleversion = $ CFG -> version ; } if ( $ moodlebranch === null ) { $ moodle...
Resolve requirements and dependencies of a plugin .
32,341
protected function resolve_core_requirements ( \ core \ plugininfo \ base $ plugin , $ moodleversion ) { $ reqs = ( object ) array ( 'hasver' => null , 'reqver' => null , 'status' => null , 'availability' => null , ) ; $ reqs -> hasver = $ moodleversion ; if ( empty ( $ plugin -> versionrequires ) ) { $ reqs -> reqver ...
Helper method to resolve plugin s requirements on the moodle core .
32,342
protected function resolve_dependency_requirements ( \ core \ plugininfo \ base $ plugin , $ otherpluginname , $ requiredversion , $ moodlebranch ) { $ reqs = ( object ) array ( 'hasver' => null , 'reqver' => null , 'status' => null , 'availability' => null , ) ; $ otherplugin = $ this -> get_plugin_info ( $ otherplugi...
Helper method to resolve plugin s dependecies on other plugins .
32,343
public function is_remote_plugin_available ( $ component , $ version , $ exactmatch ) { $ info = $ this -> get_remote_plugin_info ( $ component , $ version , $ exactmatch ) ; if ( empty ( $ info ) ) { return false ; } if ( empty ( $ info -> version ) ) { return false ; } return true ; }
Is the given plugin version available in the plugins directory?
32,344
public function is_remote_plugin_installable ( $ component , $ version , & $ reason = null ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { $ reason = 'disabled' ; return false ; } if ( ! $ this -> is_remote_plugin_available ( $ component , $ version , true ) ) { $ reason = 'remoteunavailable' ;...
Can the given plugin version be installed via the admin UI?
32,345
public function filter_installable ( $ remoteinfos ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return array ( ) ; } if ( empty ( $ remoteinfos ) ) { return array ( ) ; } $ installable = array ( ) ; foreach ( $ remoteinfos as $ index => $ remoteinfo ) { if ( $ this -> is_remote_plugin_instal...
Given the list of remote plugin infos return just those installable .
32,346
public function get_remote_plugin_info ( $ component , $ version , $ exactmatch ) { if ( $ exactmatch and $ version == ANY_VERSION ) { throw new coding_exception ( 'Invalid request for exactly any version, it does not make sense.' ) ; } $ client = $ this -> get_update_api_client ( ) ; if ( $ exactmatch ) { if ( ! isset...
Returns information about a plugin in the plugins directory .
32,347
public function missing_dependencies ( $ availableonly = false ) { $ dependencies = array ( ) ; foreach ( $ this -> get_plugins ( ) as $ plugintype => $ pluginfos ) { foreach ( $ pluginfos as $ pluginname => $ pluginfo ) { foreach ( $ this -> resolve_requirements ( $ pluginfo ) as $ reqname => $ reqinfo ) { if ( $ reqn...
Return a list of missing dependencies .
32,348
public function can_uninstall_plugin ( $ component ) { $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { return false ; } if ( ! $ this -> common_uninstall_check ( $ pluginfo ) ) { return false ; } $ subplugins = $ this -> get_subplugins_of_plugin ( $ pluginfo -> component ) ; for...
Is it possible to uninstall the given plugin?
32,349
public function get_uninstall_url ( $ component , $ return = 'overview' ) { if ( ! $ this -> can_uninstall_plugin ( $ component ) ) { return null ; } $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { return null ; } if ( method_exists ( $ pluginfo , 'get_uninstall_url' ) ) { debug...
Returns uninstall URL if exists .
32,350
public function uninstall_plugin ( $ component , progress_trace $ progress ) { $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { return false ; } $ result = $ pluginfo -> uninstall ( $ progress ) ; if ( ! $ result ) { return false ; } ob_start ( ) ; uninstall_plugin ( $ pluginfo -...
Uninstall the given plugin .
32,351
public function some_plugins_updatable ( ) { foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { if ( $ plugin -> available_updates ( ) ) { return true ; } } } return false ; }
Checks if there are some plugins with a known available update
32,352
public function load_available_updates_for_plugin ( $ component ) { global $ CFG ; $ provider = \ core \ update \ checker :: instance ( ) ; if ( ! $ provider -> enabled ( ) or during_initial_install ( ) ) { return null ; } if ( isset ( $ CFG -> updateminmaturity ) ) { $ minmaturity = $ CFG -> updateminmaturity ; } else...
Returns list of available updates for the given component .
32,353
public function available_updates ( ) { $ updates = array ( ) ; foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { $ availableupdates = $ plugin -> available_updates ( ) ; if ( empty ( $ availableupdates ) ) { continue ; } foreach ( $ availableupdates as $ update ) { if (...
Returns a list of all available updates to be installed .
32,354
public function is_plugin_folder_removable ( $ component ) { $ pluginfo = $ this -> get_plugin_info ( $ component ) ; if ( is_null ( $ pluginfo ) ) { return false ; } if ( ! is_writable ( dirname ( $ pluginfo -> rootdir ) ) ) { return false ; } return $ this -> is_directory_removable ( $ pluginfo -> rootdir ) ; }
Check to see if the given plugin folder can be removed by the web server process .
32,355
public function is_plugintype_writable ( $ plugintype ) { $ plugintypepath = $ this -> get_plugintype_root ( $ plugintype ) ; if ( is_null ( $ plugintypepath ) ) { throw new coding_exception ( 'Unknown plugin type: ' . $ plugintype ) ; } if ( $ plugintypepath === false ) { throw new coding_exception ( 'Plugin type loca...
Is it possible to create a new plugin directory for the given plugin type?
32,356
public function get_plugintype_root ( $ plugintype ) { $ plugintypepath = null ; foreach ( core_component :: get_plugin_types ( ) as $ type => $ fullpath ) { if ( $ type === $ plugintype ) { $ plugintypepath = $ fullpath ; break ; } } if ( is_null ( $ plugintypepath ) ) { return null ; } if ( ! is_dir ( $ plugintypepat...
Returns the full path of the root of the given plugin type
32,357
public static function is_deleted_standard_plugin ( $ type , $ name ) { $ plugins = array ( 'qformat' => array ( 'blackboard' , 'learnwise' ) , 'auth' => array ( 'radius' , 'fc' , 'nntp' , 'pam' , 'pop3' , 'imap' ) , 'block' => array ( 'course_overview' , 'messages' ) , 'cachestore' => array ( 'memcache' ) , 'enrol' =>...
Defines a list of all plugins that were originally shipped in the standard Moodle distribution but are not anymore and are deleted during upgrades .
32,358
public function remove_plugin_folder ( \ core \ plugininfo \ base $ plugin ) { if ( ! $ this -> is_plugin_folder_removable ( $ plugin -> component ) ) { throw new moodle_exception ( 'err_removing_unremovable_folder' , 'core_plugin' , '' , array ( 'plugin' => $ plugin -> component , 'rootdir' => $ plugin -> rootdir ) , ...
Remove the current plugin code from the dirroot .
32,359
public function can_cancel_plugin_installation ( \ core \ plugininfo \ base $ plugin ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return false ; } if ( empty ( $ plugin ) or $ plugin -> is_standard ( ) or $ plugin -> is_subplugin ( ) or ! $ this -> is_plugin_folder_removable ( $ plugin -> co...
Can the installation of the new plugin be cancelled?
32,360
public function can_cancel_plugin_upgrade ( \ core \ plugininfo \ base $ plugin ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return false ; } if ( empty ( $ plugin ) or $ plugin -> is_standard ( ) or $ plugin -> is_subplugin ( ) or ! $ this -> is_plugin_folder_removable ( $ plugin -> compone...
Can the upgrade of the existing plugin be cancelled?
32,361
public function cancel_plugin_installation ( $ component ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return false ; } $ plugin = $ this -> get_plugin_info ( $ component ) ; if ( $ this -> can_cancel_plugin_installation ( $ plugin ) ) { $ this -> remove_plugin_folder ( $ plugin ) ; } return ...
Removes the plugin code directory if it is not installed yet .
32,362
public function list_cancellable_installations ( ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return array ( ) ; } $ cancellable = array ( ) ; foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { if ( $ this -> can_cancel_plugin_installation ( $ ...
Returns plugins the installation of which can be cancelled .
32,363
public function archive_plugin_version ( \ core \ plugininfo \ base $ plugin ) { return $ this -> get_code_manager ( ) -> archive_plugin_version ( $ plugin -> rootdir , $ plugin -> component , $ plugin -> versiondisk ) ; }
Archive the current on - disk plugin code .
32,364
public function list_restorable_archives ( ) { global $ CFG ; if ( ! empty ( $ CFG -> disableupdateautodeploy ) ) { return false ; } $ codeman = $ this -> get_code_manager ( ) ; $ restorable = array ( ) ; foreach ( $ this -> get_plugins ( ) as $ type => $ plugins ) { foreach ( $ plugins as $ plugin ) { if ( $ this -> c...
Returns list of all archives that can be installed to cancel the plugin upgrade .
32,365
protected function reorder_plugin_types ( array $ types ) { $ fix = array ( 'mod' => $ types [ 'mod' ] ) ; foreach ( core_component :: get_plugin_list ( 'mod' ) as $ plugin => $ fulldir ) { if ( ! $ subtypes = core_component :: get_subplugins ( 'mod_' . $ plugin ) ) { continue ; } foreach ( $ subtypes as $ subtype => $...
Reorders plugin types into a sequence to be displayed
32,366
public function is_directory_removable ( $ fullpath ) { if ( ! is_writable ( $ fullpath ) ) { return false ; } if ( is_dir ( $ fullpath ) ) { $ handle = opendir ( $ fullpath ) ; } else { return false ; } $ result = true ; while ( $ filename = readdir ( $ handle ) ) { if ( $ filename === '.' or $ filename === '..' ) { c...
Check if the given directory can be removed by the web server process .
32,367
protected function common_uninstall_check ( \ core \ plugininfo \ base $ pluginfo ) { if ( ! $ pluginfo -> is_uninstall_allowed ( ) ) { return false ; } if ( $ pluginfo -> get_status ( ) === static :: PLUGIN_STATUS_NEW ) { return false ; } if ( method_exists ( $ pluginfo , 'get_uninstall_url' ) and is_null ( $ pluginfo...
Helper method that implements common uninstall prerequisites
32,368
protected function get_code_manager ( ) { if ( $ this -> codemanager === null ) { $ this -> codemanager = new \ core \ update \ code_manager ( ) ; } return $ this -> codemanager ; }
Returns a code_manager instance to be used for the plugins code operations .
32,369
public static function rgb ( $ red , $ green , $ blue ) { self :: throwIfInvalidColorComponentValue ( $ red ) ; self :: throwIfInvalidColorComponentValue ( $ green ) ; self :: throwIfInvalidColorComponentValue ( $ blue ) ; return strtoupper ( self :: convertColorComponentToHex ( $ red ) . self :: convertColorComponentT...
Returns an RGB color from R G and B values
32,370
public function get_handler_classname ( ) { global $ CFG ; if ( ! empty ( $ CFG -> sitepolicyhandler ) ) { $ sitepolicyhandlers = $ this -> get_all_handlers ( ) ; if ( ! isset ( $ sitepolicyhandlers [ $ CFG -> sitepolicyhandler ] ) ) { return default_handler :: class ; } else { return $ sitepolicyhandlers [ $ CFG -> si...
Returns the current site policy handler
32,371
protected function init ( ) { global $ PAGE ; $ this -> data [ 'crud' ] = 'r' ; $ this -> data [ 'edulevel' ] = self :: LEVEL_OTHER ; $ this -> context = $ PAGE -> context ; }
Set basic properties of the event .
32,372
public function set_page_detail ( ) { global $ PAGE ; if ( ! isset ( $ this -> data [ 'other' ] ) ) { $ this -> data [ 'other' ] = array ( ) ; } $ this -> data [ 'other' ] = array_merge ( array ( 'url' => $ PAGE -> url -> out_as_local_url ( false ) , 'heading' => $ PAGE -> heading , 'title' => $ PAGE -> title ) , $ thi...
Set basic page properties .
32,373
public function add ( Horde_Imap_Client_Interaction_Command $ cmd , $ top = false ) { if ( $ top ) { $ this -> _commands = array ( $ cmd -> tag => $ cmd ) + $ this -> _commands ; } else { $ this -> _commands [ $ cmd -> tag ] = $ cmd ; } $ this -> _todo [ $ cmd -> tag ] = true ; }
Add a command to the pipeline .
32,374
public function complete ( Horde_Imap_Client_Interaction_Server_Tagged $ resp ) { if ( isset ( $ this -> _commands [ $ resp -> tag ] ) ) { $ cmd = $ this -> _commands [ $ resp -> tag ] ; $ cmd -> response = $ resp ; unset ( $ this -> _todo [ $ resp -> tag ] ) ; } else { $ cmd = null ; } return $ cmd ; }
Mark a command as completed .
32,375
public function getCmd ( $ tag ) { return isset ( $ this -> _commands [ $ tag ] ) ? $ this -> _commands [ $ tag ] : null ; }
Return the command for a given tag .
32,376
public function get_author_from_stdclass ( stdClass $ record ) : author_entity { return new author_entity ( $ record -> id , $ record -> picture , $ record -> firstname , $ record -> lastname , fullname ( $ record ) , $ record -> email , $ record -> middlename , $ record -> firstnamephonetic , $ record -> lastnamephone...
Create an author entity from a user record .
32,377
public function get_discussion_summary_from_stdclass ( stdClass $ discussion , stdClass $ firstpost , stdClass $ firstpostauthor , stdClass $ latestpostauthor ) : discussion_summary_entity { $ firstpostauthorentity = $ this -> get_author_from_stdclass ( $ firstpostauthor ) ; return new discussion_summary_entity ( $ thi...
Create a discussion summary enttiy from stdClasses .
32,378
public function get_posts_sorter ( ) : sorter_entity { return new sorter_entity ( function ( post_entity $ post ) { return $ post -> get_id ( ) ; } , function ( post_entity $ post ) { return $ post -> get_parent_id ( ) ; } ) ; }
Create a sorter entity to sort post entities .
32,379
public function get_exported_posts_sorter ( ) : sorter_entity { return new sorter_entity ( function ( stdClass $ post ) { return $ post -> id ; } , function ( stdClass $ post ) { return $ post -> parentid ; } ) ; }
Create a sorter entity to sort exported posts .
32,380
public function is_filetype_group ( $ type ) { $ info = $ this -> get_groups_info ( ) ; if ( isset ( $ info [ $ type ] ) ) { return $ info [ $ type ] ; } else { return false ; } }
Is the given string a known filetype group?
32,381
public function get_groups_info ( ) { if ( $ this -> cachegroups !== null ) { return $ this -> cachegroups ; } $ groups = [ ] ; foreach ( core_filetypes :: get_types ( ) as $ ext => $ info ) { if ( isset ( $ info [ 'groups' ] ) && is_array ( $ info [ 'groups' ] ) ) { foreach ( $ info [ 'groups' ] as $ group ) { if ( ! ...
Provides a list of all known file type groups and their properties .
32,382
public function describe_file_types ( $ types ) { $ descriptions = [ ] ; $ types = $ this -> normalize_file_types ( $ types ) ; foreach ( $ types as $ type ) { if ( $ type === '*' ) { $ desc = get_string ( 'filetypesany' , 'core_form' ) ; $ descriptions [ $ desc ] = [ ] ; } else if ( $ group = $ this -> is_filetype_gro...
Describe the list of file types for human user .
32,383
public function expand ( $ types , $ keepgroups = false , $ keepmimetypes = false ) { $ expanded = [ ] ; foreach ( $ this -> normalize_file_types ( $ types ) as $ type ) { if ( $ group = $ this -> is_filetype_group ( $ type ) ) { foreach ( $ group -> extensions as $ ext ) { $ expanded [ $ ext ] = true ; } if ( $ keepgr...
Expands the file types into the list of file extensions .
32,384
public function get_not_whitelisted ( $ types , $ whitelist ) { $ whitelistedtypes = $ this -> expand ( $ whitelist , true , true ) ; if ( empty ( $ whitelistedtypes ) || $ whitelistedtypes == [ '*' ] ) { return [ ] ; } $ giventypes = $ this -> normalize_file_types ( $ types ) ; if ( empty ( $ giventypes ) ) { return [...
Returns all types that are not part of the give whitelist .
32,385
public function is_allowed_file_type ( $ filename , $ whitelist ) { $ allowedextensions = $ this -> expand ( $ whitelist ) ; if ( empty ( $ allowedextensions ) || $ allowedextensions == [ '*' ] ) { return true ; } $ haystack = strrev ( trim ( core_text :: strtolower ( $ filename ) ) ) ; foreach ( $ allowedextensions as...
Is the given filename of an allowed file type?
32,386
public function get_unknown_file_types ( $ types ) { $ unknown = [ ] ; foreach ( $ this -> normalize_file_types ( $ types ) as $ type ) { if ( $ type === '*' ) { continue ; } else if ( $ type === '.xxx' ) { $ unknown [ $ type ] = true ; } else if ( $ this -> is_filetype_group ( $ type ) ) { continue ; } else if ( $ thi...
Returns file types from the list that are not recognized
32,387
public function ParseImport ( $ full_path , $ uri , $ env ) { $ import_env = clone $ env ; if ( ( isset ( $ this -> options [ 'reference' ] ) && $ this -> options [ 'reference' ] ) || isset ( $ this -> currentFileInfo [ 'reference' ] ) ) { $ import_env -> currentFileInfo [ 'reference' ] = true ; } if ( ( isset ( $ this...
Parse the import url and return the rules
32,388
protected function get_favourite_from_record ( \ stdClass $ record ) : favourite { $ favourite = new favourite ( $ record -> component , $ record -> itemtype , $ record -> itemid , $ record -> contextid , $ record -> userid ) ; $ favourite -> id = $ record -> id ; $ favourite -> ordering = $ record -> ordering ?? null ...
Get a favourite object based on a full record .
32,389
protected function get_list_of_favourites_from_records ( array $ records ) { $ list = [ ] ; foreach ( $ records as $ index => $ record ) { $ list [ $ index ] = $ this -> get_favourite_from_record ( $ record ) ; } return $ list ; }
Get a list of favourite objects based on a list of records .
32,390
protected function validate ( favourite $ favourite ) { $ favourite = ( array ) $ favourite ; $ allowedfields = [ 'userid' => true , 'component' => true , 'itemtype' => true , 'itemid' => true , 'contextid' => true , 'ordering' => false , 'timecreated' => false , 'timemodified' => false , 'id' => false ] ; $ requiredfi...
Basic validation confirming we have the minimum field set needed to save a record to the store .
32,391
public function add ( favourite $ favourite ) : favourite { global $ DB ; $ this -> validate ( $ favourite ) ; $ favourite = ( array ) $ favourite ; $ time = time ( ) ; $ favourite [ 'timecreated' ] = $ time ; $ favourite [ 'timemodified' ] = $ time ; $ id = $ DB -> insert_record ( $ this -> favouritetable , $ favourit...
Add a favourite to the repository .
32,392
public function add_all ( array $ items ) : array { global $ DB ; $ time = time ( ) ; foreach ( $ items as $ item ) { $ this -> validate ( $ item ) ; $ favourite = ( array ) $ item ; $ favourite [ 'timecreated' ] = $ time ; $ favourite [ 'timemodified' ] = $ time ; $ ids [ ] = $ DB -> insert_record ( $ this -> favourit...
Add a collection of favourites to the repository .
32,393
public function find ( int $ id ) : favourite { global $ DB ; $ record = $ DB -> get_record ( $ this -> favouritetable , [ 'id' => $ id ] , '*' , MUST_EXIST ) ; return $ this -> get_favourite_from_record ( $ record ) ; }
Find a favourite by id .
32,394
public function find_all ( int $ limitfrom = 0 , int $ limitnum = 0 ) : array { global $ DB ; $ records = $ DB -> get_records ( $ this -> favouritetable , null , '' , '*' , $ limitfrom , $ limitnum ) ; return $ this -> get_list_of_favourites_from_records ( $ records ) ; }
Return all items in this repository as an array indexed by id .
32,395
public function find_favourite ( int $ userid , string $ component , string $ itemtype , int $ itemid , int $ contextid ) : favourite { global $ DB ; $ record = $ DB -> get_record ( $ this -> favouritetable , [ 'userid' => $ userid , 'component' => $ component , 'itemtype' => $ itemtype , 'itemid' => $ itemid , 'contex...
Find a specific favourite based on the properties known to identify it .
32,396
public function exists ( int $ id ) : bool { global $ DB ; return $ DB -> record_exists ( $ this -> favouritetable , [ 'id' => $ id ] ) ; }
Check whether a favourite exists in this repository based on its id .
32,397
public function update ( favourite $ favourite ) : favourite { global $ DB ; $ time = time ( ) ; $ favourite -> timemodified = $ time ; $ DB -> update_record ( $ this -> favouritetable , $ favourite ) ; return $ this -> find ( $ favourite -> id ) ; }
Update a favourite .
32,398
public function store_item ( $ cm ) { global $ CFG , $ DB ; require_once ( $ CFG -> dirroot . '/backup/util/includes/backup_includes.php' ) ; $ modinfo = get_fast_modinfo ( $ cm -> course ) ; if ( ! isset ( $ modinfo -> cms [ $ cm -> id ] ) ) { return ; } $ cminfo = $ modinfo -> cms [ $ cm -> id ] ; if ( ! plugin_suppo...
Store a course module in the recycle bin .
32,399
public function archive_to_storage ( array $ files , $ contextid , $ component , $ filearea , $ itemid , $ filepath , $ filename , $ userid = NULL , $ ignoreinvalidfiles = true , file_progress $ progress = null ) { global $ CFG ; $ fs = get_file_storage ( ) ; check_dir_exists ( $ CFG -> tempdir . '/zip' ) ; $ tmpfile =...
Zip files and store the result in file storage .