Moodle  2.2.1
http://www.collinsharper.com
portfolio_plugin_base Class Reference
Inheritance diagram for portfolio_plugin_base:

Public Member Functions

 supported_formats ()
 expected_time ($callertime)
 is_push ()
 instance_sanity_check ()
 has_user_config ()
 has_export_config ()
 export_config_validation (array $data)
 user_config_validation (array $data)
 set_export_config ($config)
 get_export_config ($key)
 get_export_summary ()
 prepare_package ()
 send_package ()
 get_extra_finish_options ()
 get_interactive_continue_url ()
 get_static_continue_url ()
 resolve_static_continue_url ($url)
 user_config_form (&$mform)
 admin_config_form (&$mform)
 admin_config_validation ($data)
 export_config_form (&$mform)
 steal_control ($stage)
 post_control ($stage, $params)
 __construct ($instanceid, $record=null)
 get_allowed_user_config ()
 get_allowed_export_config ()
 set_config ($config)
 get_config ($key)
 get_user_config ($key, $userid=0)
 set_user_config ($config, $userid=0)
 get ($field)
 set ($field, $value)
 save ()
 delete ()
 cleanup ()
 heading_summary ()

Static Public Member Functions

static file_mime_check ($mimetype)
static get_name ()
static plugin_sanity_check ()
static has_admin_config ()
static allows_multiple_instances ()
static create_instance ($plugin, $name, $config)
static get_allowed_config ()
static allows_multiple_exports ()

Protected Member Functions

 init ()

Protected Attributes

 $dirty
 $id
 $name
 $plugin
 $visible
 $config
 $userconfig
 $exportconfig
 $user
 $exporter

Detailed Description

the base class for portfolio plugins all plugins must subclass this either via {

See also:
portfolio_plugin_pull_base} or {
portfolio_plugin_push_base}

Definition at line 39 of file plugin.php.


Constructor & Destructor Documentation

__construct ( instanceid,
record = null 
)

construct a plugin instance subclasses should not need to override this unless they're doing something special and should call parent::__construct afterwards

Parameters:
int$instanceidid of plugin instance to construct
mixed$recordstdclass object or named array - use this i you already have the record to avoid another query
Returns:
object subclass of portfolio_plugin_base

Definition at line 487 of file plugin.php.


Member Function Documentation

admin_config_form ( &$  mform)

mform to display to the admin configuring the plugin. if your plugin can't be configured by the admin, (see 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 in portfolio_plugin_boxnet, portfolio_plugin_flickr, and portfolio_plugin_mahara.

Definition at line 378 of file plugin.php.

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.
Returns:
array keyvalue pairs - form element => error string

Definition at line 388 of file plugin.php.

static allows_multiple_exports ( ) [static]

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.

Returns:
boolean

Reimplemented in portfolio_plugin_boxnet, and portfolio_plugin_flickr.

Definition at line 753 of file plugin.php.

static allows_multiple_instances ( ) [static]

override this if your plugin doesn't allow multiple instances

Returns:
boolean

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

Definition at line 404 of file plugin.php.

cleanup ( )

perform any required cleanup functions

Reimplemented in portfolio_plugin_mahara.

Definition at line 739 of file plugin.php.

static create_instance ( plugin,
name,
config 
) [static]

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
Returns:
object subclass of portfolio_plugin_base

Definition at line 456 of file plugin.php.

Here is the call graph for this function:

Here is the caller graph for this function:

delete ( )

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.

Definition at line 726 of file plugin.php.

expected_time ( callertime) [abstract]

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.
Returns:
string (see PORTFOLIO_TIME_* constants)

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

export_config_form ( &$  mform)

mform to display to the user exporting data using this plugin. if your plugin doesn't need user input at this time, (see 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.

Definition at line 397 of file plugin.php.

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.
Returns:
array keyvalue pairs - form element => error string

Definition at line 220 of file plugin.php.

static file_mime_check ( mimetype) [static]

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

Returns:
boolean

Definition at line 123 of file plugin.php.

get ( field) [final]

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

Definition at line 673 of file plugin.php.

static 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

Returns:
array array of strings (config item names)

Reimplemented in portfolio_plugin_flickr, portfolio_plugin_boxnet, and portfolio_plugin_mahara.

Definition at line 522 of file plugin.php.

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.

Returns:
array array of strings (config field names)

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

Definition at line 544 of file plugin.php.

Here is the caller graph for this function:

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.

Returns:
array array of strings (config field names)

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

Definition at line 533 of file plugin.php.

get_config ( key) [final]

gets the value of a particular config item

Parameters:
string$keykey to fetch
Returns:
string the corresponding value

Definition at line 586 of file plugin.php.

Here is the caller graph for this function:

get_export_config ( key) [final]

gets an export time config value. subclasses should not override this.

Parameters:
stringkey field to fetch
Returns:
string config value

Definition at line 267 of file plugin.php.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Returns:
array array of config items.

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

Definition at line 293 of file plugin.php.

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

Returns:
array named array of links => titles

Definition at line 326 of file plugin.php.

the url for the user to continue to their portfolio during the lifecycle of the request

Returns:
string url or false.

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

Here is the caller graph for this function:

static get_name ( ) [static]

