1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-10 21:24:33 +01:00
OwncloudContactsOfficial/lib/controller/settingscontroller.php

55 lines
1.2 KiB
PHP
Raw Normal View History

2013-04-25 03:56:20 +02:00
<?php
/**
* @author Thomas Tanghus
2014-01-26 00:40:22 +01:00
* @copyright 2013-2014 Thomas Tanghus (thomas@tanghus.net)
*
2013-04-25 03:56:20 +02:00
* This file is licensed under the Affero General Public License version 3 or
* later.
* See the COPYING-README file.
*/
namespace OCA\Contacts\Controller;
2013-09-17 18:46:59 +02:00
use OCA\Contacts\App,
OCA\Contacts\JSONResponse,
OCP\AppFramework\Controller,
2013-09-17 18:46:59 +02:00
OCA\AppFramework\Core\API;
2013-04-25 03:56:20 +02:00
/**
* Controller class for groups/categories
*/
2013-09-17 18:46:59 +02:00
class SettingsController extends Controller {
2013-04-25 03:56:20 +02:00
/**
2013-09-24 13:39:45 +02:00
* @NoAdminRequired
2013-04-25 03:56:20 +02:00
*/
public function set() {
$request = $this->request;
//$request = json_decode(file_get_contents('php://input'), true);
$key = $request->post['key'];
$value = $request->post['value'];
$response = new JSONResponse();
if(is_null($key) || $key === "") {
$response->bailOut(App::$l10n->t('No key is given.'));
}
if(is_null($value) || $value === "") {
$response->bailOut(App::$l10n->t('No value is given.'));
}
if(\OCP\Config::setUserValue(\OCP\User::getUser(), 'contacts', $key, $value)) {
$response->setParams(array(
'key' => $key,
'value' => $value)
);
return $response;
} else {
$response->bailOut(App::$l10n->t(
'Could not set preference: ' . $key . ':' . $value)
);
}
2013-04-25 03:56:20 +02:00
}
}