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
portfolio_plugin_mahara Class Reference
Inheritance diagram for portfolio_plugin_mahara:
portfolio_plugin_pull_base portfolio_plugin_base

Public Member Functions

 __wakeup ()
 
 cleanup ()
 Perform any required cleanup functions. More...
 
 delete ()
 Deletes everything from the database about this plugin instance. More...
 
 expected_time ($callertime)
 How long does this reasonably expect to take. More...
 
 export_config_form (&$mform)
 mform to display to the user exporting data using this plugin. More...
 
 export_config_validation (array $data)
 Just like the moodle form validation function. More...
 
 get ($field)
 Generic getter for properties belonging to this instance outside the subclasses like name, visible etc. More...
 
 get_allowed_export_config ()
 A list of fields that can be configured by the user. More...
 
 get_allowed_user_config ()
 A list of fields that can be configured by the user. More...
 
 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. More...
 
 get_config ($key)
 Gets the value of a particular config item. More...
 
 get_export_config ($key)
 Gets an export time config value. More...
 
 get_export_summary ()
 After the user submits their config, they're given a confirm screen summarising what they've chosen. More...
 
 get_extra_finish_options ()
 Once everything is done and the user has the finish page displayed to them. More...
 
 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. More...
 
 get_user_config ($key, $userid=0)
 Get the value of a config item for a particular user. More...
 
 has_export_config ()
 Does this plugin need configuration during export time? If you override this to return true, you must implement export_config_form. More...
 
 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. More...
 
 heading_summary ()
 Return a string to put at the header summarising this export by default, just the plugin instance name. More...
 
 instance_sanity_check ()
 Check sanity of instances. More...
 
 is_push ()
 return the enablelity to push More...
 
 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. More...
 
 prepare_package ()
 Called after the caller has finished having control of its prepare_package function. More...
 
 resolve_static_continue_url ($remoteurl)
 Override this function if you need to add something on to the url for post-export continues (eg from the log page). More...
 
 save ()
 Saves stuff that's been stored in the object to the database. More...
 
 send_file ()
 Called from portfolio/file.php. More...
 
 send_intent ()
 sends the 'content_intent' ping to mahara if all goes well, this will set the 'token' and 'sendtype' member variables.
 
 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. More...
 
 set ($field, $value)
 Generic setter for properties belonging to this instance outside the subclass like name, visible, etc. More...
 
 set_config ($config)
 Saves (or updates) the config stored in portfolio_instance_config. More...
 
 set_export_config ($config)
 Sets the export time config from the moodle form. More...
 
 set_user_config ($config, $userid=0)
 Sets config options for a given user. More...
 
 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. More...
 
 supported_formats ()
 Array of formats this portfolio supports the intersection of what this function returns and what the caller supports will be used. More...
 
 user_config_form (&$mform)
 mform to display to the user in their profile if your plugin can't be configured by the user, More...
 
 user_config_validation (array $data)
 Just like the moodle form validation function. More...
 
 verify_file_request_params ($params)
 Before sending the file when the pull is requested, verify the request parameters. More...
 

Static Public Member Functions

static admin_config_form (&$mform)
 mform to display to the admin configuring the plugin. More...
 
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. More...
 
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. More...
 
static allows_multiple_instances ()
 Override this if your plugin doesn't allow multiple instances. More...
 
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. More...
 
static fetch_file ($token)
 xmlrpc (mnet) function to get the file. More...
 
static file_mime_check ($mimetype)
 Override this if you are supporting the 'file' type (or a subformat) but have restrictions on mimetypes. More...
 
static get_allowed_config ()
 A list of fields that can be configured per instance. More...
 
static get_name ()
 Returns the user-friendly name for this plugin. More...
 
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. More...
 
static plugin_sanity_check ()
 Check sanity of plugin. More...
 

Protected Member Functions

 get_file ()
 Gets the stored_file object from the file id in the $file instance var. More...
 
 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. More...
 

Protected Attributes

array $config
 admin configured config use } and { to access
 
bool $dirty
 whether this object needs writing out to the database
 
array $exportconfig
 export config during export use } and set export_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. More...
 
bool $visible
 whether this instance is visible or not
 

Member Function Documentation

◆ admin_config_form()

static portfolio_plugin_mahara::admin_config_form ( $mform)
static

mform to display to the admin configuring the plugin.

If your plugin can't be configured by the admin,

See also
has_admin_config Don't bother overriding this function. This function can be called statically or non statically, depending on whether it's creating a new instance (statically), or editing an existing one (non statically)
Parameters
moodleform$mformpassed by reference, add elements to it.

Reimplemented from portfolio_plugin_base.

◆ admin_config_validation()

static portfolio_plugin_base::admin_config_validation (   $data)
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.

Parameters
array$datadata from form.

◆ allows_multiple_exports()

