Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
data_portfolio_caller Class Reference

The class to handle entry exports of a database module. More...

Inheritance diagram for data_portfolio_caller:

Public Member Functions

 __construct ($callbackargs)
 
object __wakeup ()
 
 check_permissions ()
 Verify the user can still export this entry.
 
 expected_time ()
 How long we think the export will take Single entry is probably not too long.
 
 expected_time_file ()
 Helper method to calculate expected time for multi or single file exports.
 
 export_config_form (&$mform, $instance)
 If this caller wants any additional config items, they should be defined here.
 
 export_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.
 
 get ($key)
 Override the parent get function to make sure when we're asked for a course, We retrieve the object from the database as needed.
 
 get_allowed_export_config ()
 Similar to the other allowed_config functions if you need export config, you must provide a list of what the fields are.
 
 get_export_config ($key)
 Returns a particular export config value.
 
 get_export_summary ()
 After the user submits their config, they're given a confirm screen summarising what they've chosen.
 
 get_mimetype ()
 Gets mimetype.
 
 get_navigation ()
 Navigation passed to print_header.
 
 get_return_url ()
 The url to return to after export or on cancel.
 
 get_sha1 ()
 Calculate the shal1 of this export Dependent on the export format.
 
 get_sha1_file ()
 Helper function to calculate the sha1 for multi or single file exports.
 
 has_export_config ()
 Whether this caller wants any additional config during export (eg options or metadata)
 
 heading_summary ()
 Return a string to put at the header summarising this export.
 
object load_data ()
 load up the data needed for the export
 
 prepare_package ()
 Prepare the package for export.
 
 prepare_package_file ()
 Helper function to copy files into the temp area for single or multi file exports.
 
 set ($field, &$value)
 Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.
 
 set_context ($PAGE)
 Overridden to return the course module context.
 
 set_export_config ($config)
 Stores the config generated at export time.
 
 set_file_and_format_data ($ids=null)
 Set up the required files for this export.
 
 set_formats_from_button ($formats)
 The button-location always knows best what the formats are... so it should be trusted.
 
 supported_formats ()
 Array of formats this caller supports.
 

Static Public Member Functions

static base_supported_formats ()
 base supported formats before we know anything about the export
 
static display_name ()
 
static expected_callbackargs ()
 the required callback arguments for a single-record export
 
static formats ($fields, $record)
 Given the fields being exported, and the single record, work out which export format(s) we can use.
 
static has_files ($data)
 

Protected Member Functions

 add_format ($format)
 Adds a new format to the list of supported formats.
 

Protected Attributes

object $cm
 coursemodule object.
 
stdclass $course
 course object
 
array $exportconfig = array()
 configuration used for export.
 
stdClass $exporter
 a reference to the exporter object
 
int $id
 cmid
 
string $intendedmimetype
 set this for generated-file exports
 
stored_file object $multifiles
 set this for multi file exports
 
int $recordid
 the single record to export
 
stored_file $singlefile
 single file exports configuration
 
array $supportedformats
 can be optionally overridden by subclass constructors
 
stdclass $user
 user currently exporting content
 

Detailed Description

The class to handle entry exports of a database module.

Constructor & Destructor Documentation

◆ __construct()

data_portfolio_caller::__construct ( $callbackargs)
Parameters
array$callbackargsthe arguments passed through

Reimplemented from portfolio_caller_base.

Member Function Documentation

◆ __wakeup()

object data_portfolio_caller::__wakeup ( )
Return values
bool|void

◆ add_format()

portfolio_caller_base::add_format ( $format)
protectedinherited

Adds a new format to the list of supported formats.

This functions also handles removing conflicting and less specific formats at the same time.

Parameters
string$formatone of PORTFOLIO_FORMAT_XX
Return values
void

◆ base_supported_formats()

static data_portfolio_caller::base_supported_formats ( )
static

base supported formats before we know anything about the export

Reimplemented from portfolio_caller_base.

◆ check_permissions()

data_portfolio_caller::check_permissions ( )

Verify the user can still export this entry.

Return values
bool

Reimplemented from portfolio_caller_base.

◆ display_name()

static data_portfolio_caller::display_name ( )
static
Return values
string

Reimplemented from portfolio_caller_base.

◆ expected_callbackargs()

static data_portfolio_caller::expected_callbackargs ( )
static

the required callback arguments for a single-record export

Return values
array

Reimplemented from portfolio_caller_base.

◆ expected_time()

data_portfolio_caller::expected_time ( )

How long we think the export will take Single entry is probably not too long.

But we check for filesizes Else base it on the number of records

Return values
oneof PORTFOLIO_TIME_XX constants

Reimplemented from portfolio_caller_base.

◆ expected_time_file()

portfolio_caller_base::expected_time_file ( )
inherited

Helper method to calculate expected time for multi or single file exports.

Return values
stringfile time expectation

◆ export_config_form()

