Merge branch 'MDL-31500_master' of git://github.com/dmonllao/moodle

Conflicts:
	backup/util/ui/renderer.php
This commit is contained in:
Dan Poltawski 2014-11-24 10:55:27 +00:00
commit bcc4dc3eab
10 changed files with 211 additions and 16 deletions

View file

@ -524,7 +524,7 @@ abstract class backup_controller_dbops extends backup_dbops {
*/
public static function backup_get_original_course_info($courseid) {
global $DB;
return $DB->get_record('course', array('id' => $courseid), 'fullname, shortname, startdate');
return $DB->get_record('course', array('id' => $courseid), 'fullname, shortname, startdate, format');
}
/**

View file

@ -155,6 +155,11 @@ abstract class backup_general_helper extends backup_helper {
} else {
$info->include_file_references_to_external_content = 0;
}
// Introduced in Moodle 2.9.
$info->original_course_format = '';
if (!empty($infoarr['original_course_format'])) {
$info->original_course_format = $infoarr['original_course_format'];
}
// include_files is a new setting in 2.6.
if (isset($infoarr['include_files'])) {
$info->include_files = $infoarr['include_files'];

View file

@ -105,10 +105,24 @@ abstract class restore_prechecks_helper {
$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');
// The original_course_format var was introduced in Moodle 2.9.
$originalcourseformat = null;
if (!empty($controller->get_info()->original_course_format)) {
$originalcourseformat = $controller->get_info()->original_course_format;
}
// We can't restore other course's backups on the front page.
if ($controller->get_courseid() == SITEID &&
$originalcourseformat != 'site' &&
$controller->get_type() == backup::TYPE_1COURSE) {
$errors[] = get_string('errorrestorefrontpagebackup', 'backup');
}
// We can't restore front pages over other courses.
if ($controller->get_courseid() != SITEID &&
$originalcourseformat == 'site' &&
$controller->get_type() == backup::TYPE_1COURSE) {
$errors[] = get_string('errorrestorefrontpagebackup', 'backup');
}
// If restoring to different site and restoring users and backup has mnet users warn/error

View file

@ -265,7 +265,9 @@ class core_backup_renderer extends plugin_renderer_base {
$hasrestoreoption = false;
$html = html_writer::start_tag('div', array('class'=>'backup-course-selector backup-restore'));
if ($wholecourse && !empty($categories) && ($categories->get_count() > 0 || $categories->get_search())) {
if ($wholecourse && !empty($categories) && ($categories->get_count() > 0 || $categories->get_search()) &&
$currentcourse != SITEID) {
// New course
$hasrestoreoption = true;
$html .= $form;
@ -306,7 +308,7 @@ class core_backup_renderer extends plugin_renderer_base {
$courses->invalidate_results(); // Clean list of courses.
$courses->set_include_currentcourse();
}
if (!empty($courses) && ($courses->get_count() > 0 || $courses->get_search())) {
if (!empty($courses) && ($courses->get_count() > 0 || $courses->get_search()) && $currentcourse != SITEID) {
// Existing course
$hasrestoreoption = true;
$html .= $form;

View file

@ -280,13 +280,13 @@ class restore_course_search extends restore_search_base {
$params = array(
'contextlevel' => CONTEXT_COURSE,
'fullnamesearch' => '%'.$this->get_search().'%',
'shortnamesearch' => '%'.$this->get_search().'%',
'siteid' => SITEID
'shortnamesearch' => '%'.$this->get_search().'%'
);
$select = " SELECT c.id,c.fullname,c.shortname,c.visible,c.sortorder ";
$from = " FROM {course} c ";
$where = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".$DB->sql_like('c.shortname', ':shortnamesearch', false).") AND c.id <> :siteid";
$where = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".
$DB->sql_like('c.shortname', ':shortnamesearch', false).")";
$orderby = " ORDER BY c.sortorder";
if ($this->currentcourseid !== null && !$this->includecurrentcourse) {