/**
  * Constructor
  *
  * @param Request $request
  * @return CompanyProfileController
  */
 function __construct($request)
 {
     parent::__construct($request);
     $company_id = $this->request->getId('company_id');
     if ($company_id) {
         $this->active_company = Companies::findById($company_id);
     }
     // if
     if (instance_of($this->active_company, 'Company')) {
         $this->wireframe->page_actions = array();
         if (!$this->active_company->canView($this->logged_user)) {
             $this->httpError(HTTP_ERR_FORBIDDEN);
         }
         // if
         if ($this->active_company->getIsArchived() && $this->logged_user->isPeopleManager()) {
             $this->wireframe->addBreadCrumb(lang('Archive'), assemble_url('people_archive'));
         }
         // if
         $this->wireframe->addBreadCrumb($this->active_company->getName(), $this->active_company->getViewUrl());
         // Collect company tabs
         $tabs = new NamedList();
         $tabs->add('overview', array('text' => str_excerpt($this->active_company->getName(), 25), 'url' => $this->active_company->getViewUrl()));
         $tabs->add('people', array('text' => lang('People'), 'url' => $this->active_company->getViewUrl()));
         $tabs->add('projects', array('text' => lang('Projects'), 'url' => $this->active_company->getViewUrl()));
         event_trigger('on_company_tabs', array(&$tabs, &$this->logged_user, &$this->active_company));
         $this->smarty->assign(array('company_tabs' => $tabs, 'company_tab' => 'overview'));
     } else {
         $this->active_company = new Company();
     }
     // if
     $this->smarty->assign(array('active_company' => $this->active_company));
 }
示例#2
0
 public static function getInstance()
 {
     if (self::$Instance === null) {
         self::$Instance = new PeopleController();
     }
     return self::$Instance;
 }
示例#3
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);
 }
 protected function getFeed($index)
 {
     if (isset($this->feeds[$index])) {
         $feedData = $this->feeds[$index];
         if (!isset($feedData['CONTROLLER_CLASS'])) {
             $feedData['CONTROLLER_CLASS'] = 'LDAPPeopleController';
         }
         $controller = PeopleController::factory($feedData['CONTROLLER_CLASS'], $feedData);
         //$controller->setAttributes($this->detailAttributes);
         return $controller;
     } else {
         throw new KurogoConfigurationException("Error getting people feed for index {$index}");
     }
 }
示例#5
0
 protected function notifyClosedPresence($presence)
 {
     $userId = $presence->getUserId();
     $peopleController = PeopleController::getInstance();
     $contacts = $peopleController->getAllContacts($userId);
     foreach ($contacts as $contact) {
         if ($contact->getRelation()->getSourceId() != $userId) {
             $contactId = $contact->getRelation()->getSourceId();
         } else {
             $contactId = $contact->getRelation()->getTargetId();
         }
         $NetSyncMessage = new NetSyncMessage('presence', 'userDisconnect', $contactId, $userId);
         NetSyncController::getInstance()->send($NetSyncMessage);
     }
 }
