Exemple #1
0
 public static function createLink($params)
 {
     $structure = array();
     $structure['url'] = $params[0];
     $structure['width'] = $params[1];
     $structure['height'] = $params[2];
     $structure['icon'] = str_replace('eyeos/extern/', 'index.php?extern=', $params[5]);
     $structure['openInNewWindow'] = $params[6];
     $structure['type'] = 'web';
     $linkName = utf8_basename($params[3]);
     $info = pathinfo($linkName);
     if (!isset($info['extension']) || $info['extension'] != 'lnk') {
         $linkName .= '.lnk';
     }
     $path = $params[4];
     $text = json_encode($structure);
     $linkName = str_replace('?', '_', $linkName);
     $linkName = str_replace('#', '_', $linkName);
     $newFile = FSI::getFile($path . '/' . $linkName);
     $newFile->createNewFile();
     $newFile->putContents($text);
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $settings = MetaManager::getInstance()->retrieveMeta($currentUser);
     //TODO: better message?
     $message = new ClientBusMessage('file', 'uploadComplete', self::getFileInfo($newFile, $settings));
     ClientMessageBusController::getInstance()->queueMessage($message);
 }
Exemple #2
0
 /**
  * Returns the current process name.
  *
  * @return string
  */
 public function getValue()
 {
     $procManager = ProcManager::getInstance();
     $proc = new Process();
     $procManager->getCurrentProcess($proc);
     return $user->getName();
 }
 public function unsubscribe($channel)
 {
     $myProcManager = ProcManager::getInstance();
     $username = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $subscriptionProvider = new SqlSubscriptionProvider();
     return $subscriptionProvider->unsubscribe($username, $channel);
 }
Exemple #4
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;
 }
 /**
  * subscribe to a channel
  *
  * @access        public
  * @param         string     $channel    channel to subscribe
  * @return        boolean    return true on success
  * @todo          mockup function
  */
 public function subscribe($params)
 {
     //@todo filter $channel and $password
     $username = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     // exists channel?
     if (empty($params['channel'])) {
         return false;
     }
     //check to see if trying to join a user channel
     //and deny it
     if (substr($params['channel'], 0, strlen('eyeID_EyeosUser_')) == 'eyeID_EyeosUser_') {
         return false;
     }
     // exists password?
     if (empty($params['password'])) {
         $params['password'] = null;
     }
     // bypass pressence channel password
     if (0 == strcmp('pressence', $params['channel'])) {
         $params['password'] = null;
     }
     // trying to register userchannel?
     if (0 == strcmp(USERCHANNEL_PREFIX . "userchannel", $params['channel'])) {
         $params['channel'] = $username;
     }
     // finaly register any public channel
     return $this->_subscribe($params['channel'], $params['password']);
 }
 public function getAccounts()
 {
     $userid = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $myTO = new mailaccounts();
     $myTO->setUserid($userid);
     return $this->dao->search($myTO);
 }
