]> git.mjollnir.org Git - moodle.git/commitdiff
user/index: Add "enrolment details" view to Participants page - MDL-12311
authormartinlanghoff <martinlanghoff>
Fri, 23 Nov 2007 00:23:39 +0000 (00:23 +0000)
committermartinlanghoff <martinlanghoff>
Fri, 23 Nov 2007 00:23:39 +0000 (00:23 +0000)
With this patch, the additional roles/groups/groupings columns get moved
to a special "enrolment details" view. To support this, the handling of
the $mode is revamped to use $mode constants.

To keep performance issues at bay, the enrolment details view is only
available when viewing paginated resultsets, and will reset itself to
'brief' if the conditions aren't met. The $mode is sticky, so it is
quite possible to have a mismatched $mode -- so he handle the case
explicitly.

lang/en_utf8/moodle.php
user/index.php

index d2e7a640f43aa08558dc7ab4466d51e2d76cd4d1..52cd3c729c8d0aeb98e5075ff52a9aec5d7473a6 100644 (file)
@@ -177,6 +177,7 @@ $string['blockseditoff'] = 'Blocks editing off';
 $string['blocksediton'] = 'Blocks editing on';
 $string['blocksetup'] = 'Setting up block tables';
 $string['blocksuccess'] = '$a tables have been set up correctly';
+$string['brief'] = 'Brief';
 $string['bycourseorder'] = 'By course order';
 $string['byname'] = 'by $a';
 $string['bypassed'] = 'Bypassed';
@@ -535,6 +536,7 @@ The new password was automatically generated - you might like to
 $string['enable'] = 'Enable';
 $string['encryptedcode'] = 'Encrypted code';
 $string['enroldate'] = 'Date range';
+$string['enroldetails'] = 'Enrolment details';
 $string['enrolenddate'] = 'End date';
 $string['enrolenddaterror'] = 'Enrolment end date cannot be earlier than start date';
 $string['enrollable'] = 'Course enrollable';
@@ -1512,6 +1514,7 @@ $string['userconfirmed'] = 'Confirmed $a';
 $string['userdata'] = 'User Data';
 $string['userdeleted'] = 'This user account has been deleted';
 $string['userdescription'] = 'Description';
+$string['userdetails'] = 'User details';
 $string['userfiles'] = 'User Files';
 $string['userlist'] = 'User list';
 $string['username'] = 'Username';
index 58b1a3fe44216d3a446b4620b99abaff2c39d6ec..fd5060abd3d27e2ad6495f307ed5ce38025911dc 100644 (file)
@@ -9,10 +9,13 @@
     define('USER_LARGE_CLASS', 200);  // Above this is considered large
     define('DEFAULT_PAGE_SIZE', 20);
     define('SHOW_ALL_PAGE_SIZE', 5000);
+    define('MODE_BRIEF', 0);
+    define('MODE_USERDETAILS', 1);
+    define('MODE_ENROLDETAILS', 2);
 
     $page         = optional_param('page', 0, PARAM_INT);                     // which page to show
     $perpage      = optional_param('perpage', DEFAULT_PAGE_SIZE, PARAM_INT);  // how many per page
-    $mode         = optional_param('mode', NULL);                             // '0' for less details, '1' for more
+    $mode         = optional_param('mode', NULL);                             // use the MODE_ constants
     $accesssince  = optional_param('accesssince',0,PARAM_INT);               // filter by last access. -1 = never
     $search       = optional_param('search','',PARAM_CLEAN);
     $roleid       = optional_param('roleid', 0, PARAM_INT);                 // optional roleid
     $datestring->secs  = get_string('secs');
 
     if ($mode !== NULL) {
-        $SESSION->userindexmode = $fullmode = ($mode == 1);
+        $mode = (int)$mode;
+        $SESSION->userindexmode = $mode;
     } else if (isset($SESSION->userindexmode)) {
-        $fullmode = $SESSION->userindexmode;
+        $mode = (int)$SESSION->userindexmode;
     } else {
-        $fullmode = false;
+        $mode = MODE_BRIEF;
     }
 
 /// Check to see if groups are being used in this forum
         echo '</td>';
     }
 
