MDL-28253 use unique name for new manager role
authorPetr Skoda <commits@skodak.org>
Thu, 14 Jul 2011 11:36:27 +0000 (13:36 +0200)
committerPetr Skoda <commits@skodak.org>
Thu, 14 Jul 2011 11:38:36 +0000 (13:38 +0200)
lib/db/upgrade.php

index f823295..2b0bf72 100644 (file)
@@ -2858,16 +2858,16 @@ WHERE gradeitemid IS NOT NULL AND grademax IS NOT NULL");
             unset($role->capability);
             if ($role->archetype === 'admin') {
                 $i = '';
             unset($role->capability);
             if ($role->archetype === 'admin') {
                 $i = '';
-                if ($DB->record_exists('role', array('shortname'=>'manager'))) {
+                if ($DB->record_exists('role', array('shortname'=>'manager')) or $DB->record_exists('role', array('name'=>get_string('manager', 'role')))) {
                     $i = 2;
                     $i = 2;
-                    while($DB->record_exists('role', array('shortname'=>'manager'.$i))) {
+                    while($DB->record_exists('role', array('shortname'=>'manager'.$i)) or $DB->record_exists('role', array('name'=>get_string('manager', 'role').$i))) {
                         $i++;
                     }
                 }
                 $role->archetype = 'manager';
                 if ($role->shortname === 'admin') {
                     $role->shortname   = 'manager'.$i;
                         $i++;
                     }
                 }
                 $role->archetype = 'manager';
                 if ($role->shortname === 'admin') {
                     $role->shortname   = 'manager'.$i;
-                    $role->name        = get_string('manager', 'role');
+                    $role->name        = get_string('manager', 'role').$i;
                     $role->description = get_string('managerdescription', 'role');
                 }
             }
                     $role->description = get_string('managerdescription', 'role');
                 }
             }