summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-01-14 14:59:18 +0100
committerBartek Przybylski <bart.p.pl@gmail.com>2012-01-14 15:01:57 +0100
commite0dc8b8ab2c1803357e6bd4fbb477effe5d4c599 (patch)
treef43d08ae3aa3ce43030f368aaf2468d2304c105d /apps
parent4d1c414ffbcd0b9a17227067c2fbbfc96753d364 (diff)
downloadnextcloud-server-e0dc8b8ab2c1803357e6bd4fbb477effe5d4c599.tar.gz
nextcloud-server-e0dc8b8ab2c1803357e6bd4fbb477effe5d4c599.zip
handle gallery remove when removing dir via webinterface
Diffstat (limited to 'apps')
-rw-r--r--apps/gallery/lib/album.php7
-rw-r--r--apps/gallery/lib/hooks_handlers.php7
-rw-r--r--apps/gallery/lib/photo.php5
3 files changed, 17 insertions, 2 deletions
diff --git a/apps/gallery/lib/album.php b/apps/gallery/lib/album.php
index a708ba83ea4..6adff196071 100644
--- a/apps/gallery/lib/album.php
+++ b/apps/gallery/lib/album.php
@@ -42,6 +42,13 @@ class OC_Gallery_Album {
$stmt = OC_DB::prepare($sql);
return $stmt->execute($args);
}
+
+ public static function removeByPath($path, $owner) {
+ $album = self::find($owner, null, $path);
+ $album = $album->fetchRow();
+ self::remove($owner, $album['album_name']);
+ OC_Gallery_Photo::removeByAlbumId($album['album_id']);
+ }
public static function find($owner, $name=null, $path=null){
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php
index ee17c0df7df..534f76896d7 100644
--- a/apps/gallery/lib/hooks_handlers.php
+++ b/apps/gallery/lib/hooks_handlers.php
@@ -83,8 +83,11 @@ class OC_Gallery_Hooks_Handlers {
public static function removePhoto($params) {
$path = $params['path'];
- if (!self::isPhoto($path)) return;
- OC_Gallery_Photo::removeByPath($path);
+ if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) {
+ OC_Gallery_Album::removeByPath($path, OC_User::getUser());
+ } elseif (self::isPhoto($path)) {
+ OC_Gallery_Photo::removeByPath($path);
+ }
}
public static function renamePhoto($params) {
diff --git a/apps/gallery/lib/photo.php b/apps/gallery/lib/photo.php
index 23887098e0f..14b0c4b2a07 100644
--- a/apps/gallery/lib/photo.php
+++ b/apps/gallery/lib/photo.php
@@ -56,6 +56,11 @@ class OC_Gallery_Photo{
$stmt->execute(array($id));
}
+ public static function removeByAlbumId($albumid) {
+ $stmt = OC_DB::prepare('DELETE FROM *PREFIX*gallery_photos WHERE album_id = ?');
+ $stmt->execute(array($albumid));
+ }
+
public static function changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath) {
$stmt = OC_DB::prepare("UPDATE *PREFIX*gallery_photos SET file_path = ?, album_id = ? WHERE album_id = ? and file_path = ?");
$stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));