Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 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: 659 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.

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
return: bool Whether $pluginname has been updated or not.

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

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

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.

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
return: array of plugintype classes, indexed by the plugin name

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

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
return: base the instance of $typeclass

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.

param: string $name
return: mixed

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.

param: string $relativepath e.g. 'version.php'.
return: string e.g. $CFG->dirroot . '/mod/quiz/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

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

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

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

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()}.

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

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

param: string $return
return: moodle_url

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.

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