From: moodler Date: Sun, 1 Oct 2006 06:18:18 +0000 (+0000) Subject: Improvements to the user listing, security and appearance X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=04186cd9653d15ac485b2858f91e95a1dc78dd08;p=moodle.git Improvements to the user listing, security and appearance --- diff --git a/lang/en_utf8/moodle.php b/lang/en_utf8/moodle.php index 8cff28875b..40eb49b91c 100644 --- a/lang/en_utf8/moodle.php +++ b/lang/en_utf8/moodle.php @@ -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'; diff --git a/lib/weblib.php b/lib/weblib.php index 55f2de7358..058fac939d 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -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 .'
'; } - 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 .': '. $user->email .'
'; } 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 .= ''.get_string('blogs','blog').'
'; } - if (has_capability('moodle/site:viewreports', get_context_instance(CONTEXT_COURSE, $course->id))) { + if (has_capability('moodle/site:viewreports', $context)) { $timemidnight = usergetmidnight(time()); $output .= ''. $string->activity .'
'; - 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 .= ''. $string->unenrol .'
'; - } - if ($USER->id != $user->id) { - $output .= ''. $string->loginas .'
'; - } - } + } + if (has_capability('moodle/role:assign', $context, NULL)) { // Includes admins + $output .= ''. $string->unenrol .'
'; + } + if ($USER->id != $user->id && has_capability('moodle/user:loginas', $context)) { + $output .= ''. $string->loginas .'
'; } $output .= ''. $string->fullprofile .'...'; - if (!empty($messageselect) && $isteacher) { - $output .= '
'; + if (!empty($messageselect)) { + $output .= '
'; } $output .= ''; diff --git a/user/index.php b/user/index.php index f7f934fc71..8eceb9de38 100644 --- a/user/index.php +++ b/user/index.php @@ -282,7 +282,7 @@ $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); @@ -291,7 +291,7 @@ $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( @@ -361,7 +361,7 @@ $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 @@ -420,7 +420,7 @@ //--> '; - echo '
'; + echo ''; echo ''; echo ''; } @@ -431,8 +431,7 @@ if ($fullmode) { // Print simple listing if ($totalcount < 1) { - print_heading(get_string("nostudentsfound", "", $course->students)); - + print_heading(get_string('nothingtodisplay')); } else { if ($totalcount > $perpage) { @@ -479,8 +478,8 @@ } if ($matchcount > 0) { - foreach ($students as $student) { - print_user($student, $course, true); + foreach ($userlist as $user) { + print_user($user, $course, $bulkoperations); } } else { @@ -491,31 +490,31 @@ } 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), - ''.fullname($student).''); + print_user_picture($user->id, $course->id, $user->picture, false, true), + ''.fullname($user).''); if (!isset($hiddenfields['city'])) { - $data[] = $student->city; + $data[] = $user->city; } if (!isset($hiddenfields['country'])) { $data[] = $country; @@ -524,14 +523,14 @@ $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[] = ''; + $data[] = ''; } $table->add_data($data);