Blame view
sources/apps/contacts/lib/controller/settingscontroller.php
1.2 KB
|
d1bafeea1
|
1 2 3 |
<?php /** * @author Thomas Tanghus |
|
6d9380f96
|
4 5 |
* @copyright 2013-2014 Thomas Tanghus (thomas@tanghus.net) * |
|
d1bafeea1
|
6 7 8 9 10 11 12 13 14 |
* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace OCA\Contacts\Controller; use OCA\Contacts\App, OCA\Contacts\JSONResponse, |
|
6d9380f96
|
15 |
OCP\AppFramework\Controller, |
|
d1bafeea1
|
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
OCA\AppFramework\Core\API;
/**
* Controller class for groups/categories
*/
class SettingsController extends Controller {
/**
* @NoAdminRequired
*/
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.'));
}
|
|
6d9380f96
|
42 |
if(\OCP\Config::setUserValue(\OCP\User::getUser(), 'contacts', $key, $value)) {
|
|
d1bafeea1
|
43 44 45 46 47 48 49 50 51 52 53 54 |
$response->setParams(array(
'key' => $key,
'value' => $value)
);
return $response;
} else {
$response->bailOut(App::$l10n->t(
'Could not set preference: ' . $key . ':' . $value)
);
}
}
}
|