Skip to content

Commit

Permalink
MDL-23898 backup - avoid role assignments for deleted users
Browse files Browse the repository at this point in the history
  • Loading branch information
stronk7 committed Aug 24, 2010
1 parent f266594 commit 28b6ff8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions backup/moodle2/restore_stepslib.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -699,15 +699,20 @@ protected function define_structure() {
} }


public function process_assignment($data) { public function process_assignment($data) {
global $DB;

$data = (object)$data; $data = (object)$data;


// Check roleid, userid are one of the mapped ones // Check roleid, userid are one of the mapped ones
$newroleid = $this->get_mappingid('role', $data->roleid); $newroleid = $this->get_mappingid('role', $data->roleid);
$newuserid = $this->get_mappingid('user', $data->userid); $newuserid = $this->get_mappingid('user', $data->userid);
// If newroleid and newuserid and component is empty and context valid assign via API (handles dupes and friends) // If newroleid and newuserid and component is empty and context valid assign via API (handles dupes and friends)
if ($newroleid && $newuserid && empty($data->component) && $this->task->get_contextid()) { if ($newroleid && $newuserid && empty($data->component) && $this->task->get_contextid()) {
// TODO: role_assign() needs one userid param to be able to specify our restore userid // Only assign roles to not deleted users
role_assign($newroleid, $newuserid, $this->task->get_contextid()); if ($DB->record_exists('user', array('id' => $newuserid, 'deleted' => 0))) {
// TODO: role_assign() needs one userid param to be able to specify our restore userid
role_assign($newroleid, $newuserid, $this->task->get_contextid());
}
} }
} }


Expand Down

0 comments on commit 28b6ff8

Please sign in to comment.