Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Namespaces | |
namespace | core_portfolio\privacy |
| |
Classes | |
interface | core_portfolio\privacy\portfolio_provider |
Provider for the portfolio API. More... | |
class | core_portfolio\privacy\provider |
Provider for the portfolio API. More... | |
class | portfolio_add_button |
Use this to add a portfolio button or icon or form to a page. More... | |
class | portfolio_admin_form |
Admin config form. More... | |
class | portfolio_button_exception |
Exception for interacting with the button class. More... | |
class | portfolio_caller_base |
Base class for callers. More... | |
class | portfolio_caller_exception |
Exception for callers to throw when they have a problem. More... | |
class | portfolio_exception |
Top level portfolio exception. More... | |
class | portfolio_export_exception |
Exception to throw during an export - will clean up session and tempdata. More... | |
class | portfolio_export_form |
During-export config form. More... | |
class | portfolio_exporter |
The class that handles the various stages of the actual export and the communication between the caller and the portfolio plugin. More... | |
class | portfolio_format |
Base class to inherit from. More... | |
class | portfolio_format_document |
'Document format', subtype of file. More... | |
class | portfolio_format_file |
The most basic type - pretty much everything is a subtype. More... | |
class | portfolio_format_image |
Image format, subtype of file. More... | |
class | portfolio_format_leap2a |
Class used for leap2a format. More... | |
class | portfolio_format_leap2a_entry |
This class represents a single leap2a entry. More... | |
class | portfolio_format_leap2a_exception |
Leap2a exception - for invalid api calls. More... | |
class | portfolio_format_leap2a_file |
Subclass of entry, purely for dealing with files. More... | |
class | portfolio_format_leap2a_writer |
Object to encapsulate the writing of leap2a. More... | |
class | portfolio_format_pdf |
'PDF format', subtype of file. More... | |
class | portfolio_format_plainhtml |
HTML format. More... | |
class | portfolio_format_presentation |
'Presentation format', subtype of file. More... | |
class | portfolio_format_rich |
Base class for rich formats. More... | |
class | portfolio_format_richhtml |
Richhtml - html with attachments. More... | |
class | portfolio_format_spreadsheet |
'Spreadsheet format', subtype of file. More... | |
class | portfolio_format_text |
Class for plain text format. More... | |
class | portfolio_format_video |
Video format. More... | |
class | portfolio_instance_select |
Form that just contains the dropdown menu of available instances. More... | |
class | portfolio_module_caller_base |
Base class for module callers. More... | |
class | portfolio_plugin_base |
The base class for portfolio plugins. More... | |
class | portfolio_plugin_exception |
Exception for portfolio plugins to throw when they have a problem. More... | |
class | portfolio_plugin_pull_base |
Class to inherit from for 'pull' type plugins. More... | |
class | portfolio_plugin_push_base |
Class to inherit from for 'push' type plugins. More... | |
class | portfolio_user_form |
User config form. More... | |
Functions | |
portfolio_existing_exports ($userid, $type=null) | |
Return a list of current exports for the given user. | |
portfolio_existing_exports_by_plugin ($userid) | |
Return an array of existing exports by type for a given user. | |
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. | |
portfolio_expected_time_file ($totest) | |
Try and determine expected_time for purely file based exports or exports that might include large file attachments. | |
portfolio_export_pagesetup ($PAGE, $caller) | |
Setup page export. | |
portfolio_export_rethrow_exception ($exporter, $exception) | |
Helper function to rethrow a caught portfolio_exception as an export exception. | |
portfolio_export_type_to_id ($type, $userid) | |
Get export type id. | |
portfolio_filesize_info () | |
The default filesizes and threshold information for file based transfers. | |
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) | |
portfolio_format_is_abstract ($format) | |
Tiny helper to figure out whether a portfolio format is abstract. | |
portfolio_format_object ($name) | |
Helper function to return a format object from the constant. | |
portfolio_format_text_options () | |
Return default common options for format_text() when preparing a content to be exported. | |
portfolio_has_visible_instances () | |
Return whether there are visible instances in portfolio. | |
portfolio_include_callback_file ($component, $class=null) | |
Function to require any potential callback files, throwing exceptions if an issue occurs. | |
portfolio_insane_notify_admins ($insane, $instances=false) | |
Function to send portfolio report to admins. | |
portfolio_instance ($instanceid, $record=null) | |
Helper function to return an instance of a plugin (with config loaded) | |
portfolio_instance_sanity_check ($instances=null) | |
Helper function to check all the instances for sanity and set any insane ones to invisible. | |
portfolio_instance_select ($instances, $callerformats, $callbackclass, $mimetype=null, $selectname='instance', $return=false, $returnarray=false) | |
Returns a drop menu with a list of available instances. | |
portfolio_instances ($visibleonly=true, $useronly=true) | |
Return all portfolio instances. | |
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. | |
portfolio_plugin_sanity_check ($plugins=null) | |
Helper function to check all the plugins for sanity and set any insane ones to invisible. | |
portfolio_report_insane ($insane, $instances=false, $return=false) | |
Helper function to display a table of plugins (or instances) and reasons for disabling. | |
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 | |
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. | |
portfolio_static_function ($plugin, $function) | |
Helper function to call a static function on a portfolio plugin class. | |
portfolio_supported_formats () | |
Supported formats currently in use. | |
portfolio_supported_formats_intersect ($callerformats, $pluginformats) | |
Intersection of plugin formats and caller formats. | |
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. | |
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. | |
const | PORTFOLIO_TIME_LOW 'low' |
PORTFOLIO_TIME_LOW - no delay. | |
const | PORTFOLIO_TIME_MODERATE 'moderate' |
PORTFOLIO_TIME_MODERATE - a small delay. | |
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.
portfolio_insane_notify_admins | ( | $insane, | |
$instances = false ) |
Function to send portfolio report to admins.
array | $insane | array of insane plugins |
bool | $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_assign) |
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.