public function inviteSpeaker(SpeakerInvitationInputModel $model) : ServiceResponse { $lectureId = $model->getLectureId(); $speakerId = $model->getSpeakerId(); $conferenceId = $model->getConferenceId(); $lecture = $this->dbContext->getLecturesRepository()->filterById(" = {$lectureId}")->findOne(); $speaker = $this->dbContext->getUsersRepository()->filterById(" = {$speakerId}")->findOne(); if ($lecture->getId() == null) { return new ServiceResponse(404, "Lecture not found."); } if ($speaker->getId() == null) { return new ServiceResponse(404, "Speaker not found."); } $conference = $this->dbContext->getConferencesRepository()->filterById(" = {$conferenceId}")->findOne(); if ($conference->getId() == null) { return new ServiceResponse(404, 'Conference not found.'); } if (HttpContext::getInstance()->getIdentity()->getUserId() != $conference->getOwnerId()) { return new ServiceResponse(401, 'Only conference owners can invite speakers.'); } $invitation = $this->dbContext->getSpeakerInvitationsRepository()->filterByLectureId(" = {$lectureId}")->filterBySpeakerId(" = {$speakerId}")->findOne(); if ($invitation->getId() != null) { return new ServiceResponse(409, "Speaker is already invited."); } $this->dbContext->getSpeakerInvitationsRepository()->filterByLectureId(" = {$lectureId}")->delete(); $speakerInvitation = new SpeakerInvitation($lectureId, $speakerId, 0); $this->dbContext->getSpeakerInvitationsRepository()->add($speakerInvitation); $lecture->setSpeaker_Id($speakerId); $title = $lecture->getTitle(); $message = "You received Speaker invitation for the lecture '{$title}'."; $notyService = new NotificationsService($this->dbContext); $notyService->sendNotification($speakerId, $message); $this->dbContext->saveChanges(); return new ServiceResponse(null, "Invitation sent."); }
/** * Method('GET') * Authorize */ public function all() : View { $userId = HttpContext::getInstance()->getIdentity()->getUserId(); $service = new NotificationsService($this->dbContext); $result = $service->getAllNotifications($userId); $this->processResponse($result); return new View('Notifications', 'all', $result->getModel()); }
/** * @param VenueInputModel $model * @return ServiceResponse * @throws \Exception */ public function addVenue(VenueInputModel $model) : ServiceResponse { $venue = new Venue($model->getTitle(), $model->getDescription(), $model->getAddress(), HttpContext::getInstance()->getIdentity()->getUserId()); $this->dbContext->getVenuesRepository()->add($venue); $this->dbContext->saveChanges(); $title = $model->getTitle(); $owner = HttpContext::getInstance()->getIdentity()->getUsername(); $message = "New conference titled '{$title}' was added by user {$owner}."; $notyService = new NotificationsService($this->dbContext); $notyService->postToAll($message); return new ServiceResponse(null, 'Venue added successfully.'); }
public function sendVenueRequest(VenueRequestInputModel $model) : ServiceResponse { $conferenceId = $model->getConferenceId(); $venueId = $model->getVenueId(); $conference = $this->dbContext->getConferencesRepository()->filterById(" = {$conferenceId}")->findOne(); if ($conference->getId() == null) { return new ServiceResponse(404, "Conference not found."); } $venue = $this->dbContext->getVenuesRepository()->filterById(" = {$venueId}")->findOne(); if ($venue->getId() == null) { return new ServiceResponse(404, "Venue not found."); } if (HttpContext::getInstance()->getIdentity()->getUserId() != $conference->getOwnerId()) { return new ServiceResponse(401, 'Only conference owners are allowed to send venue requests.'); } $testRequest = $this->dbContext->getVenueReservationRequestsRepository()->filterByConferenceId(" = {$conferenceId}")->filterByVenueId(" = {$venueId}")->findOne(); if ($testRequest->getId() != null) { return new ServiceResponse(1, "Request for this venue already exists."); } $this->dbContext->getVenueReservationRequestsRepository()->filterByConferenceId(" = {$conferenceId}")->delete(); $conference->setVenue_Id($model->getVenueId()); $this->dbContext->saveChanges(); $venueRequest = new VenueReservationRequest($venueId, $conferenceId, 0); $this->dbContext->getVenueReservationRequestsRepository()->add($venueRequest); $conferenceTitle = $conference->getTitle(); $venueTitle = $venue->getTitle(); $message = "You received venue reservation request for venue '{$venueTitle}' by conference '{$conferenceTitle}'."; $notyService = new NotificationsService($this->dbContext); $notyService->sendNotification($venue->getOwnerId(), $message); $this->dbContext->saveChanges(); return new ServiceResponse(null, "Venue request sent successfully."); }
<a class = "navbar-brand logo-container" href="/home/index"> <img src="/Content/images/logo.png" alt="Conference Manager logo" class="logo-image" /> </a> </div> <div class="navbar-collapse collapse"> <?php use RedDevil\Core\HttpContext; use RedDevil\Services\NotificationsService; use RedDevil\View; if (HttpContext::getInstance()->getIdentity()->isAuthorised()) { ?> <ul class="nav navbar-nav"> <li><a href="/notifications/all">Notifications <span class="badge"> <?php echo NotificationsService::getUnreadCount(HttpContext::getInstance()->getIdentity()->getUserId()); ?> </span></a></li> <li><a href="/messages/index">Messages <span class="badge">11</span></a></li> <?php if (HttpContext::getInstance()->getIdentity()->isInRole('admin')) { echo "<li><a href=\"/admin/manageRoles\">Admin </a></li>"; } ?> </ul> <?php } ?> <form class="navbar-form navbar-left" role="search" action="/search/find" method="post">