From: Jan Schneider Date: Wed, 8 Dec 2010 18:16:05 +0000 (+0100) Subject: Fix domain detection. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=af8cf35634aa32383d17dd4f98487259689baa1c;p=horde.git Fix domain detection. --- diff --git a/vilma/lib/Application.php b/vilma/lib/Application.php index f7dd28fd9..60cd0c305 100644 --- a/vilma/lib/Application.php +++ b/vilma/lib/Application.php @@ -45,8 +45,21 @@ class Vilma_Application extends Horde_Registry_Application $this->driver = Vilma_Driver::singleton(); // Get the currently active domain, possibly storing a change into the - // session - $this->curdomain = Vilma::getCurDomain(); + // session. + // Domain is passed in by ID, which may or may not be the + // the same as the actual DNS domain name. + $domain_id = Horde_Util::getFormData('domain_id'); + + if (!empty($domain_id)) { + $domain = $this->driver->getDomain($domain_id); + if (!is_a($domain, 'PEAR_Error') && + !empty($domain['domain_name'])) { + $this->curdomain = $domain; + Vilma::setCurDomain($domain); + } + } elseif ($domain = $GLOBALS['session']->get('vilma', 'domain')) { + $this->curdomain = $domain; + } } public function perms() diff --git a/vilma/lib/Vilma.php b/vilma/lib/Vilma.php index f824e3346..f19bdb071 100644 --- a/vilma/lib/Vilma.php +++ b/vilma/lib/Vilma.php @@ -84,35 +84,6 @@ class Vilma } /** - * Attempt to determine the current domain name based on current user or - * a domain_id passed in by form. - * - * @return mixed string domain on success, false on failure, PEAR::Error on error - */ - function getCurDomain() - { - // Domain is passed in by ID, which may or may not be the - // the same as the actual DNS domain name - $domain_id = Horde_Util::getFormData('domain_id'); - - if (!empty($domain_id)) { - // FIXME: Make sure this only runs once per page-load - $domain = $GLOBALS['vilma_driver']->getDomain($domain_id); - if (is_a($domain, 'PEAR_Error')) { - return $domain; - } - if (empty($domain['domain_name'])) { - $domain = false; - } - Vilma::setCurDomain($domain); - } elseif (!($domain = $GLOBALS['session']->get('vilma', 'domain'))) { - $domain = false; - } - - return $domain; - } - - /** * Set the current domain */ function setCurDomain($domain) @@ -169,7 +140,7 @@ class Vilma $menu->add(Horde::url('domains/index.php'), _("_Domains"), 'domain.png'); - if (Vilma::getCurDomain()) { + if ($GLOBALS['vilma']->curdomain) { $domain = $GLOBALS['session']->get('vilma', 'domain'); $url = Horde::url('users/index.php'); $tmp = Horde_Util::addParameter($url, 'domain_id', $domain['domain_id']);