Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
portfolio_exporter Class Reference

Public Member Functions

 __construct ($instance, portfolio_caller_base $caller, $callercomponent)
 Construct a new exporter for use. More...
 
 caller ()
 Helper function to return the caller object. More...
 
 cancel_request ($logreturn=false)
 Cancels a potfolio request and cleans up the tempdata and redirects the user back to where they started. More...
 
 copy_existing_file ($oldfile)
 Copies a file from somewhere else in moodle to the portfolio temporary working directory associated with this export. More...
 
 get ($field)
 Generic getter for properties belonging to this instance outside the subclasses like name, visible etc. More...
 
 get_base_filearea ()
 Returns the context, filearea, and itemid. More...
 
 get_tempfiles ($skipfile='portfolio-export.zip')
 Returns an arary of files in the temporary working directory for this export. More...
 
 instance ()
 Helper function to return the portfolio instance. More...
 
 log_transfer ()
 Log the transfer. More...
 
 print_header ($headingstr, $summary=true)
 Local print header function to be reused across the export. More...
 
 process_stage ($stage, $alreadystolen=false)
 Process the given stage calling whatever functions are necessary. More...
 
 process_stage_cleanup ($pullok=false)
 Processes the 'cleanup' stage of the export. More...
 
 process_stage_config ()
 Processes the 'config' stage of the export. More...
 
 process_stage_confirm ()
 Processes the 'confirm' stage of the export. More...
 
 process_stage_finished ($queued=false)
 Processes the 'finish' stage of the export. More...
 
 process_stage_package ()
 Processes the 'package' stage of the export. More...
 
 process_stage_queueorwait ()
 Processes the 'queueornext' stage of the export. More...
 
 process_stage_send ()
 Processes the 'send' stage of the export. More...
 
 save ()
 Writes out the contents of this object and all its data to the portfolio_tempdata table and sets the 'id' field. More...
 
 set ($field, &$value)
 Generic setter for properties belonging to this instance outside the subclass like name, visible, etc. More...
 
 set_forcequeue ()
 Sets this export to force queued. More...
 
 update_log_url ($url)
 In some cases (mahara) we need to update this after the log has been done because of MDL-20872 More...
 
 verify_rewaken ($readonly=false)
 Verifies a rewoken object. More...
 
 write_new_file ($content, $name, $manifest=true)
 Writes out some content to a file in the portfolio temporary working directory associated with this export. More...
 
 zip_tempfiles ($filename='portfolio-export.zip', $filepath='/final/')
 Zips all files in the temporary directory. More...
 

Static Public Member Functions

static print_cleaned_export ($log, $instance=null)
 Wrapper function to print a friendly error to users. More...
 
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. More...
 
static print_finish_info ($returnurl, $continueurl, $extras=null)
 Wrapper function to print continue and/or return link. More...
 
static rewaken_object ($id)
 Rewakens the data from the database given the id. More...
 

Public Attributes

string $callercomponent
 the component that contains the class definition of the caller object used to re-waken the object after sleep
 
string $instancefile
 the file to include that contains the class defintion of the portfolio instance plugin used to re-waken the object after sleep
 

Constructor & Destructor Documentation

◆ __construct()

portfolio_exporter::__construct (   $instance,
portfolio_caller_base  $caller,
  $callercomponent 
)

Construct a new exporter for use.

Parameters
portfolio_plugin_base$instanceportfolio instance (passed by reference)
portfolio_caller_base$callerportfolio caller (passed by reference)
string$callercomponentthe name of the callercomponent

Member Function Documentation

◆ caller()

portfolio_exporter::caller ( )

Helper function to return the caller object.

Return values
portfolio_caller_basesubclass

◆ cancel_request()

portfolio_exporter::cancel_request (   $logreturn = false)

Cancels a potfolio request and cleans up the tempdata and redirects the user back to where they started.

Parameters
bool$logreturnoptions to return to porfolio log or caller return page
Return values
void@uses exit

◆ copy_existing_file()

portfolio_exporter::copy_existing_file (   $oldfile)

Copies a file from somewhere else in moodle to the portfolio temporary working directory associated with this export.

Parameters
stored_file$oldfileexisting stored file object
Return values
stored_file|boolnew file object

◆ get()

portfolio_exporter::get (   $field)

