Skip to content
Permalink
Browse files

MDL-23898 backup - avoid role assignments for deleted users

  • Loading branch information...
stronk7 committed Aug 24, 2010
1 parent f266594 commit 28b6ff82d989bf06926e5bde46d3a83497707dbb
Showing with 7 additions and 2 deletions.
  1. +7 −2 backup/moodle2/restore_stepslib.php
@@ -699,15 +699,20 @@ protected function define_structure() {
}
public function process_assignment($data) {
global $DB;
$data = (object)$data;
// Check roleid, userid are one of the mapped ones
$newroleid = $this->get_mappingid('role', $data->roleid);
$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 && $newuserid && empty($data->component) && $this->task->get_contextid()) {
// TODO: role_assign() needs one userid param to be able to specify our restore userid
role_assign($newroleid, $newuserid, $this->task->get_contextid());
// Only assign roles to not deleted users
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());
}
}
}

0 comments on commit 28b6ff8

Please sign in to comment.
You can’t perform that action at this time.