data_portfolio_caller::export_config_form ( & $mform,
$instance )

If this caller wants any additional config items, they should be defined here.

Parameters
moodleform$mformpassed by reference, add elements to it.
portfolio_plugin_base$instancesubclass of portfolio_plugin_base

Reimplemented from portfolio_caller_base.

◆ export_config_validation()

portfolio_caller_base::export_config_validation ( $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.

◆ formats()

static data_portfolio_caller::formats ( $fields,
$record )
static

Given the fields being exported, and the single record, work out which export format(s) we can use.

Parameters
array$fieldsarray of field objects
object$recordThe data record object

@uses PORTFOLIO_FORMAT_PLAINHTML @uses PORTFOLIO_FORMAT_RICHHTML

Return values
arrayof PORTFOLIO_XX constants

◆ get()

portfolio_module_caller_base::get ( $key)
inherited

Override the parent get function to make sure when we're asked for a course, We retrieve the object from the database as needed.

Parameters
string$keythe name of get function
Return values
stdClass

Reimplemented from portfolio_caller_base.

◆ get_allowed_export_config()

data_portfolio_caller::get_allowed_export_config ( )

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 values
arrayarray of allowed keys

Reimplemented from portfolio_caller_base.

◆ get_export_config()

portfolio_caller_base::get_export_config ( $key)
finalinherited

Returns a particular export config value.

Subclasses shouldn't need to override this

Parameters
string$keythe config item to fetch
Return values
null|mixedof export configuration

◆ get_export_summary()

portfolio_caller_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

◆ get_mimetype()

portfolio_caller_base::get_mimetype ( )
inherited

Gets mimetype.

Return values
string

◆ get_navigation()

portfolio_module_caller_base::get_navigation ( )
inherited

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

Reimplemented from portfolio_caller_base.

Reimplemented in forum_portfolio_caller, and mod_workshop_portfolio_caller.

◆ get_return_url()

portfolio_module_caller_base::get_return_url ( )
inherited

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

Reimplemented from portfolio_caller_base.

Reimplemented in chat_portfolio_caller, forum_portfolio_caller, and mod_workshop_portfolio_caller.

◆ get_sha1()

data_portfolio_caller::get_sha1 ( )

Calculate the shal1 of this export Dependent on the export format.

Return values
string

Reimplemented from portfolio_caller_base.

◆ get_sha1_file()

portfolio_caller_base::get_sha1_file ( )
inherited

Helper function to calculate the sha1 for multi or single file exports.

Return values
stringsha1 file exports

◆ has_export_config()

data_portfolio_caller::has_export_config ( )

Whether this caller wants any additional config during export (eg options or metadata)

Return values
bool

Reimplemented from portfolio_caller_base.

◆ heading_summary()

portfolio_module_caller_base::heading_summary ( )
inherited

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

Reimplemented from portfolio_caller_base.

◆ load_data()

object data_portfolio_caller::load_data ( )

load up the data needed for the export

$DB

Reimplemented from portfolio_caller_base.

◆ prepare_package()

data_portfolio_caller::prepare_package ( )

Prepare the package for export.

Return values
stored_fileobject

Reimplemented from portfolio_caller_base.

◆ prepare_package_file()

portfolio_caller_base::prepare_package_file ( )
inherited

Helper function to copy files into the temp area for single or multi file exports.

Return values
stored_file|bool

◆ set()

portfolio_caller_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
mixed$valueproperty's value
Return values
bool
Exceptions
moodle_exception

◆ set_context()

portfolio_module_caller_base::set_context ( $PAGE)
inherited

Overridden to return the course module context.

Parameters
moodle_page$PAGEglobal PAGE

Reimplemented from portfolio_caller_base.

◆ set_export_config()

portfolio_caller_base::set_export_config ( $config)
finalinherited

Stores the config generated at export time.

Subclasses can retrieve values using

See also
get_export_config
Parameters
array$configformdata

◆ set_file_and_format_data()

portfolio_caller_base::set_file_and_format_data ( $ids = null)
inherited

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

Parameters
mixed$idsone of:
Return values
void

◆ set_formats_from_button()

portfolio_caller_base::set_formats_from_button ( $formats)
inherited

The button-location always knows best what the formats are... so it should be trusted.

Todo
MDL-31298 - re-analyze set_formats_from_button comment
Parameters
array$formatsarray of PORTFOLIO_FORMAT_XX
Return values
void

◆ supported_formats()

portfolio_caller_base::supported_formats ( )
finalinherited

Array of formats this caller supports.

Return values
arraylist of formats

Member Data Documentation

◆ $cm

object portfolio_module_caller_base::$cm
protectedinherited

coursemodule object.

set this in the constructor like $this->cm = get_coursemodule_from_instance('forum', $this->forum->id);

◆ $exportconfig

array portfolio_caller_base::$exportconfig = array()
protectedinherited

configuration used for export.

Use set_export_config and get_export_config to access


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