handle gallery remove when removing dir via webinterface
This commit is contained in:
parent
4d1c414ffb
commit
e0dc8b8ab2
|
@ -43,6 +43,13 @@ class OC_Gallery_Album {
|
||||||
return $stmt->execute($args);
|
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){
|
public static function find($owner, $name=null, $path=null){
|
||||||
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
|
$sql = 'SELECT * FROM *PREFIX*gallery_albums WHERE uid_owner = ?';
|
||||||
$args = array($owner);
|
$args = array($owner);
|
||||||
|
|
|
@ -83,9 +83,12 @@ class OC_Gallery_Hooks_Handlers {
|
||||||
|
|
||||||
public static function removePhoto($params) {
|
public static function removePhoto($params) {
|
||||||
$path = $params['path'];
|
$path = $params['path'];
|
||||||
if (!self::isPhoto($path)) return;
|
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);
|
OC_Gallery_Photo::removeByPath($path);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static function renamePhoto($params) {
|
public static function renamePhoto($params) {
|
||||||
if (OC_Filesystem::is_dir($params['newpath']) && self::directoryContainsPhotos($params['newpath'])) {
|
if (OC_Filesystem::is_dir($params['newpath']) && self::directoryContainsPhotos($params['newpath'])) {
|
||||||
|
|
|
@ -56,6 +56,11 @@ class OC_Gallery_Photo{
|
||||||
$stmt->execute(array($id));
|
$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) {
|
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 = 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));
|
$stmt->execute(array($newpath, $newAlbumId, $oldAlbumId, $oldpath));
|
||||||
|
|
Loading…
Reference in New Issue