summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-02-04 10:30:32 +0100
committerBartek Przybylski <bart.p.pl@gmail.com>2012-02-04 10:30:32 +0100
commit5a106d10361865dfd5cffe8809caee73ff410c4c (patch)
tree372155160d809420234e52361d834e175276e422 /apps/gallery
parent8df065065892ecfb1a3e6d31294d332fa8e4daf6 (diff)
downloadnextcloud-server-5a106d10361865dfd5cffe8809caee73ff410c4c.tar.gz
nextcloud-server-5a106d10361865dfd5cffe8809caee73ff410c4c.zip
gallery: fix FS hooks
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/lib/album.php1
-rw-r--r--apps/gallery/lib/hooks_handlers.php10
2 files changed, 9 insertions, 2 deletions
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index 502237481a9..167813a1a31 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -54,6 +54,7 @@ class OC_Gallery_Album {
public static function removeByPath($path, $owner) {
$album = self::find($owner, null, $path);
$album = $album->fetchRow();
+ error_log($path . '--' . $album['album_name']);
self::remove($owner, $album['album_name']);
OC_Gallery_Photo::removeByAlbumId($album['album_id']);
// find and remove any gallery which might be stored lower in dir hierarchy
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php
index 236a4b96a07..605cb0d0037 100644
--- a/apps/gallery/lib/hooks_handlers.php
+++ b/apps/gallery/lib/hooks_handlers.php
@@ -58,12 +58,18 @@ class OC_Gallery_Hooks_Handlers {
return OC_Gallery_Album::find(OC_User::getUser(), null, $path);
}
+ public static function pathInRoot($path) {
+ $root = OC_Appconfig::getValue('gallery', 'root', '/');
+ return substr($path, 0, strlen($path)>strlen($root)?strlen($root):strlen($path)) == $root;
+ }
+
public static function addPhotoFromPath($params) {
$fullpath = $params[OC_Filesystem::signal_param_path];
if (!self::isPhoto($fullpath)) return;
$path = substr($fullpath, 0, strrpos($fullpath, '/'));
+ if (!self::pathInRoot($path)) return;
OC_Gallery_Scanner::scanDir($path, $albums);
}
@@ -71,8 +77,8 @@ class OC_Gallery_Hooks_Handlers {
public static function removePhoto($params) {
$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.'/%');
+ if(!self::pathInRoot($path)) return;
+ OC_Gallery_Album::removeByPath($path.'/', OC_User::getUser());
} elseif (self::isPhoto($path)) {
OC_Gallery_Photo::removeByPath($path);
}