Ejemplo n.º 1
0
 /**
  * Post action after updating an event to redirect to appropriately.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3
  * @access public
  * @param  SocialEvent  $event  The SocialEvent object.
  */
 public function update($event = null)
 {
     // Recurring support
     // If applies to all, we need to show a "progress update" page to update all childs through ajax.
     $applyAll = !empty($event) && $event->hasRecurringEvents() && $this->input->getInt('applyRecurring');
     // Check if need to create recurring event
     $createRecurring = !empty($event->recurringData);
     // If no apply, and no recurring create, then redirect accordingly.
     if (!$applyAll && !$createRecurring) {
         FD::info()->set($this->getMessage());
         if ($this->hasErrors() || empty($event)) {
             return $this->redirect(FRoute::events());
         }
         return $this->redirect($event->getPermalink());
     }
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_EVENTS'), FRoute::events());
     FD::page()->breadcrumb($event->getName(), $event->getPermalink());
     FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_EDIT_EVENT'));
     FD::page()->title(JText::sprintf('COM_EASYSOCIAL_PAGE_TITLE_EDIT_EVENT_TITLE', $event->getName()));
     $post = JRequest::get('POST');
     $json = FD::json();
     $data = array();
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     foreach ($post as $key => $value) {
         if (in_array($key, $disallowed)) {
             continue;
         }
         if (is_array($value)) {
             $value = $json->encode($value);
         }
         $data[$key] = $value;
     }
     $string = $json->encode($data);
     $this->set('data', $string);
     $this->set('event', $event);
     $updateids = array();
     if ($applyAll) {
         $children = $event->getRecurringEvents();
         foreach ($children as $child) {
             $updateids[] = $child->id;
         }
     }
     $this->set('updateids', $json->encode($updateids));
     $schedule = array();
     if ($createRecurring) {
         // If there is recurring data, then we back up the post values and the recurring data in the the event params
         $clusterTable = FD::table('Cluster');
         $clusterTable->load($event->id);
         $eventParams = FD::makeObject($clusterTable->params);
         $eventParams->postdata = $data;
         $eventParams->recurringData = $event->recurringData;
         $clusterTable->params = FD::json()->encode($eventParams);
         $clusterTable->store();
         // Get the recurring schedule
         $schedule = FD::model('Events')->getRecurringSchedule(array('eventStart' => $event->getEventStart(), 'end' => $event->recurringData->end, 'type' => $event->recurringData->type, 'daily' => $event->recurringData->daily));
     }
     $this->set('schedule', $json->encode($schedule));
     echo parent::display('site/events/update');
 }
Ejemplo n.º 2
0
 /**
  * Post action after storing an event to redirect to the appropriate page according to the task.
  *
  * @author Jason Rey <*****@*****.**>
  * @since  1.3
  * @access public
  * @param  string       $task   The task action.
  * @param  SocialEvent  $event  The event object.
  */
 public function store($task, $event)
 {
     // Recurring support
     // If applies to all, we need to show a "progress update" page to update all childs through ajax.
     $applyAll = $event->hasRecurringEvents() && $this->input->getInt('applyRecurring');
     // Check if need to create recurring event
     $createRecurring = !empty($event->recurringData);
     if (!$applyAll && !$createRecurring) {
         FD::info()->set($this->getMessage());
         if ($task === 'apply') {
             $activeTab = JRequest::getWord('activeTab', 'event');
             return $this->redirect(FRoute::url(array('view' => 'events', 'layout' => 'form', 'id' => $event->id, 'activeTab' => $activeTab)));
         }
         if ($task === 'savenew') {
             return $this->redirect(FRoute::url(array('view' => 'events', 'layout' => 'form', 'category_id' => $event->category_id)));
         }
         return $this->redirect(FRoute::url(array('view' => 'events')));
     }
     $this->setHeading('COM_EASYSOCIAL_EVENTS_APPLYING_RECURRING_EVENT_CHANGES');
     $this->setDescription('COM_EASYSOCIAL_EVENTS_APPLYING_RECURRING_EVENT_CHANGES_DESCRIPTION');
     $post = JRequest::get('POST');
     $json = FD::json();
     $data = array();
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     foreach ($post as $key => $value) {
         if (in_array($key, $disallowed)) {
             continue;
         }
         if (is_array($value)) {
             $value = $json->encode($value);
         }
         $data[$key] = $value;
     }
     $string = $json->encode($data);
     $this->set('data', $string);
     $this->set('event', $event);
     $updateids = array();
     if ($applyAll) {
         $children = $event->getRecurringEvents();
         foreach ($children as $child) {
             $updateids[] = $child->id;
         }
     }
     $this->set('updateids', $json->encode($updateids));
     $schedule = array();
     if ($createRecurring) {
         // Get the recurring schedule
         $schedule = FD::model('Events')->getRecurringSchedule(array('eventStart' => $event->getEventStart(), 'end' => $event->recurringData->end, 'type' => $event->recurringData->type, 'daily' => $event->recurringData->daily));
     }
     $this->set('schedule', $json->encode($schedule));
     $this->set('task', $task);
     return parent::display('admin/events/store');
 }