Fix loading login json file

This commit is contained in:
Hadi Nategh 2021-04-29 18:22:38 +02:00
parent 39eef44217
commit faadfbdc23
2 changed files with 32 additions and 8 deletions

16
api/setup/login.json Normal file
View File

@ -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":""}
}
}

View File

@ -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 .= '<a class="app" href="'.htmlspecialchars($app['url']).'" title="'.htmlspecialchars(lang($app['title'])).'">'
.'<img src="'.htmlspecialchars($app['icon']).'"/><span>'.htmlspecialchars($app['desc']).'</span></a>';
foreach ($data['apps'] as $app)
{
$icon = strpos($app['icon'], "/") === 0 ? $GLOBALS['egw_info']['server']['webserver_url'].$app['icon'] : $app['icon'];
$nodes .= '<a class="app" href="'.htmlspecialchars($app['url']).'" title="'.htmlspecialchars(lang($app['title'])).'">'
.'<img src="'.htmlspecialchars($icon).'"/><span>'.htmlspecialchars($app['desc']).'</span></a>';
}
}
return $nodes;
}