Improvements to the user listing, security and appearance
This commit is contained in:
@@ -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';
|
||||
|
||||
+13
-19
@@ -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 .'&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 .'&user='. $user->id .'">'. $string->unenrol .'</a><br />';
|
||||
}
|
||||
if ($USER->id != $user->id) {
|
||||
$output .= '<a href="'. $CFG->wwwroot .'/course/loginas.php?id='. $course->id .'&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 .'&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 .'&user='. $user->id .'">'. $string->loginas .'</a><br />';
|
||||
}
|
||||
$output .= '<a href="'. $CFG->wwwroot .'/user/view.php?id='. $user->id .'&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>';
|
||||
|
||||
+20
-21
@@ -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 @@
|
||||
//-->
|
||||
</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.'" />';
|
||||
}
|
||||
@@ -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),
|
||||
'<strong><a href="'.$CFG->wwwroot.'/user/view.php?id='.$student->id.'&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.'&course='.$course->id.'">'.fullname($user).'</a></strong>');
|
||||
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[] = '<input type="checkbox" name="user'.$student->id.'" />';
|
||||
$data[] = '<input type="checkbox" name="user'.$user->id.'" />';
|
||||
}
|
||||
$table->add_data($data);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user