MDL-32005 Avoid some notices restoring old backup files without idnumber

This commit is contained in:
Eloy Lafuente (stronk7) 2012-05-18 13:02:30 +02:00
parent 4a3d07972c
commit 128af10645

View File

@ -719,7 +719,7 @@ class restore_groups_structure_step extends restore_structure_step {
// Only allow the idnumber to be set if the user has permission and the idnumber is not already in use by
// another a group in the same course
$context = context_course::instance($data->courseid);
if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (isset($data->idnumber) and has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (groups_get_group_by_idnumber($data->courseid, $data->idnumber)) {
unset($data->idnumber);
}
@ -779,7 +779,7 @@ class restore_groups_structure_step extends restore_structure_step {
// Only allow the idnumber to be set if the user has permission and the idnumber is not already in use by
// another a grouping in the same course
$context = context_course::instance($data->courseid);
if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (isset($data->idnumber) and has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (groups_get_grouping_by_idnumber($data->courseid, $data->idnumber)) {
unset($data->idnumber);
}