Exemple #7
0
 /**
  * Notify all contact that the user goes offline and remove subscriptions to NetSync channels
  */
 private function markOffline()
 {
     $procList = ProcManager::getInstance()->getProcessesList();
     foreach ($procList as $pid => $proc) {
         if ($proc == 'session') {
             $userId = ProcManager::getInstance()->getProcessByPid($pid)->getLoginContext()->getEyeosUser()->getId();
         }
     }
     if (!$userId) {
         return;
     }
     $subscriptionProvider = new SqlSubscriptionProvider();
     // Notify to all Contacts that the user goes offline
     $contacts = PeopleController::getInstance()->getAllContacts($userId);
     $ids = array();
     $myCometSender = new CometSenderLongPolling();
     foreach ($contacts as $contact) {
         $id = $contact->getRelation()->getSourceId();
         if ($id == $userId) {
             $id = $contact->getRelation()->getTargetId();
         }
         $message = new NetSyncMessage('status', 'offline', $id, $userId);
         $myCometSender->send($message);
     }
     // Remove Subscriptions to NetSync channels
     $subscriptionProvider->removeAllSubscriptions($userId);
 }
 /**
  * @param string $internalUrl
  * @return mixed The URL to access the target file from outside, if available, or FALSE.
  */
 public static function toExternalUrl($internalUrl)
 {
     $currentProc = ProcManager::getInstance()->getCurrentProcess();
     if ($currentProc) {
         $checknum = $currentProc->getChecknum();
     } else {
         $checknum = -1;
     }
     $urlParts = AdvancedPathLib::parse_url($internalUrl);
     if ($urlParts === false) {
         return $internalUrl;
     }
     if ($urlParts['scheme'] === EyeosAbstractVirtualFile::URL_SCHEME_SYSTEM) {
         // EXTERN
         try {
             $externPath = AdvancedPathLib::resolvePath($urlParts['path'], '/extern', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             return 'index.php?extern=' . $externPath;
         } catch (Exception $e) {
         }
         // APPS
         try {
             $appPath = AdvancedPathLib::resolvePath($urlParts['path'], '/apps', AdvancedPathLib::OS_UNIX | AdvancedPathLib::RESOLVEPATH_RETURN_REFDIR_RELATIVE);
             $appName = utf8_substr($appPath, 1, utf8_strpos($appPath, '/', 1));
             $appFile = utf8_substr($appPath, utf8_strlen($appName) + 1);
             return 'index.php?checknum=' . $checknum . '&appName=' . $appName . '&appFile=' . $appFile;
         } catch (Exception $e) {
         }
         return $internalUrl;
     }
     //TODO
     return $internalUrl;
 }
 public static function close($params)
 {
     //clean the memory
     MemoryManager::getInstance()->free();
     $myProcManager = ProcManager::getInstance();
     $myProcess = $myProcManager->getCurrentProcess();
     $myProcManager->kill($myProcess);
 }
 /**
  * Gets the pid of the current process.
  *
  * @return int
  */
 private static function getCurrentPid()
 {
     if (Kernel::inSystemMode()) {
         return 0;
     }
     $process = ProcManager::getInstance()->getCurrentProcess();
     return $process->getPid();
 }
 /**
  * Kills the process defined by the given PID.
  * 
  * @param array $params(
  * 		'pid' => pid
  * )
  */
 public function killProcess($params)
 {
     if (!isset($params['pid']) || !is_numeric($params['pid'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $params[\'pid\'].');
     }
     $proc = ProcManager::getInstance()->getProcessByPid($params['pid']);
     ProcManager::getInstance()->kill($proc);
 }
 public static function close()
 {
     $currentUserId = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $presence = new Presence();
     $presence->setUserId($currentUserId);
     $presenceManager = new PresenceManager();
     $presenceManager->close($presence);
 }
 public function contactDeleted(PeopleEvent $e)
 {
     $sourceId = $e->getSource()->getRelation()->getSourceId();
     $targetId = $e->getSource()->getRelation()->getTargetId();
     $currentUserId = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $otherUser = $sourceId == $currentUserId ? $targetId : $sourceId;
     $NetSyncMessage = new NetSyncMessage('NSPeople', 'deleteContact', $otherUser, $currentUserId);
     NetSyncController::getInstance()->send($NetSyncMessage);
 }
 public function tearDown()
 {
     try {
         ProcManager::getInstance()->kill(ProcManager::getInstance()->getProcessByPid(self::$MyProcPid));
     } catch (EyeProcException $e) {
     }
     ProcManager::getInstance()->setCurrentProcess(self::$InitProcessToRestore);
     UMManager::getInstance()->deletePrincipal(UMManager::getInstance()->getUserById($this->idUser));
     UMManager::getInstance()->deletePrincipal(UMManager::getInstance()->getGroupById($this->idGroup));
 }
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     $oauth_verifier = null;
     $oauth_token = null;
     if ($request->issetGET('oauth_verifier')) {
         $oauth_verifier = $request->getGET('oauth_verifier');
     }
     if ($request->issetGET('oauth_token')) {
         $oauth_token = $request->getGET('oauth_token');
     }
     if ($oauth_verifier && $oauth_token) {
         $response->getHeaders()->append('Content-type: text/html');
         $body = '<html>
                         <div id="logo_eyeos" style="margin: 0 auto;width:350"> <img src="eyeos/extern/images/logo-eyeos.jpg"/></div>
                         <div style="margin: 0 auto;width:350;text-align:center"><span style="font-family:Verdana;font-size:20px;">Successful authentication.<br>Back to Eyeos.</span></div>
                  </html>';
         $response->getHeaders()->append('Content-Length: ' . strlen($body));
         $response->getHeaders()->append('Accept-Ranges: bytes');
         $response->getHeaders()->append('X-Pad: avoid browser bug');
         $response->getHeaders()->append('Cache-Control: ');
         $response->getHeaders()->append('pragma: ');
         $response->setBody($body);
         try {
             $userRoot = UMManager::getInstance()->getUserByName('root');
         } catch (EyeNoSuchUserException $e) {
             throw new EyeFailedLoginException('Unknown user root"' . '". Cannot proceed to login.', 0, $e);
         }
         $subject = new Subject();
         $loginContext = new LoginContext('eyeos-login', $subject);
         $cred = new EyeosPasswordCredential();
         $cred->setUsername('root');
         $cred->setPassword($userRoot->getPassword(), false);
         $subject->getPrivateCredentials()->append($cred);
         $loginContext->login();
         Kernel::enterSystemMode();
         $appProcess = new Process('stacksync');
         $appProcess->setPid('31338');
         $mem = MemoryManager::getInstance();
         $processTable = $mem->get('processTable', array());
         $processTable[31338] = $appProcess;
         $mem->set('processTable', $processTable);
         $appProcess->setLoginContext($loginContext);
         ProcManager::getInstance()->setCurrentProcess($appProcess);
         kernel::exitSystemMode();
         $token = new stdClass();
         $token->oauth_verifier = $oauth_verifier;
         $token->oauth_token = $oauth_token;
         $group = UMManager::getInstance()->getGroupByName('users');
         $users = UMManager::getInstance()->getAllUsersFromGroup($group);
         foreach ($users as $user) {
             $NetSyncMessage = new NetSyncMessage('cloud', 'token', $user->getId(), $token);
             NetSyncController::getInstance()->send($NetSyncMessage);
         }
     }
 }
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     MMapManager::startSession();
     //check if the session has expired
     MMapManager::checkSessionExpiration();
     $return = null;
     $dataManager = DataManager::getInstance();
     // restore current process using checknum
     $myProcManager = ProcManager::getInstance();
     $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum'));
     $myProcManager->setCurrentProcess($myProcess);
     $appDesc = new EyeMobileApplicationDescriptor($myProcess->getName());
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     $methodName = $request->getGET('message');
     // calling an ExecModule
     if (strpos($methodName, '__') === 0) {
         $moduleName = explode('_', substr($methodName, 2));
         $methodName = $moduleName[1];
         //ex: "FileChooser"
         $moduleName = $moduleName[0];
         //ex: "browsePath"
         $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params));
     } else {
         if ($appDesc->isJavascriptOnlyApplication()) {
             $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params);
         } else {
             if (method_exists($appDesc->getApplicationClassName(), $methodName)) {
                 $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
             } else {
                 //If no function is present, call the NOT mobile function
                 MMapMsg::getInstance()->processRequest($request, $response);
                 return;
             }
             //				try {
             //					$return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
             //				} catch (Exception $e) {
             //					//If no function is present, call the NOT mobile function
             //					MMapMsg::getInstance()->processRequest($request, $response);
             //					return;
             //				}
         }
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
Exemple #17
0
 public function testSetLoginContext()
 {
     $this->fixture = new Process('example');
     ProcManager::getInstance()->execute($this->fixture);
     $newLoginContext = new LoginContext('example', new Subject(), $this->config);
     $this->assertEquals($this->loginContext, $this->fixture->getLoginContext());
     $this->assertNotEquals($newLoginContext, $this->fixture->getLoginContext());
     $this->fixture->setLoginContext($newLoginContext);
     $this->assertNotEquals($this->loginContext, $this->fixture->getLoginContext());
     $this->assertEquals($newLoginContext, $this->fixture->getLoginContext());
 }