returns the user-friendly name for this plugin usually just get_string('pluginname', 'portfolio_something')

Returns:
string

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

Definition at line 156 of file plugin.php.

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.

Reimplemented in portfolio_plugin_mahara.

Definition at line 343 of file plugin.php.

Here is the call graph for this function:

get_user_config ( key,
userid = 0 
) [final]

get the value of a config item for a particular user

Parameters:
string$keykey to fetch
integer$useridid of user (defaults to current)
Returns:
string the corresponding value

Definition at line 606 of file plugin.php.

Here is the caller graph for this function:

static has_admin_config ( ) [static]

does this plugin need any configuration by the administrator?

if you override this to return true, you must implement {

See also:
admin_config_form}

Reimplemented in portfolio_plugin_flickr, portfolio_plugin_mahara, and portfolio_plugin_boxnet.

Definition at line 188 of file plugin.php.

does this plugin need configuration during export time?

if you override this to return true, you must implement {

See also:
export_config_form}

Reimplemented in portfolio_plugin_flickr, and portfolio_plugin_boxnet.

Definition at line 208 of file plugin.php.

can this plugin be configured by the user in their profile?

if you override this to return true, you must implement {

See also:
user_config_form}

Definition at line 198 of file plugin.php.

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

Returns:
string

Definition at line 763 of file plugin.php.

init ( ) [protected]

called after __construct - allows plugins to perform initialisation tasks without having to override the constructor.

Reimplemented in portfolio_plugin_mahara.

Definition at line 513 of file plugin.php.

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.

Returns:
mixed - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok

Reimplemented in portfolio_plugin_boxnet, and portfolio_plugin_mahara.

Definition at line 178 of file plugin.php.

is_push ( ) [abstract]

is this plugin push or pill. if push, cleanup will be called directly after send_package if not, cleanup will be called after portfolio/file.php is requested

Returns:
boolean

Reimplemented in portfolio_plugin_pull_base, and portfolio_plugin_push_base.

static 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

Returns:
mixed - string = error string KEY (must be inside portfolio_$yourplugin) or 0/false if you're ok

Reimplemented in portfolio_plugin_mahara.

Definition at line 167 of file plugin.php.

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 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_flickr, portfolio_plugin_boxnet, portfolio_plugin_googledocs, and portfolio_plugin_picasa.

Definition at line 441 of file plugin.php.

prepare_package ( ) [abstract]

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. {

See also:
get_tempfiles} to get the list of files.

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

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

Reimplemented in portfolio_plugin_mahara.

Definition at line 352 of file plugin.php.

save ( )

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.

Definition at line 707 of file plugin.php.

Here is the caller graph for this function:

send_package ( ) [abstract]

this is the function that is responsible for sending the package to the remote system, or whatever request is necessary to initiate the transfer.

Returns:
boolean success

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

set ( field,
value 
) [final]

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

Definition at line 687 of file plugin.php.

set_config ( config) [final]

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.

Definition at line 554 of file plugin.php.

set_export_config ( config)

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 {

See also:
get_allowed_export_config}

this is deliberately not final (see boxnet plugin)

Parameters:
array$confignamed array of config items to set.

Definition at line 244 of file plugin.php.

Here is the call graph for this function:

Here is the caller graph for this function:

set_user_config ( config,
userid = 0 
) [final]

sets config options for a given user

Parameters:
mixed$configarray or stdclass containing key/value pairs to set
integer$useriduserid to set config for (defaults to current)

Definition at line 640 of file plugin.php.

Here is the caller graph for this function:

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

Parameters:
intstage to steal control *before* (see constants PARAM_STAGE_*}
Returns:
boolean or string url

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

Definition at line 423 of file plugin.php.

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_*

Returns:
array list of formats

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

Definition at line 113 of file plugin.php.

user_config_form ( &$  mform)

mform to display to the user in their profile if your plugin can't be configured by the user, (see has_user_config) don't bother overriding this function

Parameters:
moodleform$mformpassed by reference, add elements to it

Definition at line 364 of file plugin.php.

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.
Returns:
array keyvalue pairs - form element => error string

Definition at line 230 of file plugin.php.


Field Documentation

$config [protected]

named array admin configured config use set_config and {} to access

Definition at line 76 of file plugin.php.

boolean $dirty [protected]

whether this object needs writing out to the database

Definition at line 45 of file plugin.php.

$exportconfig [protected]

named array export config during export use get_export_config and export_config to access.

Reimplemented in portfolio_plugin_download.

Definition at line 92 of file plugin.php.

$exporter [protected]

a reference to the exporter object

Definition at line 103 of file plugin.php.

integer $id [protected]

id of instance

Definition at line 51 of file plugin.php.

string $name [protected]

name of instance

Definition at line 57 of file plugin.php.

string $plugin [protected]

plugin this instance belongs to

Definition at line 63 of file plugin.php.

$user [protected]

stdclass object user currently exporting data

Definition at line 98 of file plugin.php.

$userconfig [protected]

user config cache named array of named arrays keyed on userid and then on config field => value use get_user_config and set_user_config to access.

Definition at line 85 of file plugin.php.

boolean $visible [protected]

whether this instance is visible or not

Definition at line 69 of file plugin.php.


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Enumerations