static portfolio_plugin_base::allows_multiple_exports ( )
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.

Return values
bool

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ allows_multiple_instances()

static portfolio_plugin_base::allows_multiple_instances ( )
staticinherited

Override this if your plugin doesn't allow multiple instances.

Return values
bool

Reimplemented in portfolio_plugin_picasa, portfolio_plugin_googledocs, portfolio_plugin_flickr, portfolio_plugin_download, and portfolio_plugin_boxnet.

◆ cleanup()

portfolio_plugin_mahara::cleanup ( )

Perform any required cleanup functions.

Return values
bool

Reimplemented from portfolio_plugin_base.

◆ create_instance()

static portfolio_plugin_base::create_instance (   $plugin,
  $name,
  $config 
)
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

Parameters
string$pluginportfolio plugin to create
string$namename of new instance
array$configwhat the admin config form returned
Return values
objectsubclass of portfolio_plugin_base

◆ delete()

portfolio_plugin_base::delete ( )
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.

Return values
bool

◆ expected_time()

portfolio_plugin_mahara::expected_time (   $callertime)

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

Parameters
string$callertime- what the caller thinks the portfolio plugin instance is given the final say because it might be (for example) download.

Reimplemented from portfolio_plugin_base.

◆ export_config_form()

portfolio_plugin_base::export_config_form ( $mform)
inherited

mform to display to the user exporting data using this plugin.

If your plugin doesn't need user input at this time,

See also
has_export_config. Don't bother overrideing this function
Parameters
moodleform$mformpassed by reference, add elements to it.

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ export_config_validation()

portfolio_plugin_base::export_config_validation ( array  $data)
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.

Parameters
array$datadata from form.

Reimplemented in portfolio_plugin_boxnet.

◆ fetch_file()

static portfolio_plugin_mahara::fetch_file (   $token)
static

xmlrpc (mnet) function to get the file.

reads in the file and returns it base_64 encoded so that it can be enrypted by mnet.

Parameters
string$tokenthe token recieved previously during send_content_intent

◆ file_mime_check()

static portfolio_plugin_base::file_mime_check (   $mimetype)
staticinherited

Override this if you are supporting the 'file' type (or a subformat) but have restrictions on mimetypes.

Parameters
string$mimetypefile type or subformat
Return values
bool

◆ get()

portfolio_plugin_base::get (   $field)
finalinherited

Generic getter for properties belonging to this instance outside the subclasses like name, visible etc.

Parameters
string$fieldproperty name
Return values
array|string|int|booleanvalue of the field

◆ get_allowed_config()

static portfolio_plugin_mahara::get_allowed_config ( )
static

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 values
arrayarray of strings (config item names)

Reimplemented from portfolio_plugin_base.

◆ get_allowed_export_config()

portfolio_plugin_base::get_allowed_export_config ( )
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.

Return values
arrayarray of strings (config field names)

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ get_allowed_user_config()

portfolio_plugin_base::get_allowed_user_config ( )
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.

Return values
arrayarray of strings (config field names)

Reimplemented in portfolio_plugin_flickr.

◆ get_base_file_url()

portfolio_plugin_pull_base::get_base_file_url ( )
inherited

The base part of the download file url to pull files from your plugin might need to add &foo=bar on the end.

See also
verify_file_request_params
Return values
stringthe url

◆ get_config()

portfolio_plugin_base::get_config (   $key)
finalinherited

Gets the value of a particular config item.

Parameters
string$keykey to fetch
Return values
null|mixedthe corresponding value

◆ get_export_config()

portfolio_plugin_base::get_export_config (   $key)
finalinherited

Gets an export time config value.

Subclasses should not override this.

Parameters
string$keyfield to fetch
Return values
null|stringconfig value

◆ get_export_summary()

portfolio_plugin_base::get_export_summary ( )
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.

Return values
bool

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ get_extra_finish_options()

portfolio_plugin_base::get_extra_finish_options ( )
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

Return values
bool

◆ get_file()

portfolio_plugin_pull_base::get_file ( )
protectedinherited

Gets the stored_file object from the file id in the $file instance var.

Return values
stored_file|nullthe stored_file object if it exists, null otherwise.

◆ get_name()

static portfolio_plugin_mahara::get_name ( )
static

Returns the user-friendly name for this plugin.

Usually just get_string('pluginname', 'portfolio_something')

Reimplemented from portfolio_plugin_base.

◆ get_static_continue_url()

portfolio_plugin_mahara::get_static_continue_url ( )

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 values
string

Reimplemented from portfolio_plugin_base.

◆ get_user_config()

portfolio_plugin_base::get_user_config (   $key,
  $userid = 0 
)
finalinherited

Get the value of a config item for a particular user.

Parameters
string$keykey to fetch
int$useridid of user (defaults to current)
Return values
stringthe corresponding value

