本文整理汇总了PHP中restore_controller::get_restoreid方法的典型用法代码示例。如果您正苦于以下问题:PHP restore_controller::get_restoreid方法的具体用法?PHP restore_controller::get_restoreid怎么用?PHP restore_controller::get_restoreid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类restore_controller
的用法示例。
在下文中一共展示了restore_controller::get_restoreid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save_controller
/**
* Send one restore controller to DB
*
* @param restore_controller $controller controller to send to DB
* @param string $checksum hash of the controller to be checked
* @param bool $includeobj to decide if the object itself must be updated (true) or no (false)
* @param bool $cleanobj to decide if the object itself must be cleaned (true) or no (false)
* @return int id of the controller record in the DB
* @throws backup_controller_exception|restore_dbops_exception
*/
public static function save_controller($controller, $checksum, $includeobj = true, $cleanobj = false)
{
global $DB;
// Check we are going to save one backup_controller
if (!$controller instanceof restore_controller) {
throw new backup_controller_exception('restore_controller_expected');
}
// Check checksum is ok. Only if we are including object info. Sounds silly but it isn't ;-).
if ($includeobj and !$controller->is_checksum_correct($checksum)) {
throw new restore_dbops_exception('restore_controller_dbops_saving_checksum_mismatch');
}
// Cannot request to $includeobj and $cleanobj at the same time.
if ($includeobj and $cleanobj) {
throw new restore_dbops_exception('restore_controller_dbops_saving_cannot_include_and_delete');
}
// Get all the columns
$rec = new stdclass();
$rec->backupid = $controller->get_restoreid();
$rec->operation = $controller->get_operation();
$rec->type = $controller->get_type();
$rec->itemid = $controller->get_courseid();
$rec->format = $controller->get_format();
$rec->interactive = $controller->get_interactive();
$rec->purpose = $controller->get_mode();
$rec->userid = $controller->get_userid();
$rec->status = $controller->get_status();
$rec->execution = $controller->get_execution();
$rec->executiontime = $controller->get_executiontime();
$rec->checksum = $checksum;
// Serialize information
if ($includeobj) {
$rec->controller = base64_encode(serialize($controller));
} else {
if ($cleanobj) {
$rec->controller = '';
}
}
// Send it to DB
if ($recexists = $DB->get_record('backup_controllers', array('backupid' => $rec->backupid))) {
$rec->id = $recexists->id;
$rec->timemodified = time();
$DB->update_record('backup_controllers', $rec);
} else {
$rec->timecreated = time();
$rec->timemodified = 0;
$rec->id = $DB->insert_record('backup_controllers', $rec);
}
return $rec->id;
}
示例2: get_restoreid
public function get_restoreid()
{
return $this->controller->get_restoreid();
}
示例3: execute_prechecks
/**
* Entry point for all the prechecks to be performed before restore
*
* Returns empty array or warnings/errors array
*/
public static function execute_prechecks(restore_controller $controller, $droptemptablesafter = false)
{
global $CFG;
$errors = array();
$warnings = array();
// Some handy vars to be used along the prechecks
$samesite = $controller->is_samesite();
$restoreusers = $controller->get_plan()->get_setting('users')->get_value();
$hasmnetusers = (int) $controller->get_info()->mnet_remoteusers;
$restoreid = $controller->get_restoreid();
$courseid = $controller->get_courseid();
$userid = $controller->get_userid();
$rolemappings = $controller->get_info()->role_mappings;
$progress = $controller->get_progress();
// Start tracking progress. There are currently 8 major steps, corresponding
// to $majorstep++ lines in this code; we keep track of the total so as to
// verify that it's still correct. If you add a major step, you need to change
// the total here.
$majorstep = 1;
$majorsteps = 8;
$progress->start_progress('Carrying out pre-restore checks', $majorsteps);
// Load all the included tasks to look for inforef.xml files
$inforeffiles = array();
$tasks = restore_dbops::get_included_tasks($restoreid);
$progress->start_progress('Listing inforef files', count($tasks));
$minorstep = 1;
foreach ($tasks as $task) {
// Add the inforef.xml file if exists
$inforefpath = $task->get_taskbasepath() . '/inforef.xml';
if (file_exists($inforefpath)) {
$inforeffiles[] = $inforefpath;
}
$progress->progress($minorstep++);
}
$progress->end_progress();
$progress->progress($majorstep++);
// Create temp tables
restore_controller_dbops::create_restore_temp_tables($controller->get_restoreid());
// Check we are restoring one backup >= $min20version (very first ok ever)
$min20version = 2010072300;
if ($controller->get_info()->backup_version < $min20version) {
$message = new stdclass();
$message->backup = $controller->get_info()->backup_version;
$message->min = $min20version;
$errors[] = get_string('errorminbackup20version', 'backup', $message);
}
// Compare Moodle's versions
if ($CFG->version < $controller->get_info()->moodle_version) {
$message = new stdclass();
$message->serverversion = $CFG->version;
$message->serverrelease = $CFG->release;
$message->backupversion = $controller->get_info()->moodle_version;
$message->backuprelease = $controller->get_info()->moodle_release;
$warnings[] = get_string('noticenewerbackup', '', $message);
}
// Error if restoring over frontpage
// TODO: Review the whole restore process in order to transform this into one warning (see 1.9)
if ($controller->get_courseid() == SITEID) {
$errors[] = get_string('errorrestorefrontpage', 'backup');
}
// If restoring to different site and restoring users and backup has mnet users warn/error
if (!$samesite && $restoreusers && $hasmnetusers) {
// User is admin (can create users at sysctx), warn
if (has_capability('moodle/user:create', context_system::instance(), $controller->get_userid())) {
$warnings[] = get_string('mnetrestore_extusers_admin', 'admin');
// User not admin
} else {
$errors[] = get_string('mnetrestore_extusers_noadmin', 'admin');
}
}
// Load all the inforef files, we are going to need them
$progress->start_progress('Loading temporary IDs', count($inforeffiles));
$minorstep = 1;
foreach ($inforeffiles as $inforeffile) {
// Load each inforef file to temp_ids.
restore_dbops::load_inforef_to_tempids($restoreid, $inforeffile, $progress);
$progress->progress($minorstep++);
}
$progress->end_progress();
$progress->progress($majorstep++);
// If restoring users, check we are able to create all them
if ($restoreusers) {
$file = $controller->get_plan()->get_basepath() . '/users.xml';
// Load needed users to temp_ids.
restore_dbops::load_users_to_tempids($restoreid, $file, $progress);
$progress->progress($majorstep++);
if ($problems = restore_dbops::precheck_included_users($restoreid, $courseid, $userid, $samesite, $progress)) {
$errors = array_merge($errors, $problems);
}
} else {
// To ensure consistent number of steps in progress tracking,
// mark progress even though we didn't do anything.
$progress->progress($majorstep++);
}
$progress->progress($majorstep++);
//.........这里部分代码省略.........