Exemple #18
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
     $meta = MetaManager::getInstance()->retrieveMeta($currentUser);
     //		Every time this Application its executed, put a metadata for not show any more time in init,
     //		maybe its interesting to put it only if not exist, like that, not working for now
     //		if(!array_key_exists('eyeos.user.desktop.showWelcome', $meta)) {
     $meta->set('eyeos.user.desktop.showWelcome', 'false');
     //		}
     MetaManager::getInstance()->storeMeta($currentUser, $meta);
 }
Exemple #19
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     MMapManager::startSession();
     //check if the session has expired
     MMapManager::checkSessionExpiration();
     $return = null;
     $dataManager = DataManager::getInstance();
     // restore current process using checknum
     $myProcManager = ProcManager::getInstance();
     $myProcess = $myProcManager->getProcessByChecknum($request->getGET('checknum'));
     $myProcManager->setCurrentProcess($myProcess);
     $appDesc = new EyeosApplicationDescriptor($myProcess->getName());
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     $methodName = $request->getGET('message');
     // calling an ExecModule
     if (strpos($methodName, '__') === 0) {
         $moduleName = explode('_', substr($methodName, 2));
         $methodName = $moduleName[1];
         //ex: "FileChooser"
         $moduleName = $moduleName[0];
         //ex: "browsePath"
         $return = call_user_func_array(array($appDesc->getApplicationClassName(), '__callModule'), array($moduleName, $methodName, $params));
     } else {
         if ($appDesc->isJavascriptOnlyApplication()) {
             $return = call_user_func(array('EyeosJavascriptApplicationExecutable', $methodName), $params);
         } else {
             $return = call_user_func(array($appDesc->getApplicationClassName(), $methodName), $params);
         }
     }
     //try to force mime type. If there is a previous mime type defined at application level
     //this have no effect
     if (!headers_sent()) {
         $response->getHeaders()->append('Content-type:text/plain');
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
 public function testProcessRequest()
 {
     $memoryManager = MemoryManager::getInstance();
     $myProcManager = ProcManager::getInstance();
     //insert application 'system'
     $_GET['getApplication'] = 'system';
     $_GET['checknum'] = $myProcManager->getCurrentProcess()->getChecknum();
     $this->myMMapManager->processRequest(new Request());
     $procs = $myProcManager->getProcessesList();
     $appWorking = false;
     foreach ($procs as $value) {
         if ($value == 'system') {
             $appWorking = true;
         }
     }
     $this->assertEquals(true, $appWorking);
 }
 public function searchContacts($text)
 {
     try {
         $text = str_replace('_', '\\_', $text);
         // looking for username in database...
         $sqlQuery = 'SELECT id FROM eyeosuser WHERE name LIKE :text0 AND id != \'eyeID_EyeosUser_register\'';
         $bindParam = array('text0' => $text);
         $text = explode(' ', $text);
         for ($i = 0; $i < count($text); $i++) {
             $sqlQuery = $sqlQuery . ' OR name LIKE :text' . ($i + 1);
             $bindParam['text' . ($i + 1)] = '%' . $text[$i] . '%';
         }
         $sqlQuery .= ' LIMIT 20';
         $stmt = $this->dao->prepare($sqlQuery);
         $stmt = $this->dao->execute($stmt, $bindParam);
         $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
         // preparing the array the function will return...
         $return = array();
         foreach ($results as $result) {
             $return[] = $result['id'];
         }
         if (count($return) >= 20) {
             return $return;
         }
         $userObj = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         $metaToLookFor = array('eyeos.user.firstname', 'eyeos.user.lastname', 'eyeos.user.email');
         for ($i = 0; $i < count($text); $i++) {
             foreach ($metaToLookFor as $metaValue) {
                 $searchForMetas = new PrincipalMetaData();
                 $searchForMetas->set($metaValue, $text[$i]);
                 $results = MetaManager::getInstance()->searchMeta($userObj, $searchForMetas);
                 $results = array_diff($results, $return);
                 if (count($results) > 0) {
                     foreach ($results as $result) {
                         $return[] = $result;
                     }
                 }
             }
         }
         return $return;
     } catch (Exception $e) {
         throw new EyePeopleException('Unable to search contacts for text ' . $text, 0, $e);
     }
 }
Exemple #22
0
 public function processRequest(MMapRequest $request, MMapResponse $response)
 {
     ob_start('mb_output_handler');
     $return = null;
     $dataManager = DataManager::getInstance();
     $POST = $request->getPOST();
     $params = array();
     if (isset($POST['params'])) {
         $params = $dataManager->doInput($POST['params']);
     } else {
         if ($request->issetGET('params')) {
             $params = $request->getGET('params');
         }
     }
     //login in the system and get a valid login context
     $subject = new Subject();
     $loginContext = new LoginContext('eyeos-login', $subject);
     $cred = new EyeosPasswordCredential();
     $cred->setUsername($_REQUEST['username']);
     $cred->setPassword($_REQUEST['password'], true);
     $subject->getPrivateCredentials()->append($cred);
     $loginContext->login();
     //now create fake process called api
     Kernel::enterSystemMode();
     $appProcess = new Process('api');
     $appProcess->setPid('31337');
     $mem = MemoryManager::getInstance();
     $processTable = $mem->get('processTable', array());
     $processTable[31337] = $appProcess;
     $mem->set('processTable', $processTable);
     $appProcess->setLoginContext($loginContext);
     ProcManager::getInstance()->setCurrentProcess($appProcess);
     kernel::exitSystemMode();
     $return = call_user_func_array(array('EyeosApplicationExecutable', '__callModule'), array($request->getPOST('module'), $request->getPOST('name'), $params));
     //try to force mime type. If there is a previous mime type defined at application level
     //this have no effect
     if (!headers_sent()) {
         $response->getHeaders()->append('Content-type:text/plain');
     }
     if ($response->getBodyRenderer() === null && $response->getBody() == '') {
         $response->setBodyRenderer(new DataManagerBodyRenderer($return));
     }
 }
 /**
  * Fill the properties of the event
  *
  * @param <AbstractEventNotification> $event
  */
 public function autoFill(AbstractEventNotification $event)
 {
     if ($event->getEventData() === null || !is_string($event->getEventData())) {
         // If the event was fired by the user itself, set the eventData field
         if ($event->getReceiver() == ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId()) {
             $event->setEventData($event->getReceiver());
         } else {
             throw new EyeInvalidArgumentException('Missing or invalid $eventData');
         }
     }
     $userId = $event->getEventData();
     if ($userId == ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId()) {
         $event->setMessageInformation('Your profile was updated');
     } else {
         $username = PeopleEventHandler::retrieveContactName($userId);
         $event->setMessageInformation(array('User %s update his/her profile', array($username)));
     }
     $event->setIsQuestion(false);
 }
Exemple #24
0
 /**
  * @param array $params(0 => username, 1 => password)
  */
 public static function login($params)
 {
     $username = $params[0];
     $password = $params[1];
     $currentProcess = ProcManager::getInstance()->getCurrentProcess();
     $currentLoginContextName = $currentProcess->getLoginContext()->getName();
     $subject = new Subject();
     $newLoginContext = new LoginContext($currentLoginContextName, $subject);
     $cred = new EyeosPasswordCredential($username, $password);
     $subject->getPrivateCredentials()->append($cred);
     try {
         $newLoginContext->login();
     } catch (EyeLoginException $e) {
         return false;
     }
     //login succeeded, we can replace our current login context by the new one
     //which will be used by the target application to run
     ProcManager::getInstance()->setProcessLoginContext($currentProcess->getPid(), $newLoginContext);
     return true;
 }
 public function __construct($type, $name, $to, $data = null)
 {
     $currentUserId = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $this->setFrom($currentUserId);
     if (!isset($type) || !is_string($type)) {
         throw new EyeInvalidArgumentException('Missing or invalid $type');
     }
     if (!isset($name) || !is_string($name)) {
         throw new EyeInvalidArgumentException('Missing or invalid $name');
     }
     if (!isset($to) || !is_string($to)) {
         throw new EyeInvalidArgumentException('Missing or invalid $to');
     }
     $this->setType($type);
     $this->setName($name);
     $this->setTo($to);
     if (isset($data)) {
         $this->setData($data);
     }
 }
 /**
  * TODO: To remove, only used by eyeos.socialbar-ShareWindow.
  * use contact manager instead
  *
  *
  * @param <type> $params
  * @return <type>
  */
 public static function getContacts($params)
 {
     $myProcManager = ProcManager::getInstance();
     $peopleController = PeopleController::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $results = array();
     foreach ($params as $userId) {
         $otherUser = UMManager::getInstance()->getUserById($userId);
         $settings = MetaManager::getInstance()->retrieveMeta($otherUser);
         $myRelation = $peopleController->getContact($currentUserId, $userId);
         $lists = array();
         $listsName = array();
         $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($myRelation->getImpression());
         foreach ($tagsPerImpression as $tagPerImpression) {
             $lists[] = $tagPerImpression->getTagId();
             $listsName[] = $peopleController->getTagName($tagPerImpression->getTagId());
         }
         $result[] = array('id' => $userId, 'name' => $settings->get('eyeos.user.firstname') . ' ' . $settings->get('eyeos.user.lastname'), 'listsName' => $listsName);
     }
     return $result;
 }
Exemple #27
0
 public static function download($path)
 {
     $myFile = FSI::getFile($path);
     $myFile->checkReadPermission();
     $len = $myFile->getSize();
     $filename = $myFile->getName();
     $mimetype = $myFile->getMimeType();
     $filename = str_replace("\n", "", $filename);
     $filename = str_replace("\r", "", $filename);
     header('Content-Length: ' . $len);
     header('Content-Type: ' . $mimetype);
     header('Accept-Ranges: bytes');
     header('X-Pad: avoid browser bug');
     header('Content-Disposition: attachment; filename="' . $filename . '"');
     $currentProc = ProcManager::getInstance()->getCurrentProcess();
     ProcManager::getInstance()->kill($currentProc);
     $myRealFile = $myFile->getRealFile();
     $fileNameDestination = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath());
     session_write_close();
     readFile($fileNameDestination);
     exit;
 }
