From a22ce04317186a460bb0ae28368e292793fcbd04 Mon Sep 17 00:00:00 2001 From: Jonas Heinrich Date: Sun, 12 Aug 2018 16:22:11 +0200 Subject: [PATCH] add controller and service --- appinfo/info.xml | 2 +- controller/settingscontroller.php | 54 +++++++++++++++++++++++++++++++ service/configservice.php | 25 ++++++++++++++ 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 controller/settingscontroller.php create mode 100644 service/configservice.php diff --git a/appinfo/info.xml b/appinfo/info.xml index e8a128d..97caf21 100755 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -14,7 +14,7 @@ multimedia https://git.project-insanity.org/onny/nextcloud-app-radio https://git.project-insanity.org/onny/nextcloud-app-radio/issues - https://onny.project-insanity.org/files/radio-app.png + https://git.project-insanity.org/onny/nextcloud-app-radio/raw/master/screenshot.png diff --git a/controller/settingscontroller.php b/controller/settingscontroller.php new file mode 100644 index 0000000..3fbb3a2 --- /dev/null +++ b/controller/settingscontroller.php @@ -0,0 +1,54 @@ +userId = $userId; + $this->appConfig = $appConfig; + } + + /** + * Save order for current user + * + * @NoAdminRequired + * @return array response + */ + public function getMenuState() { + $menu_state = $this->appConfig->getUserValue('menu_state', $this->userId); + $response = array( + 'status' => 'success', + 'data' => array('message' => 'User order saved successfully.'), + 'menu_state' => $menu_state + ); + return $response; + } + + /** + * Save order for current user + * + * @NoAdminRequired + * @param $menu_state string + * @return array response + */ + public function saveMenuState($menu_state) { + $this->appConfig->setUserValue('menu_state', $this->userId, $menu_state); + $response = array( + 'status' => 'success', + 'data' => array('message' => 'User order saved successfully.'), + 'menu_state' => $menu_state + ); + return $response; + } + +} diff --git a/service/configservice.php b/service/configservice.php new file mode 100644 index 0000000..e88d933 --- /dev/null +++ b/service/configservice.php @@ -0,0 +1,25 @@ +config = $config; + $this->appName = $appName; + } + + public function getUserValue($key, $userId) { + return $this->config->getUserValue($userId, $this->appName, $key); + } + + public function setUserValue($key, $userId, $value) { + $this->config->setUserValue($userId, $this->appName, $key, $value); + } + +}