Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
tool_installaddon_installer Class Reference

Implements main plugin features. More...

Public Member Functions

 detect_plugin_component ($zipfilepath)
 Detect the given plugin's component name. More...
 
 get_addons_repository_url ()
 Returns URL to the repository that addons can be searched in and installed from. More...
 
 get_installfromzip_form ()
 
 get_plugin_types_menu ()
 Returns localised list of available plugin types. More...
 
 handle_remote_request (tool_installaddon_renderer $output, $request)
 Hook method to handle the remote request to install an add-on. More...
 
 index_url (array $params=null)
 Returns the URL to the main page of this admin tool. More...
 
 make_installfromzip_storage ()
 Makes a unique writable storage for uploaded ZIP packages. More...
 

Static Public Member Functions

static instance ()
 Factory method returning an instance of this class. More...
 

Protected Member Functions

 __construct ()
 
 decode_remote_request ($request)
 Decode the request from the Moodle Plugins directory. More...
 
 detect_plugin_component_from_versionphp ($code)
 Return the plugin component declared in its version.php file. More...
 
 encode_site_information (array $info)
 Encodes the given array in a way that can be safely appended as HTTP GET param. More...
 
 extract_versionphp_file ($zipfilepath, $targetdir)
 Extracts the version.php from the given plugin ZIP file into the target directory. More...
 
 get_site_fullname ()
 
 get_site_major_version ()
 
 get_site_url ()
 
 should_send_site_info ()
 Decide if the encoded site information should be sent to the add-ons repository site. More...
 

Protected Attributes

tool_installaddon_installfromzip_form $installfromzipform = null
 

Detailed Description

Implements main plugin features.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tool_installaddon_installer::__construct ( )
protected
See also
self::instance()

Member Function Documentation

◆ decode_remote_request()

tool_installaddon_installer::decode_remote_request (   $request)
protected

Decode the request from the Moodle Plugins directory.

Parameters
string$requestsubmitted via 'installaddonrequest' HTTP parameter
Return values
stdClass|boolfalse on error, object otherwise

◆ detect_plugin_component()

tool_installaddon_installer::detect_plugin_component (   $zipfilepath)

Detect the given plugin's component name.

Only plugins that declare valid $plugin->component value in the version.php are supported.

Parameters
string$zipfilepathfull path to the saved ZIP file
Return values
string|booldeclared component name or false if unable to detect

◆ detect_plugin_component_from_versionphp()

tool_installaddon_installer::detect_plugin_component_from_versionphp (   $code)
protected

Return the plugin component declared in its version.php file.

Parameters
string$codethe contents of the version.php file
Return values
string|booldeclared plugin component or false if unable to detect

◆ encode_site_information()

tool_installaddon_installer::encode_site_information ( array  $info)
protected

Encodes the given array in a way that can be safely appended as HTTP GET param.

Be ware! The recipient may rely on the exact way how the site information is encoded. Do not change anything here unless you know what you are doing and understand all consequences! (Don't you love warnings like that, too? :-p)

Parameters
array$info
Return values
string

◆ extract_versionphp_file()

tool_installaddon_installer::extract_versionphp_file (   $zipfilepath,
  $targetdir 
)
protected

Extracts the version.php from the given plugin ZIP file into the target directory.

Parameters
string$zipfilepathfull path to the saved ZIP file
string$targetdirfull path to extract the file to
Return values
string|boolpath to the version.php within the $targetpath; false on error (e.g. not found)

◆ get_addons_repository_url()

tool_installaddon_installer::get_addons_repository_url ( )

Returns URL to the repository that addons can be searched in and installed from.

Return values
moodle_url

◆ get_installfromzip_form()

tool_installaddon_installer::get_installfromzip_form ( )

◆ get_plugin_types_menu()

tool_installaddon_installer::get_plugin_types_menu ( )

Returns localised list of available plugin types.

Return values
array(string)plugintype => (string)plugin name

◆ get_site_fullname()

tool_installaddon_installer::get_site_fullname ( )
protected
Return values
stringthis site full name

◆ get_site_major_version()

tool_installaddon_installer::get_site_major_version ( )
protected
Return values
stringmajor version like 2.5, 2.6 etc.

◆ get_site_url()

tool_installaddon_installer::get_site_url ( )
protected
Return values
stringthis site URL

◆ handle_remote_request()

tool_installaddon_installer::handle_remote_request ( tool_installaddon_renderer  $output,
  $request 
)

Hook method to handle the remote request to install an add-on.

This is used as a callback when the admin picks a plugin version in the Moodle Plugins directory and is redirected back to their site to install it.

This hook is called early from admin/tool/installaddon/index.php page so that it has opportunity to take over the UI and display the first confirmation screen.

Parameters
tool_installaddon_renderer$output
string | null$request

◆ index_url()

tool_installaddon_installer::index_url ( array  $params = null)

Returns the URL to the main page of this admin tool.

Parameters
arrayoptional parameters
Return values
moodle_url

◆ instance()

static tool_installaddon_installer::instance ( )
static

Factory method returning an instance of this class.

Return values
tool_installaddon_installer

◆ make_installfromzip_storage()

tool_installaddon_installer::make_installfromzip_storage ( )

Makes a unique writable storage for uploaded ZIP packages.

We need the saved ZIP to survive across multiple requests so that it can be used by the plugin manager after the installation is confirmed. In other words, we cannot use make_request_directory() here.

Return values
stringfull path to the directory

◆ should_send_site_info()

tool_installaddon_installer::should_send_site_info ( )
protected

Decide if the encoded site information should be sent to the add-ons repository site.

For now, we just return true. In the future, we may want to implement some privacy aware logic (based on site/user preferences for example).

Return values
bool

The documentation for this class was generated from the following file: