]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to make uploaded user pictures work properly on Windows :-(
authormartin <martin>
Fri, 9 Aug 2002 09:09:36 +0000 (09:09 +0000)
committermartin <martin>
Fri, 9 Aug 2002 09:09:36 +0000 (09:09 +0000)
admin/user.php
lib/moodlelib.php
user/pix.php

index ab894c47ff7e0d0347cdfa800e2c42ed71fc0ee7..1b68d99959d2034001f1bef5ba89cdb0f84fc2b3 100644 (file)
                                         "<A HREF=\"../user/edit.php?id=$user->id&course=$site->id\">$stredit</A>");
             }
             print_table($table);
+
+            print_heading("<A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A>");
         } else {
             error("No users found!");
             
index b2ccff6a8c9038deda7fc73922b31ff3d4455b28..5d872d5341594e0347e0921594631345ac884e06 100644 (file)
@@ -124,7 +124,11 @@ function print_user_picture($userid, $courseid, $picture, $large=false, $returns
         $size = 35;
     }
     if ($picture) {
-        $output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
+        if (iswindows()) { // Workaround for a PATH_INFO problem on Windows PHP
+            $output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php?file=/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
+        } else {           // Use this method if possible for better caching
+            $output .= "<IMG SRC=\"$CFG->wwwroot/user/pix.php/$userid/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
+        }
     } else {
         $output .= "<IMG SRC=\"$CFG->wwwroot/user/default/$file\" BORDER=0 WIDTH=$size HEIGHT=$size ALT=\"\">";
     }
@@ -1576,6 +1580,14 @@ function get_list_of_modules() {
     return $mods;
 }
 
+function iswindows() {
+// True if this is Windows, False if not.
+
+   global $WINDIR;
+
+   return empty($WINDIR);
+}
+
 
 
 ?>
index 7c56d644735b14254ebd4aff1d5d32e4c20eece0..b44fb0e64317b9e474011441372d98704359bc81 100644 (file)
@@ -1,13 +1,17 @@
 <?PHP // $Id$
       // This function fetches user pictures from the data directory
-      // Syntax:   file.php/userid/f1.jpg
+      // Syntax:   pix.php/userid/f1.jpg or pix.php/userid/f2.jpg
+      //     OR:   ?file=userid/f1.jpg or ?file=userid/f2.jpg
 
     require("../config.php");
 
     $lifetime = 86400;
 
-    if (!$PATH_INFO) {
-        error("This script DEPENDS on $PATH_INFO being available.  Read the README.");
+    if (isset($file)) {
+        $PATH_INFO = $file;
+
+    } else if (!$PATH_INFO) {
+        $PATH_INFO = "";       // Will just show default picture
     }
 
     $args = get_slash_arguments();
     if ($numargs == 2) {
         $userid = (integer)$args[0];
         $image  = $args[1];
+        $pathname = "$CFG->dataroot/users/$userid/$image";
     } else {
-        $userid = 0;
-        $image  = "f1.jpg";
+        $pathname = "$CFG->dirroot/user/default/f1.jpg";
     }
 
-    $pathname = "$CFG->dataroot/users/$userid/$image";
     $lastmodified = filemtime($pathname);
 
     header("Last-Modified: " . gmdate("D, d M Y H:i:s", $lastmodified) . " GMT");