Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403] [Versions 39 and 311]
1 <?php 2 3 require_once('../../config.php'); 4 require_once($CFG->libdir.'/adminlib.php'); 5 6 $sort = optional_param('sort', 'fullname', PARAM_ALPHA); 7 $dir = optional_param('dir', 'asc', PARAM_ALPHA); 8 9 admin_externalpage_setup('userbulk'); 10 11 $return = $CFG->wwwroot.'/'.$CFG->admin.'/user/user_bulk.php'; 12 13 if (empty($SESSION->bulk_users)) { 14 redirect($return); 15 } 16 17 $users = $SESSION->bulk_users; 18 $usertotal = get_users(false); 19 $usercount = count($users); 20 21 $strnever = get_string('never'); 22 23 echo $OUTPUT->header(); 24 25 $countries = get_string_manager()->get_list_of_countries(true); 26 27 $userfieldsapi = \core_user\fields::for_name(); 28 $namefields = $userfieldsapi->get_sql('', false, '', '', false)->selects; 29 foreach ($users as $key => $id) { 30 $user = $DB->get_record('user', array('id'=>$id), 'id, ' . $namefields . ', username, email, country, lastaccess, city'); 31 $user->fullname = fullname($user, true); 32 $user->country = @$countries[$user->country]; 33 unset($user->firstname); 34 unset($user->lastname); 35 $users[$key] = $user; 36 } 37 unset($countries); 38 39 // Need to sort by date 40 function sort_compare($a, $b) { 41 global $sort, $dir; 42 if($sort == 'lastaccess') { 43 $rez = $b->lastaccess - $a->lastaccess; 44 } else { 45 $rez = strcasecmp(@$a->$sort, @$b->$sort); 46 } 47 return $dir == 'desc' ? -$rez : $rez; 48 } 49 usort($users, 'sort_compare'); 50 51 $table = new html_table(); 52 $table->width = "95%"; 53 $columns = array('fullname', /*'username', */'email', 'city', 'country', 'lastaccess'); 54 foreach ($columns as $column) { 55 $strtitle = get_string($column); 56 if ($sort != $column) { 57 $columnicon = ''; 58 $columndir = 'asc'; 59 } else { 60 $columndir = $dir == 'asc' ? 'desc' : 'asc'; 61 $icon = 't/down'; 62 $iconstr = $columndir; 63 if ($dir != 'asc') { 64 $icon = 't/up'; 65 } 66 $columnicon = ' ' . $OUTPUT->pix_icon($icon, get_string($iconstr)); 67 } 68 $table->head[] = '<a href="user_bulk_display.php?sort='.$column.'&dir='.$columndir.'">'.$strtitle.'</a>'.$columnicon; 69 $table->align[] = 'left'; 70 } 71 72 foreach($users as $user) { 73 $table->data[] = array ( 74 '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.SITEID.'">'.$user->fullname.'</a>', 75 // $user->username, 76 s($user->email), 77 $user->city, 78 $user->country, 79 $user->lastaccess ? format_time(time() - $user->lastaccess) : $strnever 80 ); 81 } 82 83 echo $OUTPUT->heading("$usercount / $usertotal ".get_string('users')); 84 echo html_writer::table($table); 85 86 echo $OUTPUT->continue_button($return); 87 88 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body