]> git.mjollnir.org Git - moodle.git/commitdiff
Improvements to the user listing, security and appearance
authormoodler <moodler>
Sun, 1 Oct 2006 06:18:18 +0000 (06:18 +0000)
committermoodler <moodler>
Sun, 1 Oct 2006 06:18:18 +0000 (06:18 +0000)
lang/en_utf8/moodle.php
lib/weblib.php
user/index.php

index 8cff28875b89cbe45c8c45912236379d658f9af4..40eb49b91cc434489df353d648497988ce0ade56 100644 (file)
@@ -1382,7 +1382,7 @@ $string['usernotconfirmed'] = 'Could not confirm $a';
 $string['userprofilefor'] = 'User profile for $a';
 $string['users'] = 'Users';
 $string['usersnew'] = 'New users';
-$string['usersnoaccesssince'] = 'Show users who have been inactive for more than';
+$string['usersnoaccesssince'] = 'Inactive for more than';
 $string['userzones'] = 'User zones';
 $string['usethiscourse'] = 'Use this course';
 $string['usingexistingcourse'] = 'Using existing course';
index 55f2de735833987de8df9971271497248fe7abd3..058fac939d6e8153c597a78adff94e5c4ff04fcc 100644 (file)
@@ -3062,6 +3062,7 @@ function print_user($user, $course, $messageselect=false, $return=false) {
     static $isteacher;
 
     $context = get_context_instance(CONTEXT_COURSE, $course->id);
+
     if (empty($string)) {     // Cache all the strings for the rest of the page
 
         $string->email       = get_string('email');
@@ -3090,7 +3091,7 @@ function print_user($user, $course, $messageselect=false, $return=false) {
     }
 
 /// Get the hidden field list
-    if (has_capability('moodle/course:viewhiddenuserfields', get_context_instance(CONTEXT_COURSE, $course->id))) {
+    if (has_capability('moodle/course:viewhiddenuserfields', $context)) {
         $hiddenfields = array();
     } else {
         $hiddenfields = array_flip(explode(',', $CFG->hiddenuserfields));
@@ -3107,7 +3108,8 @@ function print_user($user, $course, $messageselect=false, $return=false) {
     if (!empty($user->role) and ($user->role <> $course->teacher)) {
         $output .= $string->role .': '. $user->role .'<br />';
     }
-    if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or has_capability('moodle/course:viewhiddenuserfields', get_context_instance(CONTEXT_COURSE, $course->id))) {
+    if ($user->maildisplay == 1 or ($user->maildisplay == 2 and $course->category and !isguest()) or
+has_capability('moodle/course:viewhiddenuserfields', $context)) {
         $output .= $string->email .': <a href="mailto:'. $user->email .'">'. $user->email .'</a><br />';
     }
     if (($user->city or $user->country) and (!isset($hiddenfields['city']) or !isset($hiddenfields['country']))) {
@@ -3138,28 +3140,20 @@ function print_user($user, $course, $messageselect=false, $return=false) {
         $output .= '<a href="'.$CFG->wwwroot.'/blog/index.php?userid='.$user->id.'">'.get_string('blogs','blog').'</a><br />';
     }
 
-    if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id))) {
+    if (has_capability('moodle/site:viewreports', $context)) {
         $timemidnight = usergetmidnight(time());
         $output .= '<a href="'. $CFG->wwwroot .'/course/user.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->activity .'</a><br />';
-        if (!has_capability('moodle/course:create', get_context_instance(CONTEXT_SYSTEM, SITEID, $user->id)) or ($isadmin and !isadmin($user->id))) {  // Includes admins
-            if ($course->category and isteacheredit($course->id) and isstudent($course->id, $user->id)) {  // Includes admins
-                $output .= '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->unenrol .'</a><br />';
-            }
-            if ($USER->id != $user->id) {
-                $output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->loginas .'</a><br />';
-            }
-        }
+    }
+    if (has_capability('moodle/role:assign', $context, NULL)) {  // Includes admins
+        $output .= '<a href="'. $CFG->wwwroot .'/course/unenrol.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->unenrol .'</a><br />';
+    }
+    if ($USER->id != $user->id && has_capability('moodle/user:loginas', $context))  {
+        $output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&amp;user='. $user->id .'">'. $string->loginas .'</a><br />';
     }
     $output .= '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&amp;course='. $course->id .'">'. $string->fullprofile .'...</a>';
 
-    if (!empty($messageselect) && $isteacher) {
-        $output .= '<br /><input type="checkbox" name="';
-        if (isteacher($course->id, $user->id)) {
-            $output .= 'teacher';
-        } else {
-            $output .= 'user';
-        }
-        $output .= $user->id.'" /> ';
+    if (!empty($messageselect)) {
+        $output .= '<br /><input type="checkbox" name="user'.$user->id.'" /> ';
     }
 
     $output .= '</td></tr></table>';
index f7f934fc71ff597e544ac4851434dd7b5787af5d..8eceb9de38f58e42684caa0cc3905883023bb470 100644 (file)
         $tableheaders[] = get_string('select');
     }
 
-    $table = new flexible_table('user-index-students-'.$course->id);
+    $table = new flexible_table('user-index-participants-'.$course->id);
 
     $table->define_columns($tablecolumns);
     $table->define_headers($tableheaders);
     $table->sortable(true, 'lastaccess', SORT_DESC);
 
     $table->set_attribute('cellspacing', '0');
-    $table->set_attribute('id', 'students');
+    $table->set_attribute('id', 'participants');
     $table->set_attribute('class', 'generaltable generalbox');
 
     $table->set_control_variables(array(
     $table->initialbars($totalcount > $perpage);
     $table->pagesize($perpage, $matchcount);
 
-    $students = get_records_sql($select.$from.$where.$wheresearch.$sort,
+    $userlist = get_records_sql($select.$from.$where.$wheresearch.$sort,
             $table->get_page_start(),  $table->get_page_size());
 
     /// If there are multiple Roles in the course, then show a drop down menu for switching
         //-->
         </script>
             ';
-        echo '<form action="action_redir.php" method="post" name="studentsform" onSubmit="return checksubmit(this);">';
+        echo '<form action="action_redir.php" method="post" name="participantsform" onSubmit="return checksubmit(this);">';
         echo '<input type="hidden" name="returnto" value="'.$_SERVER['REQUEST_URI'].'" />';
         echo '<input type="hidden" name="sesskey" value="'.$USER->sesskey.'" />';
     }
 
     if ($fullmode) {    // Print simple listing
         if ($totalcount < 1) {
-            print_heading(get_string("nostudentsfound", "", $course->students));
-
+            print_heading(get_string('nothingtodisplay'));
         } else {
             if ($totalcount > $perpage) {
 
             }
 
             if ($matchcount > 0) {
-                foreach ($students as $student) {
-                    print_user($student, $course, true);
+                foreach ($userlist as $user) {
+                    print_user($user, $course, $bulkoperations);
                 }
 
             } else {
     } else {
         $countrysort = (strpos($sort, 'country') !== false);
         $timeformat = get_string('strftimedate');
-        if (!empty($students))  {
-            foreach ($students as $student) {
-                if ($student->lastaccess) {
-                    $lastaccess = format_time(time() - $student->lastaccess, $datestring);
+        if (!empty($userlist))  {
+            foreach ($userlist as $user) {
+                if ($user->lastaccess) {
+                    $lastaccess = format_time(time() - $user->lastaccess, $datestring);
                 } else {
                     $lastaccess = $strnever;
                 }
 
-                if (empty($student->country)) {
+                if (empty($user->country)) {
                     $country = '';
 
                 } else {
                     if($countrysort) {
-                        $country = '('.$student->country.') '.$countries[$student->country];
+                        $country = '('.$user->country.') '.$countries[$user->country];
                     }
                     else {
-                        $country = $countries[$student->country];
+                        $country = $countries[$user->country];
                     }
                 }
 
                 $data = array (
-                        print_user_picture($student->id, $course->id, $student->picture, false, true),
-                        '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&amp;course='.$course->id.'">'.fullname($student).'</a></strong>');
+                        print_user_picture($user->id, $course->id, $user->picture, false, true),
+                        '<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&amp;course='.$course->id.'">'.fullname($user).'</a></strong>');
                 if (!isset($hiddenfields['city'])) {
-                    $data[] = $student->city;
+                    $data[] = $user->city;
                 }
                 if (!isset($hiddenfields['country'])) {
                     $data[] = $country;
                     $data[] = $lastaccess;
                 }
                 if ($course->enrolperiod) {
-                    if ($student->timeend) {
-                        $data[] = userdate($student->timeend, $timeformat);
+                    if ($user->timeend) {
+                        $data[] = userdate($user->timeend, $timeformat);
                     } else {
                         $data[] = get_string('unlimited');
                     }
                 }
                 if ($bulkoperations) {
-                    $data[] = '<input type="checkbox" name="user'.$student->id.'" />';
+                    $data[] = '<input type="checkbox" name="user'.$user->id.'" />';
                 }
                 $table->add_data($data);