+    // Decide wheteher we will fetch extra enrolment/groups data.
+    //
+    // MODE_ENROLDETAILS is expensive, and only suitable where the listing is small
+    // (at or below DEFAULT_PAGE_SIZE) and $USER can enrol/unenrol
+    // (will take 1 extra DB query - 2 on Oracle)
+    //
+    if ($course->id != SITEID && $perpage <= DEFAULT_PAGE_SIZE 
+        && has_capability('moodle/role:assign',$context)) {
+        $allowenroldetails=true;
+    } else {
+        $allowenroldetails=false;
+    }
+    if ($mode === MODE_ENROLDETAILS && !($allowenroldetails)) {
+        // conditions haven't been met - reset
+        $mode = MODE_BRIEF;
+    }
 
     echo '<td class="right">';
-    $formatmenu = array( '0' => get_string('detailedless'),
-                         '1' => get_string('detailedmore'));
-    popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $fullmode, '', '', '', false, 'self', get_string('userlist'));
+    $formatmenu = array( '0' => get_string('brief'),
+                         '1' => get_string('userdetails'));
+    if ($allowenroldetails) {
+        $formatmenu['2']= get_string('enroldetails');
+    }
+    popup_form($baseurl.'&amp;mode=', $formatmenu, 'formatmenu', $mode, '', '', '', false, 'self', get_string('userlist'));
     echo '</td></tr></table>';
 
     if ($currentgroup and (!$isseparategroups or has_capability('moodle/site:accessallgroups', $context))) {    /// Display info about the group
         }
     }
 
-    // Decide wheteher we will fetch extra enrolment/groups data.
-    //
-    // If the listing is small (at or below DEFAULT_PAGE_SIZE)
-    // and $USER can enrol/unenrol, display extra enrolments & groups information.
-    // (will take 1 extra DB query - 2 on Oracle)
-    //
-    if ($fullmode === false              && $course->id != SITEID
-        && $perpage <= DEFAULT_PAGE_SIZE && has_capability('moodle/role:assign',$context)) {
-        $showenroldata = true;
-    } else {
-        $showenroldata = false;
-    }
-
     /// Define a table showing a list of users in the current role selection
 
     $tablecolumns = array('userpic', 'fullname');
     $tableheaders = array(get_string('userpic'), get_string('fullname'));
-    if (!isset($hiddenfields['city'])) {
+    if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
         $tablecolumns[] = 'city';
         $tableheaders[] = get_string('city');
     }
-    if (!isset($hiddenfields['country'])) {
+    if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) {
         $tablecolumns[] = 'country';
         $tableheaders[] = get_string('country');
     }
         $tableheaders[] = get_string('enrolmentend');
     }
 
-    if ($showenroldata) {
+    if ($mode === MODE_ENROLDETAILS) {
         $tablecolumns[] = 'roles';
         $tableheaders[] = get_string('roles');
         if ($groupmode != 0) {
     // but this is much cheaper. And in any case, it is only doable with limited numbers
     // of rows anyway. On a large course it will explode badly...
     //
-    if ($showenroldata) {
+    if ($mode===MODE_ENROLDETAILS) {
         $userids = array();
 
         while ($user = rs_fetch_next_record($userlist)) {
         echo '<p id="longtimenosee">('.get_string('unusedaccounts', '', $CFG->longtimenosee).')</p>';
     }
 
-    if ($fullmode) {    // Print simple listing
+    if ($mode===MODE_USERDETAILS) {    // Print simple listing
         if ($totalcount < 1) {
             print_heading(get_string('nothingtodisplay'));
         } else {
                         print_user_picture($user, $course->id, $user->picture, false, true, $piclink),
                         $profilelink);
 
-                if (!isset($hiddenfields['city'])) {
+                if ($mode === MODE_BRIEF && !isset($hiddenfields['city'])) {
                     $data[] = $user->city;
                 }
-                if (!isset($hiddenfields['country'])) {
+                if ($mode === MODE_BRIEF && !isset($hiddenfields['country'])) {
                     $data[] = $country;
                 }
                 if (!isset($hiddenfields['lastaccess'])) {
                     foreach ($ras AS $key=>$ra) {
                         $rolename = $rolenames [ $ra['roleid'] ] ;
                         if ($ra['ctxlevel'] == CONTEXT_COURSECAT) {
-                            $rastring .= $rolename. ' @ ' . s($ra['ccname']);
+                            $rastring .= $rolename. ' @ ' . '<a href="'.$CFG->wwwroot.'/course/category.php?id='.$ra['ctxinstanceid'].'">'.s($ra['ccname']).'</a>';
                         } elseif ($ra['ctxlevel'] == CONTEXT_SYSTEM) {
-                            $rastring .= $rolename. ' @ ' . get_string('globalrole','role');
+                            $rastring .= $rolename. ' - ' . get_string('globalrole','role');
                         } else {
                             $rastring .= $rolename;
                         }