Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-25388_restore_activities_target' of git://github.co…

…m/stronk7/moodle
  • Loading branch information...
commit 25ca24d59fb4a554b5299dc4e8939d277ddf4668 2 parents 2c10c5f + 165b7bd
@skodak skodak authored
View
18 backup/util/ui/renderer.php
@@ -181,7 +181,7 @@ public function course_selector(moodle_url $nextstageurl, $details, restore_cate
$hasrestoreoption = false;
$html = html_writer::start_tag('div', array('class'=>'backup-course-selector backup-restore'));
- if (!empty($categories) && ($categories->get_count() > 0 || $categories->get_search())) {
+ if ($details->type == backup::TYPE_1COURSE && !empty($categories) && ($categories->get_count() > 0 || $categories->get_search())) {
// New course
$hasrestoreoption = true;
$html .= $form;
@@ -194,7 +194,7 @@ public function course_selector(moodle_url $nextstageurl, $details, restore_cate
$html .= html_writer::end_tag('form');
}
- if (!empty($currentcourse)) {
+ if ($details->type == backup::TYPE_1COURSE && !empty($currentcourse)) {
// Current course
$hasrestoreoption = true;
$html .= $form;
@@ -214,9 +214,17 @@ public function course_selector(moodle_url $nextstageurl, $details, restore_cate
$html .= $form;
$html .= html_writer::start_tag('div', array('class'=>'bcs-existing-course backup-section'));
$html .= $this->output->heading(get_string('restoretoexistingcourse', 'backup'), 2, array('class'=>'header'));
- $html .= $this->backup_detail_input(get_string('restoretoexistingcourseadding', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_ADDING, array('checked'=>'checked'));
- $html .= $this->backup_detail_input(get_string('restoretoexistingcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_DELETING);
- $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
+ if ($details->type == backup::TYPE_1COURSE) {
+ $html .= $this->backup_detail_input(get_string('restoretoexistingcourseadding', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_ADDING, array('checked'=>'checked'));
+ $html .= $this->backup_detail_input(get_string('restoretoexistingcoursedeleting', 'backup'), 'radio', 'target', backup::TARGET_EXISTING_DELETING);
+ $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
+ } else {
+ // We only allow restore adding to existing for now. Enforce it here.
+ $html .= html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'target', 'value'=>backup::TARGET_EXISTING_ADDING));
+ $courses->invalidate_results(); // Clean list of courses
+ $courses->set_include_currentcourse(); // Show current course in the list
+ $html .= $this->backup_detail_pair(get_string('selectacourse', 'backup'), $this->render($courses));
+ }
$html .= $this->backup_detail_pair('', html_writer::empty_tag('input', array('type'=>'submit', 'value'=>get_string('continue'))));
$html .= html_writer::end_tag('div');
$html .= html_writer::end_tag('form');
View
8 backup/util/ui/restore_ui_components.php
@@ -132,6 +132,7 @@ public function __construct(array $config=array()) {
*/
final public function invalidate_results() {
$this->results = null;
+ $this->totalcount = null;
}
/**
* Adds a required capability which all results will be checked against
@@ -217,6 +218,7 @@ class restore_course_search extends restore_search_base {
static $VAR_SEARCH = 'search';
protected $currentcourseid = null;
+ protected $includecurrentcourse;
/**
* @param array $config
@@ -226,6 +228,7 @@ public function __construct(array $config=array(), $currentcouseid = null) {
parent::__construct($config);
$this->require_capability('moodle/restore:restorecourse');
$this->currentcourseid = $currentcouseid;
+ $this->includecurrentcourse = false;
}
/**
*
@@ -246,7 +249,7 @@ protected function get_searchsql() {
$where = " WHERE (".$DB->sql_like('c.fullname', ':fullnamesearch', false)." OR ".$DB->sql_like('c.shortname', ':shortnamesearch', false).") AND c.id <> :siteid";
$orderby = " ORDER BY c.sortorder";
- if ($this->currentcourseid !== null) {
+ if ($this->currentcourseid !== null && !$this->includecurrentcourse) {
$where .= " AND c.id <> :currentcourseid";
$params['currentcourseid'] = $this->currentcourseid;
}
@@ -260,6 +263,9 @@ protected function format_results() {}
public function get_varsearch() {
return self::$VAR_SEARCH;
}
+ public function set_include_currentcourse() {
+ $this->includecurrentcourse = true;
+ }
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.