MDL-24520 use different name if manager role already exists

This commit is contained in:
Petr Skoda
2010-10-05 08:25:58 +00:00
parent 84dcdbdb58
commit 96e890bbf5
+8 -1
View File
@@ -2851,9 +2851,16 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
$role->archetype = substr($role->capability, $substart);
unset($role->capability);
if ($role->archetype === 'admin') {
$i = '';
if ($DB->record_exists('role', array('shortname'=>'manager'))) {
$i = 2;
while($DB->record_exists('role', array('shortname'=>'manager'.$i))) {
$i++;
}
}
$role->archetype = 'manager';
if ($role->shortname === 'admin') {
$role->shortname = 'manager';
$role->shortname = 'manager'.$i;
$role->name = get_string('manager', 'role');
$role->description = get_string('managerdescription', 'role');
}