本文整理汇总了PHP中backup_controller_dbops::apply_version_and_release方法的典型用法代码示例。如果您正苦于以下问题:PHP backup_controller_dbops::apply_version_and_release方法的具体用法?PHP backup_controller_dbops::apply_version_and_release怎么用?PHP backup_controller_dbops::apply_version_and_release使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类backup_controller_dbops
的用法示例。
在下文中一共展示了backup_controller_dbops::apply_version_and_release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor for the backup controller class.
*
* @param int $type Type of the backup; One of backup::TYPE_1COURSE, TYPE_1SECTION, TYPE_1ACTIVITY
* @param int $id The ID of the item to backup; e.g the course id
* @param int $format The backup format to use; Most likely backup::FORMAT_MOODLE
* @param bool $interactive Whether this backup will require user interaction; backup::INTERACTIVE_YES or INTERACTIVE_NO
* @param int $mode One of backup::MODE_GENERAL, MODE_IMPORT, MODE_SAMESITE, MODE_HUB, MODE_AUTOMATED
* @param int $userid The id of the user making the backup
*/
public function __construct($type, $id, $format, $interactive, $mode, $userid)
{
$this->type = $type;
$this->id = $id;
$this->courseid = backup_controller_dbops::get_courseid_from_type_id($this->type, $this->id);
$this->format = $format;
$this->interactive = $interactive;
$this->mode = $mode;
$this->userid = $userid;
// Apply some defaults
$this->execution = backup::EXECUTION_INMEDIATE;
$this->operation = backup::OPERATION_BACKUP;
$this->executiontime = 0;
$this->checksum = '';
// Apply current backup version and release if necessary
backup_controller_dbops::apply_version_and_release();
// Check format and type are correct
backup_check::check_format_and_type($this->format, $this->type);
// Check id is correct
backup_check::check_id($this->type, $this->id);
// Check user is correct
backup_check::check_user($this->userid);
// Calculate unique $backupid
$this->calculate_backupid();
// Default logger chain (based on interactive/execution)
$this->logger = backup_factory::get_logger_chain($this->interactive, $this->execution, $this->backupid);
// By default there is no progress reporter. Interfaces that wish to
// display progress must set it.
$this->progress = new \core\progress\none();
// Instantiate the output_controller singleton and active it if interactive and inmediate
$oc = output_controller::get_instance();
if ($this->interactive == backup::INTERACTIVE_YES && $this->execution == backup::EXECUTION_INMEDIATE) {
$oc->set_active(true);
}
$this->log('instantiating backup controller', backup::LOG_INFO, $this->backupid);
// Default destination chain (based on type/mode/execution)
$this->destination = backup_factory::get_destination_chain($this->type, $this->id, $this->mode, $this->execution);
// Set initial status
$this->set_status(backup::STATUS_CREATED);
// Load plan (based on type/format)
$this->load_plan();
// Apply all default settings (based on type/format/mode)
$this->apply_defaults();
// Perform all initial security checks and apply (2nd param) them to settings automatically
backup_check::check_security($this, true);
// Set status based on interactivity
if ($this->interactive == backup::INTERACTIVE_YES) {
$this->set_status(backup::STATUS_SETTING_UI);
} else {
$this->set_status(backup::STATUS_AWAITING);
}
}
示例2: __construct
/**
*
* @param string $tempdir Directory under tempdir/backup awaiting restore
* @param int $courseid Course id where restore is going to happen
* @param bool $interactive backup::INTERACTIVE_YES[true] or backup::INTERACTIVE_NO[false]
* @param int $mode backup::MODE_[ GENERAL | HUB | IMPORT | SAMESITE ]
* @param int $userid
* @param int $target backup::TARGET_[ NEW_COURSE | CURRENT_ADDING | CURRENT_DELETING | EXISTING_ADDING | EXISTING_DELETING ]
*/
public function __construct($tempdir, $courseid, $interactive, $mode, $userid, $target)
{
$this->tempdir = $tempdir;
$this->courseid = $courseid;
$this->interactive = $interactive;
$this->mode = $mode;
$this->userid = $userid;
$this->target = $target;
// Apply some defaults
$this->type = '';
$this->format = backup::FORMAT_UNKNOWN;
$this->execution = backup::EXECUTION_INMEDIATE;
$this->operation = backup::OPERATION_RESTORE;
$this->executiontime = 0;
$this->samesite = false;
$this->checksum = '';
$this->precheck = null;
// Apply current backup version and release if necessary
backup_controller_dbops::apply_version_and_release();
// Check courseid is correct
restore_check::check_courseid($this->courseid);
// Check user is correct
restore_check::check_user($this->userid);
// Calculate unique $restoreid
$this->calculate_restoreid();
// Default logger chain (based on interactive/execution)
$this->logger = backup_factory::get_logger_chain($this->interactive, $this->execution, $this->restoreid);
// Instantiate the output_controller singleton and active it if interactive and inmediate
$oc = output_controller::get_instance();
if ($this->interactive == backup::INTERACTIVE_YES && $this->execution == backup::EXECUTION_INMEDIATE) {
$oc->set_active(true);
}
$this->log('instantiating restore controller', backup::LOG_INFO, $this->restoreid);
// Set initial status
$this->set_status(backup::STATUS_CREATED);
// Calculate original restore format
$this->format = backup_general_helper::detect_backup_format($tempdir);
// If format is not moodle2, set to conversion needed
if ($this->format !== backup::FORMAT_MOODLE) {
$this->set_status(backup::STATUS_REQUIRE_CONV);
// Else, format is moodle2, load plan, apply security and set status based on interactivity
} else {
// Load plan
$this->load_plan();
// Perform all initial security checks and apply (2nd param) them to settings automatically
restore_check::check_security($this, true);
if ($this->interactive == backup::INTERACTIVE_YES) {
$this->set_status(backup::STATUS_SETTING_UI);
} else {
$this->set_status(backup::STATUS_NEED_PRECHECK);
}
}
}