Moodle APIs 4.3
Moodle 4.3.6 (Build: 20240812)
tiny_autosave\autosave_manager Class Reference

Autosave Manager. More...

Public Member Functions

 __construct (int $contextid, string $pagehash, string $pageinstance, string $elementid, ?stdClass $user=null)
 Constructor for the autosave manager.
 
 create_autosave_record (string $drafttext, ?int $draftid=null)
 Create an autosave record for the session.
 
 get_autosave_record ()
 Get the autosave record for this session.
 
 remove_autosave_record ()
 Remove the autosave record.
 
 resume_autosave_session (?int $draftid=null)
 Resume an autosave session, updating the draft file area if relevant.
 
 update_autosave_record (string $drafttext)
 Update the text of the autosave session.
 

Protected Member Functions

 is_autosave_stale (stdClass $record)
 Check whether the autosave data is stale.
 
 update_draftid_for_record (stdClass $record, int $newdraftid)
 Move the files relating to the autosave session to a new draft file area.
 

Protected Attributes

int $contextid
 The contextid.
 
string $elementid
 The elementid for this editor.
 
string $pagehash
 The page hash reference.
 
string $pageinstance
 The page instance reference.
 
stdClass $user
 The user record.
 

Detailed Description

Autosave Manager.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

tiny_autosave\autosave_manager::__construct ( int $contextid,
string $pagehash,
string $pageinstance,
string $elementid,
?stdClass $user = null )

Constructor for the autosave manager.

Parameters
int$contextidThe contextid of the session
string$pagehashThe page hash
string$pageinstanceThe page instance
string$elementidThe element id
null | stdClass$userThe user object for the owner of the autosave

Member Function Documentation

◆ create_autosave_record()

tiny_autosave\autosave_manager::create_autosave_record ( string $drafttext,
?int $draftid = null )

Create an autosave record for the session.

Parameters
string$drafttextThe draft text to save
null | int$draftidThe draft file area if one is used
Return values
stdClassThe autosave record

◆ get_autosave_record()

tiny_autosave\autosave_manager::get_autosave_record ( )

Get the autosave record for this session.

Return values
stdClass|null

◆ is_autosave_stale()

tiny_autosave\autosave_manager::is_autosave_stale ( stdClass $record)
protected

Check whether the autosave data is stale.

Records are considered stale if either of the following conditions are true:

  • The record is older than the stale period
  • Any of the files in the draft area are newer than the autosave data itself
Parameters
stdClass$recordThe autosave record
Return values
boolWhether the record is stale

◆ resume_autosave_session()

tiny_autosave\autosave_manager::resume_autosave_session ( ?int $draftid = null)

Resume an autosave session, updating the draft file area if relevant.

Parameters
null | int$draftidThe draft file area to update
Return values
stdClassThe updated autosave record

◆ update_autosave_record()

tiny_autosave\autosave_manager::update_autosave_record ( string $drafttext)

Update the text of the autosave session.

Parameters
string$drafttextThe text to save
Return values
stdClassThe updated record

◆ update_draftid_for_record()

tiny_autosave\autosave_manager::update_draftid_for_record ( stdClass $record,
int $newdraftid )
protected

Move the files relating to the autosave session to a new draft file area.

Parameters
stdClass$recordThe autosave record
int$newdraftidThe new draftid to move files to
Return values
stdClassThe updated autosave record

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