/** * Updates the AUTOSAVE stash of the given persistent stage * * For every user, AMOS keeps a single instance of mlang_stash to store the most recent * stage state. This behaves as a backup of the staged strings before they are committed. * * @param mlang_persistent_stage $stage */ public static function autosave(mlang_persistent_stage $stage) { global $DB; $instance = new mlang_stash($stage->userid); $instance->name = 'AUTOSAVE'; $instance->set_stage($stage); $instance->hash = 'xxxxautosaveuser' . $stage->userid; if ($id = $DB->get_field('amos_stashes', 'id', array('hash' => $instance->hash, 'ownerid' => $stage->userid))) { $instance->id = $id; } $instance->push(); }