Branch 'dev/configuration-handling' - lib/Conf.php lib/kolab_client_task.php

Jeroen van Meeuwen vanmeeuwen at kolabsys.com
Fri Mar 30 13:36:05 CEST 2012


 lib/Conf.php              |   15 +++++++++++----
 lib/kolab_client_task.php |    6 ++++--
 2 files changed, 15 insertions(+), 6 deletions(-)

New commits:
commit df76f949cbc592a3b58079ace738b3d16e0f323d
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date:   Fri Mar 30 13:35:44 2012 +0200

    Only use $_SESSION['user']->get_domain() if the method actually exists

diff --git a/lib/Conf.php b/lib/Conf.php
index 7c35baf..d333e42 100644
--- a/lib/Conf.php
+++ b/lib/Conf.php
@@ -106,10 +106,17 @@ class Conf {
         // and we can try and iterate over it.
 
         // First, try the most exotic.
-        if (isset($_SESSION['user'])) {
-            $domain_section_name = $_SESSION['user']->get_domain();
-            if (isset($this->_conf[$domain_section_name][$key1])) {
-                return $this->_conf[$domain_section_name][$key1];
+        if (isset($_SESSION['user']) && method_exists($_SESSION['user'], 'get_domain')) {
+            try {
+                $domain_section_name = $_SESSION['user']->get_domain();
+                if (isset($this->_conf[$domain_section_name][$key1])) {
+                    return $this->_conf[$domain_section_name][$key1];
+                }
+            } catch (Exception $e) {
+                $domain_section_name = $this->get('kolab', 'primary_domain');
+                if (isset($this->_conf[$domain_section_name][$key1])) {
+                    return $this->_conf[$domain_section_name][$key1];
+                }
             }
         }
 
diff --git a/lib/kolab_client_task.php b/lib/kolab_client_task.php
index d454215..54a5c2d 100644
--- a/lib/kolab_client_task.php
+++ b/lib/kolab_client_task.php
@@ -107,7 +107,7 @@ class kolab_client_task
         $url = $this->config_get('api_url', '');
 
         // TODO: Debug logging
-        console($url);
+        //console($url);
 
         if (!$url) {
             $url = kolab_utils::https_check() ? 'https://' : 'http://';
@@ -117,7 +117,7 @@ class kolab_client_task
         }
 
         // TODO: Debug logging
-        console($url);
+        //console($url);
 
         $this->api = new kolab_client_api($url);
     }
@@ -173,6 +173,8 @@ class kolab_client_task
             if ($login['username']) {
                 $result = $this->api->login($login['username'], $login['password']);
 
+                //console($result);
+
                 if ($token = $result->get('session_token')) {
                     $user = array('token' => $token, 'domain' => $result->get('domain'));
 





More information about the commits mailing list