summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-09-05 14:39:37 +0200
committerAleksander Machniak <alec@alec.pl>2012-09-05 14:39:37 +0200
commit4c191f31bed15fea60c3e754383288ea7adbb195 (patch)
treeac54551ce9633a3012726b5d7856f302b6c3f9f1
parente7a5de02a6bf4b04fc2ab740e4c1206df68e15de (diff)
downloadwebadmin-4c191f31bed15fea60c3e754383288ea7adbb195.tar.gz
Fix devel_mode option handling
-rw-r--r--lib/client/kolab_client_task_resource.php4
-rw-r--r--lib/client/kolab_client_task_role.php8
-rw-r--r--lib/kolab_client_task.php53
3 files changed, 37 insertions, 28 deletions
diff --git a/lib/client/kolab_client_task_resource.php b/lib/client/kolab_client_task_resource.php
index 2d8f099..ace2929 100644
--- a/lib/client/kolab_client_task_resource.php
+++ b/lib/client/kolab_client_task_resource.php
@@ -337,14 +337,14 @@ class kolab_client_task_resource extends kolab_client_task
*/
public function resource_types()
{
- if (isset($_SESSION['resource_types'])) {
+ if (isset($_SESSION['resource_types']) && !$this->devel_mode) {
return $_SESSION['resource_types'];
}
$result = $this->api->post('resource_types.list');
$list = $result->get('list');
- if (is_array($list) && !$this->config_get('devel_mode')) {
+ if (is_array($list) && !$this->devel_mode) {
$_SESSION['resource_types'] = $list;
}
diff --git a/lib/client/kolab_client_task_role.php b/lib/client/kolab_client_task_role.php
index e460a95..b625f73 100644
--- a/lib/client/kolab_client_task_role.php
+++ b/lib/client/kolab_client_task_role.php
@@ -294,16 +294,14 @@ class kolab_client_task_role extends kolab_client_task
*/
public function role_types()
{
- if (!$this->config_get('devel_mode', false)) {
- if (isset($_SESSION['role_types'])) {
- return $_SESSION['role_types'];
- }
+ if (isset($_SESSION['role_types']) && !$this->devel_mode) {
+ return $_SESSION['role_types'];
}
$result = $this->api->post('role_types.list');
$list = $result->get('list');
- if (is_array($list)) {
+ if (is_array($list) && !$this->devel_mode) {
$_SESSION['role_types'] = $list;
}
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index 8807589..910de6c 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -45,6 +45,7 @@ class kolab_client_task
protected $page_title = 'Kolab Admin Panel';
protected $menu = array();
protected $cache = array();
+ protected $devel_mode = false;
protected static $translation = array();
@@ -54,6 +55,9 @@ class kolab_client_task
public function __construct()
{
$this->config_init();
+
+ $this->devel_mode = $this->config_get('devel_mode', false, Conf::BOOL);
+
$this->output_init();
$this->api_init();
@@ -401,12 +405,13 @@ class kolab_client_task
*
* @param string $name Option name
* @param mixed $fallback Default value
+ * @param int $type Value type (one of Conf class constants)
*
* @return mixed Option value
*/
- public function config_get($name, $fallback = null)
+ public function config_get($name, $fallback = null, $type = null)
{
- $value = $this->config->get('kolab_wap', $name);
+ $value = $this->config->get('kolab_wap', $name, $type);
return $value !== null ? $value : $fallback;
}
@@ -525,14 +530,13 @@ class kolab_client_task
*/
protected function user_types($used_for = NULL)
{
- if (isset($_SESSION['user_types']) && !empty($_SESSION['user_types']) && !$this->config_get('devel_mode')) {
+ if (isset($_SESSION['user_types']) && !empty($_SESSION['user_types']) && !$this->devel_mode) {
return $_SESSION['user_types'];
}
- $list = Array();
-
+ $list = array();
$result = $this->api->post('user_types.list');
- $_list = $result->get('list');
+ $_list = $result->get('list');
if (!empty($used_for)) {
foreach ($_list as $user_type_id => $user_type_attrs) {
@@ -544,7 +548,7 @@ class kolab_client_task
$list = $_list;
}
- if (is_array($list) && !$this->config_get('devel_mode')) {
+ if (is_array($list) && !$this->devel_mode) {
$_SESSION['user_types'] = $list;
}
@@ -562,7 +566,7 @@ class kolab_client_task
*/
protected function user_name($dn)
{
- if (!$this->config_get('devel_mode', false)) {
+ if (!$this->devel_mode) {
if (!empty($this->cache['user_names']) && isset($this->cache['user_names'][$dn])) {
return $this->cache['user_names'][$dn];
}
@@ -580,7 +584,7 @@ class kolab_client_task
}
}
- if (!$this->config_get('devel_mode', false)) {
+ if (!$this->devel_mode) {
return $this->cache['user_names'][$dn] = $username;
} else {
return $username;
@@ -590,18 +594,13 @@ class kolab_client_task
/**
* Returns list of system capabilities.
*
+ * @param bool $all If enabled capabilities for all domains will be returned
+ *
* @return array List of system capabilities
*/
- protected function capabilities()
+ protected function capabilities($all = false)
{
- $conf = Conf::get_instance();
- $devel_mode = $conf->get('kolab_wap', 'devel_mode');
-
- if (empty($devel_mode)) {
- $devel_mode = FALSE;
- }
-
- if (!isset($_SESSION['capabilities']) || $devel_mode) {
+ if (!isset($_SESSION['capabilities']) || $this->devel_mode) {
$result = $this->api->post('system.capabilities');
$list = $result->get('list');
@@ -614,7 +613,7 @@ class kolab_client_task
$domain = $_SESSION['user']['domain'];
- return $_SESSION['capabilities'][$domain];
+ return !$all ? $_SESSION['capabilities'][$domain] : $_SESSION['capabilities'];
}
/**
@@ -632,6 +631,18 @@ class kolab_client_task
}
/**
+ * Returns domains list (based on capabilities response)
+ *
+ * @return array List of domains
+ */
+ protected function get_domains()
+ {
+ $caps = $this->capabilities(true);
+
+ return is_array($caps) ? array_keys($caps) : array();
+ }
+
+ /**
* Returns execution time in seconds
*
* @param string Execution time
@@ -911,7 +922,7 @@ class kolab_client_task
// See if "administrators" (those who can delete and add back on the entry
// level) may override the automatically generated contents of auto_form_fields.
- $admin_auto_fields_rw = $this->config_get('admin_auto_fields_rw', false);
+ $admin_auto_fields_rw = $this->config_get('admin_auto_fields_rw', false, Conf::BOOL);
foreach ($fields as $idx => $field) {
if (!array_key_exists($idx, $attribute_rights)) {
@@ -975,7 +986,7 @@ class kolab_client_task
}
// Add debug information
- if ($this->config_get('devel_mode')) {
+ if ($this->devel_mode) {
ksort($data);
$debug = kolab_html::escape(print_r($data, true));
$debug = preg_replace('/(^Array\n\(|\n*\)$|\t)/', '', $debug);