]> source.dussan.org Git - nextcloud-server.git/commitdiff
creating thumbnails on upload, recursive remove
authorBartek Przybylski <bart.p.pl@gmail.com>
Wed, 25 Jan 2012 20:07:43 +0000 (21:07 +0100)
committerBartek Przybylski <bart.p.pl@gmail.com>
Wed, 25 Jan 2012 20:07:43 +0000 (21:07 +0100)
apps/gallery/lib/hooks_handlers.php
apps/gallery/lib/images_utils.php
apps/gallery/lib/photo.php

index 53a924ff40abceef95488450da8e55b3604ce51a..236a4b96a0769be3ca03b4579963e8af006c5960 100644 (file)
@@ -63,21 +63,8 @@ class OC_Gallery_Hooks_Handlers {
 
     if (!self::isPhoto($fullpath)) return;
 
-    OC_Log::write(self::$APP_TAG, 'Adding file with path '. $fullpath, OC_Log::DEBUG);
     $path = substr($fullpath, 0, strrpos($fullpath, '/'));
-    if ($path == '') $path = '/';
-    $album = OC_Gallery_Album::find(OC_User::getUser(), null, $path);
-
-    if ($album->numRows() == 0) {
-      $album = self::createAlbum($path);
-    }
-    $album = $album->fetchRow();
-    $albumId = $album['album_id'];
-    $photo = OC_Gallery_Photo::find($albumId, $fullpath);
-    if ($photo->numRows() == 0) { // don't duplicate photo entries
-      OC_Log::write(self::$APP_TAG, 'Adding new photo to album', OC_Log::DEBUG);
-      OC_Gallery_Photo::create($albumId, $fullpath);
-    }
+    OC_Gallery_Scanner::scanDir($path, $albums);
 
   }
 
@@ -85,6 +72,7 @@ class OC_Gallery_Hooks_Handlers {
     $path = $params[OC_Filesystem::signal_param_path];
     if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) {
       OC_Gallery_Album::removeByPath($path, OC_User::getUser());
+      OC_Gallery_Photo::removeByPath($path.'/%');
     } elseif (self::isPhoto($path)) {
       OC_Gallery_Photo::removeByPath($path);
     }
index 0cfa52eb56431f8510d637882c0c93cda8c77e74..126298913be10ce71e93ce5bfbdda8c2b8f70d71 100644 (file)
 * 
 */
 
-require_once('../../../lib/base.php');
+if (file_exists('../../../lib/base.php'))
+  require_once('../../../lib/base.php');
+elseif (file_exists('lib/base.php'))
+  require_once('lib/base.php');
+
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('gallery');
 
index 14b0c4b2a070ffd22be4e07ba8b70dc8d85d62a0..d1fb166aee9a900940d5ce2081106dde7b3fd593 100644 (file)
@@ -47,7 +47,7 @@ class OC_Gallery_Photo{
        }
 
   public static function removeByPath($path) {
-    $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path = ?');
+    $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE file_path LIKE ?');
     $stmt->execute(array($path));
   }