diff options
author | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-01-14 23:12:32 +0100 |
---|---|---|
committer | Bartek Przybylski <bart.p.pl@gmail.com> | 2012-01-14 23:13:01 +0100 |
commit | ef69abd4dc696305474e45d7cd2661dcb51bdb8a (patch) | |
tree | a46dcfd9eed09304c79d27f5b1247b5c58ff5262 /apps | |
parent | 2d25bb3b0104ca9150fbf316517f686fa89729a3 (diff) | |
download | nextcloud-server-ef69abd4dc696305474e45d7cd2661dcb51bdb8a.tar.gz nextcloud-server-ef69abd4dc696305474e45d7cd2661dcb51bdb8a.zip |
constans for signals handling
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gallery/lib/hooks_handlers.php | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php index 534f76896d7..7248e67f0a2 100644 --- a/apps/gallery/lib/hooks_handlers.php +++ b/apps/gallery/lib/hooks_handlers.php @@ -21,9 +21,9 @@ * */ -OC_Hook::connect("OC_Filesystem", "post_write", "OC_Gallery_Hooks_Handlers", "addPhotoFromPath"); -OC_Hook::connect("OC_Filesystem", "delete", "OC_Gallery_Hooks_Handlers", "removePhoto"); -OC_Hook::connect("OC_Filesystem", "post_rename", "OC_Gallery_Hooks_Handlers", "renamePhoto"); +OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_write, "OC_Gallery_Hooks_Handlers", "addPhotoFromPath"); +OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_delete, "OC_Gallery_Hooks_Handlers", "removePhoto"); +OC_Hook::connect(OC_Filesystem::CLASSNAME, OC_Filesystem::signal_post_rename, "OC_Gallery_Hooks_Handlers", "renamePhoto"); require_once(OC::$CLASSPATH['OC_Gallery_Album']); require_once(OC::$CLASSPATH['OC_Gallery_Photo']); @@ -61,8 +61,10 @@ class OC_Gallery_Hooks_Handlers { } public static function addPhotoFromPath($params) { - if (!self::isPhoto($params['path'])) return; - $fullpath = $params['path']; + $fullpath = $params[OC_Filesystem::signal_param_path]; + + 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 = '/'; @@ -82,7 +84,7 @@ class OC_Gallery_Hooks_Handlers { } public static function removePhoto($params) { - $path = $params['path']; + $path = $params[OC_Filesystem::signal_param_path]; if (OC_Filesystem::is_dir($path) && self::directoryContainsPhotos($path)) { OC_Gallery_Album::removeByPath($path, OC_User::getUser()); } elseif (self::isPhoto($path)) { @@ -91,15 +93,17 @@ class OC_Gallery_Hooks_Handlers { } public static function renamePhoto($params) { - if (OC_Filesystem::is_dir($params['newpath']) && self::directoryContainsPhotos($params['newpath'])) { - OC_Gallery_Album::changePath($params['oldpath'], $params['newpath'], OC_User::getUser()); - } elseif (!self::isPhoto($params['newpath'])) { - $olddir = substr($params['oldpath'], 0, strrpos($params['oldpath'], '/')); - $newdir = substr($params['newpath'], 0, strrpos($params['newpath'], '/')); + $oldpath = $params[OC_Filesystem::signal_param_oldpath]; + $newpath = $params[OC_Filesystem::signal_param_newpath]; + if (OC_Filesystem::is_dir($newpath) && self::directoryContainsPhotos($newpath)) { + OC_Gallery_Album::changePath($oldpath, $newpath, OC_User::getUser()); + } elseif (!self::isPhoto($newpath)) { + $olddir = substr($oldpath, 0, strrpos($oldpath, '/')); + $newdir = substr($newpath, 0, strrpos($newpath, '/')); if ($olddir == '') $olddir = '/'; if ($newdir == '') $newdir = '/'; - if (!self::isPhoto($params['newpath'])) return; - OC_Log::write(self::$APP_TAG, 'Moving photo from '.$params['oldpath'].' to '.$params['newpath'], OC_Log::DEBUG); + if (!self::isPhoto($newpath)) return; + OC_Log::write(self::$APP_TAG, 'Moving photo from '.$oldpath.' to '.$newpath, OC_Log::DEBUG); $album; $newAlbumId; $oldAlbumId; @@ -120,7 +124,7 @@ class OC_Gallery_Hooks_Handlers { } $newalbum = $newalbum->fetchRow(); if ($oldalbum->numRows() == 0) { - OC_Gallery_Photo::create($newalbum['album_id'], $params['newpath']); + OC_Gallery_Photo::create($newalbum['album_id'], $newpath); return; } $oldalbum = $oldalbum->fetchRow(); @@ -128,7 +132,7 @@ class OC_Gallery_Hooks_Handlers { $oldAlbumId = $oldalbum['album_id']; } - OC_Gallery_Photo::changePath($oldAlbumId, $newAlbumId, $params['oldpath'], $params['newpath']); + OC_Gallery_Photo::changePath($oldAlbumId, $newAlbumId, $oldpath, $newpath); } } } |