MDL-14279: use get_file_url instead of checking $CFG->slashargument manually (merge...
[moodle.git] / userpix / index.php
CommitLineData
dbaf630a 1<?php // $Id$
2 // This simple script displays all the users with pictures on one page.
0be6f678 3 // By default it is not linked anywhere on the site. If you want to
dbaf630a 4 // make it available you should link it in yourself from somewhere.
5 // Remember also to comment or delete the lines restricting access
6 // to administrators only (see below)
7
8
9 include('../config.php');
10
11 require_login();
12
13/// Remove the following three lines if you want everyone to access it
ef35441d 14 require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM));
dbaf630a 15
5d910388 16 if (!$users = $DB->get_records("user", array("picture"=>"1"), "lastaccess DESC", "id,firstname,lastname")) {
28800f02 17 print_error("nousers");
dbaf630a 18 }
0be6f678 19
dbaf630a 20 $title = get_string("users");
0be6f678 21
22 print_header($title, $title, build_navigation(array(array('name' => $title, 'link' => null, 'type' => 'misc'))));
23
dbaf630a 24 foreach ($users as $user) {
e525e3d3 25 $fullname = fullname($user);
249ab0fd 26 echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=1\" ".
e525e3d3 27 "title=\"$fullname\">";
5a254a29 28 require_once($CFG->libdir.'/filelib.php');
29 $userpictureurl = get_file_url($user->id.'/f1.jpg', null, 'user');
30 echo '<img src="'. $userpictureurl .'"'.
31 ' style="border:0px; width:100px; height:100px" alt="'.$fullname.'" />';
e525e3d3 32 echo "</a> \n";
dbaf630a 33 }
0be6f678 34
dbaf630a 35 print_footer();
05f53652 36
37?>