◆ has_admin_config()

static portfolio_plugin_mahara::has_admin_config ( )
static

Does this plugin need any configuration by the administrator? If you override this to return true, you must implement admin_config_form.

See also
admin_config_form
Return values
bool

Reimplemented from portfolio_plugin_base.

◆ has_export_config()

portfolio_plugin_base::has_export_config ( )
inherited

Does this plugin need configuration during export time? If you override this to return true, you must implement export_config_form.

See also
export_config_form
Return values
bool

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ has_user_config()

portfolio_plugin_base::has_user_config ( )
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.

See also
user_config_form
Return values
bool

◆ heading_summary()

portfolio_plugin_base::heading_summary ( )
inherited

Return a string to put at the header summarising this export by default, just the plugin instance name.

Return values
string

◆ instance_sanity_check()

portfolio_plugin_mahara::instance_sanity_check ( )

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 values
int|string|bool- string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok

Reimplemented from portfolio_plugin_base.

◆ is_push()

portfolio_plugin_pull_base::is_push ( )
inherited

return the enablelity to push

Return values
bool

Reimplemented from portfolio_plugin_base.

◆ plugin_sanity_check()

static portfolio_plugin_mahara::plugin_sanity_check ( )
static

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 values
string|int|bool- string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok

Reimplemented from portfolio_plugin_base.

◆ post_control()

portfolio_plugin_base::post_control (   $stage,
  $params 
)
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 boxnet portfolio plugin.

Parameters
int$stagethe stage before control was stolen
array$paramsa merge of $_GET and $_POST

Reimplemented in portfolio_plugin_picasa, portfolio_plugin_googledocs, portfolio_plugin_flickr, and portfolio_plugin_boxnet.

◆ prepare_package()

portfolio_plugin_mahara::prepare_package ( )

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.

See also
get_tempfiles

Reimplemented from portfolio_plugin_base.

◆ resolve_static_continue_url()

portfolio_plugin_mahara::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).

Mahara does this, for example, to start a jump session.

Parameters
string$urlstatic continue url
Return values
string

Reimplemented from portfolio_plugin_base.

◆ save()

portfolio_plugin_base::save ( )
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.

Return values
bool

◆ send_file()

portfolio_plugin_pull_base::send_file ( )
inherited

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

◆ send_package()

portfolio_plugin_mahara::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.

Return values
boolsuccess

Reimplemented from portfolio_plugin_base.

◆ set()

portfolio_plugin_base::set (   $field,
  $value 
)
finalinherited

Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.

Parameters
string$fieldproperty's name
string$valueproperty's value
Return values
bool

◆ set_config()

portfolio_plugin_base::set_config (   $config)
finalinherited

Saves (or updates) the config stored in portfolio_instance_config.

You shouldn't need to override this unless you're doing something funky.

Parameters
array$configarray of config items.

◆ set_export_config()

portfolio_plugin_base::set_export_config (   $config)
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 boxnet plugin)

See also
get_allowed_export_config
Parameters
array$confignamed array of config items to set.

◆ set_file()

portfolio_plugin_pull_base::set_file ( \stored_file  $file)
protectedinherited

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.

Parameters
stored_file$fileThe stored_file instance.
Return values
void

◆ set_user_config()

portfolio_plugin_base::set_user_config (   $config,
  $userid = 0 
)
finalinherited

Sets config options for a given user.

Parameters
array$configarray containing key/value pairs to set
int$useriduserid to set config for (defaults to current)

◆ steal_control()

portfolio_plugin_mahara::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.

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,

See also
post_control
Parameters
int$stageto steal control before (see constants PARAM_STAGE_*}
Return values
bool

Reimplemented from portfolio_plugin_base.

◆ supported_formats()

portfolio_plugin_mahara::supported_formats ( )

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 values
arraylist of formats

Reimplemented from portfolio_plugin_base.

◆ user_config_form()

portfolio_plugin_base::user_config_form ( $mform)
inherited

mform to display to the user in their profile if your plugin can't be configured by the user,

See also
has_user_config. Don't bother overriding this function
Parameters
moodleform$mformpassed by reference, add elements to it

◆ user_config_validation()

portfolio_plugin_base::user_config_validation ( array  $data)
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.

Parameters
array$datadata from form.

◆ verify_file_request_params()

portfolio_plugin_mahara::verify_file_request_params (   $params)

Before sending the file when the pull is requested, verify the request parameters.

These might include a token of some sort of whatever

Parameters
array$paramsrequest parameters (POST wins over GET)

Reimplemented from portfolio_plugin_pull_base.

Member Data Documentation

◆ $userconfig

array portfolio_plugin_base::$userconfig
protectedinherited

user config cache.

keyed on userid and then on config field => value use } and set_user_config to access.


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