]> git.mjollnir.org Git - moodle.git/commitdiff
Checks for bad permissions and defaults to default picture
authormartin <martin>
Sat, 18 May 2002 03:13:44 +0000 (03:13 +0000)
committermartin <martin>
Sat, 18 May 2002 03:13:44 +0000 (03:13 +0000)
user/edit.php

index 12aac784a02118c30ad658a2b7f60cbba42a726d..8080252a32b440f27a2115aa9d7f500bc7a97e1d 100644 (file)
                 }
     
                 if (!file_exists("$CFG->dataroot/users")) {
-                    mkdir("$CFG->dataroot/users", 0777);
+                    if (! mkdir("$CFG->dataroot/users", 0777)) {
+                        $badpermissions = true;
+                    }
                 }
                 if (!file_exists("$CFG->dataroot/users/$USER->id")) {
-                    mkdir("$CFG->dataroot/users/$USER->id", 0777);
+                    if (! mkdir("$CFG->dataroot/users/$USER->id", 0777)) {
+                        $badpermissions = true;
+                    }
                 }
                 
-                ImageCopyBicubic($im1, $im, 0, 0, $cx-$half, $cy-$half, 100, 100, $half*2, $half*2);
-                ImageCopyBicubic($im2, $im, 0, 0, $cx-$half, $cy-$half, 35, 35, $half*2, $half*2);
+                if ($badpermissions) {
+                    $usernew->picture = "0";
+
+                } else {
+                    ImageCopyBicubic($im1, $im, 0, 0, $cx-$half, $cy-$half, 100, 100, $half*2, $half*2);
+                    ImageCopyBicubic($im2, $im, 0, 0, $cx-$half, $cy-$half, 35, 35, $half*2, $half*2);
     
-                // Draw borders over the top.
-                $black1 = ImageColorAllocate ($im1, 0, 0, 0);
-                $black2 = ImageColorAllocate ($im2, 0, 0, 0);
-                ImageLine ($im1, 0, 0, 0, 99, $black1);
-                ImageLine ($im1, 0, 99, 99, 99, $black1);
-                ImageLine ($im1, 99, 99, 99, 0, $black1);
-                ImageLine ($im1, 99, 0, 0, 0, $black1);
-                ImageLine ($im2, 0, 0, 0, 34, $black2);
-                ImageLine ($im2, 0, 34, 34, 34, $black2);
-                ImageLine ($im2, 34, 34, 34, 0, $black2);
-                ImageLine ($im2, 34, 0, 0, 0, $black2);
-            
-                ImageJpeg($im1, "$CFG->dataroot/users/$USER->id/f1.jpg", 90);
-                ImageJpeg($im2, "$CFG->dataroot/users/$USER->id/f2.jpg", 95);
-                $usernew->picture = "1";
+                    // Draw borders over the top.
+                    $black1 = ImageColorAllocate ($im1, 0, 0, 0);
+                    $black2 = ImageColorAllocate ($im2, 0, 0, 0);
+                    ImageLine ($im1, 0, 0, 0, 99, $black1);
+                    ImageLine ($im1, 0, 99, 99, 99, $black1);
+                    ImageLine ($im1, 99, 99, 99, 0, $black1);
+                    ImageLine ($im1, 99, 0, 0, 0, $black1);
+                    ImageLine ($im2, 0, 0, 0, 34, $black2);
+                    ImageLine ($im2, 0, 34, 34, 34, $black2);
+                    ImageLine ($im2, 34, 34, 34, 0, $black2);
+                    ImageLine ($im2, 34, 0, 0, 0, $black2);
+                
+                    ImageJpeg($im1, "$CFG->dataroot/users/$USER->id/f1.jpg", 90);
+                    ImageJpeg($im2, "$CFG->dataroot/users/$USER->id/f2.jpg", 95);
+                    $usernew->picture = "1";
+                }
             } else {
                 $usernew->picture = $user->picture;
             }