本文整理汇总了PHP中restore_dbops::delete_course_content方法的典型用法代码示例。如果您正苦于以下问题:PHP restore_dbops::delete_course_content方法的具体用法?PHP restore_dbops::delete_course_content怎么用?PHP restore_dbops::delete_course_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类restore_dbops
的用法示例。
在下文中一共展示了restore_dbops::delete_course_content方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: import_course
//.........这里部分代码省略.........
$importtocontext = context_course::instance($importto->id);
self::validate_context($importtocontext);
$backupdefaults = array(
'activities' => 1,
'blocks' => 1,
'filters' => 1
);
$backupsettings = array();
// Check for backup and restore options.
if (!empty($params['options'])) {
foreach ($params['options'] as $option) {
// Strict check for a correct value (allways 1 or 0, true or false).
$value = clean_param($option['value'], PARAM_INT);
if ($value !== 0 and $value !== 1) {
throw new moodle_exception('invalidextparam', 'webservice', '', $option['name']);
}
if (!isset($backupdefaults[$option['name']])) {
throw new moodle_exception('invalidextparam', 'webservice', '', $option['name']);
}
$backupsettings[$option['name']] = $value;
}
}
// Capability checking.
require_capability('moodle/backup:backuptargetimport', $importfromcontext);
require_capability('moodle/restore:restoretargetimport', $importtocontext);
$bc = new backup_controller(backup::TYPE_1COURSE, $importfrom->id, backup::FORMAT_MOODLE,
backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id);
foreach ($backupsettings as $name => $value) {
$bc->get_plan()->get_setting($name)->set_value($value);
}
$backupid = $bc->get_backupid();
$backupbasepath = $bc->get_plan()->get_basepath();
$bc->execute_plan();
$bc->destroy();
// Restore the backup immediately.
// Check if we must delete the contents of the destination course.
if ($params['deletecontent']) {
$restoretarget = backup::TARGET_EXISTING_DELETING;
} else {
$restoretarget = backup::TARGET_EXISTING_ADDING;
}
$rc = new restore_controller($backupid, $importto->id,
backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, $restoretarget);
foreach ($backupsettings as $name => $value) {
$rc->get_plan()->get_setting($name)->set_value($value);
}
if (!$rc->execute_precheck()) {
$precheckresults = $rc->get_precheck_results();
if (is_array($precheckresults) && !empty($precheckresults['errors'])) {
if (empty($CFG->keeptempdirectoriesonbackup)) {
fulldelete($backupbasepath);
}
$errorinfo = '';
foreach ($precheckresults['errors'] as $error) {
$errorinfo .= $error;
}
if (array_key_exists('warnings', $precheckresults)) {
foreach ($precheckresults['warnings'] as $warning) {
$errorinfo .= $warning;
}
}
throw new moodle_exception('backupprecheckerrors', 'webservice', '', $errorinfo);
}
} else {
if ($restoretarget == backup::TARGET_EXISTING_DELETING) {
restore_dbops::delete_course_content($importto->id);
}
}
$rc->execute_plan();
$rc->destroy();
if (empty($CFG->keeptempdirectoriesonbackup)) {
fulldelete($backupbasepath);
}
return null;
}
示例2: fulldelete
// If errors are found, terminate the import.
fulldelete($tempdestination);
echo $OUTPUT->header();
echo $renderer->precheck_notices($precheckresults);
echo $OUTPUT->continue_button(new moodle_url('/course/view.php', array('id' => $course->id)));
echo $OUTPUT->footer();
die;
}
if (!empty($precheckresults['warnings'])) {
// If warnings are found, go ahead but display warnings later.
$warnings = $precheckresults['warnings'];
}
}
}
if ($restoretarget == backup::TARGET_CURRENT_DELETING || $restoretarget == backup::TARGET_EXISTING_DELETING) {
restore_dbops::delete_course_content($course->id);
}
// Execute the restore.
$rc->execute_plan();
// Delete the temp directory now
fulldelete($tempdestination);
// Display a notification and a continue button
echo $OUTPUT->header();
if ($warnings) {
echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('warning'), 'notifyproblem');
echo html_writer::start_tag('ul', array('class' => 'list'));
foreach ($warnings as $warning) {
echo html_writer::tag('li', $warning);
}
echo html_writer::end_tag('ul');
示例3: execute
/**
* Executes the restore plan
* @throws restore_ui_exception if the progress or stage is wrong.
* @return bool
*/
public function execute()
{
if ($this->progress >= self::PROGRESS_EXECUTED) {
throw new restore_ui_exception('restoreuialreadyexecuted');
}
if ($this->stage->get_stage() < self::STAGE_PROCESS) {
throw new restore_ui_exception('restoreuifinalisedbeforeexecute');
}
if ($this->controller->get_target() == backup::TARGET_CURRENT_DELETING || $this->controller->get_target() == backup::TARGET_EXISTING_DELETING) {
$options = array();
$options['keep_roles_and_enrolments'] = $this->get_setting_value('keep_roles_and_enrolments');
$options['keep_groups_and_groupings'] = $this->get_setting_value('keep_groups_and_groupings');
restore_dbops::delete_course_content($this->controller->get_courseid(), $options);
}
$this->controller->execute_plan();
$this->progress = self::PROGRESS_EXECUTED;
$this->stage = new restore_ui_stage_complete($this, $this->stage->get_params(), $this->controller->get_results());
return true;
}
示例4: backup_and_restore
function backup_and_restore($courseid_from,$courseid_to,$admin) {
global $USER, $CFG;
// Turn off file logging, otherwise it can't delete the file (Windows).
$CFG->backup_file_logger_level = backup::LOG_NONE;
// Do backup with default settings. MODE_IMPORT means it will just
// create the directory and not zip it.
$bc = new backup_controller(backup::TYPE_1COURSE, $courseid_from,
backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_IMPORT,
$admin->id);
$backupid = $bc->get_backupid();
$bc->execute_plan();
$bc->destroy();
// Do restore to new course with default settings.
//$newcourseid = restore_dbops::create_new_course(
// $course_fullname, $course_shortname, $course_category);
//directly to particular course id
restore_dbops::delete_course_content($courseid_to);
$rc = new restore_controller($backupid, $courseid_to,
backup::INTERACTIVE_NO, backup::MODE_GENERAL, $admin->id,1);
$rc->execute_precheck();
$rc->execute_plan();
$rc->destroy();
return 0;
}
示例5: restore_course_generic_setting
$options['keep_groups_and_groupings'] = new restore_course_generic_setting('keep_groups_and_groupings', base_setting::IS_BOOLEAN, true);
restore_dbops::delete_course_content($courseid, $options);
}
$controller = new restore_controller($filepath, $courseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id, $target);
$controller->execute_precheck();
$controller->execute_plan();
$transaction->allow_commit();
} else {
$courseids = required_param('targetid', PARAM_INT);
$transaction = $DB->start_delegated_transaction();
foreach ($courseids as $key => $courseid) {
if ($target == backup::TARGET_EXISTING_DELETING) {
$options = array();
$options['keep_roles_and_enrolments'] = new restore_course_generic_setting('keep_roles_and_enrolments', base_setting::IS_BOOLEAN, true);
$options['keep_groups_and_groupings'] = new restore_course_generic_setting('keep_groups_and_groupings', base_setting::IS_BOOLEAN, true);
restore_dbops::delete_course_content($courseid, $options);
}
$controller = new restore_controller($filepath, $courseid, backup::INTERACTIVE_NO, backup::MODE_GENERAL, $USER->id, $target);
$controller->execute_precheck();
$controller->execute_plan();
}
$transaction->allow_commit();
}
backup_helper::delete_backup_dir($filepath);
}
}
echo $OUTPUT->header();
if ($restore) {
$heading = $course->fullname;
$PAGE->set_title($heading . ': ' . $restore->get_stage_name());
$PAGE->set_heading($heading);
示例6: restore_course
public static function restore_course($emptycourseid, $backupfilename)
{
global $DB, $CFG;
try {
$courseid = $emptycourseid;
$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
$restoretarget = 0;
$fb = get_file_packer();
$fb->extract_to_pathname("{$CFG->dataroot}/temp/backup/" . $backupfilename, "{$CFG->dataroot}/temp/backup/" . md5($backupfilename) . "/");
restore_dbops::delete_course_content($course->id);
$rc = new restore_controller(md5($backupfilename), $course->id, backup::INTERACTIVE_NO, backup::MODE_GENERAL, 2, $restoretarget);
$rc->execute_precheck();
$rc->execute_plan();
return 'success';
} catch (Exception $e) {
if (extension_loaded('newrelic')) {
newrelic_notice_error($e->getMessage() . "{$CFG->dataroot}/temp/backup/" . $backupfilename, $e);
}
return 'Exception ' . $e->getMessage() . "{$CFG->dataroot}/temp/backup/" . $backupfilename;
}
}