Beispiel #1
1
 /**
  * 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);
 }
 /**
  * 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');
     }
     switch ($event->getAnswer()) {
         case 'Confirm':
             try {
                 $eventData = $event->getEventData();
                 $assignation = UMManager::getInstance()->getNewUserWorkgroupAssignationInstance();
                 $assignation->setUserId($event->getReceiver());
                 $assignation->setWorkgroupId($eventData['groupId']);
                 $assignation->setStatus(WorkgroupConstants::STATUS_MEMBER);
                 UMManager::getInstance()->updateUserWorkgroupAssignation($assignation);
             } catch (Exception $e) {
                 //FIXME Need real control of error
             }
             break;
         case 'Cancel':
             try {
                 $eventData = $event->getEventData();
                 $assignation = UMManager::getInstance()->getNewUserWorkgroupAssignationInstance();
                 $assignation->setUserId($event->getReceiver());
                 $assignation->setWorkgroupId($eventData['groupId']);
                 UMManager::getInstance()->unregisterUserWorkgroupAssignation($assignation);
             } catch (Exception $e) {
                 //FIXME Need real control of error
             }
             break;
         default:
             throw new EyeInvalidArgumentException('The answer to this events is not correct');
     }
 }
 /**
  * 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['userId']) || !is_string($eventData['userId'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $eventData[\'userId\']');
     }
     if (!isset($eventData['groupId']) || !is_string($eventData['groupId'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $eventData[\'groupId\']');
     }
     $userId = $eventData['userId'];
     $username = GroupsEventHandler::retrieveContactName($userId);
     $wGroupId = $eventData['groupId'];
     $wGroupName = GroupsEventHandler::retrieveWorkgroupName($wGroupId);
     //Event sent to the owner of the group
     if ($event->getReceiver() !== $userId) {
         $event->setMessageInformation(array('User %s was banned from %s group.', array($username, $wGroupName)));
     } else {
         //Event sent to the banned user
         $event->setMessageInformation(array('You were banned from %s group.', array($wGroupName)));
     }
     $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())) {
         // If the event was fired by the user itself, set the eventData field
         if ($event->getReceiver() == ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId()) {
             $event->setEventData($event->getReceiver());
         } else {
             throw new EyeInvalidArgumentException('Missing or invalid $eventData');
         }
     }
     $userId = $event->getEventData();
     if ($userId == ProcManager::getInstance()->getCurrentProcess()->getLoginContext()->getEyeosUser()->getId()) {
         $event->setMessageInformation('Your profile was updated');
     } else {
         $username = PeopleEventHandler::retrieveContactName($userId);
         $event->setMessageInformation(array('User %s update his/her profile', array($username)));
     }
     $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())) {
         throw new EyeInvalidArgumentException('Missing or invalid eventData property');
     }
     $wGroupId = $event->getEventData();
     $wGroupName = GroupsEventHandler::retrieveWorkgroupName($wGroupId);
     $username = GroupsEventHandler::retrieveContactName($event->getReceiver());
     $event->setMessageInformation(array('You request the membership for the group %s.', array($wGroupName)));
     $event->setIsQuestion(false);
 }
Beispiel #7
0
 /**
  * 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['userId']) || !is_string($eventData['userId'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $eventData[\'userId\']');
     }
     if (!isset($eventData['groupId']) || !is_string($eventData['groupId'])) {
         throw new EyeInvalidArgumentException('Missing or invalid $eventData[\'groupId\']');
     }
     $userId = $eventData['userId'];
     $wGroupId = $eventData['groupId'];
     $wGroupName = GroupsEventHandler::retrieveWorkgroupName($wGroupId);
     if ($userId == $event->getReceiver()) {
         $event->setMessageInformation(array('You now are a memberof the group %s.', array($wGroupName)));
     } else {
         $userName = GroupsEventHandler::retrieveContactName($userId);
         $event->setMessageInformation(array('User %s is now member of your group %s.', array($userName, $wGroupName)));
     }
     $event->setIsQuestion(false);
 }
 /**
  * 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');
     }
 }