Author: uncleringo
Date: 2010-03-11 12:14:11 +0100 (Thu, 11 Mar 2010)
New Revision: 28478

Modified:
   plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
Log:
Added some checking that images exist & target location is writable



Modified: plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php
===================================================================
--- plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php        
2010-03-11 09:51:47 UTC (rev 28477)
+++ plugins/sfDoctrineJCroppablePlugin/trunk/lib/doctrine/JCroppable.php        
2010-03-11 11:14:11 UTC (rev 28478)
@@ -268,8 +268,16 @@
        */
       if (!sfContext::hasInstance() && file_exists('data/images/' . $editable))
       {
-        print('Found data/images/' . $editable . "\n");
-        copy('data/images/' . $editable, $to);
+        print('Found data/images/' . $editable . "... ");
+        if (is_writable('data/images/' . $to))
+        {
+          copy('data/images/' . $editable, $to);
+          print("copied\n");
+        }
+        else
+        {
+          print("Don't have permission to copy\n");
+        }
       }
       /**
        * We don't have the original for some reason and we can't find a data
@@ -287,6 +295,22 @@
        */
       rename($from, $to);
     }
+
+    /**
+     * Check we have permission to save the images
+     */
+    if (!is_writable($dir . DIRECTORY_SEPARATOR . $editable)
+          || !is_writable($dir . DIRECTORY_SEPARATOR . $original))
+    {
+      if (sfContext::hasInstance())
+      {
+        sfContext::getInstance()->getLogger()->debug("Can't save image(s). 
Maybe it/they exist already or the dir doesn't have write permission
+        " . $dir . DIRECTORY_SEPARATOR . $editable . "
+        " . $dir . DIRECTORY_SEPARATOR . $original);
+      }
+      
+      return;
+    }
     
     /**
      * Load the original and resize it for the editable version

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to