1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-12 23:09:15 +01:00
OwncloudContactsOfficial/ajax/categories/add.php
2012-10-19 21:38:40 +02:00

30 lines
707 B
PHP

<?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.
*/
OCP\JSON::checkLoggedIn();
OCP\JSON::checkAppEnabled('contacts');
OCP\JSON::callCheck();
require_once __DIR__.'/../loghandler.php';
$category = isset($_POST['category']) ? $_POST['category'] : null;
if(is_null($category)) {
bailOut(OC_Contacts_App::$l10n->t('No category name given.'));
}
$catman = new OC_VCategories('contact');
$id = $catman->add($category);
if($id !== false) {
OCP\JSON::success(array('data' => array('id'=>$id)));
} else {
bailOut(OC_Contacts_App::$l10n->t('Error adding group.'));
}