Ejemplo n.º 1
0
 /**
  * Return the contacts in the cache
  */
 public static function getAllContacts($params)
 {
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $peopleController = PeopleController::getInstance();
     $contacts = $peopleController->getAllContacts($currentUserId);
     $contacts = array_merge($contacts, $peopleController->getAllContactsInPending($currentUserId));
     $results = array();
     foreach ($contacts as $contact) {
         // Retrieve List information
         $lists = array();
         $listsName = array();
         $date = 0;
         $myRelationManager = RelationsManager::getInstance();
         $relation = $contact->getRelation();
         $state = $relation != null ? $relation->getState() : null;
         if ($state == 'accepted') {
             $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($contact->getImpression());
             foreach ($tagsPerImpression as $tagPerImpression) {
                 $lists[] = $tagPerImpression->getTagId();
                 $listsName[] = $peopleController->getTagName($tagPerImpression->getTagId());
             }
         }
         $date = $contact->getRelation()->getLastModification();
         //retrieve information about the meta
         if ($contact->getRelation()->getSourceId() != $currentUserId) {
             $contactId = $contact->getRelation()->getSourceId();
             $confirmable = true;
         } else {
             $contactId = $contact->getRelation()->getTargetId();
             $confirmable = false;
         }
         $myContact = UMManager::getInstance()->getUserById($contactId);
         $metaObject = MetaManager::getInstance()->retrieveMeta($myContact);
         if ($metaObject == null) {
             $meta = array();
         } else {
             $meta = $metaObject->getAll();
         }
         $manager = new CometManager();
         $connected = $manager->isUserConnected($contactId);
         $results[] = array('id' => $contactId, 'nickname' => $myContact->getName(), 'state' => $state, 'confirmable' => $confirmable, 'lists' => $lists, 'listsName' => $listsName, 'meta' => $meta, 'relationDate' => $date, 'connected' => $connected);
     }
     return $results;
 }
Ejemplo n.º 2
0
 /**
  * getSubscribers
  *
  * @access		public
  * @param		string     $channel
  * @return		json
  */
 public function getSubscribers($params)
 {
     if (empty($params['channel'])) {
         return false;
     }
     $myCometManager = new CometManager();
     $channels = $myCometManager->getSubscribers($params['channel']);
     $allchannels = array();
     foreach ($channels as $channel) {
         $allchannels[] = $channel->getAttributesMap();
     }
     //$Logger = Logger::getLogger('system.Frameworks.EyeosModules.NetSync');
     //$Logger->debug('channels: ' . $channels);
     return json_encode($allchannels);
 }
Ejemplo n.º 3
0
 public static function fileOpen($path)
 {
     $file = FSI::getFile($path);
     $memory = MemoryManager::getInstance();
     if (strtolower($file->getExtension()) == 'edoc') {
         $file->checkReadPermission();
         //we have to extract etc etc
         $filepath = 'home:///';
         $myFile = FSI::getFile($filepath);
         $myRealFile = $myFile->getRealFile();
         $fileNameDestination = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath());
         $fileNameDestination .= '/.office/documents/' . ProcManager::getInstance()->getCurrentProcess()->getPid();
         if (!file_exists(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/')) {
             mkdir(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/');
         } else {
             $cmd = 'rm -fr ' . escapeshellarg(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/documents/');
             shell_exec($cmd);
         }
         mkdir(AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath()) . '/.office/documents/');
         if (file_exists($fileNameDestination)) {
             AdvancedPathLib::rmdirs($fileNameDestination);
         }
         mkdir($fileNameDestination);
         $myRealFile = $file->getRealFile();
         $originalFile = AdvancedPathLib::getPhpLocalHackPath($myRealFile->getPath());
         $cmd = 'unzip  -d ' . escapeshellarg($fileNameDestination) . ' ' . escapeshellarg($originalFile);
         shell_exec($cmd);
         if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
             $isIE = true;
         } else {
             $isIE = false;
         }
         $documentUniqueId = file_get_contents($fileNameDestination . '/duid');
         if (!$isIE) {
             $channel = '/topic/document_' . $documentUniqueId;
             if (!file_exists('/tmp/doc_' . basename($documentUniqueId))) {
                 /* @todo  */
                 //exec('nohup python ' . EYE_ROOT . '/' . APPS_DIR . '/documents/libs/listener.py ' . escapeshellarg($channel) . ' ' . escapeshellarg($fileNameDestination) . '/document.html' . ' ' . escapeshellarg($documentUniqueId). ' | at now');
                 DocumentsApplication::createSharedFile($channel, $fileNameDestination . '/document.html', $documentUniqueId);
             } else {
                 $manager = new CometManager();
                 $subscriptions = $manager->getSubscriptions($channel);
                 if (!$subscriptions) {
                     DocumentsApplication::createSharedFile($channel, $fileNameDestination . '/document.html', $documentUniqueId);
                 }
             }
             $content = file_get_contents('/tmp/doc_' . $documentUniqueId);
             $checknum = ProcManager::getInstance()->getCurrentProcess()->getChecknum();
             // var_dump($checknum, $content); exit;
             $content = str_replace('CHECKNUM_HERE', $checknum, $content);
         } else {
             $content = file_get_contents($fileNameDestination . '/document.html');
         }
         $return[] = $content;
         $return[] = $file->getName();
         $return[] = $documentUniqueId;
     } else {
         $return[] = $file->getContents();
         $return[] = $file->getName();
     }
     $memory->set('currentDocument', $path);
     //var_dump($return);exit;
     return $return;
 }