当前位置: 首页>>代码示例>>PHP>>正文


PHP restore_controller::convert方法代码示例

本文整理汇总了PHP中restore_controller::convert方法的典型用法代码示例。如果您正苦于以下问题:PHP restore_controller::convert方法的具体用法?PHP restore_controller::convert怎么用?PHP restore_controller::convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在restore_controller的用法示例。


在下文中一共展示了restore_controller::convert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

require_capability('moodle/restore:restorecourse', $context);
if ($stage & restore_ui::STAGE_CONFIRM + restore_ui::STAGE_DESTINATION) {
    $restore = restore_ui::engage_independent_stage($stage, $contextid);
} else {
    $restoreid = optional_param('restore', false, PARAM_ALPHANUM);
    $rc = restore_ui::load_controller($restoreid);
    if (!$rc) {
        $restore = restore_ui::engage_independent_stage($stage / 2, $contextid);
        if ($restore->process()) {
            $rc = new restore_controller($restore->get_filepath(), $restore->get_course_id(), backup::INTERACTIVE_YES, backup::MODE_GENERAL, $USER->id, $restore->get_target());
        }
    }
    if ($rc) {
        // check if the format conversion must happen first
        if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
            $rc->convert();
        }
        $restore = new restore_ui($rc, array('contextid' => $context->id));
    }
}
$outcome = $restore->process();
if (!$restore->is_independent()) {
    if ($restore->get_stage() == restore_ui::STAGE_PROCESS && !$restore->requires_substage()) {
        try {
            $restore->execute();
        } catch (Exception $e) {
            $restore->cleanup();
            throw $e;
        }
    } else {
        $restore->save_controller();
开发者ID:Burick,项目名称:moodle,代码行数:31,代码来源:restore.php

示例2: execute

 /**
  * https://github.com/tmuras/moosh/blob/master/Moosh/Command/Moodle23/Course/CourseRestore.php
  * @param $bkpfile
  * @param $categoryId
  */
 public static function execute($bkpfile, $categoryId)
 {
     global $CFG, $DB, $USER;
     require_once $CFG->dirroot . "/backup/util/includes/backup_includes.php";
     require_once $CFG->dirroot . "/backup/util/includes/restore_includes.php";
     if (empty($CFG->tempdir)) {
         $CFG->tempdir = $CFG->dataroot . DIRECTORY_SEPARATOR . 'temp';
     }
     //unzip into $CFG->tempdir / "backup" / "auto_restore_" . $split[1];
     $backupdir = "moosh_restore_" . uniqid();
     $path = $CFG->tempdir . DIRECTORY_SEPARATOR . "backup" . DIRECTORY_SEPARATOR . $backupdir;
     /** @var $fp file_packer */
     $fp = get_file_packer('application/vnd.moodle.backup');
     $fp->extract_to_pathname($bkpfile, $path);
     //extract original full & short names
     $xmlfile = $path . DIRECTORY_SEPARATOR . "course" . DIRECTORY_SEPARATOR . "course.xml";
     // Different XML file in Moodle 1.9 backup
     if (!file_exists($xmlfile)) {
         $xmlfile = $path . DIRECTORY_SEPARATOR . "moodle.xml";
     }
     $xml = simplexml_load_file($xmlfile);
     $fullname = $xml->xpath('/course/fullname');
     if (!$fullname) {
         $fullname = $xml->xpath('/MOODLE_BACKUP/COURSE/HEADER/FULLNAME');
     }
     $shortname = $xml->xpath('/course/shortname');
     if (!$shortname) {
         $shortname = $xml->xpath('/MOODLE_BACKUP/COURSE/HEADER/SHORTNAME');
     }
     $fullname = (string) $fullname[0];
     $shortname = (string) $shortname[0];
     if (!$shortname) {
         cli_error('No shortname in the backup file.');
     }
     if (!$fullname) {
         $fullname = $shortname;
     }
     $courseid = \restore_dbops::create_new_course($fullname, $shortname, $categoryId);
     $rc = new \restore_controller($backupdir, $courseid, \backup::INTERACTIVE_NO, \backup::MODE_GENERAL, 2, \backup::TARGET_NEW_COURSE);
     echo "Restoring (new course id,shortname,destination category): {$courseid}, {$shortname}," . $categoryId . "\n";
     if ($rc->get_status() == \backup::STATUS_REQUIRE_CONV) {
         $rc->convert();
     }
     $plan = $rc->get_plan();
     //TODO: valider les options réquises.
     $restopt = array('activities' => 1, 'blocks' => 1, 'filters' => 1, 'users' => 0, 'role_assignments' => 1, 'comments' => 0, 'logs' => 0, 'grade_histories' => 0);
     foreach ($restopt as $name => $value) {
         $setting = $plan->get_setting($name);
         if ($setting->get_status() == \backup_setting::NOT_LOCKED) {
             $setting->set_value($value);
         }
     }
     $rc->execute_precheck();
     $rc->execute_plan();
     $rc->destroy();
     echo "New course ID for '{$shortname}': {$courseid} in {$categoryId}\n";
     // Ajouter le idnumber dans le nouveau cours.
     $c = $DB->get_record('course', array('id' => $courseid));
     $c->idnumber = self::get_idnumber($shortname);
     $DB->update_record('course', $c);
 }
开发者ID:nmoller,项目名称:backup-restore,代码行数:66,代码来源:restore.php

示例3: proceed

 /**
  * Proceed with the import of the course.
  *
  * @return void
  */
 public function proceed()
 {
     global $CFG, $USER;
     if (!$this->prepared) {
         throw new coding_exception('The course has not been prepared.');
     } else {
         if ($this->has_errors()) {
             throw new moodle_exception('Cannot proceed, errors were detected.');
         } else {
             if ($this->processstarted) {
                 throw new coding_exception('The process has already been started.');
             }
         }
     }
     $this->processstarted = true;
     if ($this->do === self::DO_DELETE) {
         if ($this->delete()) {
             $this->status('coursedeleted', new lang_string('coursedeleted', 'tool_uploadcourse'));
         } else {
             $this->error('errorwhiledeletingcourse', new lang_string('errorwhiledeletingcourse', 'tool_uploadcourse'));
         }
         return true;
     } else {
         if ($this->do === self::DO_CREATE) {
             $course = create_course((object) $this->data);
             $this->id = $course->id;
             $this->status('coursecreated', new lang_string('coursecreated', 'tool_uploadcourse'));
         } else {
             if ($this->do === self::DO_UPDATE) {
                 $course = (object) $this->data;
                 update_course($course);
                 $this->id = $course->id;
                 $this->status('courseupdated', new lang_string('courseupdated', 'tool_uploadcourse'));
             } else {
                 // Strangely the outcome has not been defined, or is unknown!
                 throw new coding_exception('Unknown outcome!');
             }
         }
     }
     // Restore a course.
     if (!empty($this->restoredata)) {
         $rc = new restore_controller($this->restoredata, $course->id, backup::INTERACTIVE_NO, backup::MODE_IMPORT, $USER->id, backup::TARGET_CURRENT_ADDING);
         // Check if the format conversion must happen first.
         if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
             $rc->convert();
         }
         if ($rc->execute_precheck()) {
             $rc->execute_plan();
             $this->status('courserestored', new lang_string('courserestored', 'tool_uploadcourse'));
         } else {
             $this->error('errorwhilerestoringcourse', new lang_string('errorwhilerestoringthecourse', 'tool_uploadcourse'));
         }
         $rc->destroy();
     }
     // Proceed with enrolment data.
     $this->process_enrolment_data($course);
     // Reset the course.
     if ($this->importoptions['reset'] || $this->options['reset']) {
         if ($this->do === self::DO_UPDATE && $this->can_reset()) {
             $this->reset($course);
             $this->status('coursereset', new lang_string('coursereset', 'tool_uploadcourse'));
         }
     }
     // Mark context as dirty.
     $context = context_course::instance($course->id);
     $context->mark_dirty();
 }
开发者ID:evltuma,项目名称:moodle,代码行数:72,代码来源:course.php

示例4: restore_to_course

function restore_to_course($courseid, $backupid, $restoretarget, $admin) {
    global $CFG; 

    // Check whether the backup directory still exists. If missing, something
    // went really wrong in backup, throw error. Note that backup::MODE_IMPORT
    // backups don't store resulting files ever
    $tempdestination = $CFG->tempdir . '/backup/' . $backupid;
    if (!file_exists($tempdestination) || !is_dir($tempdestination)) {
        print_error('unknownbackupexporterror'); // shouldn't happen ever
    }
 
    $rc = new restore_controller($backupid, $courseid, backup::INTERACTIVE_YES, 
                                backup::MODE_IMPORT,$admin->id,$restoretarget);
 
    // Convert the backup if required.... it should NEVER happed
    if ($rc->get_status() == backup::STATUS_REQUIRE_CONV) {
        $rc->convert();
    }
    // Mark the UI finished.
    $rc->finish_ui();
    // Execute prechecks
    $rc->execute_precheck();
    
    //if ($restoretarget == backup::TARGET_CURRENT_DELETING || $restoretarget == backup::TARGET_EXISTING_DELETING) {
    //    restore_dbops::delete_course_content($courseid);
    //}
    // Execute the restore.
    $rc->execute_plan();
    $rc->destroy();
    unset($rc);
    
    // Delete the temp directory now
    fulldelete($tempdestination);
}
开发者ID:rm77,项目名称:pd1tt_module,代码行数:34,代码来源:fungsi_moodle.php


注:本文中的restore_controller::convert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。