From 8cbe61336bd6ae4eacdc1a3ee3a330ae4f03783c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 18 Feb 2019 08:35:10 +0100 Subject: [PATCH 1/3] Add public footer links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/AppInfo/Application.php | 2 +- lib/Controller/APIController.php | 2 ++ lib/SitesManager.php | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index 1832d977..b637d9b4 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -53,7 +53,7 @@ public function register() { */ public function registerNavigationEntries(IServerContainer $server, array $sites) { foreach ($sites as $id => $site) { - if ($site['type'] !== SitesManager::TYPE_LINK && $site['type'] !== SitesManager::TYPE_SETTING) { + if ($site['type'] !== SitesManager::TYPE_LINK && $site['type'] !== SitesManager::TYPE_SETTING && $site['type'] !== SitesManager::TYPE_LOGIN ) { continue; } diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index e16cc90f..f1915874 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -123,6 +123,8 @@ public function getAdmin() { ['type' => SitesManager::TYPE_LINK, 'name' => $this->l->t('Header')], ['type' => SitesManager::TYPE_SETTING, 'name' => $this->l->t('Setting menu')], ['type' => SitesManager::TYPE_QUOTA, 'name' => $this->l->t('User quota')], + ['type' => SitesManager::TYPE_LOGIN, 'name' => $this->l->t('Public footer')], + ]; $devices = [ diff --git a/lib/SitesManager.php b/lib/SitesManager.php index 1cee9132..dcb312b3 100644 --- a/lib/SitesManager.php +++ b/lib/SitesManager.php @@ -45,6 +45,7 @@ class SitesManager { const TYPE_LINK = 'link'; const TYPE_SETTING = 'settings'; const TYPE_QUOTA = 'quota'; + const TYPE_LOGIN = 'guest'; const DEVICE_ALL = ''; const DEVICE_ANDROID = 'android'; @@ -237,7 +238,7 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups } } - if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA], true)) { + if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, self::TYPE_LOGIN], true)) { throw new InvalidTypeException(); } @@ -326,7 +327,7 @@ public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array } } - if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA], true)) { + if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, self::TYPE_LOGIN], true)) { throw new InvalidTypeException(); } From bce6cdeaf64e59c77d70ad667c4e3781286eee63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Mon, 18 Feb 2019 09:14:01 +0100 Subject: [PATCH 2/3] Allow to add external guest links MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- js/admin.js | 8 ++++++++ lib/SitesManager.php | 14 +++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/js/admin.js b/js/admin.js index 19da3e19..2f5ea6c5 100644 --- a/js/admin.js +++ b/js/admin.js @@ -167,6 +167,9 @@ _.each(this._sites.models, function(site) { var $el = $(self._renderSite(site.attributes)); self._attachEvents($el); + if (site.attributes.type === 'guest') { + $el.find('.site-redirect-box').hide(); + } self.$list.append($el); }); }, @@ -232,6 +235,11 @@ $site.removeClass('failure saved').addClass('saving'); $site.find('.invalid-value').removeClass('invalid-value'); + if (data.type === 'guest') { + $site.find('.site-redirect-box').hide(); + } else { + $site.find('.site-redirect-box').show(); + } if (!_.isUndefined(site)) { site.save(data, { diff --git a/lib/SitesManager.php b/lib/SitesManager.php index dcb312b3..b70f1da6 100644 --- a/lib/SitesManager.php +++ b/lib/SitesManager.php @@ -35,6 +35,7 @@ use OCP\Files\SimpleFS\ISimpleFile; use OCP\IConfig; use OCP\IGroupManager; +use OCP\INavigationManager; use OCP\IRequest; use OCP\IUser; use OCP\IUserSession; @@ -45,7 +46,6 @@ class SitesManager { const TYPE_LINK = 'link'; const TYPE_SETTING = 'settings'; const TYPE_QUOTA = 'quota'; - const TYPE_LOGIN = 'guest'; const DEVICE_ALL = ''; const DEVICE_ANDROID = 'android'; @@ -238,7 +238,7 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups } } - if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, self::TYPE_LOGIN], true)) { + if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, INavigationManager::TYPE_GUEST], true)) { throw new InvalidTypeException(); } @@ -260,6 +260,10 @@ public function addSite($name, $url, $lang, $type, $device, $icon, array $groups throw new IconNotFoundException(); } + if ($type === INavigationManager::TYPE_GUEST) { + $redirect = true; + } + $sites = $this->getSites(); $sites[$id] = [ 'id' => $id, @@ -327,7 +331,7 @@ public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array } } - if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, self::TYPE_LOGIN], true)) { + if (!in_array($type, [self::TYPE_LINK, self::TYPE_SETTING, self::TYPE_QUOTA, INavigationManager::TYPE_GUEST], true)) { throw new InvalidTypeException(); } @@ -349,6 +353,10 @@ public function updateSite($id, $name, $url, $lang, $type, $device, $icon, array throw new IconNotFoundException(); } + if ($type === INavigationManager::TYPE_GUEST) { + $redirect = true; + } + $sites[$id] = [ 'id' => $id, 'name' => $name, From 44b09b44b5e6f626ef85b03fdea52a8c7715b12f Mon Sep 17 00:00:00 2001 From: Joas Schilling <213943+nickvergessen@users.noreply.github.com> Date: Mon, 18 Feb 2019 11:29:25 +0100 Subject: [PATCH 3/3] Update lib/Controller/APIController.php MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl Co-Authored-By: juliushaertl --- lib/Controller/APIController.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Controller/APIController.php b/lib/Controller/APIController.php index f1915874..194cd3bc 100644 --- a/lib/Controller/APIController.php +++ b/lib/Controller/APIController.php @@ -124,7 +124,6 @@ public function getAdmin() { ['type' => SitesManager::TYPE_SETTING, 'name' => $this->l->t('Setting menu')], ['type' => SitesManager::TYPE_QUOTA, 'name' => $this->l->t('User quota')], ['type' => SitesManager::TYPE_LOGIN, 'name' => $this->l->t('Public footer')], - ]; $devices = [