diff options
-rw-r--r-- | lib/kolab_api_controller.php | 6 | ||||
-rw-r--r-- | lib/kolab_client_task.php | 37 | ||||
-rw-r--r-- | lib/locale/en_US.php | 3 | ||||
-rw-r--r-- | public_html/js/kolab_admin.js | 4 |
4 files changed, 38 insertions, 12 deletions
diff --git a/lib/kolab_api_controller.php b/lib/kolab_api_controller.php index e7adbab..d96d4ac 100644 --- a/lib/kolab_api_controller.php +++ b/lib/kolab_api_controller.php @@ -437,10 +437,10 @@ class kolab_api_controller $label = $args[0]; if (isset(self::$translation[$label])) { - $content = trim(self::$translation[$label]); + $content = trim(self::$translation[$label]); } - else { - $content = $label; + else { + $content = $label; } for ($i = 1, $len = count($args); $i < $len; $i++) { diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php index ec11136..1740384 100644 --- a/lib/kolab_client_task.php +++ b/lib/kolab_client_task.php @@ -234,8 +234,17 @@ class kolab_client_task } } else if (!empty($_SESSION['user']) && !empty($_SESSION['user']['token'])) { + // Validate session + $timeout = $this->config_get('session_timeout', 3600); + if ($timeout && $_SESSION['time'] && $_SESSION['time'] < time() - $timeout) { + $this->action_logout(true); + } + + // update session time + $_SESSION['time'] = time(); + + // Set API session key $this->api->set_session_token($_SESSION['user']['token']); - return; } } @@ -295,7 +304,7 @@ class kolab_client_task /** * Logout action. */ - private function action_logout() + private function action_logout($sess_expired = false) { if (!empty($_SESSION['user']) && !empty($_SESSION['user']['token'])) { $this->api->logout(); @@ -303,10 +312,24 @@ class kolab_client_task $_SESSION = array(); if ($this->output->is_ajax()) { - $this->output->command('main_logout'); + if ($sess_expired) { + $args = array('error' => 'session.expired'); + } + $this->output->command('main_logout', $args); + } + else { + $this->output->add_translation('loginerror', 'internalerror', 'session.expired'); + } + + if ($sess_expired) { + $error = 'session.expired'; } else { - $this->output->add_translation('loginerror', 'internalerror'); + $error = $this->get_input('error', 'GET'); + } + + if ($error) { + $this->output->command('display_message', $error, 'error'); } $this->output->send('login'); @@ -404,10 +427,10 @@ class kolab_client_task $label = $args[0]; if (isset(self::$translation[$label])) { - $content = trim(self::$translation[$label]); + $content = trim(self::$translation[$label]); } - else { - $content = $label; + else { + $content = $label; } for ($i = 1, $len = count($args); $i < $len; $i++) { diff --git a/lib/locale/en_US.php b/lib/locale/en_US.php index db04bef..564803b 100644 --- a/lib/locale/en_US.php +++ b/lib/locale/en_US.php @@ -96,6 +96,9 @@ $LANG['search.loading'] = 'Searching...'; $LANG['search.acchars'] = 'At least $min characters required for autocompletion'; $LANG['servererror'] = 'Server Error!'; + +$LANG['session.expired'] = 'Session has expired. Login again, please'; + $LANG['submit.button'] = 'Submit'; $LANG['user.add'] = 'Add User'; diff --git a/public_html/js/kolab_admin.js b/public_html/js/kolab_admin.js index d6f0927..b640679 100644 --- a/public_html/js/kolab_admin.js +++ b/public_html/js/kolab_admin.js @@ -1032,9 +1032,9 @@ function kolab_admin() /********* Client commands *********/ /*********************************************************/ - this.main_logout = function() + this.main_logout = function(params) { - location.href = '?task=main&action=logout'; + location.href = '?task=main&action=logout' + (params ? '&' + $.param(params) : ''); return false; }; |