2012-10-19 21:38:40 +02:00
|
|
|
<?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';
|
|
|
|
|
2012-11-22 19:34:31 +01:00
|
|
|
$category = isset($_POST['category']) ? trim(strip_tags($_POST['category'])) : null;
|
2012-10-19 21:38:40 +02:00
|
|
|
|
2012-11-22 19:34:31 +01:00
|
|
|
if(is_null($category) || $category === "") {
|
2012-10-25 03:34:12 +02:00
|
|
|
bailOut(OCA\Contacts\App::$l10n->t('No category name given.'));
|
2012-10-19 21:38:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$catman = new OC_VCategories('contact');
|
|
|
|
$id = $catman->add($category);
|
|
|
|
|
|
|
|
if($id !== false) {
|
|
|
|
OCP\JSON::success(array('data' => array('id'=>$id)));
|
|
|
|
} else {
|
2012-10-25 03:34:12 +02:00
|
|
|
bailOut(OCA\Contacts\App::$l10n->t('Error adding group.'));
|
2012-10-19 21:38:40 +02:00
|
|
|
}
|