diff options
author | Thomas Tanghus <thomas@tanghus.net> | 2012-08-01 23:59:44 +0200 |
---|---|---|
committer | Thomas Tanghus <thomas@tanghus.net> | 2012-08-02 00:02:07 +0200 |
commit | a8faae4f421ab8b85c2bd88b9617efb191c3ff62 (patch) | |
tree | 5e6deffb8a37acdf3b2a9fe3c2c265fdf7e8b3e3 /apps/contacts/ajax | |
parent | 47e4793c30b9efdf419115b77343d456cf17594b (diff) | |
download | nextcloud-server-a8faae4f421ab8b85c2bd88b9617efb191c3ff62.tar.gz nextcloud-server-a8faae4f421ab8b85c2bd88b9617efb191c3ff62.zip |
Addressbooks settings rewrite and cleanup.
Diffstat (limited to 'apps/contacts/ajax')
-rw-r--r-- | apps/contacts/ajax/activation.php | 32 | ||||
-rw-r--r-- | apps/contacts/ajax/addressbook/add.php (renamed from apps/contacts/ajax/addaddressbook.php) | 6 | ||||
-rw-r--r-- | apps/contacts/ajax/addressbook/delete.php (renamed from apps/contacts/ajax/deletebook.php) | 5 | ||||
-rw-r--r-- | apps/contacts/ajax/addressbook/update.php (renamed from apps/contacts/ajax/updateaddressbook.php) | 23 | ||||
-rw-r--r-- | apps/contacts/ajax/chooseaddressbook.php | 15 | ||||
-rw-r--r-- | apps/contacts/ajax/createaddressbook.php | 36 | ||||
-rw-r--r-- | apps/contacts/ajax/editaddressbook.php | 16 |
7 files changed, 19 insertions, 114 deletions
diff --git a/apps/contacts/ajax/activation.php b/apps/contacts/ajax/activation.php deleted file mode 100644 index 69173c54c44..00000000000 --- a/apps/contacts/ajax/activation.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> - * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - - -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('contacts'); -OCP\JSON::callCheck(); - -$bookid = $_POST['bookid']; -$book = OC_Contacts_App::getAddressbook($bookid);// is owner access check - -if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { - OCP\Util::writeLog('contacts', - 'ajax/activation.php: Error activating addressbook: '. $bookid, - OCP\Util::ERROR); - OCP\JSON::error(array( - 'data' => array( - 'message' => OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')))); - exit(); -} - -OCP\JSON::success(array( - 'active' => OC_Contacts_Addressbook::isActive($bookid), - 'bookid' => $bookid, - 'book' => $book, -)); diff --git a/apps/contacts/ajax/addaddressbook.php b/apps/contacts/ajax/addressbook/add.php index 40773704bb4..617c2fd1822 100644 --- a/apps/contacts/ajax/addaddressbook.php +++ b/apps/contacts/ajax/addressbook/add.php @@ -6,13 +6,13 @@ * later. * See the COPYING-README file. */ - + // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); -require_once 'loghandler.php'; +require_once __DIR__.'/../loghandler.php'; debug('name: '.$_POST['name']); @@ -34,4 +34,4 @@ if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { bailOut('Error activating addressbook.'); } $addressbook = OC_Contacts_App::getAddressbook($bookid); -OCP\JSON::success(array('data' => $addressbook)); +OCP\JSON::success(array('addressbook' => $addressbook)); diff --git a/apps/contacts/ajax/deletebook.php b/apps/contacts/ajax/addressbook/delete.php index 1b86ecf223e..f59c605f4e4 100644 --- a/apps/contacts/ajax/deletebook.php +++ b/apps/contacts/ajax/addressbook/delete.php @@ -24,9 +24,12 @@ OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); OCP\JSON::callCheck(); +require_once __DIR__.'/../loghandler.php'; -//$id = $_GET['id']; $id = $_POST['id']; +if(!$id) { + bailOut(OC_Contacts_App::$l10n->t('id is not set.')); +} OC_Contacts_App::getAddressbook( $id ); // is owner access check OC_Contacts_Addressbook::delete($id); diff --git a/apps/contacts/ajax/updateaddressbook.php b/apps/contacts/ajax/addressbook/update.php index a14b2158431..0fc66c3a3bf 100644 --- a/apps/contacts/ajax/updateaddressbook.php +++ b/apps/contacts/ajax/addressbook/update.php @@ -6,33 +6,34 @@ * See the COPYING-README file. */ - + // Check if we are a user OCP\JSON::checkLoggedIn(); OCP\JSON::checkAppEnabled('contacts'); -require_once 'loghandler.php'; - -$bookid = $_POST['id']; -OC_Contacts_App::getAddressbook($bookid); // is owner access check +require_once __DIR__.'/../loghandler.php'; +$id = $_POST['id']; $name = trim(strip_tags($_POST['name'])); +$description = trim(strip_tags($_POST['description'])); +if(!$id) { + bailOut(OC_Contacts_App::$l10n->t('id is not set.')); +} + if(!$name) { bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.')); } -if(!OC_Contacts_Addressbook::edit($bookid, $name, null)) { +if(!OC_Contacts_Addressbook::edit($id, $name, $description)) { bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.')); } -if(!OC_Contacts_Addressbook::setActive($bookid, $_POST['active'])) { +if(!OC_Contacts_Addressbook::setActive($id, $_POST['active'])) { bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.')); } -$addressbook = OC_Contacts_App::getAddressbook($bookid); -$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); -$tmpl->assign('addressbook', $addressbook); +OC_Contacts_App::getAddressbook($id); // is owner access check +$addressbook = OC_Contacts_App::getAddressbook($id); OCP\JSON::success(array( - 'page' => $tmpl->fetchPage(), 'addressbook' => $addressbook, )); diff --git a/apps/contacts/ajax/chooseaddressbook.php b/apps/contacts/ajax/chooseaddressbook.php deleted file mode 100644 index 1ce8dd46eef..00000000000 --- a/apps/contacts/ajax/chooseaddressbook.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Thomas Tanghus <thomas@tanghus.net> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - - -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('contacts'); - -$tmpl = new OCP\Template("contacts", "part.chooseaddressbook"); -$page = $tmpl->fetchPage(); -OCP\JSON::success(array('data' => array('page'=>$page))); diff --git a/apps/contacts/ajax/createaddressbook.php b/apps/contacts/ajax/createaddressbook.php deleted file mode 100644 index 8dbd63f6425..00000000000 --- a/apps/contacts/ajax/createaddressbook.php +++ /dev/null @@ -1,36 +0,0 @@ -<?php -/** - * Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net> - * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - - -// Check if we are a user -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('contacts'); -OCP\JSON::callCheck(); -require_once 'loghandler.php'; - -$userid = OCP\USER::getUser(); -$name = trim(strip_tags($_POST['name'])); -if(!$name) { - bailOut('Cannot add addressbook with an empty name.'); -} -$bookid = OC_Contacts_Addressbook::add($userid, $name, null); -if(!$bookid) { - bailOut('Error adding addressbook: '.$name); -} - -if(!OC_Contacts_Addressbook::setActive($bookid, 1)) { - bailOut('Error activating addressbook.'); -} -$addressbook = OC_Contacts_App::getAddressbook($bookid); -$tmpl = new OCP\Template('contacts', 'part.chooseaddressbook.rowfields'); -$tmpl->assign('addressbook', $addressbook); -OCP\JSON::success(array( - 'page' => $tmpl->fetchPage(), - 'addressbook' => $addressbook, -)); diff --git a/apps/contacts/ajax/editaddressbook.php b/apps/contacts/ajax/editaddressbook.php deleted file mode 100644 index 4bc77302e5b..00000000000 --- a/apps/contacts/ajax/editaddressbook.php +++ /dev/null @@ -1,16 +0,0 @@ -<?php -/** - * Copyright (c) 2011 Bart Visscher <bartv@thisnet.nl> - * This file is licensed under the Affero General Public License version 3 or - * later. - * See the COPYING-README file. - */ - - -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('contacts'); -$addressbook = OC_Contacts_App::getAddressbook($_GET['bookid']); -$tmpl = new OCP\Template("contacts", "part.editaddressbook"); -$tmpl->assign('new', false); -$tmpl->assign('addressbook', $addressbook); -$tmpl->printPage(); |