summaryrefslogtreecommitdiffstats
path: root/lib/kolab_api_controller.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-02-23 11:45:08 +0100
committerAleksander Machniak <alec@alec.pl>2012-02-23 11:45:08 +0100
commit4bf2d1c7d09bd20bccc0b6449486804899e53b91 (patch)
treeaa1c4ce2811ca10ab3e6b8ba3af861d1a89ad7dd /lib/kolab_api_controller.php
parent9585885a269813009c3c3fb540e306a0be98b9b5 (diff)
downloadwebadmin-4bf2d1c7d09bd20bccc0b6449486804899e53b91.tar.gz
Added system.configure action
Diffstat (limited to 'lib/kolab_api_controller.php')
-rw-r--r--lib/kolab_api_controller.php49
1 files changed, 40 insertions, 9 deletions
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php
index 87cdbc2..b9885ca 100644
--- a/lib/kolab_api_controller.php
+++ b/lib/kolab_api_controller.php
@@ -256,6 +256,8 @@ class kolab_api_controller
*
* @param array GET request parameters
* @param array POST data
+ *
+ * @param array|false Authentication result
*/
private function authenticate($request, $postdata)
{
@@ -308,7 +310,8 @@ class kolab_api_controller
$domain_name = is_array($domain) ? $domain['associateddomain'] : $domain;
// define our very own capabilities
$actions = array(
- 'system.quit' => array('type' => 'w'),
+ 'system.quit' => array('type' => 'w'),
+ 'system.configure' => array('type' => 'w'),
);
foreach ($this->services as $sname => $handler) {
@@ -350,6 +353,36 @@ class kolab_api_controller
}
}
+ /**
+ * Configure current user session parameters
+ *
+ * @param array $request GET request parameters
+ * @param array $postdata POST data
+ *
+ * @return array|false
+ */
+ private function configure($request, $postdata)
+ {
+ if (!$this->session_validate($postdata)) {
+ return false;
+ }
+
+ $result = array();
+
+ foreach ($postdata as $key => $value) {
+ switch ($key) {
+ case 'language':
+ if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $value)) {
+ $_SESSION['language'] = $value;
+ $result[$key] = $value;
+ }
+ break;
+ }
+ }
+
+ return $result;
+ }
+
/* ======== Utility functions ======== */
@@ -358,24 +391,22 @@ class kolab_api_controller
*/
private function locale_init()
{
- // @TODO: read language from logged user data
$lang = 'en_US';
- if ($lang != 'en_US' && file_exists(INSTALL_PATH . "/locale/$lang.api.php")) {
- $language = $lang;
+ // @TODO: read language of logged user in authenticate?
+ if (!empty($_SESSION['language'])) {
+ $lang = $_SESSION['language'];
}
$LANG = array();
@include INSTALL_PATH . '/locale/en_US.api.php';
- if (isset($language)) {
+ if ($lang != 'en_US' && file_exists(INSTALL_PATH . "/locale/$lang.api.php")) {
@include INSTALL_PATH . "/locale/$language.api.php";
- setlocale(LC_ALL, $language . '.utf8', 'en_US.utf8');
- }
- else {
- setlocale(LC_ALL, 'en_US.utf8');
}
+ setlocale(LC_ALL, $lang . '.utf8', 'en_US.utf8');
+
self::$translation = $LANG;
}