]> git.mjollnir.org Git - moodle.git/commitdiff
Added a progress bar for the role assignments
authormoodler <moodler>
Fri, 29 Sep 2006 06:19:47 +0000 (06:19 +0000)
committermoodler <moodler>
Fri, 29 Sep 2006 06:19:47 +0000 (06:19 +0000)
lib/accesslib.php
lib/adminlib.php

index 8d72cda7cfff6983cc0b041d35d8e2b440a59938..4d6f167bd568806d06ab86bb6e8de2e6d4d66cda 100755 (executable)
@@ -949,6 +949,18 @@ function moodle_install_roles() {
 
     $dbtables = $db->MetaTables('TABLES');
 
+/// Set up the progress bar
+
+    $usertables = array('user_admins', 'user_coursecreators', 'user_teachers', 'user_students');
+
+    $totalcount = $progresscount = 0;
+    foreach ($usertables as $usertable) {
+        if (in_array($CFG->prefix.$usertable, $dbtables)) {
+             $totalcount += count_records($usertable);
+        }
+    }
+
+    print_progress(0, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
 
 /// Upgrade the admins.
 /// Sort using id ASC, first one is primary admin.
@@ -958,6 +970,8 @@ function moodle_install_roles() {
             while (! $rs->EOF) {
                 $admin = $rs->FetchObj();
                 role_assign($adminrole, $admin->userid, 0, $systemcontext->id);
+                $progresscount++;
+                print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
                 $rs->MoveNext();
             }
         }
@@ -972,6 +986,8 @@ function moodle_install_roles() {
             while (! $rs->EOF) {
                 $coursecreator = $rs->FetchObj();
                 role_assign($coursecreatorrole, $coursecreator->userid, 0, $systemcontext->id);
+                $progresscount++;
+                print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
                 $rs->MoveNext();
             }
         }
@@ -998,6 +1014,8 @@ function moodle_install_roles() {
                 } else {
                     role_assign($noneditteacherrole, $teacher->userid, 0, $coursecontext->id);
                 }
+                $progresscount++;
+                print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
 
                 $rs->MoveNext();
             }
@@ -1021,6 +1039,8 @@ function moodle_install_roles() {
                 // assign the default student role
                 $coursecontext = get_context_instance(CONTEXT_COURSE, $student->course);
                 role_assign($studentrole, $student->userid, 0, $coursecontext->id);
+                $progresscount++;
+                print_progress($progresscount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
 
                 $rs->MoveNext();
             }
@@ -1032,6 +1052,7 @@ function moodle_install_roles() {
     if ($guestuser = get_record('user', 'username', 'guest')) {
         role_assign($guestrole, $guestuser->id, 0, $systemcontext->id);
     }
+    print_progress($totalcount, $totalcount, 5, 1, 'Processing '.$totalcount.'role assignments');
 
 
 /// Insert the correct records for legacy roles
index cc147fea1387039758b7f430b366828c20206ea8..469976fd73495307b93b8dbd0a1e44b434aaad88 100644 (file)
@@ -436,10 +436,10 @@ function print_progress($done, $total, $updatetime=5, $sleeptime=1, $donetext=''
         $starttime = $lasttime = time();
         $lasttime = $starttime - $updatetime;
         echo '<table width="500" cellpadding="0" cellspacing="0" align="center"><tr><td width="500">';
-        echo '<div id="bar" style="border-style:solid;border-width:1px;width:500px;height:50px;">';
-        echo '<div id="slider" style="border-style:solid;border-width:1px;height:48px;width:10px;background-color:green;"></div>';
+        echo '<div id="bar'.$total.'" style="border-style:solid;border-width:1px;width:500px;height:50px;">';
+        echo '<div id="slider'.$total.'" style="border-style:solid;border-width:1px;height:48px;width:10px;background-color:green;"></div>';
         echo '</div>';
-        echo '<div id="text" align="center" style="width:500px;"></div>';
+        echo '<div id="text'.$total.'" align="center" style="width:500px;"></div>';
         echo '</td></tr></table>';
         echo '</div>';
     }