Ejemplo n.º 1
0
 /**
  * Gets the Event entrants.
  *
  * @param integer $id
  * @return EntrantsModel|null
  */
 public function getEventEntrantsById($eventId)
 {
     $entryArray = $this->db()->select('*')->from('events_entrants')->where(array('event_id' => $eventId))->limit('17')->execute()->fetchRows();
     if (empty($entryArray)) {
         return null;
     }
     $entry = array();
     foreach ($entryArray as $entries) {
         $entryModel = new EntrantsModel();
         $entryModel->setUserId($entries['user_id']);
         $entryModel->setStatus($entries['status']);
         $entry[] = $entryModel;
     }
     return $entry;
 }
Ejemplo n.º 2
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')));
 }