Exemple #28
0
 public static function searchPeople($params)
 {
     //Buscar en Provider con consulta rollo LIKE etc...
     $peopleController = PeopleController::getInstance();
     $resultsSearch = $peopleController->searchContacts($params);
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     //$peopleController = new PeopleController();
     $results = array();
     foreach ($resultsSearch as $result) {
         if ($result != $currentUserId) {
             // I don't want to search myself
             try {
                 $user = UMManager::getInstance()->getUserById($result);
             } catch (Exception $e) {
                 continue;
             }
             $settings = MetaManager::getInstance()->retrieveMeta($user);
             $nameOfUser = $user->getName();
             $realName = $nameOfUser;
             $description = 'No description';
             $pathImage = 'index.php?extern=images/48x48/apps/system-users.png';
             if ($settings != null) {
                 if ($settings->get('eyeos.user.firstname') != null && $settings->get('eyeos.user.lastname') != null) {
                     $realName = $settings->get('eyeos.user.firstname') . ' ' . $settings->get('eyeos.user.lastname');
                 }
                 if ($settings->get('eyeos.user.currentlife.city') != null) {
                     $description = $settings->get('eyeos.user.currentlife.city');
                 }
             }
             $myRelationManager = RelationsManager::getInstance();
             $relation = $myRelationManager->getRelation($result, $currentUserId);
             $state = $relation != null ? $relation->getState() : null;
             $results[] = array('userId' => $result, 'description' => $nameOfUser, 'realName' => $realName, 'state' => $state);
         }
     }
     return $results;
 }
