Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

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 that are extended to create portfolio export functionality. For places in moodle that want to add export functionality to subclass.

Copyright: 2008 Penny Leach <penny@catalyst.net.nz>, Martin Dougiamas
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 572 lines (19 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 classes


Class: portfolio_caller_base  - X-Ref

Base class for callers

__construct($callbackargs)   X-Ref
Create portfolio_caller object

param: array $callbackargs argument properties

export_config_form(&$mform, $instance)   X-Ref
If this caller wants any additional config items,
they should be defined here.

param: moodleform $mform passed by reference, add elements to it.
param: portfolio_plugin_base $instance subclass of portfolio_plugin_base

has_export_config()   X-Ref
Whether this caller wants any additional
config during export (eg options or metadata)

return: bool

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

expected_time_file()   X-Ref
Helper method to calculate expected time for multi or single file exports

return: string file time expectation

get_sha1_file()   X-Ref
Helper function to calculate the sha1 for multi or single file exports

return: string sha1 file exports

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's name
return: mixed

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: mixed $value property's value
return: bool

set_export_config($config)   X-Ref
Stores the config generated at export time.
Subclasses can retrieve values using

param: array $config formdata

get_export_config($key)   X-Ref
Returns a particular export config value.
Subclasses shouldn't need to override this

param: string $key the config item to fetch
return: null|mixed of export configuration

get_allowed_export_config()   X-Ref
Similar to the other allowed_config functions
if you need export config, you must provide
a list of what the fields are.
Even if you want to store stuff during export
without displaying a form to the user,
you can use this.

return: array array of allowed keys

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

prepare_package_file()   X-Ref
Helper function to copy files into the temp area
for single or multi file exports.

return: stored_file|bool

supported_formats()   X-Ref
Array of formats this caller supports.

return: array list of formats

base_supported_formats()   X-Ref
Base supported formats


display_name()   X-Ref
Clean name to display to the user about this caller location


heading_summary()   X-Ref
Return a string to put at the header summarising this export.
By default, it just display the name (usually just 'assignment' or something unhelpful

return: string

set_file_and_format_data($ids=null )   X-Ref
Set up the required files for this export.
This supports either passing files directly
or passing area arguments directly through
to the files api using file_storage::get_area_files

param: mixed $ids one of:
return: void

set_formats_from_button($formats)   X-Ref
The button-location always knows best
what the formats are... so it should be trusted.

param: array $formats array of PORTFOLIO_FORMAT_XX
return: void

add_format($format)   X-Ref
Adds a new format to the list of supported formats.
This functions also handles removing conflicting and less specific
formats at the same time.

param: string $format one of PORTFOLIO_FORMAT_XX
return: void

get_mimetype()   X-Ref
Gets mimetype

return: string

expected_callbackargs()   X-Ref
Array of arguments the caller expects to be passed through to it.
This must be keyed on the argument name, and the array value is a boolean,
whether it is required, or just optional
eg array(
id            => true,
somethingelse => false
)


Class: portfolio_module_caller_base  - X-Ref

Base class for module callers.

This just implements a few of the abstract functions
from portfolio_caller_base so that caller authors
don't need to.
get_navigation()   X-Ref
Navigation passed to print_header.
Override this to do something more specific than the module view page
like adding more links to the breadcrumb.

return: array

get_return_url()   X-Ref
The url to return to after export or on cancel.
Defaults value is set to the module 'view' page.
Override this if it's deeper inside the module.

return: string

get($key)   X-Ref
Override the parent get function
to make sure when we're asked for a course,
We retrieve the object from the database as needed.

param: string $key the name of get function
return: stdClass

heading_summary()   X-Ref
Return a string to put at the header summarising this export.
by default, this function just display the name and module instance name.
Override this to do something more specific

return: string

set_context($PAGE)   X-Ref
Overridden to return the course module context

param: moodle_page $PAGE global PAGE