From f4fd4a5a529aac331c7453bc1d3372da5c71f05c Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 19 Oct 2012 00:06:18 +0200 Subject: Updated category ajax files to use type instead of app and add callCheck. --- core/ajax/vcategories/add.php | 21 ++++++++++++--------- core/ajax/vcategories/delete.php | 24 ++++++++++++++---------- core/ajax/vcategories/edit.php | 15 +++++++++------ 3 files changed, 35 insertions(+), 25 deletions(-) (limited to 'core/ajax') diff --git a/core/ajax/vcategories/add.php b/core/ajax/vcategories/add.php index 81fa06dbf19..e97612c28f2 100644 --- a/core/ajax/vcategories/add.php +++ b/core/ajax/vcategories/add.php @@ -15,23 +15,26 @@ function debug($msg) { } 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.')); -} +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$l = OC_L10N::get('core'); -OC_JSON::checkAppEnabled($app); +$category = isset($_POST['category']) ? strip_tags($_POST['category']) : null; +$type = isset($_POST['type']) ? $_POST['type'] : null; + +if(is_null($type)) { + bailOut($l->t('Category type not provided.')); +} if(is_null($category)) { - bailOut(OC_Contacts_App::$l10n->t('No category to add?')); + bailOut($l->t('No category to add?')); } debug(print_r($category, true)); -$categories = new OC_VCategories($app); +$categories = new OC_VCategories($type); if($categories->hasCategory($category)) { bailOut(OC_Contacts_App::$l10n->t('This category already exists: '.$category)); } else { diff --git a/core/ajax/vcategories/delete.php b/core/ajax/vcategories/delete.php index cd46a25b79d..fd7b71be5d3 100644 --- a/core/ajax/vcategories/delete.php +++ b/core/ajax/vcategories/delete.php @@ -16,21 +16,25 @@ function debug($msg) { } require_once '../../../lib/base.php'; -OC_JSON::checkLoggedIn(); -$app = isset($_POST['app'])?$_POST['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); +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$l = OC_L10N::get('core'); + +$type = isset($_POST['type']) ? $_POST['type'] : null; +$categories = isset($_POST['categories']) ? $_POST['categories'] : null; + +if(is_null($type)) { + bailOut($l->t('Object type not provided.')); +} -debug('The application "'.$app.'" uses the default file. OC_VObjects will not be updated.'); +debug('The application using category type "' . $type . '" uses the default file for deletion. OC_VObjects will not be updated.'); if(is_null($categories)) { - bailOut('No categories selected for deletion.'); + bailOut($l->t('No categories selected for deletion.')); } -$vcategories = new OC_VCategories($app); +$vcategories = new OC_VCategories($type); $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 index a0e67841c55..4e9c9c17b55 100644 --- a/core/ajax/vcategories/edit.php +++ b/core/ajax/vcategories/edit.php @@ -17,16 +17,19 @@ function debug($msg) { require_once '../../../lib/base.php'; OC_JSON::checkLoggedIn(); -$app = isset($_GET['app'])?$_GET['app']:null; -if(is_null($app)) { - bailOut('Application name not provided.'); +$l = OC_L10N::get('core'); + +$type = isset($_GET['type']) ? $_GET['type'] : null; + +if(is_null($type)) { + bailOut($l->t('Category type not provided.')); } -OC_JSON::checkAppEnabled($app); -$tmpl = new OC_TEMPLATE("core", "edit_categories_dialog"); +OC_JSON::checkAppEnabled($type); +$tmpl = new OCP\Template("core", "edit_categories_dialog"); -$vcategories = new OC_VCategories($app); +$vcategories = new OC_VCategories($type); $categories = $vcategories->categories(); debug(print_r($categories, true)); $tmpl->assign('categories', $categories); -- cgit v1.2.3 From 26719005a466a0730bd24110115192188c5e60dd Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 19 Oct 2012 00:07:41 +0200 Subject: Added ajax files for favorite category handling. --- core/ajax/vcategories/addToFavorites.php | 40 +++++++++++++++++++++++++++ core/ajax/vcategories/favorites.php | 33 ++++++++++++++++++++++ core/ajax/vcategories/removeFromFavorites.php | 40 +++++++++++++++++++++++++++ 3 files changed, 113 insertions(+) create mode 100644 core/ajax/vcategories/addToFavorites.php create mode 100644 core/ajax/vcategories/favorites.php create mode 100644 core/ajax/vcategories/removeFromFavorites.php (limited to 'core/ajax') diff --git a/core/ajax/vcategories/addToFavorites.php b/core/ajax/vcategories/addToFavorites.php new file mode 100644 index 00000000000..f330d19c8a4 --- /dev/null +++ b/core/ajax/vcategories/addToFavorites.php @@ -0,0 +1,40 @@ + + * 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/addToFavorites.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); +} + +require_once '../../../lib/base.php'; + +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$l = OC_L10N::get('core'); + +$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null; +$type = isset($_POST['type']) ? $_POST['type'] : null; + +if(is_null($type)) { + bailOut($l->t('Object type not provided.')); +} + +if(is_null($id)) { + bailOut($l->t('%s ID not provided.', $type)); +} + +$categories = new OC_VCategories($type); +if(!$categories->addToFavorites($id, $type)) { + bailOut($l->t('Error adding %s to favorites.', $id)); +} + +OC_JSON::success(); diff --git a/core/ajax/vcategories/favorites.php b/core/ajax/vcategories/favorites.php new file mode 100644 index 00000000000..35b23e29c13 --- /dev/null +++ b/core/ajax/vcategories/favorites.php @@ -0,0 +1,33 @@ + + * 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/addToFavorites.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); +} + +require_once '../../../lib/base.php'; + +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + + +$type = isset($_POST['type']) ? $_POST['type'] : null; + +if(is_null($type)) { + $l = OC_L10N::get('core'); + bailOut($l->t('Object type not provided.')); +} + +$categories = new OC_VCategories($type); +$ids = $categories->getFavorites($type)) { + +OC_JSON::success(array('ids' => $ids)); diff --git a/core/ajax/vcategories/removeFromFavorites.php b/core/ajax/vcategories/removeFromFavorites.php new file mode 100644 index 00000000000..f779df48f21 --- /dev/null +++ b/core/ajax/vcategories/removeFromFavorites.php @@ -0,0 +1,40 @@ + + * 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/addToFavorites.php: '.$msg, OC_Log::DEBUG); + exit(); +} +function debug($msg) { + OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); +} + +require_once '../../../lib/base.php'; + +OCP\JSON::checkLoggedIn(); +OCP\JSON::callCheck(); + +$l = OC_L10N::get('core'); + +$id = isset($_POST['id']) ? strip_tags($_POST['id']) : null; +$type = isset($_POST['type']) ? $_POST['type'] : null; + +if(is_null($type)) { + bailOut($l->t('Object type not provided.')); +} + +if(is_null($id)) { + bailOut($l->t('%s ID not provided.', $type)); +} + +$categories = new OC_VCategories($type); +if(!$categories->removeFromFavorites($id, $type)) { + bailOut($l->t('Error removing %s from favorites.', $id)); +} + +OC_JSON::success(); -- cgit v1.2.3 From b9c9fdfe200d42bc75afe42d9ecfa98e3ccef8c1 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 19 Oct 2012 00:38:23 +0200 Subject: Use get for loading dialog. --- core/ajax/vcategories/favorites.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'core/ajax') diff --git a/core/ajax/vcategories/favorites.php b/core/ajax/vcategories/favorites.php index 35b23e29c13..b72fc7a9fee 100644 --- a/core/ajax/vcategories/favorites.php +++ b/core/ajax/vcategories/favorites.php @@ -20,7 +20,7 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -$type = isset($_POST['type']) ? $_POST['type'] : null; +$type = isset($_GET['type']) ? $_GET['type'] : null; if(is_null($type)) { $l = OC_L10N::get('core'); -- cgit v1.2.3 From e55cc2313299d770733a0d488bb11d3ff256bc76 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Fri, 19 Oct 2012 02:24:57 +0200 Subject: app !== type --- core/ajax/vcategories/edit.php | 1 - 1 file changed, 1 deletion(-) (limited to 'core/ajax') diff --git a/core/ajax/vcategories/edit.php b/core/ajax/vcategories/edit.php index 4e9c9c17b55..e7f2ff8ce5f 100644 --- a/core/ajax/vcategories/edit.php +++ b/core/ajax/vcategories/edit.php @@ -26,7 +26,6 @@ if(is_null($type)) { bailOut($l->t('Category type not provided.')); } -OC_JSON::checkAppEnabled($type); $tmpl = new OCP\Template("core", "edit_categories_dialog"); $vcategories = new OC_VCategories($type); -- cgit v1.2.3 From b0ae67d5c5af56b6174815795360a7c5a4026e57 Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Thu, 1 Nov 2012 03:06:20 +0100 Subject: Update vcategories ajax scripts. --- core/ajax/vcategories/addToFavorites.php | 2 -- core/ajax/vcategories/favorites.php | 3 --- core/ajax/vcategories/removeFromFavorites.php | 6 ++---- 3 files changed, 2 insertions(+), 9 deletions(-) (limited to 'core/ajax') diff --git a/core/ajax/vcategories/addToFavorites.php b/core/ajax/vcategories/addToFavorites.php index f330d19c8a4..52f62d5fc6b 100644 --- a/core/ajax/vcategories/addToFavorites.php +++ b/core/ajax/vcategories/addToFavorites.php @@ -14,8 +14,6 @@ function debug($msg) { OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); } -require_once '../../../lib/base.php'; - OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); diff --git a/core/ajax/vcategories/favorites.php b/core/ajax/vcategories/favorites.php index b72fc7a9fee..20accea61cd 100644 --- a/core/ajax/vcategories/favorites.php +++ b/core/ajax/vcategories/favorites.php @@ -14,12 +14,9 @@ function debug($msg) { OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); } -require_once '../../../lib/base.php'; - OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); - $type = isset($_GET['type']) ? $_GET['type'] : null; if(is_null($type)) { diff --git a/core/ajax/vcategories/removeFromFavorites.php b/core/ajax/vcategories/removeFromFavorites.php index f779df48f21..ba6e95c2497 100644 --- a/core/ajax/vcategories/removeFromFavorites.php +++ b/core/ajax/vcategories/removeFromFavorites.php @@ -7,15 +7,13 @@ */ function bailOut($msg) { OC_JSON::error(array('data' => array('message' => $msg))); - OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG); exit(); } function debug($msg) { - OC_Log::write('core', 'ajax/vcategories/addToFavorites.php: '.$msg, OC_Log::DEBUG); + OC_Log::write('core', 'ajax/vcategories/removeFromFavorites.php: '.$msg, OC_Log::DEBUG); } -require_once '../../../lib/base.php'; - OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); -- cgit v1.2.3 From 3c59bc41d7a83c6811f55ac7986ac77743e60d9e Mon Sep 17 00:00:00 2001 From: Thomas Tanghus Date: Mon, 5 Nov 2012 16:32:20 +0100 Subject: VCategories: Line too long. --- core/ajax/vcategories/delete.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'core/ajax') diff --git a/core/ajax/vcategories/delete.php b/core/ajax/vcategories/delete.php index 057c9bb0e94..dfec3785743 100644 --- a/core/ajax/vcategories/delete.php +++ b/core/ajax/vcategories/delete.php @@ -27,7 +27,9 @@ if(is_null($type)) { bailOut($l->t('Object type not provided.')); } -debug('The application using category type "' . $type . '" uses the default file for deletion. OC_VObjects will not be updated.'); +debug('The application using category type "' + . $type + . '" uses the default file for deletion. OC_VObjects will not be updated.'); if(is_null($categories)) { bailOut($l->t('No categories selected for deletion.')); -- cgit v1.2.3