/** * Triggers when an event is created * * @since 1.3 * @access public * @param SocialEvent The event object * @param SocialUser The user object * @param bool Determines if the event is a new event * @return */ public function onEventAfterSave(SocialEvent &$event, SocialUser &$author, $isNew) { // When a new event is created, we want to ensure that it's stored in the user's calendar if ($isNew) { $eventstart = $event->getEventStart(); $eventend = $event->getEventEnd(); // Ensure that the start and end date is set if (!$eventstart && !$eventend) { return; } $calendar = FD::table('Calendar'); // Get the start and end date $calendar->title = $event->getName(); $calendar->description = $event->description; $calendar->uid = $event->id; $calendar->type = SOCIAL_TYPE_EVENT; $calendar->date_start = $eventstart->toSql(); $calendar->date_end = $eventend->toSql(); $calendar->user_id = $author->id; $calendar->store(); } }
/** * 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'); }