/** * 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 completing an event creation to redirect either to the event listing for the event item. * * @author Jason Rey <*****@*****.**> * @since 1.3 * @access public * @param SocialEvent $event The SocialEvent object. */ public function complete($event) { // Recurring support // If no recurring data, then just redirect accordingly. // If event is in pending, then also redirect accordingly. if (empty($event->recurringData) || $event->isPending()) { $this->info->set($this->getMessage()); if ($event->isPublished()) { return $this->redirect(FRoute::events(array('layout' => 'item', 'id' => $event->getAlias()), false)); } return $this->redirect(FRoute::events(array(), false)); } // If has recurring data, then we need to show the complete page to create all the necessary recurring events 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_CREATE_RECURRING_EVENT')); FD::page()->title(JText::_('COM_EASYSOCIAL_PAGE_TITLE_CREATE_RECURRING_EVENT')); // 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', $schedule); $this->set('event', $event); echo parent::display('site/events/createRecurring'); }