function __construct() { if ($this->provider === null) { $this->provider = new SQLContactsProvider(); } $this->relationsManager = RelationsManager::getInstance(); $this->impressionsManager = ImpressionsManager::getInstance(); }
/** * 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; }
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; }
/** * 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; }
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; }