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 contactDeleted(PeopleEvent $e) { $contact = $e->getSource(); $sourceId = $contact->getRelation()->getSourceId(); $targetId = $contact->getRelation()->getTargetId(); $currentUserId = ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId(); $otherUser = $sourceId == $currentUserId ? $targetId : $sourceId; $state = $contact->getRelation()->getState(); if ($state == 'pending') { // Send Event to Receiver... $info = new EyeosEventNotification(); $info->setType('People_CancelRequest'); $info->setEventData($otherUser); $eventManager = new EventNotificationManager(); $eventManager->sendEventByType($info); } else { if ($state == 'accepted') { // end Event to Receiver... $info = new EyeosEventNotification(); $info->setType('People_DeleteContact'); $info->setEventData($otherUser); $eventManager = new EventNotificationManager(); $eventManager->sendEventByType($info); } } // Closing the relatives events... $info = new EyeosEventNotification(); $info->setType('People_RequestRelationshipReceiver'); $info->setSender($sourceId); $info->setReceiver($targetId); $info->setIsQuestion(1); $eventManager = new EventNotificationManager(); $eventsToRemove = $eventManager->searchEvents($info); foreach ($eventsToRemove as $event) { $eventManager->deleteEvent($event->getId()); } }