/** * Return an instance of an EyeosEventNotification * * @param array $param => array( * 'id' => String * 'answer' => String * 'creationdate' => timestamp * 'sender' => String * 'receiver' => String * 'question' => String * 'messageInformation' => String * 'availableAnswer' => JSON * 'isQuestion' => Boolean * 'eventData' => String * 'ended' => Boolean * ) */ protected static function createEventFromJson($params) { if ($params !== null && !is_array($params)) { throw new EyeInvalidArgumentException('Missing or invalid $params'); } $event = new EyeosEventNotification(); $event->getEventInformation()->setAll($params['eventInformation']); return $event; }
/** * * @param array $params ( * 'userId' => String, * 'files' => Array * ) * @return <Array> */ public static function changePrivilege($params) { $toBeRemoved = false; $user = UMManager::getInstance()->getUserById($params['userId']); if ($params['operation'] == 'Viewer') { $perms = new SharePermission('read'); } else { if ($params['operation'] == 'Editor') { $perms = new SharePermission('read, write'); } else { if ($params['operation'] == 'Remove') { $toBeRemoved = true; } } } $files = array(); $paramsFiles = $params['files']; for ($i = 0; $i < count($paramsFiles); $i++) { $trueFile = FSI::getFile($paramsFiles[$i]); if ($toBeRemoved) { SharingManager::getInstance()->removeCollaborator($trueFile, $user); $files[] = self::getSharedInfo($trueFile); } else { try { SharingManager::getInstance()->addCollaborator($trueFile, $user, $perms); $files[] = self::getSharedInfo($trueFile); $info = new EyeosEventNotification(); $info->setType('Share_NewShare'); $info->setReceiver($params['userId']); $eventManager = new EventNotificationManager(); $eventManager->sendEventByType($info); } catch (EyeDBException $e) { SharingManager::getInstance()->updateCollaboratorPermission($trueFile, $user, $perms); $files[] = self::getSharedInfo($trueFile); } } } return $files; }
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 deleteEvent($id) { $event = new EyeosEventNotification(); $info = new EventNotificationInformation(); $info->setId($id); $event->setEventInformation($info); $this->getProvider()->deleteEventNotification($event); }
public function userWorkgroupAssignationUpdated(UMEvent $e) { if ($e->getSource() instanceof IUserWorkgroupAssignation) { $assignation = $e->getSource(); $oldAssignation = $e->getRelatedSource(); $userId = $assignation->getUserId(); $groupId = $assignation->getWorkgroupId(); if ($assignation->getStatus() === WorkgroupConstants::STATUS_BANNED) { $event1 = new EyeosEventNotification(); $event1->setType('Groups_BannedUser'); $event1->setEventData(array('userId' => $userId, 'groupId' => $groupId)); $eventManager = new EventNotificationManager(); //Send event to the owner $eventManager->sendEventByType($event1); //Send event to the banned user $event2 = new EyeosEventNotification(); $event2->setType('Groups_BannedUser'); $event2->setEventData(array('userId' => $userId, 'groupId' => $groupId)); $event2->setReceiver($userId); $eventManager->sendEventByType($event2); } if (($oldAssignation->getStatus() === WorkgroupConstants::STATUS_PENDING || $oldAssignation->getStatus() === WorkgroupConstants::STATUS_INVITED) && $assignation->getStatus() === WorkgroupConstants::STATUS_MEMBER) { $event = new EyeosEventNotification(); $event->setType('Groups_ConfirmedUser'); $event->setEventData($groupId); $event->setReceiver($userId); $eventManager = new EventNotificationManager(); $eventManager->sendEventByType($event); // Closing the relatives events in case of pending 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) { $abstractEvent = new EyeosEventNotification(); $abstractEvent->setEventInformation($event); $abstractEvent->setHasEnded(true); $eventManager->updateEventNotification($abstractEvent); } // Closing the relatives events in case of invited request... $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) { $abstractEvent = new EyeosEventNotification(); $abstractEvent->setEventInformation($event); $abstractEvent->setHasEnded(true); $eventManager->updateEventNotification($abstractEvent); } } $NetSyncMessage = new NetSyncMessage('NSGroup', 'userWorkgroupAssignationUpdated', $userId, $groupId); NetSyncController::getInstance()->send($NetSyncMessage); } }
public function searchEvents(EyeosEventNotification $event) { $query = 'SELECT * FROM eventnotificationinformation WHERE 1=1 '; if ($event->isQuestion()) { $query .= 'AND isquestion = :isquestion '; } if ($event->getType()) { $query .= 'AND type = :type '; } if ($event->getEventData()) { $query .= 'AND eventdata LIKE :eventdata '; } if ($event->getSender()) { $query .= 'AND sender = :sender '; } if ($event->getReceiver()) { $query .= 'AND receiver = :receiver '; } $dbh = $this->dao; $stmt = $dbh->prepare($query); $bindParam = array(); if ($event->isQuestion()) { $bindParam['isquestion'] = $event->isQuestion(); } if ($event->getType()) { $bindParam['type'] = $event->getType(); } if ($event->getEventData()) { $eventData = '%' . $event->getEventData() . '%'; $bindParam['eventdata'] = $eventData; } if ($event->getSender()) { $bindParam['sender'] = $event->getSender(); } if ($event->getReceiver()) { $bindParam['receiver'] = $event->getReceiver(); } $query .= 'ORDER BY creationdate ASC'; $stmt = $dbh->execute($stmt, $bindParam); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); $toReturn = array(); foreach ($result as $entry) { $objectClass = new EventNotificationInformation(); $row = new $objectClass(); foreach ($entry as $key => $value) { $methodName = 'set' . ucfirst($key); $row->{$methodName}($value); } $row->setEventData(unserialize($row->getEventData())); $toReturn[] = $row; } return $toReturn; }