Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 311 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Defines classes used for plugin info.

Copyright: 2011 David Mudrak <david@moodle.com>
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 654 lines (23 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: base  - X-Ref

Base class providing access to the information about a plugin

get_enabled_plugins()   X-Ref
Finds all enabled plugins, the result may include missing plugins.

return: array|null of enabled plugins $pluginname=>$pluginname, null means unknown

enable_plugin(string $pluginname, int $enabled)   X-Ref
Enable or disable a plugin.
When possible, the change will be stored into the config_log table, to let admins check when/who has modified it.

return: bool Whether $pluginname has been updated or not.
param: string $pluginname The plugin name to enable/disable.
param: int $enabled Whether the pluginname should be enabled (1) or not (0). This is an integer because some plugins, such

get_enabled_plugin(string $pluginname)   X-Ref
Returns current status for a pluginname.

return: int The current status (enabled, disabled...) of $pluginname.
param: string $pluginname The plugin name to check.

get_plugins($type, $typerootdir, $typeclass, $pluginman)   X-Ref
Gathers and returns the information about all plugins of the given type,
either on disk or previously installed.

This is supposed to be used exclusively by the plugin manager when it is
populating its tree of plugins.

return: array of plugintype classes, indexed by the plugin name
param: string $type the name of the plugintype, eg. mod, auth or workshopform
param: string $typerootdir full path to the location of the plugin dir
param: string $typeclass the name of the actually called class
param: core_plugin_manager $pluginman the plugin manager calling this method

make_plugin_instance($type, $typerootdir, $name, $namerootdir, $typeclass, $pluginman)   X-Ref
Makes a new instance of the plugininfo class

return: base the instance of $typeclass
param: string $type the plugin type, eg. 'mod'
param: string $typerootdir full path to the location of all the plugins of this type
param: string $name the plugin name, eg. 'workshop'
param: string $namerootdir full path to the location of the plugin
param: string $typeclass the name of class that holds the info about the plugin
param: core_plugin_manager $pluginman the plugin manager of the new instance

is_installed_and_upgraded()   X-Ref
Is this plugin already installed and updated?

return: bool true if plugin installed and upgraded.

init_display_name()   X-Ref
Sets {@link $displayname} property to a localized name of the plugin


__get($name)   X-Ref
Magic method getter, redirects to read only values.

return: mixed
param: string $name

full_path($relativepath)   X-Ref
Return the full path name of a file within the plugin.

No check is made to see if the file exists.

return: string e.g. $CFG->dirroot . '/mod/quiz/version.php'.
param: string $relativepath e.g. 'version.php'.

load_disk_version()   X-Ref
Sets {@link $versiondisk} property to a numerical value representing the
version of the plugin's source code.

If the value is null after calling this method, either the plugin
does not use versioning (typically does not have any database
data) or is missing from disk.

get_other_required_plugins()   X-Ref
Get the list of other plugins that this plugin requires to be installed.

return: array with keys the frankenstyle plugin name, and values either

is_subplugin()   X-Ref
Is this is a subplugin?

return: boolean

get_parent_plugin()   X-Ref
If I am a subplugin, return the name of my parent plugin.

return: string|bool false if not a subplugin, name of the parent otherwise

load_db_version()   X-Ref
Sets {@link $versiondb} property to a numerical value representing the
currently installed version of the plugin.

If the value is null after calling this method, either the plugin
does not use versioning (typically does not have any database
data) or has not been installed yet.

init_is_standard()   X-Ref
Sets {@link $source} property to one of core_plugin_manager::PLUGIN_SOURCE_xxx
constants.

If the property's value is null after calling this method, then
the type of the plugin has not been recognized and you should throw
an exception.

is_standard()   X-Ref
Returns true if the plugin is shipped with the official distribution
of the current Moodle version, false otherwise.

return: bool

is_core_dependency_satisfied($moodleversion)   X-Ref
Returns true if the the given Moodle version is enough to run this plugin

return: bool
param: string|int|double $moodleversion

is_core_compatible_satisfied(int $branch)   X-Ref
Returns true if the the given moodle branch is not stated incompatible with the plugin

return: bool true if not incompatible with moodle branch
param: int $branch the moodle branch number

get_status()   X-Ref
Returns the status of the plugin

return: string one of core_plugin_manager::PLUGIN_STATUS_xxx constants

is_enabled()   X-Ref
Returns the information about plugin availability

True means that the plugin is enabled. False means that the plugin is
disabled. Null means that the information is not available, or the
plugin does not support configurable availability or the availability
can not be changed.

return: null|bool

available_updates()   X-Ref
If there are updates for this plugin available, returns them.

Returns array of {@link \core\update\info} objects, if some update
is available. Returns null if there is no update available or if the update
availability is unknown.

Populates the property {@link $availableupdates} on first call (lazy
loading).

return: array|null

get_settings_section_name()   X-Ref
Returns the node name used in admin settings menu for this plugin settings (if applicable)

return: null|string node name or null if plugin does not create settings node (default)

get_settings_url()   X-Ref
Returns the URL of the plugin settings screen

Null value means that the plugin either does not have the settings screen
or its location is not available via this library.

return: null|moodle_url

load_settings(\part_of_admin_tree $adminroot, $parentnodename, $hassiteconfig)   X-Ref
Loads plugin settings to the settings tree

This function usually includes settings.php file in plugins folder.
Alternatively it can create a link to some settings page (instance of admin_externalpage)

param: \part_of_admin_tree $adminroot
param: string $parentnodename
param: bool $hassiteconfig whether the current user has moodle/site:config capability

is_uninstall_allowed()   X-Ref
Should there be a way to uninstall the plugin via the administration UI.

By default uninstallation is not allowed, plugin developers must enable it explicitly!

return: bool

get_uninstall_extra_warning()   X-Ref
Optional extra warning before uninstallation, for example number of uses in courses.

return: string

uninstall_cleanup()   X-Ref
Pre-uninstall hook.

This is intended for disabling of plugin, some DB table purging, etc.

NOTE: to be called from uninstall_plugin() only.

get_dir()   X-Ref
Returns relative directory of the plugin with heading '/'

return: string

uninstall(\progress_trace $progress)   X-Ref
Hook method to implement certain steps when uninstalling the plugin.

This hook is called by {@link core_plugin_manager::uninstall_plugin()} so
it is basically usable only for those plugin types that use the default
uninstall tool provided by {@link self::get_default_uninstall_url()}.

return: bool true on success, false on failure
param: \progress_trace $progress traces the process

get_return_url_after_uninstall($return)   X-Ref
Where should we return after plugin of this type is uninstalled?

return: moodle_url
param: string $return

get_manage_url()   X-Ref
Return URL used for management of plugins of this type.

return: moodle_url

get_default_uninstall_url($return = 'overview')   X-Ref
Returns URL to a script that handles common plugin uninstall procedure.

This URL is intended for all plugin uninstallations.

return: moodle_url
param: string $return either 'overview' or 'manage'