diff --git a/controller/citycontroller.php b/controller/citycontroller.php index 3a03d08..b664e15 100644 --- a/controller/citycontroller.php +++ b/controller/citycontroller.php @@ -34,7 +34,7 @@ class CityController extends IntermediateController { $this->userId = $userId; $this->mapper = $mapper; $this->settingsMapper = $settingsMapper; - $this->apiKey = $settingsMapper->getApiKey($this->userId); + $this->apiKey = \OC::$server->getConfig()->getAppValue('weather', 'openweathermap_api_key', ''); } /** diff --git a/controller/weathercontroller.php b/controller/weathercontroller.php index 182c327..fe73d54 100644 --- a/controller/weathercontroller.php +++ b/controller/weathercontroller.php @@ -37,7 +37,7 @@ class WeatherController extends IntermediateController { $this->userId = $userId; $this->mapper = $mapper; $this->settingsMapper = $settingsMapper; - $this->apiKey = $settingsMapper->getApiKey($this->userId); + $this->apiKey = \OC::$server->getConfig()->getAppValue('weather', 'openweathermap_api_key', ''); $this->metric = $settingsMapper->getMetric($this->userId); } diff --git a/db/settingsmapper.php b/db/settingsmapper.php index 0debdd7..c8f5a59 100644 --- a/db/settingsmapper.php +++ b/db/settingsmapper.php @@ -28,14 +28,6 @@ class SettingsMapper extends Mapper { return $this->getSetting($userId, "home"); } - public function setApiKey ($userId, $apiKey) { - $this->setSetting("apikey", $userId, $apiKey); - } - - public function getApiKey ($userId) { - return $this->getSetting($userId, "apikey"); - } - public function setMetric ($userId, $metric) { $this->setSetting("metric", $userId, $metric); } diff --git a/js/public/app.js b/js/public/app.js index 3ee5490..c1ce73e 100644 --- a/js/public/app.js +++ b/js/public/app.js @@ -198,7 +198,7 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil $scope.cityLoadNeedsAPIKey = false; } else if (r.status == 401) { - $scope.cityLoadError = "Your OpenWeatherMap API key is invalid. Please provide a working API Key."; + $scope.cityLoadError = "Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in administration settings"; $scope.cityLoadNeedsAPIKey = true; } else { @@ -232,7 +232,10 @@ app.controller('WeatherController', ['$scope', '$interval', '$timeout', '$compil } }, function (r) { - if (r.status == 404) { + if (r.status == 401) { + $scope.addCityError = "Your OpenWeatherMap API key is invalid. Contact your administrator to configure a valid API key in administration settings"; + } + else if (r.status == 404) { $scope.addCityError = "No city with this name found."; } else if (r.status == 409) {