summaryrefslogtreecommitdiffstats
path: root/apps/gallery
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-01-08 11:25:08 +0100
committerBartek Przybylski <bart.p.pl@gmail.com>2012-01-08 11:25:08 +0100
commitc2392bbace7511dfa424513ba88a8d76f3ee620c (patch)
tree5ec0809230d7e4d5abdbc90a22f3addf3299d2cb /apps/gallery
parent6a295997bc723e54bed849dfa6bca9cc70cf0f8e (diff)
downloadnextcloud-server-c2392bbace7511dfa424513ba88a8d76f3ee620c.tar.gz
nextcloud-server-c2392bbace7511dfa424513ba88a8d76f3ee620c.zip
db overwriting, gallery creating fix
Diffstat (limited to 'apps/gallery')
-rw-r--r--apps/gallery/appinfo/database.xml2
-rw-r--r--apps/gallery/lib/hooks_handlers.php9
2 files changed, 8 insertions, 3 deletions
diff --git a/apps/gallery/appinfo/database.xml b/apps/gallery/appinfo/database.xml
index db88e4c1b5a..ccdfad9433a 100644
--- a/apps/gallery/appinfo/database.xml
+++ b/apps/gallery/appinfo/database.xml
@@ -2,7 +2,7 @@
<database>
<name>*dbname*</name>
<create>true</create>
- <overwrite>false</overwrite>
+ <overwrite>true</overwrite>
<charset>latin1</charset>
<table>
<name>*dbprefix*gallery_albums</name>
diff --git a/apps/gallery/lib/hooks_handlers.php b/apps/gallery/lib/hooks_handlers.php
index b6aa8a400cf..65f3faaeeaf 100644
--- a/apps/gallery/lib/hooks_handlers.php
+++ b/apps/gallery/lib/hooks_handlers.php
@@ -32,6 +32,7 @@ class OC_Gallery_Hooks_Handlers {
private static $APP_TAG = "Gallery";
private static function isPhoto($filename) {
+ OC_Log::write(self::$APP_TAG, "Checking file ".$filename." with mimetype ".OC_Filesystem::getMimeType($filename), OC_Log::DEBUG);
if (substr(OC_Filesystem::getMimeType($filename), 0, 6) == "image/")
return 1;
return 0;
@@ -53,6 +54,7 @@ class OC_Gallery_Hooks_Handlers {
$fullpath = $params['path'];
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) {
@@ -75,9 +77,12 @@ class OC_Gallery_Hooks_Handlers {
}
public static function renamePhoto($params) {
- $olddir = substr($params['oldpath'], 0, strrpos($params['oldpath'], '/')+1);
- $newdir = substr($params['newpath'], 0, strrpos($params['newpath'], '/')+1);
+ $olddir = substr($params['oldpath'], 0, strrpos($params['oldpath'], '/'));
+ $newdir = substr($params['newpath'], 0, strrpos($params['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);
$album;
$newAlbumId;
$oldAlbumId;