public function deleteAction()
 {
     SxCms_Acl::requireAcl('subscriptions', 'subscription.delete');
     $subscription_id = $this->_getParam('id');
     $proxy = new SxCms_Event_Subscription_DataMapper();
     $subscription = $proxy->getSubscriptionById($subscription_id);
     $Subscription = new SxCms_Event_Subscription();
     $Subscription->setSubscriptionId($subscription_id);
     $Subscription->delete();
     $flashMessenger = $this->_helper->getHelper('FlashMessenger');
     $flashMessenger->addMessage($this->admin_tmx->_('subscriptiondeleted'));
     $this->_helper->redirector->gotoSimple('list', 'event_subscription', null, array('id' => $subscription->getEventId()));
 }
예제 #2
0
 public function getSubscriptionById($subscription_id)
 {
     $db = Zend_Registry::get('db');
     $select = $db->select()->from(array('sub' => 'EventSubscription'), array('*'))->where('sub.subscription_id = ?', (int) $subscription_id);
     $result = $db->fetchRow($select);
     $subscription = new SxCms_Event_Subscription();
     $subscription->setSubscriptionId((int) $result['subscription_id'])->setEventId((int) $result['event_id'])->setStatus($result['status']);
     $select = $db->select()->from(array('field' => 'EventSubscriptionField'), array('*'))->where('field.subscription_id = ?', (int) $result['subscription_id']);
     $fields = $db->fetchAll($select);
     foreach ($fields as $field) {
         $subscription->addFields($field['name'], $field['value']);
     }
     return $subscription;
 }
예제 #3
0
 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"));
 }