Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
|
The class that handles the various stages of the actual export and the communication between the caller and the portfolio plugin. More...
Public Member Functions | |
__construct ($instance, portfolio_caller_base $caller, $callercomponent) | |
Construct a new exporter for use. | |
caller () | |
Helper function to return the caller object. | |
cancel_request ($logreturn=false) | |
Cancels a potfolio request and cleans up the tempdata and redirects the user back to where they started. | |
copy_existing_file ($oldfile) | |
Copies a file from somewhere else in moodle to the portfolio temporary working directory associated with this export. | |
get ($field) | |
Generic getter for properties belonging to this instance outside the subclasses like name, visible etc. | |
get_base_filearea () | |
Returns the context, filearea, and itemid. | |
get_tempfiles ($skipfile='portfolio-export.zip') | |
Returns an arary of files in the temporary working directory for this export. | |
instance () | |
Helper function to return the portfolio instance. | |
log_transfer () | |
Log the transfer. | |
print_header ($headingstr, $summary=true) | |
Local print header function to be reused across the export. | |
process_stage ($stage, $alreadystolen=false) | |
Process the given stage calling whatever functions are necessary. | |
process_stage_cleanup ($pullok=false) | |
Processes the 'cleanup' stage of the export. | |
process_stage_config () | |
Processes the 'config' stage of the export. | |
process_stage_confirm () | |
Processes the 'confirm' stage of the export. | |
process_stage_finished ($queued=false) | |
Processes the 'finish' stage of the export. | |
process_stage_package () | |
Processes the 'package' stage of the export. | |
process_stage_queueorwait () | |
Processes the 'queueornext' stage of the export. | |
process_stage_send () | |
Processes the 'send' stage of the export. | |
save () | |
Writes out the contents of this object and all its data to the portfolio_tempdata table and sets the 'id' field. | |
set ($field, &$value) | |
Generic setter for properties belonging to this instance outside the subclass like name, visible, etc. | |
set_forcequeue () | |
Sets this export to force queued. | |
update_log_url ($url) | |
In some cases (mahara) we need to update this after the log has been done because of MDL-20872 | |
verify_rewaken ($readonly=false) | |
Verifies a rewoken object. | |
write_new_file ($content, $name, $manifest=true) | |
Writes out some content to a file in the portfolio temporary working directory associated with this export. | |
zip_tempfiles ($filename='portfolio-export.zip', $filepath='/final/') | |
Zips all files in the temporary directory. | |
Static Public Member Functions | |
static | print_cleaned_export ($log, $instance=null) |
Wrapper function to print a friendly error to users. | |
static | print_expired_export () |
Wrapper function to print a friendly error to users This is generally caused by them hitting an expired transfer through the usage of the backbutton. | |
static | print_finish_info ($returnurl, $continueurl, $extras=null) |
Wrapper function to print continue and/or return link. | |
static | rewaken_object ($id) |
Rewakens the data from the database given the id. | |
The class that handles the various stages of the actual export and the communication between the caller and the portfolio plugin.
This is stored in the database between page requests in serialized base64 encoded form also contains helper methods for the plugin and caller to use (at the end of the file)
portfolio_exporter::__construct | ( | $instance, | |
portfolio_caller_base | $caller, | ||
$callercomponent ) |
Construct a new exporter for use.
portfolio_plugin_base | $instance | portfolio instance (passed by reference) |
portfolio_caller_base | $caller | portfolio caller (passed by reference) |
string | $callercomponent | the name of the callercomponent |
portfolio_exporter::caller | ( | ) |
Helper function to return the caller object.
portfolio_caller_base | subclass |
portfolio_exporter::cancel_request | ( | $logreturn = false | ) |
Cancels a potfolio request and cleans up the tempdata and redirects the user back to where they started.
bool | $logreturn | options to return to porfolio log or caller return page |
void | @uses exit |
portfolio_exporter::copy_existing_file | ( | $oldfile | ) |
Copies a file from somewhere else in moodle to the portfolio temporary working directory associated with this export.
stored_file | $oldfile | existing stored file object |
stored_file|bool | new file object |
portfolio_exporter::get | ( | $field | ) |
Generic getter for properties belonging to this instance outside the subclasses like name, visible etc.
string | $field | property's name |
portfolio_format|mixed |
portfolio_exporter::get_base_filearea | ( | ) |
Returns the context, filearea, and itemid.
Parts of a filearea (not filepath) to be used by plugins if they want to do things like zip up the contents of the temp area to here, or something that can't be done just using write_new_file, copy_existing_file or get_tempfiles
array | contextid, filearea, itemid are the keys. |
portfolio_exporter::get_tempfiles | ( | $skipfile = 'portfolio-export.zip' | ) |
Returns an arary of files in the temporary working directory for this export.
Always use this instead of the files api directly
string | $skipfile | name of the file to be skipped |
array | of stored_file objects keyed by name |
portfolio_exporter::instance | ( | ) |
Helper function to return the portfolio instance.
portfolio_plugin_base | subclass |
portfolio_exporter::log_transfer | ( | ) |
Log the transfer.
this should only be called after the file has been sent either via push, or sent from a pull request.
|
static |
Wrapper function to print a friendly error to users.
stdClass | $log | portfolio_log object |
portfolio_plugin_base | $instance | portfolio instance @uses exit |
|
static |
Wrapper function to print a friendly error to users This is generally caused by them hitting an expired transfer through the usage of the backbutton.
@uses exit
|
static |
Wrapper function to print continue and/or return link.
string | $returnurl | link to previos page |
string | $continueurl | continue to next page |
array | $extras | (optional) other links to be display. |
portfolio_exporter::print_header | ( | $headingstr, | |
$summary = true ) |
Local print header function to be reused across the export.
string | $headingstr | full language string |
bool | $summary | (optional) to print summary, default is set to true |
void |
portfolio_exporter::process_stage | ( | $stage, | |
$alreadystolen = false ) |
Process the given stage calling whatever functions are necessary.
int | $stage | (see PORTFOLIO_STAGE_* constants) |
bool | $alreadystolen | used to avoid letting plugins steal control twice. |
bool | whether or not to process the next stage. this is important as the function is called recursively. |
portfolio_exporter::process_stage_cleanup | ( | $pullok = false | ) |
Processes the 'cleanup' stage of the export.
bool | $pullok | normally cleanup is deferred for pull plugins until after the file is requested from portfolio/file.php if you want to clean up earlier, pass true here (defaults to false) |
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_exporter::process_stage_config | ( | ) |
Processes the 'config' stage of the export.
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_exporter::process_stage_confirm | ( | ) |
Processes the 'confirm' stage of the export.
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_exporter::process_stage_finished | ( | $queued = false | ) |
Processes the 'finish' stage of the export.
bool | $queued | let the process to be queued |
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_exporter::process_stage_package | ( | ) |
Processes the 'package' stage of the export.
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_export_exception |
portfolio_exporter::process_stage_queueorwait | ( | ) |
Processes the 'queueornext' stage of the export.
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
portfolio_exporter::process_stage_send | ( | ) |
Processes the 'send' stage of the export.
bool | whether or not to process the next stage. this is important as the control function is called recursively. |
|
static |
Rewakens the data from the database given the id.
Makes sure to load the required files with the class definitions
int | $id | id of data |
portfolio_exporter |
portfolio_exporter::save | ( | ) |
Writes out the contents of this object and all its data to the portfolio_tempdata table and sets the 'id' field.
void |
portfolio_exporter::set | ( | $field, | |
& | $value ) |
Generic setter for properties belonging to this instance outside the subclass like name, visible, etc.
string | $field | property's name |
mixed | $value | property's value |
bool |
portfolio_export_exception |
portfolio_exporter::set_forcequeue | ( | ) |
Sets this export to force queued.
Sometimes plugins need to set this randomly if an external system changes its mind about what's supported
portfolio_exporter::update_log_url | ( | $url | ) |
In some cases (mahara) we need to update this after the log has been done because of MDL-20872
string | $url | link to be recorded to portfolio log |
portfolio_exporter::verify_rewaken | ( | $readonly = false | ) |
Verifies a rewoken object.
Checks to make sure it belongs to the same user and session as is currently in use.
bool | $readonly | if we're reawakening this for a user to just display in the log view, don't verify the sessionkey |
portfolio_exception |
portfolio_exporter::write_new_file | ( | $content, | |
$name, | |||
$manifest = true ) |
Writes out some content to a file in the portfolio temporary working directory associated with this export.
string | $content | content to write |
string | $name | filename to use |
bool | $manifest | whether this is the main file or an secondary file (eg attachment) |
stored_file |
portfolio_exporter::zip_tempfiles | ( | $filename = 'portfolio-export.zip', | |
$filepath = '/final/' ) |
Zips all files in the temporary directory.
string | $filename | name of resulting zipfile (optional, defaults to portfolio-export.zip) |
string | $filepath | subpath in the filearea (optional, defaults to final) |
stored_file|bool | resulting stored_file object, or false |