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()); } }
public function userWorkgroupAssignationDeleted(UMEvent $e) { if ($e->getSource() instanceof IUserWorkgroupAssignation) { $assignation = $e->getSource(); $userId = $assignation->getUserId(); $groupId = $assignation->getWorkgroupId(); // closing event in case of membership request... $eventData = serialize(array('groupId' => $groupId, 'userId' => $userId)); $info = new EyeosEventNotification(); $info->setType('Groups_RequestMembershipReceiver'); $info->setEventData($eventData); $info->setIsQuestion(1); $eventManager = new EventNotificationManager(); $eventsToRemove = $eventManager->searchEvents($info); foreach ($eventsToRemove as $event) { // should we create a new event to advise the group's owner // about the user who is leaving the group?? $eventManager->deleteEvent($event->getId()); $NetSyncMessage = new NetSyncMessage('events', 'updateEvent', $event->getReceiver()); NetSyncController::getInstance()->send($NetSyncMessage); } // closing event in case of membership invitation... $eventData = serialize(array('groupId' => $groupId)); $info = new EyeosEventNotification(); $info->setType('Groups_InvitedUsersReceiver'); $info->setEventData($eventData); $info->setIsQuestion(1); $eventManager = new EventNotificationManager(); $eventsToRemove = $eventManager->searchEvents($info); foreach ($eventsToRemove as $event) { // should we create a new event to advise the group's owner // about the user who is leaving the group?? $eventManager->deleteEvent($event->getId()); $NetSyncMessage = new NetSyncMessage('events', 'updateEvent', $event->getReceiver()); NetSyncController::getInstance()->send($NetSyncMessage); } $NetSyncMessage = new NetSyncMessage('NSGroup', 'userWorkgroupAssignationDeleted', $userId, $groupId); NetSyncController::getInstance()->send($NetSyncMessage); } }