/** * Fill the properties of the event * * @param <AbstractEventNotification> $event */ public function autoFill(AbstractEventNotification $event) { if (($event->getEventData() === null || !is_string($event->getEventData())) && ($event->getReceiver() === null || !is_string($event->getReceiver()))) { throw new EyeInvalidArgumentException('Missing or invalid eventData property'); } if ($event->getEventData() === null) { $event->setEventData($event->getSender()); } $event->setMessageInformation(array('User %s shared a file with you.', array(PeopleEventHandler::retrieveContactName($event->getSender())))); $event->setIsQuestion(false); }
/** * Fill the properties of the event * * @param <AbstractEventNotification> $event */ public function autoFill(AbstractEventNotification $event) { if (($event->getEventData() === null || !is_string($event->getEventData())) && ($event->getReceiver() === null || !is_string($event->getReceiver()))) { throw new EyeInvalidArgumentException('Missing or invalid eventData property'); } if ($event->getEventData() === null) { $event->setEventData($event->getSender()); } $username = PeopleEventHandler::retrieveContactName($event->getEventData()); $event->setMessageInformation(array('%s accepted you and is now in your eyeOS Network', array($username))); $event->setIsQuestion(false); }
/** * Fill the properties of the event * * @param <AbstractEventNotification> $event */ public function autoFill(AbstractEventNotification $event) { if ($event->getEventData() === null) { throw new EyeInvalidArgumentException('You must specify the eventData property'); } $eventData = $event->getEventData(); if (!isset($eventData['groupId']) || !is_string($eventData['groupId'])) { throw new EyeInvalidArgumentException('Missing or invalid $eventData[\'groupId\']'); } $wGroupId = $eventData['groupId']; $wGroupName = GroupsEventHandler::retrieveWorkgroupName($wGroupId); $username = GroupsEventHandler::retrieveContactName($event->getSender()); $event->setMessageInformation(array('User %s invited you in %s group.', array($username, $wGroupName))); $event->setIsQuestion(true); $event->setQuestion('Do you want to confirm?'); $event->setAvailableAnswers('Confirm#Cancel'); }
/** * 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'); } }