コード例 #1
0
ファイル: toptabs.php プロジェクト: DavidGarciaCat/eyeos
 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);
 }
コード例 #2
0
ファイル: topmenu.php プロジェクト: DavidGarciaCat/eyeos
 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);
 }
コード例 #3
0
ファイル: desktop.php プロジェクト: DavidGarciaCat/eyeos
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $currentUser = $context->getProcess()->getLoginContext()->getEyeosUser();
     $files = EyeosApplicationExecutable::__callModule('FileSystem', 'browsePath', array('home:///Desktop/', null, null));
     $context->getArgs()->offsetSet(0, $currentUser->getName());
     $context->getArgs()->offsetSet(1, $files);
     if ($context->getIncludeBody()) {
         $buffer = '';
         $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/desktop/';
         $buffer .= file_get_contents($itemsPath . '/desktop.WidgetManager.js');
         $buffer .= file_get_contents($itemsPath . '/desktop.SelectionManager.js');
         $buffer .= file_get_contents($itemsPath . '/desktop.actionManager.js');
         $buffer .= file_get_contents($itemsPath . '/desktop.chatManager.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.events.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.favorites.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.files.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.groups.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.notes.js');
         $buffer .= file_get_contents($itemsPath . '/widgets/desktop.widget.desktop.js');
         $response->appendToBody($buffer);
     }
 }
コード例 #4
0
ファイル: taskbar.php プロジェクト: DavidGarciaCat/eyeos
 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);
     $eventManager = new EventNotificationManager();
     $from = 0;
     $to = 1000;
     $result = $eventManager->getAllQuestionEvents($from, $to);
     $result = self::toArray($result);
     $context->getArgs()->offsetSet(1, $result);
 }
コード例 #5
0
ファイル: interfaces.php プロジェクト: DavidGarciaCat/eyeos
 private function loadTranslations(AppExecutionContext $context, MMapResponse $response)
 {
     $buffer = '';
     if ($context->getProcess()->getLoginContext() !== null) {
         try {
             // Load the translations only if running as a regular (non-system) user
             $procGroup = $context->getProcess()->getLoginContext()->getEyeosGroup();
             if ($procGroup->getName() != 'sys') {
                 $currentUser = $context->getProcess()->getLoginContext()->getEyeosUser();
                 $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
                 if ($settings->exists('eyeos.user.language')) {
                     $lang = basename($settings->get('eyeos.user.language'));
                     if (is_dir($this->getPath() . '/lang/' . $lang . '/')) {
                         $directory = new DirectoryIterator($this->getPath() . '/lang/' . $lang . '/');
                         foreach ($directory as $fileInfo) {
                             if ($fileInfo->isFile()) {
                                 $buffer .= file_get_contents($this->getPath() . '/lang/' . $lang . '/' . $fileInfo->getFilename());
                             }
                         }
                     }
                 }
             }
         } catch (EyeNullPointerException $e) {
             // No user in login context: skip translations
         }
     }
     return $buffer;
 }
コード例 #6
0
ファイル: MMapGetApp.php プロジェクト: DavidGarciaCat/eyeos
 private function startProcess(AppExecutionContext $appContext)
 {
     $appProcess = $appContext->getProcess();
     // if no process is already present in the context, create a new one
     if ($appProcess === null) {
         $appMeta = $appContext->getApplicationDescriptor()->getMeta();
         if ($appMeta === null) {
             throw new EyeNullPointerException('Missing metadata for application "' . $appContext->getApplicationDescriptor()->getName() . '"');
         }
         $sysParams = $appMeta->get('eyeos.application.systemParameters');
         if ($appContext->getParentProcess() === null) {
             // TODO should we also prevent anonymous execution to JS-only apps?
             if (!isset($sysParams['anonymous']) || $sysParams['anonymous'] != 'true') {
                 self::$Logger->warn('Execution without checknum denied for application "' . $appContext->getApplicationDescriptor()->getName() . '".');
                 throw new EyeMMapException($appContext->getApplicationDescriptor()->getName() . ' application cannot be executed without a checknum.');
             }
         }
         // execute new process
         $appProcess = new Process($appContext->getApplicationDescriptor()->getName());
         ProcManager::getInstance()->execute($appProcess);
         $appContext->setProcess($appProcess);
         // SUID
         if (isset($sysParams['suid']) && $sysParams['suid'] == 'true' && !empty($sysParams['owner'])) {
             try {
                 $owner = UMManager::getInstance()->getUserByName($sysParams['owner']);
                 // force login with owner
                 try {
                     $subject = new Subject();
                     $subject->getPrivateCredentials()->append(new EyeosPasswordCredential($sysParams['owner'], $owner->getPassword(), false));
                     $loginContext = new LoginContext('eyeos-login', $subject);
                     $loginContext->login();
                 } catch (Exception $e) {
                     self::$Logger->error('Exception caught while trying to elevate privileges by SUID to owner ' . $sysParams['owner'] . ' in application "' . $appContext->getApplicationDescriptor()->getName() . '".');
                     // kill unfinished process
                     ProcManager::getInstance()->kill($appContext->getProcess());
                     throw $e;
                 }
                 if (self::$Logger->isInfoEnabled()) {
                     self::$Logger->info('Privileges elevation successful with owner ' . $sysParams['owner'] . ' for application "' . $appContext->getApplicationDescriptor()->getName() . '".');
                 }
                 ProcManager::getInstance()->setProcessLoginContext($appProcess->getPid(), $loginContext);
             } catch (Exception $e) {
                 self::$Logger->error('Cannot elevate privileges with owner ' . $sysParams['owner'] . ' for application "' . $appContext->getApplicationDescriptor()->getName() . '".');
                 throw $e;
             }
         }
     }
 }