From faadfbdc236653196fd9a00d409f283845991afc Mon Sep 17 00:00:00 2001 From: Hadi Nategh Date: Thu, 29 Apr 2021 18:22:38 +0200 Subject: [PATCH] Fix loading login json file --- api/setup/login.json | 16 ++++++++++++++++ api/src/Framework/Login.php | 24 ++++++++++++++++-------- 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 api/setup/login.json diff --git a/api/setup/login.json b/api/setup/login.json new file mode 100644 index 0000000000..7b5c08fe42 --- /dev/null +++ b/api/setup/login.json @@ -0,0 +1,16 @@ +{ + "apps": { + "admin": {"title":"Admin","icon":"/admin/templates/pixelegg/images/navbar.svg","desc":""}, + "mail": {"title":"Mail","icon":"/mail/templates/pixelegg/images/navbar.svg","desc":""}, + "kanban": {"title":"Kanban","icon":"/kanban/templates/default/images/navbar.svg","desc":""}, + "timesheet": {"title":"Timesheet","icon":"/timesheet/templates/pixelegg/images/navbar.svg","desc":""}, + "calendar": {"title":"Calendar","icon":"/calendar/templates/pixelegg/images/navbar.svg","desc":""}, + "smallpart": {"title":"SmallPart","icon":"/smallpart/templates/default/images/navbar.svg","desc":""}, + "infolog": {"title":"Infolog","icon":"/infolog/templates/pixelegg/images/navbar.svg","desc":""}, + "tracker": {"title":"Tracker","icon":"/tracker/templates/pixelegg/images/navbar.svg","desc":""}, + "rocketchat": {"title":"Rocket.Chat","icon":"/rocketchat/templates/default/images/navbar.svg","desc":""}, + "videoconference": {"title":"Videoconference","icon":"/status/templates/pixelegg/images/videoconference.svg","desc":""}, + "addressbook": {"title":"Addressbook","icon":"/addressbook/templates/pixelegg/images/navbar.svg","desc":""}, + "projectmanager": {"title":"Projectmanager","icon":"/projectmanager/templates/pixelegg/images/navbar.svg","desc":""} + } +} diff --git a/api/src/Framework/Login.php b/api/src/Framework/Login.php index 173bb942d4..d9723cf511 100644 --- a/api/src/Framework/Login.php +++ b/api/src/Framework/Login.php @@ -304,17 +304,25 @@ class Login */ static function get_apps_node() { - $object = json_decode(file_get_contents('https://laklak.egroupware.org/egroupware/login_feed.json'), true); - $apps = []; //TODO: set what we want to dispaly for instances with no access to outside - $nodes = ''; - if (is_array($object)) + if (!($json = Api\Cache::getCache(Api\Cache::TREE, __CLASS__, 'egw_login_json'))) { - $apps = (is_array($object['apps'])) ? $object['apps'] : $apps; + $json = file_get_contents('https://www.egroupware.org/egw_login_feed.json', + false, Api\Framework::proxy_context()); + // Fallback login.json + if (!$json) $json = file_get_contents('api/setup/login.json'); + // Cache the json object for a day + Api\Cache::setCache(Api\Cache::TREE, __CLASS__, 'egw_login_json', $json, 86400); } - foreach ($apps as $app) + $data = json_decode($json, true); + $nodes = ''; + if (is_array($data)) { - $nodes .= '' - .''.htmlspecialchars($app['desc']).''; + foreach ($data['apps'] as $app) + { + $icon = strpos($app['icon'], "/") === 0 ? $GLOBALS['egw_info']['server']['webserver_url'].$app['icon'] : $app['icon']; + $nodes .= '' + .''.htmlspecialchars($app['desc']).''; + } } return $nodes; }