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


PHP restore_controller::get_results方法代码示例

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


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

示例1: copy_content

 /**
  * Returns welcome message.
  * @param string $sourcecourse
  * @param string $destinationcourse
  * @param bool $excludequestionbank
  * @return string welcome message.
  */
 public static function copy_content($sourcecourse = '', $destinationcourse = '', $excludequestionbank = false)
 {
     global $DB;
     try {
         $courseid = $destinationcourse;
         $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
         // The id of the course we are importing FROM (will only be set if past first stage.
         $importcourseid = $sourcecourse;
         // The target method for the restore (adding or deleting).
         $restoretarget = backup::TARGET_EXISTING_DELETING;
         $importcourse = $DB->get_record('course', array('id' => $importcourseid), '*', MUST_EXIST);
         $bc = new backup_controller(backup::TYPE_1COURSE, $importcourse->id, backup::FORMAT_MOODLE, backup::INTERACTIVE_NO, backup::MODE_IMPORT, 2);
         $bc->get_plan()->get_setting('users')->set_status(backup_setting::LOCKED_BY_CONFIG);
         $settings = $bc->get_plan()->get_settings();
         // If excludequestionbank is set, do not backup question bank.
         if ($excludequestionbank && $bc->get_plan()->setting_exists('questionbank')) {
             $setting = $bc->get_plan()->get_setting('questionbank');
             $setting->set_value(0);
         }
         // For the initial stage we want to hide all locked settings and if there are.
         // No visible settings move to the next stage.
         foreach ($settings as $setting) {
             if ($setting->get_status() !== backup_setting::NOT_LOCKED) {
                 $setting->set_visibility(backup_setting::HIDDEN);
             }
         }
         $backupid = $bc->get_backupid();
         $bc->execute_plan();
         restore_dbops::delete_course_content($course->id);
         $rc = new restore_controller($backupid, $course->id, backup::INTERACTIVE_NO, backup::MODE_GENERAL, 2, $restoretarget);
         $rc->execute_precheck();
         // If excludequestionbank is set, do not restore quizzes.
         if ($excludequestionbank) {
             $settings = $rc->get_plan()->get_settings();
             foreach ($settings as $setting) {
                 if (preg_match('/(quiz)(_)(\\d+)(_)(included)/', $setting->get_name())) {
                     $rc->get_plan()->get_setting($setting->get_name())->set_value(0);
                 }
             }
         }
         $rc->execute_plan();
         $results = $rc->get_results();
         if (isset($results["file_missing_in_backup"])) {
             if (extension_loaded('newrelic')) {
                 newrelic_notice_error($results["file_missing_in_backup"], new Exception('Missing file in backup'));
             }
         }
         $course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST);
         $importcourse->id = $course->id;
         $importcourse->modinfo = $course->modinfo;
         $importcourse->idnumber = $course->idnumber;
         $importcourse->fullname = $course->fullname;
         $importcourse->shortname = $course->shortname;
         $importcourse->startdate = $course->startdate;
         $importcourse->sectioncache = null;
         $sourceformat = $DB->get_field('course', 'format', array('id' => $importcourseid), MUST_EXIST);
         if (!($coursenumsections = $DB->get_field('course_format_options', 'value', array('courseid' => $importcourseid, 'name' => 'numsections', 'format' => $sourceformat)))) {
             $coursenumsections = 10;
         }
         if ($courseformatconfig = $DB->get_record('course_format_options', array('courseid' => $course->id, 'name' => 'numsections', 'format' => $sourceformat))) {
             $courseformatconfig->value = $coursenumsections;
             $DB->update_record('course_format_options', $courseformatconfig);
         } else {
             $courseformatconfig = new stdClass();
             $courseformatconfig->courseid = $course->id;
             $courseformatconfig->name = 'numsections';
             $courseformatconfig->value = $coursenumsections;
             $courseformatconfig->format = $sourceformat;
             $courseformatconfig->sectionid = 0;
             $DB->insert_record('course_format_options', $courseformatconfig);
         }
         $DB->update_record('course', $importcourse);
         return 'success';
     } catch (Exception $e) {
         if (extension_loaded('newrelic')) {
             newrelic_notice_error($e->getMessage(), $e);
         }
         return 'Exception ' . $e->getMessage();
     }
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:87,代码来源:externallib.php


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