protected function __construct($course_id, $section_i)
 {
     global $CFG;
     //error_reporting(E_ALL);
     require_login($course_id);
     // 権限チェック
     $this->requireCapabilities($course_id);
     // 必要な関数が使用可能かチェック
     backup_required_functions();
     // このタイミングで各モジュールのテーブルをアップグレード
     $return_to = $_SERVER['REQUEST_URI'];
     upgrade_backup_db($return_to);
     // 設定オブジェクトを生成
     $this->prefs =& $this->createPreferences();
     // ユニーク値をセット (Moodleコアはここにtime()が入っているのを期待しているのでそれに従う)
     $this->prefs->backup_unique_code = time();
     // コースを取得
     $this->course = get_record('course', 'id', $course_id);
     if (!$this->course) {
         throw new SharingCart_CourseException('Invalid ID');
     }
     // セクションを取得
     $this->section = get_record('course_sections', 'course', $course_id, 'section', $section_i);
     if (!$this->section) {
         throw new SharingCart_SectionException('Invalid ID');
     }
 }
Beispiel #2
0
        error("You need to be a teacher or admin user to use this page.", "{$CFG->wwwroot}/login/index.php");
    }
}
//Check site
if (!($site = get_site())) {
    error("Site not found!");
}
//Check necessary functions exists. Thanks to gregb@crowncollege.edu
backup_required_functions();
//Check backup_version
if ($id) {
    $linkto = "backup.php?id=" . $id . (!empty($to) ? '&to=' . $to : '');
} else {
    $linkto = "backup.php";
}
upgrade_backup_db($linkto);
//Get strings
if (empty($to)) {
    $strcoursebackup = get_string("coursebackup");
} else {
    $strcoursebackup = get_string('importdata');
}
$stradministration = get_string("administration");
//If cancel has been selected, go back to course main page (bug 2817)
if ($cancel) {
    if ($id) {
        $redirecto = $CFG->wwwroot . '/course/view.php?id=' . $id;
        //Course page
    } else {
        $redirecto = $CFG->wwwroot . '/';
    }
Beispiel #3
0
    }
}
/// Groups install/upgrade is now in core above.
/// Find and check all main modules and load them up or upgrade them if necessary
/// first old *.php update and then the new upgrade.php script
upgrade_activity_modules("{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Check all questiontype plugins and upgrade if necessary
/// first old *.php update and then the new upgrade.php script
/// It is important that this is done AFTER the quiz module has been upgraded
upgrade_plugins('qtype', 'question/type', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Upgrade backup/restore system if necessary
/// first old *.php update and then the new upgrade.php script
require_once "{$CFG->dirroot}/backup/lib.php";
upgrade_backup_db("{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Upgrade blocks system if necessary
/// first old *.php update and then the new upgrade.php script
require_once "{$CFG->dirroot}/lib/blocklib.php";
upgrade_blocks_db("{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Check all blocks and load (or upgrade them if necessary)
/// first old *.php update and then the new upgrade.php script
upgrade_blocks_plugins("{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Check all enrolment plugins and upgrade if necessary
/// first old *.php update and then the new upgrade.php script
upgrade_plugins('enrol', 'enrol', "{$CFG->wwwroot}/{$CFG->admin}/index.php");
// Return here afterwards
/// Check all auth plugins and upgrade if necessary
Beispiel #4
0
/**
 * Refactored code from SBCC
 * Actually perform the course content rollover operation.
 * Rollover will restore into a new blank course
 *
 * @param int $from The course ID we are taking content from.
 * @return bool True on success, False otherwise.
 */
function content_rollover($from, $startdate = 0)
{
    global $CFG;
    require_once $CFG->dirroot . '/backup/lib.php';
    require_once $CFG->dirroot . '/backup/backuplib.php';
    require_once $CFG->libdir . '/blocklib.php';
    require_once $CFG->libdir . '/adminlib.php';
    require_once $CFG->libdir . '/xmlize.php';
    require_once $CFG->dirroot . '/course/lib.php';
    require_once $CFG->dirroot . '/backup/restorelib.php';
    require_once $CFG->dirroot . '/backup//bb/restore_bb.php';
    require_once $CFG->libdir . '/wiki_to_markdown.php';
    /// Make sure the destination course has the same "format" and structure as the template.
    $coursefrom = get_record('course', 'id', $from);
    /// Proceed with the content rollover...
    /// Check necessary functions exists.
    backup_required_functions();
    /// Adjust some php variables to the execution of this script
    @ini_set('max_execution_time', '3000');
    if (empty($CFG->extramemorylimit)) {
        raise_memory_limit('128M');
    } else {
        raise_memory_limit($CFG->extramemorylimit);
    }
    /// Check backup_version.
    ob_start("callback_for_upgrade_backup_db");
    upgrade_backup_db('curriculum/index.php?s=cur&section=curr');
    ob_end_flush();
    $prefs = array('backup_metacourse' => 0, 'backup_users' => 2, 'backup_logs' => 0, 'backup_user_files' => 0, 'backup_course_files' => 1, 'backup_site_files' => 1, 'backup_messages' => 0);
    $errorstr = '';
    if (($filename = rollover_backup_course_silently($from, $prefs, $errorstr)) === false) {
        error($errorstr);
        return false;
    }
    flush();
    /// Handle the import.
    $errorstr = '';
    $prefs = array('restore_metacourse' => 0, 'restore_logs' => 0, 'restore_site_files' => 1, 'restore_course_files' => 1, 'restore_messages' => 0, 'restore_startdate' => $startdate);
    $newcourseid = false;
    if (!($newcourseid = rollover_import_backup_file_silently($filename, 0, false, false, $prefs))) {
        error('Error importing course data');
        return false;
    }
    flush();
    /// Delete the backup file that was created during this process.
    fulldelete($filename);
    return $newcourseid;
}