Exemple #29
0
 /**
  * program entrypoint
  * 
  * @access public
  * @param AppExecutionContext $context
  * @param MMapResponse $response 
  */
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     $buffer = '';
     $basePath = EYE_ROOT . '/' . APPS_DIR . '/netsync/';
     $buffer .= file_get_contents($basePath . 'netsync.js');
     $response->appendToBody($buffer);
     //notify users about my new online status, i'm inside netsync!
     $peopleController = PeopleController::getInstance();
     //now we have the patch, lets apply it!
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $contacts = $peopleController->getAllContacts($currentUserId);
     $ids = array();
     $myCometSender = new CometSenderLongPolling();
     foreach ($contacts as $contact) {
         $id = $contact->getRelation()->getSourceId();
         if ($id == $currentUserId) {
             $id = $contact->getRelation()->getTargetId();
         }
         $message = new NetSyncMessage('status', 'online', $id, $currentUserId);
         $myCometSender->send($message);
     }
 }
 /**
  * Handle the answer provided by the user and execute the relative action
  *
  * @param AbstractEventNotification $event
  */
 public function handleAnswer(AbstractEventNotification $event)
 {
     if ($event->getAnswer() === null || !is_string($event->getAnswer())) {
         throw new EyeInvalidArgumentException('Missing or invalid answer property');
     }
     $peopleController = PeopleController::getInstance();
     switch ($event->getAnswer()) {
         case 'Confirm':
             try {
                 //Action for add the contact
                 $myProcManager = ProcManager::getInstance();
                 $currentUser = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser();
                 $peopleController = PeopleController::getInstance();
                 $peopleController->confirmContact($currentUser, $user = UMManager::getInstance()->getUserById($event->getSender()));
                 //Send message to the BUS
                 $message = new ClientBusMessage('events', 'confirmContact', $event->getSender());
                 ClientMessageBusController::getInstance()->queueMessage($message);
             } catch (Exception $e) {
                 //FIXME There should be real control on exception
             }
             break;
         case 'Cancel':
             try {
                 //Action for delete the contact
                 $contact = $peopleController->getContact($event->getReceiver(), $event->getSender());
                 $peopleController->removeContact($contact);
                 //Send message to the bus
                 $message = new ClientBusMessage('events', 'deleteContact', $event->getSender());
                 ClientMessageBusController::getInstance()->queueMessage($message);
             } catch (Exception $e) {
                 //FIXME There should be real control on exception
             }
             break;
         default:
             throw new EyeInvalidArgumentException('The answer to this events is not correct');
     }
 }