From ab9c3db43af1ff6285c4bfe78da5aefbf4ae3393 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 6 Dec 2013 14:11:05 +0100 Subject: [PATCH] Improved role-based settings handling, especially 'skin' setting --- plugins/kolab_auth/kolab_auth.php | 36 ++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/plugins/kolab_auth/kolab_auth.php b/plugins/kolab_auth/kolab_auth.php index 7ff57616..1fa77557 100644 --- a/plugins/kolab_auth/kolab_auth.php +++ b/plugins/kolab_auth/kolab_auth.php @@ -155,24 +155,27 @@ class kolab_auth extends rcube_plugin if (!empty($role_plugins)) { foreach ($role_plugins as $role_dn => $plugins) { - $role_plugins[self::parse_ldap_vars($role_dn)] = $plugins; + $role_dn = self::parse_ldap_vars($role_dn); + if (!empty($role_plugins[$role_dn])) { + $role_plugins[$role_dn] = array_unique(array_merge((array)$role_plugins[$role_dn], $plugins)); + } else { + $role_plugins[$role_dn] = $plugins; + } } } if (!empty($role_settings)) { foreach ($role_settings as $role_dn => $settings) { - $role_settings[self::parse_ldap_vars($role_dn)] = $settings; + if (!empty($role_settings[$role_dn])) { + $role_settings[$role_dn] = array_merge((array)$role_settings[$role_dn], $settings); + } else { + $role_settings[$role_dn] = $settings; + } } } foreach ($_SESSION['user_roledns'] as $role_dn) { - if (isset($role_plugins[$role_dn]) && is_array($role_plugins[$role_dn])) { - foreach ($role_plugins[$role_dn] as $plugin) { - $this->require_plugin($plugin); - } - } - - if (isset($role_settings[$role_dn]) && is_array($role_settings[$role_dn])) { + if (!empty($role_settings[$role_dn]) && is_array($role_settings[$role_dn])) { foreach ($role_settings[$role_dn] as $setting_name => $setting) { if (!isset($setting['mode'])) { $setting['mode'] = 'override'; @@ -194,7 +197,7 @@ class kolab_auth extends rcube_plugin $dont_override = (array) $rcmail->config->get('dont_override'); - if (!isset($setting['allow_override']) || !$setting['allow_override']) { + if (empty($setting['allow_override'])) { $rcmail->config->set('dont_override', array_merge($dont_override, array($setting_name))); } else { @@ -208,6 +211,19 @@ class kolab_auth extends rcube_plugin $rcmail->config->set('dont_override', $_dont_override); } } + + if ($setting_name == 'skin') { + if ($rcmail->output->type == 'html') { + $rcmail->output->set_skin($setting['value']); + $rcmail->output->set_env('skin', $setting['value']); + } + } + } + } + + if (!empty($role_plugins[$role_dn])) { + foreach ((array)$role_plugins[$role_dn] as $plugin) { + $this->require_plugin($plugin); } } }