Changed CONTEXT_SITE to CONTEXT_SYSTEM MDL-6506
[moodle.git] / userpix / index.php
index 900ff6d..9e4e5e3 100644 (file)
     require_login();
 
 /// Remove the following three lines if you want everyone to access it
-    if (!isadmin()) {
-        error("Currently only the administrator can access this page!");
-    }
+    require_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM, SITEID));
 
-    
     if (!$users = get_records("user", "picture", "1", "lastaccess DESC", "id,firstname,lastname")) {
         error("no users!");
     }
     print_header($title, $title, $title);
     
     foreach ($users as $user) {
-       echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=1\"".
-            "title=\"$user->firstname $user->lastname\">";
-       echo "<img border=0 src=\"$CFG->wwwroot/user/pix.php/$user->id/f1.jpg\" ".
-            "width=100 height=100 alt=\"$user->firstname $user->lastname\" />";
-       echo "</a> \n";
+        $fullname = fullname($user);
+        echo "<a href=\"$CFG->wwwroot/user/view.php?id=$user->id&amp;course=1\"".
+             "title=\"$fullname\">";
+        if ($CFG->slasharguments) {        // Use this method if possible for better caching
+            echo '<img src="'. $CFG->wwwroot .'/user/pix.php/'.$user->id.'/f1.jpg"'.
+                 ' border="0" width="100" height="100" alt="'.$fullname.'" />';
+        } else {
+            echo '<img src="'. $CFG->wwwroot .'/user/pix.php?file=/'. $user->id .'/f1.jpg"'.
+                 ' border="0" width="100" height="100" alt="'.$fullname.'" />';
+        }
+        echo "</a> \n";
     }
     
     print_footer();