From 187a3b97fc5d62b7f484a7012bbcba7d07062b5e Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 8 Jun 2009 01:13:46 +0200 Subject: [PATCH] Fix scope. Try work address if home address is not set. Try first location is serveral returned. --- timeobjects/lib/Driver/Weatherdotcom.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/timeobjects/lib/Driver/Weatherdotcom.php b/timeobjects/lib/Driver/Weatherdotcom.php index 10cc37f50..02ec0c78c 100644 --- a/timeobjects/lib/Driver/Weatherdotcom.php +++ b/timeobjects/lib/Driver/Weatherdotcom.php @@ -24,7 +24,13 @@ class TimeObjects_Driver_Weatherdotcom extends TimeObjects_Driver $own = $GLOBALS['registry']->horde->getPreference('turba', 'own_contact'); @list($source, $id) = explode(';', $own); $contact = $GLOBALS['registry']->contacts->getContact($source, $id); - $params['location'] = $contact['homeCity'] . (!empty($contact['homeProvince']) ? ', ' . $contact['homeProvince'] : '') . (!empty($contact['homeCountry']) ? ', ' . $contact['homeCountry'] : ''); + $params['location'] = !empty($contact['homeCity']) + ? $contact['homeCity'] + . (!empty($contact['homeProvince']) ? ', ' . $contact['homeProvince'] : '') + . (!empty($contact['homeCountry']) ? ', ' . $contact['homeCountry'] : '') + : $contact['workCity'] + . (!empty($contact['workProvince']) ? ', ' . $contact['workProvince'] : '') + . (!empty($contact['workCountry']) ? ', ' . $contact['workCountry'] : ''); } // TODO: Try some other way, maybe a hook or a new preference in Horde @@ -43,8 +49,8 @@ class TimeObjects_Driver_Weatherdotcom extends TimeObjects_Driver if (!class_exists('Services_Weather') || !class_exists('Cache') || empty($this->_params['location']) || - empty($conf['weatherdotcom']['partner_id']) || - empty($conf['weatherdotcom']['license_key'])) { + empty($GLOBALS['conf']['weatherdotcom']['partner_id']) || + empty($GLOBALS['conf']['weatherdotcom']['license_key'])) { return false; } @@ -139,7 +145,7 @@ class TimeObjects_Driver_Weatherdotcom extends TimeObjects_Driver } } if (is_array($search)) { - throw new TimeObjects_Exception(_(sprintf("Several locations possible with the paramter: ", $this->_params['location']))); + $search = key($search); } $forecast = $weatherDotCom->getForecast($search, $this->_params['days']); if (is_a($forecast, 'PEAR_Error')) { -- 2.11.0