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); }
function getAllMobileApplications() { $directory = new DirectoryIterator(EYE_ROOT . '/' . APPS_DIR); $applications = array(); foreach ($directory as $fileInfo) { $fileInfoName = $fileInfo->getFilename(); $mobilePath = EYE_ROOT . '/' . APPS_DIR . '/' . $fileInfo->getFilename() . '/mobile'; if ($fileInfo->isDir() && $fileInfoName[0] != '.' && is_dir($mobilePath)) { $appDesc = new EyeMobileApplicationDescriptor($fileInfoName); $appMeta = $appDesc->getMeta(); $sysParams = $appMeta->get('eyeos.application.systemParameters'); if ($sysParams['listable'] == 'true') { $applications[] = array('name' => $appDesc->getName(), 'displayName' => $appMeta->get('eyeos.application.name') !== null ? $appMeta->get('eyeos.application.name') : $appDesc->getName(), 'description' => $appMeta->get('eyeos.application.description'), 'image' => FSI::toExternalUrl($appMeta->get('eyeos.application.iconUrl'))); } } } return $applications; }
public static function createLink($params) { $structure = array(); $structure['app'] = $params[0]; $structure['type'] = 'application'; //we need to fill $structure['icon'] with the application icon! $app = new EyeosApplicationDescriptor(utf8_basename($params[0])); $icon = FSI::toExternalUrl($app->getMeta()->get('eyeos.application.iconUrl')); $structure['icon'] = str_replace('eyeos/extern/', 'index.php?extern=', $icon); $linkName = utf8_basename($params[0]); $info = pathinfo($linkName); if (!isset($info['extension']) || $info['extension'] != 'lnk') { $linkName .= '.lnk'; } $path = 'home:///Desktop/'; $text = json_encode($structure); $newFile = FSI::getFile($path . '/' . $linkName); $newFile->createNewFile(); $newFile->putContents($text); $newfile = FSI::getFile($path . '/' . $linkName); $meta = $newfile->getMeta(); $meta->set('iconPositionX', $params[1]); $meta->set('iconPositionY', $params[2]); $newfile->setMeta($meta); $return = array('class' => get_class($newfile), 'type' => $newfile->isDirectory() ? 'folder' : ($newfile->isLink() ? 'link' : 'file'), 'extension' => utf8_strtoupper($newfile->getExtension()), 'size' => $newfile->isDirectory() ? 0 : $newfile->getSize(), 'permissions' => $newfile->getPermissions(false), 'owner' => $newfile->getOwner(), 'group' => $newfile->getGroup(), 'absolutepath' => $newfile->getAbsolutePath(), 'meta' => $newfile->getMeta()->getAll()); if ($return['extension'] == 'LNK') { $return['content'] = $newfile->getContents(); } $return['name'] = $newfile->getName() != '/' ? $newfile->getName() : $return['absolutepath']; if ($newfile instanceof EyeosAbstractVirtualFile) { $return['virtual'] = 'true'; } else { $return['virtual'] = 'false'; } return $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; }
/** * * @return [ * { * name: ..., * javascriptOnly: "true"/"false", * meta: {Map} * }, * ... * ] */ public static function getAllInstalledApplications() { $myApplicationsManager = new EyeosApplicationsManager(); $applications = $myApplicationsManager->getAllInstalledApplications(); $return = array(); foreach ($applications as $appDesc) { $jsonAppDesc = self::toArray($appDesc); // Translate icon URL to enable caching if (isset($jsonAppDesc['meta']['eyeos.application.iconUrl'])) { $extUrl = FSI::toExternalUrl($jsonAppDesc['meta']['eyeos.application.iconUrl']); if ($extUrl) { $jsonAppDesc['meta']['eyeos.application.iconUrl'] = $extUrl; } } $sysParams = $jsonAppDesc['meta']['eyeos.application.systemParameters']; if ($sysParams['listable'] == 'true') { $return[] = $jsonAppDesc; } } return $return; }