public function indexAction() { $this->_helper->layout->setLayout('full'); $event_id = $this->_getParam('id'); if ($this->getRequest()->isGet()) { $proxy = new SxCms_Event_DataMapper(); $event = $proxy->getEventById($event_id); } if ($this->getRequest()->isPost()) { $proxy = new SxCms_Event_DataMapper(); $event = $proxy->getEventById($event_id); $subscription = array(); $errors = array(); foreach ($event->getFields() as $field) { if (!$this->_getParam($field->getName())) { $errors[$field->getName()] = $field->getLabel(); } $subscription[$field->getName()] = $this->_getParam($field->getName()); } if (sizeof($errors) == 0) { $Subscription = new SxCms_Event_Subscription(); $Subscription->setEventId($event_id); if ($event->isValidateIntern()) { $Subscription->setStatus(0); $sub_id = $Subscription->save(); } else { $Subscription->setStatus(1); $sub_id = $Subscription->save(); $Subscription->sendConfirmation(); } foreach ($event->getFields() as $field) { if ($field->getType() == 'checkbox') { $value = implode(';', $this->_getParam($field->getName())); } else { $value = $this->_getParam($field->getName()); } $SubF = new SxCms_Event_Subscription_Field(); $SubF->setSubscriptionId($sub_id)->setFieldId($field->getId())->setName($field->getName())->setValue($value); $SubF->save(); } $this->view->result = true; } else { $this->view->errors = $errors; } $this->view->subscription = $subscription; } $mapperSub = new SxCms_Event_Subscription_DataMapper(); $subscriptions = $mapperSub->getSubscriptionsForEvent($event_id); $now = strtotime(date('Y-m-d')); if (count($subscriptions) >= $event->getSubscriptionMax() || strtotime($event->getDateEnd()) < $now || strtotime($event->getDateStart()) > $now) { $event->setSubscriptionAllow(false); } $this->view->subscriptions = $subscriptions; $this->view->event = $event; $this->getResponse()->setHeader('Last-Modified', $event->getDateStart("%a, %d %b %Y %H:%I%S GMT")); }
public function listAction() { SxCms_Acl::requireAcl('subscriptions', 'subscription.list'); $event_id = $this->_getParam('id'); $proxy = new SxCms_Event_DataMapper(); $this->_event = $proxy->getEventById($event_id); if (!$this->_event) { $this->_helper->redirector->gotoSimple('index', 'event', null, array()); } $subProxy = new SxCms_Event_Subscription_DataMapper(); $subscriptions = $subProxy->getSubscriptionsForEvent($this->_getParam('id')); $fieldProxy = new SxCms_Event_Field_DataMapper(); $fields = $fieldProxy->getFieldsByEvent($this->_getParam('id')); $this->view->event = $this->_event; $this->view->subscriptions = $subscriptions; $this->view->fields = $fields; }