Пример #1
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     // Kill "login" process if any
     $PM = ProcManager::getInstance();
     $procList = $PM->getProcessesTable();
     foreach ($procList as $proc) {
         switch ($proc->getName()) {
             case 'init':
                 break;
             case 'session':
                 break;
             default:
                 try {
                     $PM->kill($proc);
                 } catch (Exception $e) {
                     Logger::getLogger('eyeosmobile.session')->warn('Cannot kill login process ' . $proc . ': ' . $e->getMessage());
                 }
                 break;
         }
     }
     $args = $context->getArgs();
     // User information (cached in eyeos.js)
     $args[0] = EyeosApplicationExecutable::__callModule('UserInfo', 'getCurrentUserInfo', array());
     // Initial application(s) to launch (= static list $initApps excluding already running processes)
     //		$procList = ProcManager::getInstance()->getProcessesList();
     //$args[1] = array_diff(self::$initApps, $procList);
     //        $args[1] = array_values(array_diff(self::$initApps, $procList));
     //For the moment we just restore init application
     $args[1] = self::$initApps;
 }
Пример #2
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $meta = MetaManager::getInstance()->retrieveMeta(kernel::getInstance('SecurityManager'))->getAll();
     if (isset($meta['register']) && $meta['register'] == 'false') {
         $currentProc = ProcManager::getInstance()->getCurrentProcess();
         ProcManager::getInstance()->kill($currentProc);
         $context->setExecuteJavascript(false);
     }
 }
Пример #3
0
 /**
  * eyeDocs program entrypoint
  *
  * @author        Jordi Rubio
  * @access        public
  * @package       eyeDocs
  * @param         AppExecutionContext    $context
  * @param         MMapResponse           $response
  * @since         1.0
  */
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     self::singleInstanceCheck();
     if ($context->getIncludeBody()) {
         self::insertNeededJS($response);
     }
     //ExecModule::registerCallback('changesOnFile', $_SERVER['SCRIPT_NAME']);
     $myCometManager = new CometManager();
     $myCometManager->registerCallback('DocumentsApplication::reciveMessagesFromNetSync', __FILE__);
 }
Пример #4
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $myMemoryManager = MemoryManager::getInstance();
     Kernel::enterSystemMode();
     $isExternLogin = $myMemoryManager->get('isExternLogin');
     $loginPage = $myMemoryManager->get('loginPage');
     Kernel::exitSystemMode();
     $context->getArgs()->append($isExternLogin);
     if ($isExternLogin) {
         $context->getArgs()->append($loginPage);
     }
 }
Пример #5
0
 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);
 }
Пример #6
0
 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);
 }
Пример #7
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     //if ($context->getIncludeBody()) {
     $buffer = '';
     $itemsPath = EYE_ROOT . '/' . APPS_DIR . '/viewer/library';
     $dir = new DirectoryIterator($itemsPath);
     foreach ($dir as $file) {
         $fileName = $file->getBasename();
         if (!$file->isDot() && $fileName[0] != '.' && strchr($fileName, '.js')) {
             $buffer .= file_get_contents($itemsPath . '/' . $fileName);
         }
     }
     $response->appendToBody($buffer);
     //}
     $instance = MemoryManager::getInstance();
     $instance->set('playList', $context->getArgs()->getArrayCopy());
 }
Пример #8
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $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')));
             }
         }
     }
     $args = $context->getArgs();
     $args[0] = $applications;
 }
Пример #9
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $memoryManager = MemoryManager::getInstance();
     Kernel::enterSystemMode();
     $isExternLogin = $memoryManager->get('isExternLogin');
     Kernel::exitSystemMode();
     $list = new ArrayList();
     $list->append($isExternLogin);
     if ($isExternLogin) {
         Kernel::enterSystemMode();
         $username = $memoryManager->get('username');
         $password = $memoryManager->get('password');
         Kernel::exitSystemMode();
         $list->append($username);
         $list->append($password);
     }
     $context->setArgs($list);
     $response->appendToBody('eyeos.isRegisterActive=' . self::isRegisterActive() . ';');
 }
Пример #10
0
 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);
     }
 }
Пример #11
0
 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);
 }
Пример #12
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $args = $context->getArgs();
     if (!isset($args[0]) || !is_string($args[0])) {
         throw new EyeMissingArgumentException('Missing filename to open.');
     }
     try {
         $file = FSI::getFile($args[0]);
     } catch (Exception $e) {
         throw new EyeInvalidArgumentException('args[0] must be a valid path to a file.', 0, $e);
     }
     $appName = false;
     if ($file->isDirectory()) {
         $appName = 'files';
     } else {
         $extension = utf8_strtolower($file->getExtension());
         // TODO: Currently hard-coded here but in the future associations will be read from a DB.
         // We must have general entries, common to all the users of the system, that will be used
         // as default, and then user-customized entries with a higher priority on the general ones.
         switch ($extension) {
             //
             //	VIEWER
             //
             case 'jpg':
             case 'gif':
             case 'jpeg':
             case 'png':
             case 'htm':
             case 'html':
             case 'flv':
             case 'm4a':
             case 'mp3':
                 $appName = 'viewer';
                 break;
                 //
                 //	EDITOR
                 //
             //
             //	EDITOR
             //
             case 'txt':
             case 'xml':
             case 'ini':
             case 'js':
             case 'sql':
             case 'log':
                 $appName = 'femto';
                 break;
         }
     }
     // Association found: execute matching application
     if ($appName) {
         $myProcess = ProcManager::getInstance()->getCurrentProcess();
         // prepare context and execute application
         $currentAppDesc = new EyeosApplicationDescriptor($appName);
         $appContext = new AppExecutionContext();
         $appContext->setParentProcess($myProcess);
         $appContext->setApplicationDescriptor($currentAppDesc);
         $appContext->setArgs(clone $args);
         MMapGetApp::getInstance()->processRequest(MMapManager::getCurrentRequest(), $response, $appContext);
         // Kill our process
         $context->setExecuteJavascript(false);
         ProcManager::getInstance()->kill($myProcess);
         return;
     }
     // Otherwise, show the OpenWith dialog
 }
Пример #13
0
 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;
 }
Пример #14
0
 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;
             }
         }
     }
 }
Пример #15
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     //DEBUG
     $context->setIncludeBody(true);
     $response->appendToBody(file_get_contents('./extern/js/eyeos/ui/widgets/TextArea.js'));
 }
Пример #16
0
 private static function startLogin(MMapResponse $response)
 {
     // start Process
     $loginProcess = new Process('login');
     ProcManager::getInstance()->execute($loginProcess);
     // prepare context and execute application
     $loginAppDesc = new EyeosApplicationDescriptor('login');
     $appContext = new AppExecutionContext();
     $appContext->setApplicationDescriptor($loginAppDesc);
     $appContext->setIncludeBody(true);
     $appContext->setProcess($loginProcess);
     MMapGetApp::getInstance()->processRequest(MMapManager::getCurrentRequest(), $response, $appContext);
 }