]> git.mjollnir.org Git - moodle.git/commitdiff
minor fix for count of users
authortoyomoyo <toyomoyo>
Wed, 19 Sep 2007 03:48:44 +0000 (03:48 +0000)
committertoyomoyo <toyomoyo>
Wed, 19 Sep 2007 03:48:44 +0000 (03:48 +0000)
admin/roles/assign.php

index b1c2f9ab4cef7dde43400d49b066040a2ce7e1f0..417d878b99f965c02e7ce3df7310d1317e138d1e 100755 (executable)
                         }
                     }
                 }
-            
+
                 if ($validroleids) {
                     $roleids =  '('.implode(',', $validroleids).')';
             
                     $select = " SELECT u.id, u.firstname, u.lastname, u.email";
+                    $countselect = "SELECT COUNT(u.id)";
                     $from   = " FROM {$CFG->prefix}user u
                                 INNER JOIN {$CFG->prefix}role_assignments ra ON ra.userid = u.id
                                 INNER JOIN {$CFG->prefix}role r ON r.id = ra.roleid";
                     $where  = " WHERE ra.contextid ".get_related_contexts_string($context)."
                                 AND u.deleted = 0
-                                AND ra.roleid in $roleids
-                                $selectsql
-                                AND u.id NOT IN (
+                                AND ra.roleid in $roleids";
+                    $excsql = " AND u.id NOT IN (
                                     SELECT u.id
                                     FROM {$CFG->prefix}role_assignments r,
                                     {$CFG->prefix}user u
                                     AND r.roleid = $roleid
                                     $selectsql)";
             
-                    $availableusers = get_recordset_sql($select . $from . $where);         
+                    $availableusers = get_recordset_sql($select . $from . $where . $selectsql . $excsql);         
                 }
+                
+                $usercount =  count_records_sql($countselect . $from . $where) - count($contextusers);
             }
 
         } else { 
                                                     AND r.roleid = '.$roleid.'
                                                     '.$selectsql.')
                                                 ORDER BY lastname ASC, firstname ASC');
+            $usercount = count_records_select('user', $select) - count($contextusers);
    
         }