Generic getter for properties belonging to this instance outside the subclasses like name, visible etc.

Parameters
string$fieldproperty's name
Return values
portfolio_format|mixed

◆ get_base_filearea()

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

Return values
arraycontextid, filearea, itemid are the keys.

◆ get_tempfiles()

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

Parameters
string$skipfilename of the file to be skipped
Return values
arrayof stored_file objects keyed by name

◆ instance()

portfolio_exporter::instance ( )

Helper function to return the portfolio instance.

Return values
portfolio_plugin_basesubclass

◆ log_transfer()

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.

◆ print_cleaned_export()

static portfolio_exporter::print_cleaned_export (   $log,
  $instance = null 
)
static

Wrapper function to print a friendly error to users.

Parameters
stdClass$logportfolio_log object
portfolio_plugin_base$instanceportfolio instance @uses exit

◆ print_expired_export()

static portfolio_exporter::print_expired_export ( )
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

◆ print_finish_info()

static portfolio_exporter::print_finish_info (   $returnurl,
  $continueurl,
  $extras = null 
)
static

Wrapper function to print continue and/or return link.

Parameters
string$returnurllink to previos page
string$continueurlcontinue to next page
array$extras(optional) other links to be display.

◆ print_header()

portfolio_exporter::print_header (   $headingstr,
  $summary = true 
)

Local print header function to be reused across the export.

Parameters
string$headingstrfull language string
bool$summary(optional) to print summary, default is set to true
Return values
void

◆ process_stage()

portfolio_exporter::process_stage (   $stage,
  $alreadystolen = false 
)

Process the given stage calling whatever functions are necessary.

Parameters
int$stage(see PORTFOLIO_STAGE_* constants)
bool$alreadystolenused to avoid letting plugins steal control twice.
Return values
boolwhether or not to process the next stage. this is important as the function is called recursively.

◆ process_stage_cleanup()

portfolio_exporter::process_stage_cleanup (   $pullok = false)

Processes the 'cleanup' stage of the export.

Parameters
bool$pulloknormally 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)
Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ process_stage_config()

portfolio_exporter::process_stage_config ( )

Processes the 'config' stage of the export.

Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ process_stage_confirm()

portfolio_exporter::process_stage_confirm ( )

Processes the 'confirm' stage of the export.

Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ process_stage_finished()

portfolio_exporter::process_stage_finished (   $queued = false)

Processes the 'finish' stage of the export.

Parameters
bool$queuedlet the process to be queued
Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ process_stage_package()

portfolio_exporter::process_stage_package ( )

Processes the 'package' stage of the export.

Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.
Exceptions
portfolio_export_exception

◆ process_stage_queueorwait()

portfolio_exporter::process_stage_queueorwait ( )

Processes the 'queueornext' stage of the export.

Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ process_stage_send()

portfolio_exporter::process_stage_send ( )

Processes the 'send' stage of the export.

Return values
boolwhether or not to process the next stage. this is important as the control function is called recursively.

◆ rewaken_object()

static portfolio_exporter::rewaken_object (   $id)
static

Rewakens the data from the database given the id.

Makes sure to load the required files with the class definitions

Parameters
int$idid of data
Return values
portfolio_exporter

◆ save()

portfolio_exporter::save ( )

Writes out the contents of this object and all its data to the portfolio_tempdata table and sets the 'id' field.

Return values
void

◆ set()

portfolio_exporter::set (   $field,
$value 
)

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
portfolio_export_exception

◆ set_forcequeue()

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

◆ update_log_url()

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

Parameters
string$urllink to be recorded to portfolio log

◆ verify_rewaken()

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.

Parameters
bool$readonlyif we're reawakening this for a user to just display in the log view, don't verify the sessionkey
Exceptions
portfolio_exception

◆ write_new_file()

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.

Parameters
string$contentcontent to write
string$namefilename to use
bool$manifestwhether this is the main file or an secondary file (eg attachment)
Return values
stored_file

◆ zip_tempfiles()

portfolio_exporter::zip_tempfiles (   $filename = 'portfolio-export.zip',
  $filepath = '/final/' 
)

Zips all files in the temporary directory.

Parameters
string$filenamename of resulting zipfile (optional, defaults to portfolio-export.zip)
string$filepathsubpath in the filearea (optional, defaults to final)
Return values
stored_file|boolresulting stored_file object, or false

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