mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 08:26:37 +02:00
MDL-15355 restore - proper category selection when restoring from SITE + improved defaults ; merged from 19_STABLE
This commit is contained in:
parent
56f3599bb9
commit
a547c180f6
1 changed files with 15 additions and 6 deletions
|
@ -239,14 +239,23 @@ function selectItemInCheckboxByName(formId, checkName, checked ) {
|
||||||
echo '<label for="menurestore_restorecatto">'.get_string ('category').'</label>';
|
echo '<label for="menurestore_restorecatto">'.get_string ('category').'</label>';
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
// Category selection isn't alowed if restoring from within SITEID course
|
// Get the list of categories where the user can create courses
|
||||||
if ($id != SITEID) {
|
make_categories_list($categories, $parents, 'moodle/course:create');
|
||||||
make_categories_list($categories, $parents);
|
$category_default = null;
|
||||||
choose_from_menu($categories, "restore_restorecatto", $course_header->category->id, "");
|
// Best default 1: restoring in same site, use category of original course if available
|
||||||
|
if (backup_is_same_site($info) &&
|
||||||
|
!empty($course_header->category->id) &&
|
||||||
|
array_key_exists($course_header->category->id, $categories)) {
|
||||||
|
$category_default = $course_header->category->id;
|
||||||
|
// Best default 2: restore to the category of the course we are restoring from if available
|
||||||
} else {
|
} else {
|
||||||
print_string('notavailable');
|
$fromcat = $DB->get_field('course', 'category', array('id' => $id));
|
||||||
echo '<input type="hidden" name="restore_restorecatto" id="menurestore_restorecatto" value="0" />';
|
if (!empty($fromcat) &&
|
||||||
|
array_key_exists($fromcat, $categories)) {
|
||||||
|
$category_default = $fromcat;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
choose_from_menu($categories, 'restore_restorecatto', $category_default, "");
|
||||||
echo "</td>";
|
echo "</td>";
|
||||||
echo "</tr>";
|
echo "</tr>";
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue