Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]
This file contains the base classes for portfolio plugins to inherit from: portfolio_plugin_pull_base and portfolio_plugin_push_base which both in turn inherit from portfolio_plugin_base.
Copyright: | 2008 Penny Leach <penny@catalyst.net.nz>, |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 872 lines (31 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
portfolio_plugin_base:: (40 methods):
supported_formats()
file_mime_check()
get_name()
plugin_sanity_check()
instance_sanity_check()
has_admin_config()
has_user_config()
has_export_config()
export_config_validation()
user_config_validation()
set_export_config()
get_export_config()
get_export_summary()
get_extra_finish_options()
get_static_continue_url()
resolve_static_continue_url()
user_config_form()
admin_config_form()
admin_config_validation()
export_config_form()
allows_multiple_instances()
steal_control()
post_control()
create_instance()
__construct()
init()
get_allowed_config()
get_allowed_user_config()
get_allowed_export_config()
set_config()
get_config()
get_user_config()
set_user_config()
get()
set()
save()
delete()
cleanup()
allows_multiple_exports()
heading_summary()
portfolio_plugin_push_base:: (1 method):
is_push()
portfolio_plugin_pull_base:: (5 methods):
is_push()
get_base_file_url()
send_file()
set_file()
get_file()
Class: portfolio_plugin_base - X-Ref
The base class for portfolio plugins.supported_formats() X-Ref |
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_* return: array list of formats |
file_mime_check($mimetype) X-Ref |
Override this if you are supporting the 'file' type (or a subformat) but have restrictions on mimetypes param: string $mimetype file type or subformat return: bool |
get_name() X-Ref |
Returns the user-friendly name for this plugin. Usually just get_string('pluginname', 'portfolio_something') |
plugin_sanity_check() X-Ref |
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 return: string|int|bool - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok |
instance_sanity_check() X-Ref |
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. return: int|string|bool - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok |
has_admin_config() X-Ref |
Does this plugin need any configuration by the administrator? If you override this to return true, you <b>must</b> implement admin_config_form. return: bool |
has_user_config() X-Ref |
Can this plugin be configured by the user in their profile? If you override this to return true, you <b>must</b> implement user_config_form return: bool |
has_export_config() X-Ref |
Does this plugin need configuration during export time? If you override this to return true, you <b>must</b> implement export_config_form. return: bool |
export_config_validation(array $data) X-Ref |
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. param: array $data data from form. |
user_config_validation(array $data) X-Ref |
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. param: array $data data from form. |
set_export_config($config) X-Ref |
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) param: array $config named array of config items to set. |
get_export_config($key) X-Ref |
Gets an export time config value. Subclasses should not override this. param: string $key field to fetch return: null|string config value |
get_export_summary() X-Ref |
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. return: bool |
get_extra_finish_options() X-Ref |
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 return: bool |
get_static_continue_url() X-Ref |
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. return: string |
resolve_static_continue_url($url) X-Ref |
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. param: string $url static continue url return: string |
user_config_form(&$mform) X-Ref |
mform to display to the user in their profile if your plugin can't be configured by the user, param: moodleform $mform passed by reference, add elements to it |
admin_config_form(&$mform) X-Ref |
mform to display to the admin configuring the plugin. If your plugin can't be configured by the admin, param: moodleform $mform passed by reference, add elements to it. |
admin_config_validation($data) X-Ref |
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. param: array $data data from form. |
export_config_form(&$mform) X-Ref |
mform to display to the user exporting data using this plugin. If your plugin doesn't need user input at this time, param: moodleform $mform passed by reference, add elements to it. |
allows_multiple_instances() X-Ref |
Override this if your plugin doesn't allow multiple instances return: bool |
steal_control($stage) X-Ref |
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, param: int $stage to steal control *before* (see constants PARAM_STAGE_*} return: bool |
post_control($stage, $params) X-Ref |
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. param: int $stage the stage before control was stolen param: array $params a merge of $_GET and $_POST |
create_instance($plugin, $name, $config) X-Ref |
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 param: string $plugin portfolio plugin to create param: string $name name of new instance param: array $config what the admin config form returned return: object subclass of portfolio_plugin_base |
__construct($instanceid, $record=null) X-Ref |
Construct a plugin instance. Subclasses should not need to override this unless they're doing something special and should call parent::__construct afterwards. param: int $instanceid id of plugin instance to construct param: mixed $record stdclass object or named array - use this if you already have the record to avoid another query return: portfolio_plugin_base |
init() X-Ref |
Called after __construct - allows plugins to perform initialisation tasks without having to override the constructor. |
get_allowed_config() X-Ref |
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. return: array array of strings (config item names) |
get_allowed_user_config() X-Ref |
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. return: array array of strings (config field names) |
get_allowed_export_config() X-Ref |
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. return: array array of strings (config field names) |
set_config($config) X-Ref |
Saves (or updates) the config stored in portfolio_instance_config. You shouldn't need to override this unless you're doing something funky. param: array $config array of config items. |
get_config($key) X-Ref |
Gets the value of a particular config item param: string $key key to fetch return: null|mixed the corresponding value |
get_user_config($key, $userid=0) X-Ref |
Get the value of a config item for a particular user. param: string $key key to fetch param: int $userid id of user (defaults to current) return: string the corresponding value |
set_user_config($config, $userid=0) X-Ref |
Sets config options for a given user. param: array $config array containing key/value pairs to set param: int $userid userid to set config for (defaults to current) |
get($field) X-Ref |
Generic getter for properties belonging to this instance <b>outside</b> the subclasses like name, visible etc. param: string $field property name return: mixed value of the field |
set($field, $value) X-Ref |
Generic setter for properties belonging to this instance <b>outside</b> the subclass like name, visible, etc. param: string $field property's name param: string $value property's value return: bool |
save() X-Ref |
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. return: bool |
delete() X-Ref |
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. return: bool |
cleanup() X-Ref |
Perform any required cleanup functions return: bool |
allows_multiple_exports() X-Ref |
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. return: bool |
heading_summary() X-Ref |
Return a string to put at the header summarising this export by default, just the plugin instance name return: string |
Class: portfolio_plugin_push_base - X-Ref
Class to inherit from for 'push' type pluginsClass: portfolio_plugin_pull_base - X-Ref
Class to inherit from for 'pull' type plugins.is_push() X-Ref |
return the enablelity to push return: bool |
get_base_file_url() X-Ref |
The base part of the download file url to pull files from your plugin might need to add &foo=bar on the end return: string the url |
send_file() X-Ref |
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 |
set_file(\stored_file $file) X-Ref |
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. param: \stored_file $file The stored_file instance. return: void |
get_file() X-Ref |
Gets the \stored_file object from the file id in the $file instance var. return: stored_file|null the \stored_file object if it exists, null otherwise. |