Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
|
Files | |
file | caller.php |
This file contains the base classes that are extended to create portfolio export functionality. | |
file | constants.php |
This file contains all the defined constants to do with portfolios. | |
file | exceptions.php |
This file contains all the portfolio exception classes. | |
file | exporter.php |
This file contains the class definition for the exporter object. | |
file | formats.php |
This file contains all the class definitions of the export formats. | |
file | forms.php |
This file contains all the form definitions used by the portfolio code. | |
file | legacy_polyfill.php |
This file contains the polyfill to allow a plugin to operate with Moodle 3.3 up. | |
file | lib.php |
This file contains the LEAP2a writer used by portfolio_format_leap2a. | |
file | plugin.php |
This file contains the base classes for portfolio plugins to inherit from: | |
file | portfolio_provider.php |
Privacy class for requesting user data. | |
file | portfoliolib.php |
This file contains all global functions to do with manipulating portfolios. | |
file | provider.php |
Privacy class for requesting user data. | |
Namespaces | |
namespace | core_portfolio\privacy |
| |
Functions | |
portfolio_existing_exports ($userid, $type=null) | |
Return a list of current exports for the given user. More... | |
portfolio_existing_exports_by_plugin ($userid) | |
Return an array of existing exports by type for a given user. More... | |
portfolio_expected_time_db ($recordcount) | |
Try and determine expected_time for purely database based exports or exports that might include large parts of a database. More... | |
portfolio_expected_time_file ($totest) | |
Try and determine expected_time for purely file based exports or exports that might include large file attachments. More... | |
portfolio_export_pagesetup ($PAGE, $caller) | |
Setup page export. More... | |
portfolio_export_rethrow_exception ($exporter, $exception) | |
Helper function to rethrow a caught portfolio_exception as an export exception. More... | |
portfolio_export_type_to_id ($type, $userid) | |
Get export type id. More... | |
portfolio_filesize_info () | |
The default filesizes and threshold information for file based transfers. More... | |
portfolio_format_from_mimetype ($mimetype) | |
Deduce export format from file mimetype This function returns the revelant portfolio export format which is used to determine which portfolio plugins can be used for exporting this content according to the given mime type this only works when exporting exactly one file, or generating a new one (like a pdf or csv export) More... | |
portfolio_format_is_abstract ($format) | |
Tiny helper to figure out whether a portfolio format is abstract. More... | |
portfolio_format_object ($name) | |
Helper function to return a format object from the constant. More... | |
portfolio_format_text_options () | |
Return default common options for format_text() when preparing a content to be exported. More... | |
portfolio_has_visible_instances () | |
Return whether there are visible instances in portfolio. More... | |
portfolio_include_callback_file ($component, $class=null) | |
Function to require any potential callback files, throwing exceptions if an issue occurs. More... | |
portfolio_insane_notify_admins ($insane, $instances=false) | |
Function to send portfolio report to admins. More... | |
portfolio_instance ($instanceid, $record=null) | |
Helper function to return an instance of a plugin (with config loaded) More... | |
portfolio_instance_sanity_check ($instances=null) | |
Helper function to check all the instances for sanity and set any insane ones to invisible. More... | |
portfolio_instance_select ($instances, $callerformats, $callbackclass, $mimetype=null, $selectname='instance', $return=false, $returnarray=false) | |
Returns a drop menu with a list of available instances. More... | |
portfolio_instances ($visibleonly=true, $useronly=true) | |
Return all portfolio instances. More... | |
portfolio_most_specific_formats ($specificformats, $generalformats) | |
Return the combination of the two arrays of formats with duplicates in terms of specificity removed and also removes conflicting formats. More... | |
portfolio_plugin_sanity_check ($plugins=null) | |
Helper function to check all the plugins for sanity and set any insane ones to invisible. More... | |
portfolio_report_insane ($insane, $instances=false, $return=false) | |
Helper function to display a table of plugins (or instances) and reasons for disabling. More... | |
portfolio_rewrite_pluginfile_url_callback ($contextid, $component, $filearea, $itemid, $format, $options, $matches) | |
callback function from portfolio_rewrite_pluginfile_urls looks through preg_replace matches and replaces content with whatever the active portfolio export format says More... | |
portfolio_rewrite_pluginfile_urls ($text, $contextid, $component, $filearea, $itemid, $format, $options=null) | |
Go through all the @PLUGINFILE@ matches in some text, extract the file information and pass it back to the portfolio export format to regenerate the html to output. More... | |
portfolio_static_function ($plugin, $function) | |
Helper function to call a static function on a portfolio plugin class. More... | |
portfolio_supported_formats () | |
Supported formats currently in use. More... | |
portfolio_supported_formats_intersect ($callerformats, $pluginformats) | |
Intersection of plugin formats and caller formats. More... | |
Variables | |
const | PORTFOLIO_ADD_FAKE_URL 5 |
PORTFOLIO_ADD_FAKE_URL - hacky way to turn the button class into a url to redirect to this replaces the old portfolio_fake_add_url function. | |
const | PORTFOLIO_ADD_FULL_FORM 1 |
PORTFOLIO_ADD_FULL_FORM - a whole form, containing a drop down menu (where necessary) and a submit button. | |
const | PORTFOLIO_ADD_ICON_FORM 2 |
PORTFOLIO_ADD_ICON_FORM - a whole form, containing a drop down menu (where necessary) but has an icon instead of a button to submit. | |
const | PORTFOLIO_ADD_ICON_LINK 3 |
PORTFOLIO_ADD_ICON_LINK - just an icon with a link around it (yuk, as will result in a long url only use where necessary) | |
const | PORTFOLIO_ADD_MOODLE_URL 6 |
PORTFOLIO_ADD_MOODULE_URL - hacky way to turn the button class into a moodle_url to redirect to this replaces the old portfolio_fake_add_url function. | |
const | PORTFOLIO_ADD_TEXT_LINK 4 |
PORTFOLIO_ADD_TEXT_LINK - just some text with a link around it (yuk, as will result in a long url only use where necessary) | |
const | PORTFOLIO_FORMAT_DOCUMENT 'document' |
PORTFOLIO_FORMAT_DOCUMENT - subtype of file. | |
const | PORTFOLIO_FORMAT_FILE 'file' |
PORTFOLIO_FORMAT_FILE - the most basic fallback format. More... | |
const | PORTFOLIO_FORMAT_IMAGE 'image' |
PORTFOLIO_FORMAT_IMAGE - subtype of file. | |
const | PORTFOLIO_FORMAT_LEAP2A 'leap2a' |
PORTFOLIO_FORMAT_LEAP2A - supported by mahara and and others {http://wiki.cetis.ac.uk/LEAP_2.0}. | |
const | PORTFOLIO_FORMAT_MBKP 'mbkp' |
PORTFOLIO_FORMAT_MBKP - the plugin needs to be able to write a complete backup the caller need to be able to export the particular XML bits to insert into moodle.xml (?and the file bits if necessary) | |
const | PORTFOLIO_FORMAT_PDF 'pdf' |
PORTFOLIO_FORMAT_PDF - subtype of file. | |
const | PORTFOLIO_FORMAT_PLAINHTML 'plainhtml' |
PORTFOLIO_FORMAT_PLAINHTML - a single html representation - no attachments. | |
const | PORTFOLIO_FORMAT_PRESENTATION 'presentation' |
PORTFOLIO_FORMAT_PRESENTATION - subtype of file. | |
const | PORTFOLIO_FORMAT_RICH 'rich' |
PORTFOLIO_FORMAT_RICH - just used to say, "we support all these". | |
const | PORTFOLIO_FORMAT_RICHHTML 'richhtml' |
PORTFOLIO_FORMAT_RICHHTML - like html but with attachments. | |
const | PORTFOLIO_FORMAT_SPREADSHEET 'spreadsheet' |
PORTFOLIO_FORMAT_SPREADSHEET - subtype of file. | |
const | PORTFOLIO_FORMAT_TEXT 'text' |
PORTFOLIO_FORMAT_TEXT - subtype of file. | |
const | PORTFOLIO_FORMAT_VIDEO 'video' |
PORTFOLIO_FORMAT_VIDEO - subtype of file. | |
const | PORTFOLIO_STAGE_CLEANUP 6 |
PORTFOLIO_STAGE_CLEANUP - cleanup the temporary area. | |
const | PORTFOLIO_STAGE_CONFIG 1 |
PORTFOLIO_STAGE_CONFIG - display a form to the user this one might not be used if neither the plugin, or the caller has any config. | |
const | PORTFOLIO_STAGE_CONFIRM 2 |
PORTFOLIO_STAGE_CONFIRM - summarise the form and ask for confirmation if we skipped PORTFOLIO_STAGE_CONFIG, just confirm the send. | |
const | PORTFOLIO_STAGE_FINISHED 7 |
PORTFOLIO_STAGE_FINISHED - display the "finished notification". | |
const | PORTFOLIO_STAGE_PACKAGE 4 |
PORTFOLIO_STAGE_PACKAGE - package up the various bits during this stage both the caller and the plugin get their package methods called. | |
const | PORTFOLIO_STAGE_QUEUEORWAIT 3 |
PORTFOLIO_STAGE_QUEUEORWAIT - either queue the event and skip to PORTFOLIO_STAGE_FINISHED. | |
const | PORTFOLIO_STAGE_SEND 5 |
PORTFOLIO_STAGE_SEND - the portfolio plugin must send the file. | |
const | PORTFOLIO_TIME_FORCEQUEUE 'queue' |
PORTFOLIO_TIME_FORCEQUEUE - very slow, or immediate transfers not supported. | |
const | PORTFOLIO_TIME_HIGH 'high' |
PORTFOLIO_TIME_HIGH - slow. More... | |
const | PORTFOLIO_TIME_LOW 'low' |
PORTFOLIO_TIME_LOW - no delay. More... | |
const | PORTFOLIO_TIME_MODERATE 'moderate' |
PORTFOLIO_TIME_MODERATE - a small delay. More... | |
portfolio_existing_exports | ( | $userid, | |
$type = null |
|||
) |
Return a list of current exports for the given user.
This will not go through and call rewaken_object, because it's heavy. It's really just used to figure out what exports are currently happening. This is useful for plugins that don't support multiple exports per session
int | $userid | the user to check for |
string | $type | (optional) the portfolio plugin to filter by |
array |
portfolio_existing_exports_by_plugin | ( | $userid | ) |
Return an array of existing exports by type for a given user.
This is much more lightweight than existing_exports because it only returns the types, rather than the whole serialised data so can be used for checking availability of multiple plugins at the same time.
int | $userid | the user to check for |
array |
portfolio_expected_time_db | ( | $recordcount | ) |
Try and determine expected_time for purely database based exports or exports that might include large parts of a database.
int | $recordcount | number of records trying to export |
string | PORTFOLIO_TIME_XXX |
portfolio_expected_time_file | ( | $totest | ) |
Try and determine expected_time for purely file based exports or exports that might include large file attachments.
stored_file | array | $totest | - either an array of stored_file objects or a single stored_file object |
string | PORTFOLIO_TIME_XXX |
portfolio_export_pagesetup | ( | $PAGE, | |
$caller | |||
) |
Setup page export.
moodle_page | $PAGE | global variable from page object |
portfolio_caller_base | $caller | plugin type caller |
portfolio_export_rethrow_exception | ( | $exporter, | |
$exception | |||
) |
Helper function to rethrow a caught portfolio_exception as an export exception.
Used because when a portfolio_export exception is thrown the export is cancelled throws portfolio_export_exceptiog
portfolio_exporter | $exporter | current exporter object |
object | $exception | exception to rethrow |
portfolio_export_type_to_id | ( | $type, | |
$userid | |||
) |
Get export type id.
string | $type | plugin type |
int | $userid | the user to check for |
mixed|bool |
portfolio_filesize_info | ( | ) |
The default filesizes and threshold information for file based transfers.
This shouldn't need to be used outside the admin pages and the portfolio code
array |
portfolio_format_from_mimetype | ( | $mimetype | ) |
Deduce export format from file mimetype This function returns the revelant portfolio export format which is used to determine which portfolio plugins can be used for exporting this content according to the given mime type this only works when exporting exactly one file, or generating a new one (like a pdf or csv export)
string | $mimetype | (usually $file->get_mimetype()) |
string | the format constant (see PORTFOLIO_FORMAT_XXX constants) |
portfolio_format_is_abstract | ( | $format | ) |
Tiny helper to figure out whether a portfolio format is abstract.
string | $format | the format to test |
bool |
portfolio_format_object | ( | $name | ) |
Helper function to return a format object from the constant.
string | $name | the constant PORTFOLIO_FORMAT_XXX |
portfolio_format |
portfolio_format_text_options | ( | ) |
Return default common options for format_text() when preparing a content to be exported.
It is important not to apply filters and not to clean the HTML in format_text()
stdClass |
portfolio_has_visible_instances | ( | ) |
Return whether there are visible instances in portfolio.
bool | true when there are some visible instances. |
portfolio_include_callback_file | ( | $component, | |
$class = null |
|||
) |
Function to require any potential callback files, throwing exceptions if an issue occurs.
string | $component | This is the name of the component in Moodle, eg 'mod_forum' |
string | $class | Name of the class containing the callback functions activity components should ALWAYS use their name_portfolio_caller other locations must use something unique |
portfolio_insane_notify_admins | ( | $insane, | |
$instances = false |
|||
) |
Function to send portfolio report to admins.
array | $insane | array of insane plugins |
array | $instances | (optional) if reporting instances rather than whole plugins |
portfolio_instance | ( | $instanceid, | |
$record = null |
|||
) |
Helper function to return an instance of a plugin (with config loaded)
int | $instanceid | id of instance |
object | $record | database row that corresponds to this instance this is passed to avoid unnecessary lookups Optional, and the record will be retrieved if null. |
object | of portfolio_plugin_XXX |
portfolio_instance_sanity_check | ( | $instances = null | ) |
Helper function to check all the instances for sanity and set any insane ones to invisible.
array | $instances | array of plugin instances |
array | array of insane instances (keys= id, values = reasons (keys for plugin lang) |
portfolio_instance_select | ( | $instances, | |
$callerformats, | |||
$callbackclass, | |||
$mimetype = null , |
|||
$selectname = 'instance' , |
|||
$return = false , |
|||
$returnarray = false |
|||
) |
Returns a drop menu with a list of available instances.
array | $instances | array of portfolio plugin instance objects - the instances to put in the menu |
array | $callerformats | array of PORTFOLIO_FORMAT_XXX constants - the formats the caller supports (this is used to filter plugins) |
string | $callbackclass | the callback class name - used for debugging only for when there are no common formats |
string | $mimetype | if we already know we have exactly one file, or are going to write one, pass it here to do mime filtering. |
string | $selectname | the name of the select element. Optional, defaults to instance. |
bool | $return | whether to print or return the output. Optional, defaults to print. |
bool | $returnarray | if returning, whether to return the HTML or the array of options. Optional, defaults to HTML. |
void|array|string | the html, from <select> to </select> inclusive. |
portfolio_instances | ( | $visibleonly = true , |
|
$useronly = true |
|||
) |
Return all portfolio instances.
bool | $visibleonly | Don't include hidden instances. Defaults to true and will be overridden to true if the next parameter is true |
bool | $useronly | Check the visibility preferences and permissions of the logged in user. Defaults to true. |
array | of portfolio instances (full objects, not just database records) |
portfolio_most_specific_formats | ( | $specificformats, | |
$generalformats | |||
) |
Return the combination of the two arrays of formats with duplicates in terms of specificity removed and also removes conflicting formats.
Use case: a module is exporting a single file, so the general formats would be FILE and MBKP while the specific formats would be the specific subclass of FILE based on mime (say IMAGE) and this function would return IMAGE and MBKP
array | $specificformats | array of more specific formats (eg based on mime detection) |
array | $generalformats | array of more general formats (usually more supported) |
array | merged formats with dups removed |
portfolio_plugin_sanity_check | ( | $plugins = null | ) |
Helper function to check all the plugins for sanity and set any insane ones to invisible.
array | $plugins | array of supported plugin types |
array | array of insane instances (keys= id, values = reasons (keys for plugin lang) |
portfolio_report_insane | ( | $insane, | |
$instances = false , |
|||
$return = false |
|||
) |
Helper function to display a table of plugins (or instances) and reasons for disabling.
array | $insane | array of portfolio plugin |
array | $instances | if reporting instances rather than whole plugins, pass the array (key = id, value = object) here |
bool | $return | option to deliver the report in html format or print it out directly to the page. |
void|string | of portfolio report in html table format |
portfolio_rewrite_pluginfile_url_callback | ( | $contextid, | |
$component, | |||
$filearea, | |||
$itemid, | |||
$format, | |||
$options, | |||
$matches | |||
) |
callback function from portfolio_rewrite_pluginfile_urls looks through preg_replace matches and replaces content with whatever the active portfolio export format says
int | $contextid | module context id |
string | $component | module name (eg:mod_assignment) |
string | $filearea | normal file_area arguments |
int | $itemid | component item id |
portfolio_format | $format | exporter format type |
array | $options | extra options to pass through to the file_output function in the format (optional) |
array | $matches | internal matching |
object|array|string |
portfolio_rewrite_pluginfile_urls | ( | $text, | |
$contextid, | |||
$component, | |||
$filearea, | |||
$itemid, | |||
$format, | |||
$options = null |
|||
) |
Go through all the @PLUGINFILE@ matches in some text, extract the file information and pass it back to the portfolio export format to regenerate the html to output.
string | $text | the text to search through |
int | $contextid | normal file_area arguments |
string | $component | module name |
string | $filearea | normal file_area arguments |
int | $itemid | normal file_area arguments |
portfolio_format | $format | the portfolio export format |
array | $options | additional options to be included in the plugin file url (optional) |
mixed |
portfolio_static_function | ( | $plugin, | |
$function | |||
) |
Helper function to call a static function on a portfolio plugin class.
This will figure out the classname and require the right file and call the function. You can send a variable number of arguments to this function after the first two and they will be passed on to the function you wish to call.
string | $plugin | name of plugin |
string | $function | function to call |
mixed |
portfolio_supported_formats | ( | ) |
Supported formats currently in use.
Canonical place for a list of all formats that portfolio plugins and callers can use for exporting content
array | keyed array of all the available export formats (constant => classname) |
portfolio_supported_formats_intersect | ( | $callerformats, | |
$pluginformats | |||
) |
Intersection of plugin formats and caller formats.
Walks both the caller formats and portfolio plugin formats and looks for matches (walking the hierarchy as well) and returns the intersection
array | $callerformats | formats the caller supports |
array | $pluginformats | formats the portfolio plugin supports |
array |
const PORTFOLIO_FORMAT_FILE 'file' |
PORTFOLIO_FORMAT_FILE - the most basic fallback format.
this should always be supported in remote system.s
const PORTFOLIO_TIME_HIGH 'high' |
PORTFOLIO_TIME_HIGH - slow.
the user really should not be given the option to choose this.
const PORTFOLIO_TIME_LOW 'low' |
PORTFOLIO_TIME_LOW - no delay.
don't even offer the user the option of not waiting for the transfer
const PORTFOLIO_TIME_MODERATE 'moderate' |
PORTFOLIO_TIME_MODERATE - a small delay.
user can still easily opt to watch this transfer and wait.