示例#6
0
 protected function getFeed($index)
 {
     if (isset($this->feeds[$index])) {
         $feedData = $this->feeds[$index];
         if (!isset($feedData['CONTROLLER_CLASS'])) {
             $feedData['CONTROLLER_CLASS'] = 'LDAPPeopleController';
         }
         $controller = PeopleController::factory($feedData['CONTROLLER_CLASS'], $feedData);
         //$controller->setAttributes($this->detailAttributes);
         $controller->setDebugMode($this->getSiteVar('DATA_DEBUG'));
         return $controller;
     } else {
         throw new Exception("Error getting people feed for index $index");
     }
 }
 /**
  * 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;
 }
示例#8
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;
 }
示例#9
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');
     }
 }
示例#11
0
 public static function getRecentsContacts($params)
 {
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $myRelationManager = RelationsManager::getInstance();
     $lastRelationIds = $myRelationManager->getLastRelationsId($currentUserId, $params);
     $results = array();
     $peopleController = PeopleController::getInstance();
     foreach ($lastRelationIds as $resultId) {
         $result = $peopleController->getContact($currentUserId, $resultId);
         if ($result->getRelation()->getSourceId() != $currentUserId) {
             $contactId = $result->getRelation()->getSourceId();
         } else {
             $contactId = $result->getRelation()->getTargetId();
         }
         $state = $result->getRelation()->getState();
         $lists = array();
         $listsName = array();
         $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($result->getImpression());
         foreach ($tagsPerImpression as $tagPerImpression) {
             $lists[] = $tagPerImpression->getTagId();
             $listsName[] = $peopleController->getTagName($tagPerImpression->getTagId());
         }
         $otherUser = UMManager::getInstance()->getUserById($contactId);
         $meta = MetaManager::getInstance()->retrieveMeta($otherUser)->getAll();
         $results[] = array('id' => $contactId, 'nickname' => $otherUser->getName(), 'lists' => $lists, 'listsName' => $listsName, 'state' => $state, 'meta' => $meta);
     }
     return $results;
 }
    protected function init($args) {
        parent::init($args);
        
        $args = is_array($args) ? $args : array();
        if (!isset($args['DB_TYPE'])) {
            $args = array_merge(Kurogo::getSiteSection('database'), $args);
        }
        
        $this->connection = new db($args);                
        if (isset($args['SORTFIELDS']) && is_array($args['SORTFIELDS'])) {
            $this->sortFields = $args['SORTFIELDS'];
        }
                        
        $this->table = isset($args['DB_USER_TABLE']) ? $args['DB_USER_TABLE'] : 'users';

        $this->fieldMap = array(
            'userid'=>isset($args['DB_USERID_FIELD']) ? $args['DB_USERID_FIELD'] : 'userID',
            'email'=>isset($args['DB_EMAIL_FIELD']) ? $args['DB_EMAIL_FIELD'] : 'email',
            'firstname'=>isset($args['DB_FIRSTNAME_FIELD']) ? $args['DB_FIRSTNAME_FIELD'] : 'firstname',
            'lastname'=>isset($args['DB_LASTNAME_FIELD']) ? $args['DB_LASTNAME_FIELD'] : 'lastname'
        );
    }
示例#13
0
 public function listFiles($pattern = '*', $flags = AdvancedPathLib::GLOB_NORMAL)
 {
     $files = array();
     $urlParts = $this->getURLComponents();
     $isRoot = false;
     if (!isset($urlParts['principalname'])) {
         $isRoot = true;
         if ($urlParts['path'] != '/') {
             throw new EyeBadMethodCallException('Cannot list files: ' . $this->path . ' is not a (handled) directory.');
         }
     }
     // ROOT (share://): list the owners sharing files with the current user
     if ($isRoot) {
         //--- Legacy code [I'd like to keep this part of the code in case some people change suddenly their minds, once again...]
         /*$currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         		$shareInfo = SharingManager::getInstance()->getAllShareInfoFromCollaborator($currentUser, null, 'IShareableFile');
         		
         		// Build an array(ownerId => ownerName)
         		$owners = array();
         		foreach($shareInfo as $shareInfoData) {
         			try {
         				$currentOwner = $shareInfoData->getOwner();
         				if (!isset($owners[$currentOwner->getId()])) {
         					$owners[$currentOwner->getId()] = $currentOwner->getName();
         				}
         			} catch (Exception $e) {
         				Logger::getLogger('system.services.FileSystem.EyeSharedFile')->warn('Cannot retrieve ShareInfo components from shared file: "' . $shareInfoData->getShareable() . '", skipping.');
         			}
         		}
         		sort($owners);
         		
         		foreach($owners as $ownerName) {
         			$files[] = new EyeSharedFile(self::URL_SCHEME_SHARE . '://' . self::URL_LOCATOR_CHAR . $ownerName . '/');
         		}*/
         //--- Legacy code
         $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         $peopleController = PeopleController::getInstance();
         $contacts = $peopleController->getAllContacts($currentUser->getId());
         foreach ($contacts as $contact) {
             if ($contact->getRelation()->getSourceId() == $currentUser->getId()) {
                 $otherUser = UMManager::getInstance()->getUserById($contact->getRelation()->getTargetId());
             } else {
                 $otherUser = UMManager::getInstance()->getUserById($contact->getRelation()->getSourceId());
             }
             $files[] = new EyeSharedFile(self::URL_SCHEME_SHARE . '://' . self::URL_LOCATOR_CHAR . $otherUser->getName() . '/');
         }
     } else {
         if ($flags & AdvancedPathLib::GLOB_ONLY_DIR) {
             // Folders are not shareable yet
             return array();
         }
         $ownerName = $urlParts['principalname'];
         $owner = UMManager::getInstance()->getUserByName($ownerName);
         $currentUser = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser();
         // CURRENT USER ROOT (share://~currentUser/): Show the list of all the files that are currently
         // shared by the current user
         if ($owner == $currentUser) {
             $shareInfo = SharingManager::getInstance()->getAllShareInfoFromOwner($currentUser, 'IShareableFile');
         } else {
             $shareInfo = SharingManager::getInstance()->getAllShareInfoFromCollaborator($currentUser, $owner, 'IShareableFile');
         }
         // Special temporary array for files IDs to avoid duplication in the returned array
         $fileIds = array();
         foreach ($shareInfo as $shareInfoData) {
             $sharedFile = $shareInfoData->getShareable();
             $id = $sharedFile->getId();
             if (!isset($fileIds[$id])) {
                 $fileIds[$id] = 0;
                 // Arbitrary value (we only use keys in this array)
                 $files[] = $sharedFile;
             }
         }
     }
     return $files;
 }
    protected function init($args)
    {
        parent::init($args);

        $this->port = isset($args['PORT']) ? $args['PORT'] : 389;
        $this->searchBase = isset($args['SEARCH_BASE']) ? $args['SEARCH_BASE'] : '';
        $this->adminDN = isset($args['ADMIN_DN']) ? $args['ADMIN_DN'] : null;
        $this->adminPassword = isset($args['ADMIN_PASSWORD']) ? $args['ADMIN_PASSWORD'] : null;
    }
 public function listen($manager)
 {
     $userId = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $username = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getName();
     $subscriptionProvider = new SqlSubscriptionProvider();
     if ($subscriptionProvider->getSubscriptions($userId) == false) {
         /**
          * User try to listen message, but for same reason (connection problem, logout)
          * netSync delete subscriptions to this user.
          *
          * Stop LongPolling and notify client
          */
         echo "forceRefresh";
         exit;
     }
     //$myPressence = new Pressence();
     //$myPressence->markOnline($username, $manager);
     session_write_close();
     set_time_limit(0);
     ignore_user_abort(1);
     header('Cache-Control: no-cache, must-revalidate');
     header('Content-type: application/json');
     $Logger = Logger::getLogger('system.Frameworks.EyeosModules.NetSync');
     //one of every 20 loops, will update the pressence time
     //but the first one, should do it ever
     $loop = 20;
     while (1) {
         try {
             echo "\n";
             ob_flush();
             flush();
             if (connection_status() != CONNECTION_NORMAL) {
                 //Maybe user gone offline
                 sleep(35);
                 //Check if user is still connected
                 if (!$subscriptionProvider->isUserConnected($userId)) {
                     // if not notify to all contacts
                     $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);
                         //TODO24 ultra hardcoded, we need some kind of php listeners here!
                         $myCometSender->send($message);
                     }
                     shell_exec('rm -rf ' . escapeshellarg(EYE_ROOT . '/' . USERS_DIR . '/' . utf8_basename($username) . '/files/.office/'));
                     $subscriptionProvider->removeAllSubscriptions($userId);
                 }
                 exit;
             }
             if ($loop == 20) {
                 $mySubscriptionProvider = new SqlSubscriptionProvider();
                 $mySubscriptionProvider->refreshPressence($userId);
                 $loop = 0;
             } else {
                 $loop++;
             }
             $mySubscriptionProvider = new SqlSubscriptionProvider();
             $channels = $mySubscriptionProvider->getSubscriptions($userId);
             $messageProvider = new CometSqlMessageProvider();
             if (is_array($channels)) {
                 $messages = $messageProvider->read($channels, $userId, $this->lastId);
                 if (is_array($messages) && count($messages) > 0) {
                     @session_start();
                     usort($messages, "customMessageComparation");
                     $_SESSION['comet']['lastid'] = $messages[count($messages) - 1]['id'];
                     //$Logger->debug("last message id: " . $_SESSION['comet']['lastid']);
                     //@todo use pseudo-random-related-to-tableid or something as transaction ID, no a id of table
                     return $messages;
                 }
             }
             sleep(1);
         } catch (Exception $e) {
             $logger = Logger::getLogger('netsync');
             $logger->fatal('Exception in netsync!');
             $logger->fatal(ExceptionStackUtil::getStackTrace($e, false));
             exit;
         }
     }
 }
 protected function getFeed($index)
 {
     if (isset($this->controllers[$index])) {
         return $this->controllers[$index];
     }
     if (isset($this->feeds[$index])) {
         $feedData = $this->feeds[$index];
         try {
             if (isset($feedData['CONTROLLER_CLASS'])) {
                 $modelClass = $feedData['CONTROLLER_CLASS'];
             } else {
                 $modelClass = isset($feedData['MODEL_CLASS']) ? $feedData['MODEL_CLASS'] : self::$defaultModel;
             }
             $controller = PeopleDataModel::factory($modelClass, $feedData);
         } catch (KurogoException $e) {
             $controller = PeopleController::factory($feedData['CONTROLLER_CLASS'], $feedData);
             $this->legacyController = true;
         }
         $controller->setAttributes($this->detailAttributes);
         $this->controllers[$index] = $controller;
         return $controller;
     } else {
         throw new KurogoConfigurationException("Error getting people feed for index {$index}");
     }
 }
 protected function init($args)
 {
     parent::init($args);
     if (isset($args['HOST'])) {
         $this->setHost($args['HOST']);
     }
     $this->port = isset($args['PORT']) ? $args['PORT'] : 389;
     $this->searchBase = isset($args['SEARCH_BASE']) ? $args['SEARCH_BASE'] : '';
     $this->adminDN = isset($args['ADMIN_DN']) ? $args['ADMIN_DN'] : null;
     $this->adminPassword = isset($args['ADMIN_PASSWORD']) ? $args['ADMIN_PASSWORD'] : null;
     $this->searchTimelimit = isset($args['SEARCH_TIMELIMIT']) ? $args['SEARCH_TIMELIMIT'] : 30;
     $this->readTimelimit = isset($args['READ_TIMELIMIT']) ? $args['READ_TIMELIMIT'] : 30;
     $this->fieldMap = array('userid' => isset($args['LDAP_USERID_FIELD']) ? $args['LDAP_USERID_FIELD'] : 'uid', 'email' => isset($args['LDAP_EMAIL_FIELD']) ? $args['LDAP_EMAIL_FIELD'] : 'mail', 'fullname' => isset($args['LDAP_FULLNAME_FIELD']) ? $args['LDAP_FULLNAME_FIELD'] : '', 'firstname' => isset($args['LDAP_FIRSTNAME_FIELD']) ? $args['LDAP_FIRSTNAME_FIELD'] : 'givenname', 'lastname' => isset($args['LDAP_LASTNAME_FIELD']) ? $args['LDAP_LASTNAME_FIELD'] : 'sn', 'phone' => isset($args['LDAP_PHONE_FIELD']) ? $args['LDAP_PHONE_FIELD'] : 'telephonenumber');
     if (isset($args['SORTFIELDS']) && is_array($args['SORTFIELDS'])) {
         $this->sortFields = $args['SORTFIELDS'];
     }
 }
    {
        // nothing to do for the moment....
    }
    public function beforeTagDeletionToContact(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
    public function tagDeletedToContact(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
    public function tagCreated(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
    public function tagModified(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
    public function beforeTagDeletion(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
    public function tagRemoved(PeopleEvent $e)
    {
        // nothing to do for the moment....
    }
}
// Register singleton listener on the target dispatcher
PeopleController::getInstance()->addPeopleListener(ContactManagerPeopleListener::getInstance());
 protected function init($args) {
     parent::init($args);
     
     if (isset($args['HOST'])) {
         $this->setHost($args['HOST']);
     }
     
     $this->port = isset($args['PORT']) ? $args['PORT'] : 389;
     $this->searchBase = isset($args['SEARCH_BASE']) ? $args['SEARCH_BASE'] : '';
     $this->adminDN = isset($args['ADMIN_DN']) ? $args['ADMIN_DN'] : null;
     $this->adminPassword = isset($args['ADMIN_PASSWORD']) ? $args['ADMIN_PASSWORD'] : null;
     $this->searchTimelimit = isset($args['SEARCH_TIMELIMIT']) ? $args['SEARCH_TIMELIMIT'] : 30;
     $this->readTimelimit = isset($args['READ_TIMELIMIT']) ? $args['READ_TIMELIMIT'] : 30;
     
     if (isset($args['SORTFIELDS']) && is_array($args['SORTFIELDS'])) {
         $this->sortFields = $args['SORTFIELDS'];
     }
 }
示例#20
0
 /**
  * Update the Lists of a Contact whit a new one and return a list of changes
  *
  * @param string $contactId The id of the contact involved in the changes
  * @param array $newLists The array with the new list of the contact
  *
  * @return array $results = (
  *			'add' => array,			The list of the id that was added
  *			'delete' => array		The list of the id that was removed
  * )
  *
  */
 private static function syncLists($contactId, $newLists)
 {
     $myProcManager = ProcManager::getInstance();
     $peopleController = PeopleController::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $contact = $peopleController->getContact($currentUserId, $contactId);
     //Retrive the old list
     $oldLists = array();
     $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($contact->getImpression());
     foreach ($tagsPerImpression as $tagPerImpression) {
         $oldLists[] = $tagPerImpression->getTagId();
     }
     //Check if we have to add Tags
     $results = array('add' => array(), 'delete' => array());
     foreach ($newLists as $newTagId) {
         if (!in_array($newTagId, $oldLists)) {
             //Add the tag to the contact
             $tag = new PeopleTag();
             $tag->setId($newTagId);
             $tag->setName($peopleController->getTagName($newTagId));
             $tag->setUserId($currentUserId);
             $peopleController->addTagToContact($tag, $contact);
             //Update the return value
             $results['add'][] = (int) $newTagId;
         }
     }
     //Check if we have to delete Tags
     foreach ($oldLists as $oldTagId) {
         if (!in_array($oldTagId, $newLists)) {
             //Add the tag to the contact
             $tag = new PeopleTag();
             $tag->setId($oldTagId);
             $tag->setName($peopleController->getTagName($oldTagId));
             $tag->setUserId($currentUserId);
             $peopleController->removeTagToContact($tag, $contact);
             //Update the return value
             $results['delete'][] = (int) $oldTagId;
         }
     }
     return $results;
 }
示例#21
0
 public static function getAllContacts($params)
 {
     $peopleController = PeopleController::getInstance();
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $tempResults = $peopleController->getAllContacts($currentUserId);
     $results = array();
     foreach ($tempResults as $result) {
         if ($result->getRelation()->getSourceId() != $currentUserId) {
             $contactId = $result->getRelation()->getSourceId();
         } else {
             $contactId = $result->getRelation()->getTargetId();
         }
         $lists = array();
         $listsName = array();
         $tagsPerImpression = ImpressionsManager::getInstance()->getTagsPerImpression($result->getImpression());
         foreach ($tagsPerImpression as $tagPerImpression) {
             $lists[] = $tagPerImpression->getTagId();
             $listsName[] = $peopleController->getTagName($tagPerImpression->getTagId());
         }
         $otherUser = UMManager::getInstance()->getUserById($contactId);
         $settings = MetaManager::getInstance()->retrieveMeta($otherUser);
         $nameOfUser = utf8_encode($otherUser->getName());
         $pathImage = 'index.php?extern=images/48x48/apps/system-users.png';
         if ($settings != null) {
             if ($settings->get('eyeos.user.picture.url') != null) {
                 $pathImage = $settings->get('eyeos.user.picture.url');
             }
             if ($settings->get('eyeos.user.firstname') != null && $settings->get('eyeos.user.lastname') != null) {
                 $nameOfUser = utf8_encode($settings->get('eyeos.user.firstname') . ' ' . $settings->get('eyeos.user.lastname'));
             }
         }
         $results[] = array('userId' => $contactId, 'userName' => $nameOfUser, 'image' => $pathImage, 'lists' => $lists, 'listsName' => $listsName, 'icon' => $pathImage);
     }
     return $results;
 }
示例#22
0
 /**
  * Retrieve the name of a tag by its id
  */
 public static function getListName($listId)
 {
     $myProcManager = ProcManager::getInstance();
     $currentUserId = $myProcManager->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId();
     $peopleController = PeopleController::getInstance();
     return $peopleController->getTagName($listId);
 }