public static function __run(AppExecutionContext $context, MMapResponse $response) { $currentUser = $context->getProcess()->getLoginContext()->getEyeosUser(); $groups = UMManager::getInstance()->getAllGroupsByPrincipal($currentUser); $isAdmin = 0; if ($currentUser->getPrimaryGroupId() == 'eyeID_EyeosGroup_root' || $currentUser->getPrimaryGroupId() == 'eyeID_EyeosGroup_admin') { $isAdmin = 1; } else { foreach ($groups as $group) { if ($group->getId() == 'eyeID_EyeosGroup_admin') { $isAdmin = 1; } } } $context->getArgs()->offsetSet(0, $isAdmin); //get the applications $myApplicationsManager = new EyeosApplicationsManager(); $applications = $myApplicationsManager->getAllApplications(); $return = array(); foreach ($applications as $appDesc) { $appMeta = $appDesc->getMeta(); $systemParameters = $appMeta->get('eyeos.application.systemParameters'); $currentApplicationGroup = 'eyeID_EyeosGroup_' . $systemParameters['group']; $currentUserGroup = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getPrimaryGroupId(); if ($currentUserGroup == 'eyeID_EyeosGroup_users' && $currentApplicationGroup == 'eyeID_EyeosGroup_users' || $currentUserGroup != 'eyeID_EyeosGroup_users') { $sysParams = $appMeta->get('eyeos.application.systemParameters'); $imagePath = $appMeta->get('eyeos.application.iconUrl'); $imageIsValid = true; $imagePath = str_replace('48x48', '22x22', $imagePath); $imagePath = str_replace('64x64', '22x22', $imagePath); try { $file = FSI::getFile($imagePath); } catch (Exception $e) { $imageIsValid = false; } if ($imageIsValid && !$file->isReadable()) { $imageIsValid = false; } if (!$imageIsValid) { $imagePath = 'sys:///extern/images/22x22/apps/preferences-desktop-default-applications.png'; } $return[] = array('name' => $appDesc->getName(), 'displayName' => $appMeta->get('eyeos.application.name') !== null ? $appMeta->get('eyeos.application.name') : $appDesc->getName(), 'app' => $appDesc->getName(), 'shortDescription' => $appMeta->get('eyeos.application.description'), 'image' => FSI::toExternalUrl($imagePath), 'favorite' => $myApplicationsManager->isApplicationFavorite($appDesc) ? 1 : 0, 'lists' => $appMeta->get('eyeos.application.category'), 'listable' => $sysParams['listable'] == 'true' ? 1 : 0); } } $context->getArgs()->offsetSet(1, $return); }
public static function getAllInstalledApplications($params) { $myApplicationsManager = new EyeosApplicationsManager(); $applications = $myApplicationsManager->getAllInstalledApplications($params); $return = array(); foreach ($applications as $appDesc) { $appMeta = $appDesc->getMeta(); $sysParams = $appMeta->get('eyeos.application.systemParameters'); $imagePath = $appMeta->get('eyeos.application.iconUrl'); $imageIsValid = true; try { $file = FSI::getFile($imagePath); } catch (Exception $e) { $imageIsValid = false; } if ($imageIsValid && !$file->isReadable()) { $imageIsValid = false; } if (!$imageIsValid) { $imagePath = 'sys:///extern/images/48x48/apps/preferences-desktop-default-applications.png'; } $return[] = array('name' => $appDesc->getName(), 'displayName' => $appMeta->get('eyeos.application.name') !== null ? $appMeta->get('eyeos.application.name') : $appDesc->getName(), 'app' => $appDesc->getName(), 'shortDescription' => $appMeta->get('eyeos.application.description'), 'image' => FSI::toExternalUrl($imagePath), 'favorite' => $myApplicationsManager->isApplicationFavorite($appDesc) ? true : false, 'lists' => $appMeta->get('eyeos.application.category'), 'listable' => $sysParams['listable'] == 'true' ? 1 : 0, 'installed' => $myApplicationsManager->isApplicationInstalled($appDesc) ? true : false); } return $return; }