Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
Class to inherit from for 'pull' type plugins. More...
Public Member Functions | |
cleanup () | |
Perform any required cleanup functions. | |
delete () | |
Deletes everything from the database about this plugin instance. | |
expected_time ($callertime) | |
How long does this reasonably expect to take. | |
export_config_form (&$mform) | |
mform to display to the user exporting data using this plugin. | |
export_config_validation (array $data) | |
Just like the moodle form validation function. | |
get ($field) | |
Generic getter for properties belonging to this instance outside the subclasses like name, visible etc. | |
get_allowed_export_config () | |
A list of fields that can be configured by the user. | |
get_allowed_user_config () | |
A list of fields that can be configured by the user. | |
get_base_file_url () | |
The base part of the download file url to pull files from your plugin might need to add &foo=bar on the end. | |
get_config ($key) | |
Gets the value of a particular config item. | |
get_export_config ($key) | |
Gets an export time config value. | |
get_export_summary () | |
After the user submits their config, they're given a confirm screen summarising what they've chosen. | |
get_extra_finish_options () | |
Once everything is done and the user has the finish page displayed to them. | |
get_interactive_continue_url () | |
The url for the user to continue to their portfolio during the lifecycle of the request. | |
get_static_continue_url () | |
The url to save in the log as the continue url. | |
get_user_config ($key, $userid=0) | |
Get the value of a config item for a particular user. | |
has_export_config () | |
Does this plugin need configuration during export time? If you override this to return true, you must implement export_config_form. | |
has_user_config () | |
Can this plugin be configured by the user in their profile? If you override this to return true, you must implement user_config_form. | |
heading_summary () | |
Return a string to put at the header summarising this export by default, just the plugin instance name. | |
instance_sanity_check () | |
Check sanity of instances. | |
is_push () | |
return the enablelity to push | |
post_control ($stage, $params) | |
After a plugin has elected to steal control, and control returns to portfolio/add.php|postcontrol=1, this function is called, and passed the stage that was stolen control from and the request (get and post but not cookie) parameters. | |
prepare_package () | |
Called after the caller has finished having control of its prepare_package function. | |
resolve_static_continue_url ($url) | |
Override this function if you need to add something on to the url for post-export continues (eg from the log page). | |
save () | |
Saves stuff that's been stored in the object to the database. | |
send_file () | |
Called from portfolio/file.php. | |
send_package () | |
This is the function that is responsible for sending the package to the remote system, or whatever request is necessary to initiate the transfer. | |
set ($field, $value) | |
Generic setter for properties belonging to this instance outside the subclass like name, visible, etc. | |
set_config ($config) | |
Saves (or updates) the config stored in portfolio_instance_config. | |
set_export_config ($config) | |
Sets the export time config from the moodle form. | |
set_user_config ($config, $userid=0) | |
Sets config options for a given user. | |
steal_control ($stage) | |
If at any point the caller wants to steal control, it can, by returning something that isn't false in this function The controller will redirect to whatever url this function returns. | |
supported_formats () | |
Array of formats this portfolio supports the intersection of what this function returns and what the caller supports will be used. | |
user_config_form (&$mform) | |
mform to display to the user in their profile if your plugin can't be configured by the user, | |
user_config_validation (array $data) | |
Just like the moodle form validation function. | |
verify_file_request_params ($params) | |
Before sending the file when the pull is requested, verify the request parameters. | |
Static Public Member Functions | |
static | admin_config_form (&$mform) |
mform to display to the admin configuring the plugin. | |
static | admin_config_validation ($data) |
Just like the moodle form validation function, this is passed in the data array from the form and if a non empty array is returned, form processing will stop. | |
static | allows_multiple_exports () |
Whether this plugin supports multiple exports in the same session most plugins should handle this, but some that require a redirect for authentication and then don't support dynamically constructed urls to return to (eg box.net) need to override this to return false. | |
static | allows_multiple_instances () |
Override this if your plugin doesn't allow multiple instances. | |
static | create_instance ($plugin, $name, $config) |
This function creates a new instance of a plugin saves it in the database, saves the config and returns it. | |
static | file_mime_check ($mimetype) |
Override this if you are supporting the 'file' type (or a subformat) but have restrictions on mimetypes. | |
static | get_allowed_config () |
A list of fields that can be configured per instance. | |
static | get_name () |
Returns the user-friendly name for this plugin. | |
static | has_admin_config () |
Does this plugin need any configuration by the administrator? If you override this to return true, you must implement admin_config_form. | |
static | plugin_sanity_check () |
Check sanity of plugin. | |
Protected Member Functions | |
get_file () | |
Gets the stored_file object from the file id in the $file instance var. | |
init () | |
Called after __construct - allows plugins to perform initialisation tasks without having to override the constructor. | |
set_file (\stored_file $file) | |
Sets the $file instance var to the id of the supplied stored_file. | |
Protected Attributes | |
stdClass | $config |
admin configured config use { | |
bool | $dirty |
whether this object needs writing out to the database | |
array | $exportconfig |
export config during export use get_export_config and setexport_config to access. | |
stdClass | $exporter |
a reference to the exporter object | |
int | $file |
$file the id of a single file | |
integer | $id |
id of instance | |
string | $name |
name of instance | |
string | $plugin |
plugin this instance belongs to | |
stdClass | $user |
user currently exporting data | |
array | $userconfig |
user config cache. | |
bool | $visible |
whether this instance is visible or not | |
Class to inherit from for 'pull' type plugins.
Eg: those that write a file and wait for the remote system to request it from portfolio/file.php. If you're using this you must do $this->set('file', $file) so that it can be served.
|
staticinherited |
mform to display to the admin configuring the plugin.
If your plugin can't be configured by the admin,
moodleform | $mform | passed by reference, add elements to it. |
Reimplemented in portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
staticinherited |
Just like the moodle form validation function, this is passed in the data array from the form and if a non empty array is returned, form processing will stop.
array | $data | data from form. |
|
staticinherited |
Whether this plugin supports multiple exports in the same session most plugins should handle this, but some that require a redirect for authentication and then don't support dynamically constructed urls to return to (eg box.net) need to override this to return false.
This means that moodle will prevent multiple exports of this type of plugin occurring in the same session.
bool |
Reimplemented in portfolio_plugin_flickr.
|
staticinherited |
Override this if your plugin doesn't allow multiple instances.
bool |
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, and portfolio_plugin_googledocs.
|
inherited |
Perform any required cleanup functions.
bool |
Reimplemented in portfolio_plugin_mahara.
|
staticinherited |
This function creates a new instance of a plugin saves it in the database, saves the config and returns it.
You shouldn't need to override it unless you're doing something really funky
string | $plugin | portfolio plugin to create |
string | $name | name of new instance |
array | $config | what the admin config form returned |
object | subclass of portfolio_plugin_base |
|
inherited |
Deletes everything from the database about this plugin instance.
You shouldn't need to override this unless you're storing stuff in your own tables. and if so, call parent\delete when you're done.
bool |
|
abstractinherited |
How long does this reasonably expect to take.
Should we offer the user the option to wait.. This is deliberately nonstatic so it can take filesize into account
string | $callertime | - what the caller thinks the portfolio plugin instance is given the final say because it might be (for example) download. |
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
mform to display to the user exporting data using this plugin.
If your plugin doesn't need user input at this time,
moodleform | $mform | passed by reference, add elements to it. |
Reimplemented in portfolio_plugin_flickr.
|
inherited |
Just like the moodle form validation function.
This is passed in the data array from the form and if a non empty array is returned, form processing will stop.
array | $data | data from form. |
|
staticinherited |
Override this if you are supporting the 'file' type (or a subformat) but have restrictions on mimetypes.
string | $mimetype | file type or subformat |
bool |
|
finalinherited |
Generic getter for properties belonging to this instance outside the subclasses like name, visible etc.
string | $field | property name |
mixed | value of the field |
|
staticinherited |
A list of fields that can be configured per instance.
This is used for the save handlers of the config form and as checks in set_config and get_config.
array | array of strings (config item names) |
Reimplemented in portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
A list of fields that can be configured by the user.
This is used for the save handlers in the config form and as checks in set_export_config and get_export_config.
array | array of strings (config field names) |
Reimplemented in portfolio_plugin_flickr.
|
inherited |
A list of fields that can be configured by the user.
This is used for the save handlers in the config form and as checks in set_user_config and get_user_config.
array | array of strings (config field names) |
Reimplemented in portfolio_plugin_flickr.
portfolio_plugin_pull_base::get_base_file_url | ( | ) |
The base part of the download file url to pull files from your plugin might need to add &foo=bar on the end.
string | the url |
|
finalinherited |
Gets the value of a particular config item.
string | $key | key to fetch |
null|mixed | the corresponding value |
|
finalinherited |
Gets an export time config value.
Subclasses should not override this.
string | $key | field to fetch |
null|string | config value |
|
inherited |
After the user submits their config, they're given a confirm screen summarising what they've chosen.
This function should return a table of nice strings => values of what they've chosen to be displayed in a table.
bool |
Reimplemented in portfolio_plugin_flickr.
|
inherited |
Once everything is done and the user has the finish page displayed to them.
The base class takes care of printing them "return to where you are" or "continue to portfolio" links. This function allows for exta finish options from the plugin
bool |
|
protected |
Gets the stored_file object from the file id in the $file instance var.
stored_file|null | the stored_file object if it exists, null otherwise. |
|
abstractinherited |
The url for the user to continue to their portfolio during the lifecycle of the request.
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
staticinherited |
Returns the user-friendly name for this plugin.
Usually just get_string('pluginname', 'portfolio_something')
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
The url to save in the log as the continue url.
This is passed through resolve_static_continue_url() at display time to the user.
string |
Reimplemented in portfolio_plugin_mahara.
|
finalinherited |
Get the value of a config item for a particular user.
string | $key | key to fetch |
int | $userid | id of user (defaults to current) |
string | the corresponding value |
|
staticinherited |
Does this plugin need any configuration by the administrator? If you override this to return true, you must implement admin_config_form.
bool |
Reimplemented in portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
Does this plugin need configuration during export time? If you override this to return true, you must implement export_config_form.
bool |
Reimplemented in portfolio_plugin_flickr.
|
inherited |
Can this plugin be configured by the user in their profile? If you override this to return true, you must implement user_config_form.
bool |
|
inherited |
Return a string to put at the header summarising this export by default, just the plugin instance name.
string |
|
protectedinherited |
Called after __construct - allows plugins to perform initialisation tasks without having to override the constructor.
Reimplemented in portfolio_plugin_mahara.
|
inherited |
Check sanity of instances.
If this function returns something non empty, the instance will be set to invislbe and not be able to be set back until it's fixed.
int|string|bool | - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok |
Reimplemented in portfolio_plugin_googledocs, and portfolio_plugin_mahara.
portfolio_plugin_pull_base::is_push | ( | ) |
|
staticinherited |
Check sanity of plugin.
If this function returns something non empty, ALL instances of your plugin will be set to invisble and not be able to be set back until it's fixed
string|int|bool | - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok |
Reimplemented in portfolio_plugin_mahara.
|
inherited |
After a plugin has elected to steal control, and control returns to portfolio/add.php|postcontrol=1, this function is called, and passed the stage that was stolen control from and the request (get and post but not cookie) parameters.
This is useful for external systems that need to redirect the user back with some extra data in the url (like auth tokens etc) for an example implementation, see googledocs portfolio plugin.
int | $stage | the stage before control was stolen |
array | $params | a merge of $_GET and $_POST |
Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_googledocs.
|
abstractinherited |
Called after the caller has finished having control of its prepare_package function.
This function should read all the files from the portfolio working file area and zip them and send them or whatever it wants. get_tempfiles to get the list of files.
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
Override this function if you need to add something on to the url for post-export continues (eg from the log page).
Mahara does this, for example, to start a jump session.
string | $url | static continue url |
string |
Reimplemented in portfolio_plugin_mahara.
|
inherited |
Saves stuff that's been stored in the object to the database.
You shouldn't need to override this unless you're doing something really funky. and if so, call parent\save when you're done.
bool |
portfolio_plugin_pull_base::send_file | ( | ) |
Called from portfolio/file.php.
This function sends the stored file out to the browser. The default is to just use send_stored_file, but other implementations might do something different, for example, send back the file base64 encoded and encrypted mahara does this but in the response to an xmlrpc request rather than through file.php
|
abstractinherited |
This is the function that is responsible for sending the package to the remote system, or whatever request is necessary to initiate the transfer.
bool | success |
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
finalinherited |
Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.
string | $field | property's name |
string | $value | property's value |
bool |
|
finalinherited |
Saves (or updates) the config stored in portfolio_instance_config.
You shouldn't need to override this unless you're doing something funky.
array | $config | array of config items. |
|
inherited |
Sets the export time config from the moodle form.
You can also use this to set export config that isn't actually controlled by the user. Eg: things that your subclasses want to keep in state across the export. Keys must be in get_allowed_export_config This is deliberately not final (see googledocs plugin)
array | $config | named array of config items to set. |
|
protected |
Sets the $file instance var to the id of the supplied stored_file.
This helper allows the $this->get('file') call to return a stored_file, but means that we only ever record an id reference in the $file instance var.
stored_file | $file | The stored_file instance. |
void |
|
finalinherited |
Sets config options for a given user.
array | $config | array containing key/value pairs to set |
int | $userid | userid to set config for (defaults to current) |
|
inherited |
If at any point the caller wants to steal control, it can, by returning something that isn't false in this function The controller will redirect to whatever url this function returns.
Afterwards, you can redirect back to portfolio/add.php?postcontrol=1 and post_control is called before the rest of the processing for the stage is done,
int | $stage | to steal control before (see constants PARAM_STAGE_*} |
bool |
Reimplemented in portfolio_plugin_download, portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
Array of formats this portfolio supports the intersection of what this function returns and what the caller supports will be used.
Use the constants PORTFOLIO_FORMAT_*
array | list of formats |
Reimplemented in portfolio_plugin_flickr, portfolio_plugin_googledocs, and portfolio_plugin_mahara.
|
inherited |
mform to display to the user in their profile if your plugin can't be configured by the user,
moodleform | $mform | passed by reference, add elements to it |
|
inherited |
Just like the moodle form validation function.
This is passed in the data array from the form and if a non empty array is returned, form processing will stop.
array | $data | data from form. |
|
abstract |
Before sending the file when the pull is requested, verify the request parameters.
These might include a token of some sort of whatever
array | $params | request parameters (POST wins over GET) |
Reimplemented in portfolio_plugin_download, and portfolio_plugin_mahara.
|
protectedinherited |
admin configured config use {
|
protectedinherited |
user config cache.
keyed on userid and then on config field => value use get_user_config and set_user_config to access.