2011-12-05 06:38:06 +04:00
|
|
|
<?php
|
|
|
|
/**
|
2012-01-11 23:07:15 +04:00
|
|
|
* Copyright (c) 2011-2012 Thomas Tanghus <thomas@tanghus.net>
|
2011-12-05 06:38:06 +04:00
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
2012-08-02 01:59:44 +04:00
|
|
|
|
2011-12-05 06:38:06 +04:00
|
|
|
|
|
|
|
// Check if we are a user
|
2012-05-03 14:23:29 +04:00
|
|
|
OCP\JSON::checkLoggedIn();
|
|
|
|
OCP\JSON::checkAppEnabled('contacts');
|
2012-08-02 01:59:44 +04:00
|
|
|
require_once __DIR__.'/../loghandler.php';
|
2012-01-11 23:07:15 +04:00
|
|
|
|
2012-08-02 01:59:44 +04:00
|
|
|
$id = $_POST['id'];
|
2012-02-20 18:24:54 +04:00
|
|
|
$name = trim(strip_tags($_POST['name']));
|
2012-08-02 01:59:44 +04:00
|
|
|
$description = trim(strip_tags($_POST['description']));
|
|
|
|
if(!$id) {
|
|
|
|
bailOut(OC_Contacts_App::$l10n->t('id is not set.'));
|
|
|
|
}
|
|
|
|
|
2012-02-20 18:24:54 +04:00
|
|
|
if(!$name) {
|
2012-06-25 00:22:58 +04:00
|
|
|
bailOut(OC_Contacts_App::$l10n->t('Cannot update addressbook with an empty name.'));
|
2012-02-20 18:24:54 +04:00
|
|
|
}
|
|
|
|
|
2012-08-02 01:59:44 +04:00
|
|
|
if(!OC_Contacts_Addressbook::edit($id, $name, $description)) {
|
2012-06-25 00:22:58 +04:00
|
|
|
bailOut(OC_Contacts_App::$l10n->t('Error updating addressbook.'));
|
2012-01-11 23:07:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-02 01:59:44 +04:00
|
|
|
if(!OC_Contacts_Addressbook::setActive($id, $_POST['active'])) {
|
2012-06-25 00:22:58 +04:00
|
|
|
bailOut(OC_Contacts_App::$l10n->t('Error (de)activating addressbook.'));
|
2012-01-11 23:07:15 +04:00
|
|
|
}
|
|
|
|
|
2012-08-02 01:59:44 +04:00
|
|
|
OC_Contacts_App::getAddressbook($id); // is owner access check
|
|
|
|
$addressbook = OC_Contacts_App::getAddressbook($id);
|
2012-05-03 14:23:29 +04:00
|
|
|
OCP\JSON::success(array(
|
2011-12-05 06:38:06 +04:00
|
|
|
'addressbook' => $addressbook,
|
|
|
|
));
|