summaryrefslogtreecommitdiffstats
path: root/apps/gallery/ajax
diff options
context:
space:
mode:
authorBartek Przybylski <bart.p.pl@gmail.com>2012-02-03 21:38:44 +0100
committerBartek Przybylski <bart.p.pl@gmail.com>2012-02-03 21:38:44 +0100
commit8df065065892ecfb1a3e6d31294d332fa8e4daf6 (patch)
tree83e824eb08d6e20f6bdbc117dcf67097332c4d30 /apps/gallery/ajax
parentee01d1a81d561fb41916bb3d231452956317b7bc (diff)
downloadnextcloud-server-8df065065892ecfb1a3e6d31294d332fa8e4daf6.tar.gz
nextcloud-server-8df065065892ecfb1a3e6d31294d332fa8e4daf6.zip
gallery settings, defining scan root and shor order
Diffstat (limited to 'apps/gallery/ajax')
-rw-r--r--apps/gallery/ajax/galleryOp.php30
1 files changed, 27 insertions, 3 deletions
diff --git a/apps/gallery/ajax/galleryOp.php b/apps/gallery/ajax/galleryOp.php
index 0c2674f8859..187cd8af292 100644
--- a/apps/gallery/ajax/galleryOp.php
+++ b/apps/gallery/ajax/galleryOp.php
@@ -54,9 +54,11 @@ function handleGalleryScanning() {
OC_JSON::success(array('albums' => OC_Gallery_Scanner::scan('/')));
}
-function handleFilescan() {
+function handleFilescan($cleanup) {
OC_JSON::checkLoggedIn();
- $pathlist = OC_Gallery_Scanner::find_paths('/');
+ if ($cleanup) OC_Gallery_Album::cleanup();
+ $root = OC_Appconfig::getValue('gallery', 'root', '').'/';
+ $pathlist = OC_Gallery_Scanner::find_paths($root);
sort($pathlist);
OC_JSON::success(array('paths' => $pathlist));
}
@@ -72,6 +74,25 @@ function handlePartialCreate($path) {
OC_JSON::success(array('album_details' => $albums));
}
+function handleStoreSettings($root, $order) {
+ OC_JSON::checkLoggedIn();
+ if (!OC_Filesystem::file_exists($root)) {
+ OC_JSON::error(array('cause' => 'No such file or directory'));
+ return;
+ }
+ if (!OC_Filesystem::is_dir($root)) {
+ OC_JSON::error(array('cause' => $root . ' is not a directory'));
+ return;
+ }
+
+ $current_root = OC_Appconfig::getValue('gallery', 'root', '/');
+ $root = trim(rtrim($root, '/'));
+ $rescan = $current_root==$root?'no':'yes';
+ OC_Appconfig::setValue('gallery', 'root', $root);
+ OC_Appconfig::setValue('gallery', 'order', $order);
+ OC_JSON::success(array('rescan' => $rescan));
+}
+
if ($_GET['operation']) {
switch($_GET['operation']) {
case 'rename':
@@ -89,11 +110,14 @@ if ($_GET['operation']) {
handleGalleryScanning();
break;
case 'filescan':
- handleFilescan();
+ handleFilescan($_GET['cleanup']);
break;
case 'partial_create':
handlePartialCreate($_GET['path']);
break;
+ case 'store_settings':
+ handleStoreSettings($_GET['root'], $_GET['order']);
+ break;
default:
OC_JSON::error(array('cause' => 'Unknown operation'));
}