MDL-39213 allow role assignments in frontpage in user upload

This commit is contained in:
Petr Škoda
2013-04-21 17:24:51 +02:00
parent 3a8c4380c0
commit 968083cd02
+22 -1
View File
@@ -900,7 +900,28 @@ if ($formdata = $mform2->is_cancelled()) {
}
}
if ($manual and $manualcache[$courseid]) {
if ($courseid == SITEID) {
// Technically frontpage does not have enrolments, but only role assignments,
// let's not invent new lang strings here for this rarely used feature.
if (!empty($user->{'role'.$i})) {
$addrole = $user->{'role'.$i};
if (array_key_exists($addrole, $rolecache)) {
$rid = $rolecache[$addrole]->id;
} else {
$upt->track('enrolments', get_string('unknownrole', 'error', s($addrole)), 'error');
continue;
}
role_assign($rid, $user->id, context_course::instance($courseid));
$a = new stdClass();
$a->course = $shortname;
$a->role = $rolecache[$rid]->name;
$upt->track('enrolments', get_string('enrolledincourserole', 'enrol_manual', $a));
}
} else if ($manual and $manualcache[$courseid]) {
// find role
$rid = false;