Beispiel #1
0
 public function eventAction()
 {
     $eventMapper = new EventMapper();
     $entrantsMapper = new EntrantsMapper();
     $entrantsModel = new EntrantsModel();
     $commentMapper = new CommentMapper();
     $commentModel = new CommentModel();
     $event = $eventMapper->getEventById($this->getRequest()->getParam('id'));
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuEvents'), array('controller' => 'index', 'action' => 'index'))->add($event->getTitle(), array('controller' => 'show', 'action' => 'event', 'id' => $event->getId()));
     if ($this->getRequest()->isPost()) {
         if ($this->getRequest()->getPost('save')) {
             $entrantsModel->setEventId(trim($this->getRequest()->getPost('id')));
             $entrantsModel->setUserId($this->getUser()->getId());
             $entrantsModel->setStatus(trim($this->getRequest()->getPost('save')));
             $entrantsMapper->saveUserOnEvent($entrantsModel);
             $this->addMessage('saveSuccess');
         }
         if ($this->getRequest()->getPost('commentEvent')) {
             $date = new \Ilch\Date();
             $commentModel->setKey('events/show/event/id/' . $this->getRequest()->getParam('id'));
             $commentModel->setText($this->getRequest()->getPost('commentEvent'));
             $commentModel->setDateCreated($date);
             $commentModel->setUserId($this->getUser()->getId());
             $commentMapper->save($commentModel);
             $this->addMessage('saveSuccess');
         }
         if ($this->getRequest()->getPost('deleteUser')) {
             $entrantsMapper->deleteUserFromEvent($this->getRequest()->getParam('id'), $this->getUser()->getId());
             $this->addMessage('deleteSuccess');
         }
         if ($this->getRequest()->getPost('deleteEvent')) {
             $eventMapper->delete($this->getRequest()->getParam('id'));
             $this->addMessage('deleteSuccess');
             $this->redirect(array('controller' => 'index', 'action' => 'index'));
         }
     }
     if ($this->getUser()) {
         $this->getView()->set('eventEntrants', $entrantsMapper->getEventEntrants($this->getRequest()->getParam('id'), $this->getUser()->getId()));
     }
     $this->getView()->set('event', $eventMapper->getEventById($this->getRequest()->getParam('id')));
     $this->getView()->set('eventEntrantsUser', $entrantsMapper->getEventEntrantsById($this->getRequest()->getParam('id')));
     $this->getView()->set('eventEntrantsCount', count($entrantsMapper->getEventEntrantsById($this->getRequest()->getParam('id'))));
     $this->getView()->set('eventComments', $commentMapper->getCommentsByKey('events/show/event/id/' . $this->getRequest()->getParam('id')));
 }
Beispiel #2
0
 public function delAction()
 {
     if ($this->getRequest()->isSecure()) {
         $eventMapper = new EventMapper();
         $eventMapper->delete($this->getRequest()->getParam('id'));
         $this->addMessage('deleteSuccess');
     }
     $this->redirect(array('action' => 'index'));
 }