diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-03-12 14:07:48 +0100 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-03-12 14:13:03 +0100 |
commit | 03eb5197b62664ee89060e2d644531c9e7fe8250 (patch) | |
tree | a2963dc7388339ba68ff4ebb7abae06d6db53271 /core/ajax | |
parent | a85a10b378883bfb3f3337d963dc573c2e803e2d (diff) | |
download | nextcloud-server-03eb5197b62664ee89060e2d644531c9e7fe8250.tar.gz nextcloud-server-03eb5197b62664ee89060e2d644531c9e7fe8250.zip |
Added category editor for apps using OC_VObjects.
Diffstat (limited to 'core/ajax')
-rw-r--r-- | core/ajax/vcategories/add.php | 43 | ||||
-rw-r--r-- | core/ajax/vcategories/delete.php | 38 | ||||
-rw-r--r-- | core/ajax/vcategories/edit.php | 35 |
3 files changed, 116 insertions, 0 deletions
diff --git a/core/ajax/vcategories/add.php b/core/ajax/vcategories/add.php new file mode 100644 index 00000000000..a58489228d8 --- /dev/null +++ b/core/ajax/vcategories/add.php @@ -0,0 +1,43 @@ +<?php +/** + * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('core','ajax/vcategories/add.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core','ajax/vcategories/add.php: '.$msg, OC_Log::DEBUG); +} + +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$category = isset($_GET['category'])?strip_tags($_GET['category']):null; +$app = isset($_GET['app'])?$_GET['app']:null; + +if(is_null($app)) { + bailOut(OC_Contacts_App::$l10n->t('Application name not provided.')); +} + +OC_JSON::checkAppEnabled($app); + +if(is_null($category)) { + bailOut(OC_Contacts_App::$l10n->t('No category to add?')); +} + +debug(print_r($category, true)); + +$categories = new OC_VCategories($app); +if($categories->hasCategory($category)) { + bailOut(OC_Contacts_App::$l10n->t('This category already exists: '.$category)); +} else { + $categories->add($category, true); +} + +OC_JSON::success(array('data' => array('categories'=>$categories->categories()))); + +?> diff --git a/core/ajax/vcategories/delete.php b/core/ajax/vcategories/delete.php new file mode 100644 index 00000000000..602ee1d74a4 --- /dev/null +++ b/core/ajax/vcategories/delete.php @@ -0,0 +1,38 @@ +<?php +/** + * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('core','ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core','ajax/vcategories/delete.php: '.$msg, OC_Log::DEBUG); +} + +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$app = isset($_GET['app'])?$_GET['app']:null; +$categories = isset($_POST['categories'])?$_POST['categories']:null; +if(is_null($app)) { + bailOut(OC_Contacts_App::$l10n->t('Application name not provided.')); +} + +OC_JSON::checkAppEnabled($app); + +debug('The application "'.$app.'" uses the default file. OC_VObjects will not be updated.'); + +if(is_null($categories)) { + bailOut('No categories selected for deletion.'); +} + +$vcategories = new OC_VCategories($app); +$vcategories->delete($categories); +OC_JSON::success(array('data' => array('categories'=>$vcategories->categories()))); + +?> diff --git a/core/ajax/vcategories/edit.php b/core/ajax/vcategories/edit.php new file mode 100644 index 00000000000..252b3d3454c --- /dev/null +++ b/core/ajax/vcategories/edit.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright (c) 2012 Thomas Tanghus <thomas@tanghus.net> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +function bailOut($msg) { + OC_JSON::error(array('data' => array('message' => $msg))); + OC_Log::write('core','ajax/vcategories/edit.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core','ajax/vcategories/edit.php: '.$msg, OC_Log::DEBUG); +} + +require_once('../../../lib/base.php'); +OC_JSON::checkLoggedIn(); +$app = isset($_GET['app'])?$_GET['app']:null; + +if(is_null($app)) { + bailOut('Application name not provided.'); +} + +OC_JSON::checkAppEnabled($app); +$tmpl = new OC_TEMPLATE("core", "edit_categories_dialog"); + +$vcategories = new OC_VCategories($app); +$categories = $vcategories->categories(); +debug(print_r($categories, true)); +$tmpl->assign('categories',$categories); +$tmpl->printpage(); + +?> |