]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-8319 avatar image is now deleted from disk, user/pix.php redirects to default...
authorskodak <skodak>
Fri, 26 Jan 2007 20:15:54 +0000 (20:15 +0000)
committerskodak <skodak>
Fri, 26 Jan 2007 20:15:54 +0000 (20:15 +0000)
user/editlib.php
user/pix.php

index b7eb065fdcc4c56935b7661436a92218dd4449df..3fde1226a2f85139cb20236929c7a61e2ea5bd97 100644 (file)
@@ -20,8 +20,11 @@ function useredit_update_user_preference($usernew) {
 }
 
 function useredit_update_picture(&$usernew, &$userform) {
+    global $CFG;
+
     if (isset($usernew->deletepicture) and $usernew->deletepicture) {
-        //TODO - delete the file
+        $location = $CFG->dataroot.'/users/'.$usernew->id;
+        @remove_dir($location);
         set_field('user', 'picture', 0, 'id', $usernew->id);
     } else if ($usernew->picture = save_profile_image($usernew->id, $userform->get_um(), 'users')) {
         set_field('user', 'picture', 1, 'id', $usernew->id);
index 0fdf6411708d8ccfdb3191563ae551a8f13b9ee8..b3435be9c8a6c916b26fff68e3b9d5b851b2e33e 100644 (file)
         $userid   = (integer)$args[0];
         $image    = $args[1];
         $pathname = $CFG->dataroot.'/users/'.$userid.'/'.$image;
-    } else {
-        $image    = 'f1.png';
-        $pathname = $CFG->dirroot.'/pix/u/f1.png';
+        if (file_exists($pathname) and !is_dir($pathname)) {
+            send_file($pathname, $image);
+        }
     }
 
-    if (file_exists($pathname) and !is_dir($pathname)) {
-        send_file($pathname, $image);
-    } else {
-        header('HTTP/1.0 404 not found');
-        error(get_string('filenotfound', 'error')); //this is not displayed on IIS??
-    }
+    // picture was deleted - use default instead
+    redirect($CFG->pixpath.'/u/f1.png');
 ?>