protected function toggleICalEventPublish($cid, $newstate) { // clean out the cache $cache =& JFactory::getCache('com_jevents'); $cache->clean(JEV_COM_COMPONENT); // Must be at least an event creator to publish events $is_event_editor = JEVHelper::isEventPublisher(); if (!$is_event_editor) { if (is_array($cid)) { foreach ($cid as $id) { if (!JEVHelper::canPublishOwnEvents($id)) { JError::raiseError(403, JText::_('ALERTNOTAUTH')); } } } $is_event_editor = true; } if (!$is_event_editor) { JError::raiseError(403, JText::_('ALERTNOTAUTH')); } $db =& JFactory::getDBO(); foreach ($cid as $id) { // I should be able to do this in one operation but that can come later $event = $this->queryModel->getEventById(intval($id), 1, "icaldb"); if (is_null($event) || !JEVHelper::canPublishEvent($event)) { JError::raiseError(403, JText::_('ALERTNOTAUTH')); } $sql = "UPDATE #__jevents_vevent SET state={$newstate} where ev_id='" . $id . "'"; $db->setQuery($sql); $db->query(); $params = JComponentHelper::getParams(JEV_COM_COMPONENT); if ($newstate == 1 && $params->get("com_notifyauthor", 0) && !$event->_author_notified) { $sql = "UPDATE #__jevents_vevent SET author_notified=1 where ev_id='" . $id . "'"; $db->setQuery($sql); $db->query(); JEV_CommonFunctions::notifyAuthorPublished($event); } } // I also need to trigger any onpublish event triggers $dispatcher =& JDispatcher::getInstance(); // just incase we don't have jevents plugins registered yet JPluginHelper::importPlugin("jevents"); $res = $dispatcher->trigger('onPublishEvent', array($cid, $newstate)); if (JFactory::getApplication()->isAdmin()) { $this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . '&task=icalevent.list', "IcalEvent : New published state Saved"); } else { $Itemid = JRequest::getInt("Itemid"); list($year, $month, $day) = JEVHelper::getYMD(); $rettask = JRequest::getString("rettask", "day.listevents"); // Don't return to the event detail since we may be filtering on published state! //$this->setRedirect( JRoute::_('index.php?option=' . JEV_COM_COMPONENT. "&task=icalrepeat.detail&evid=$id&year=$year&month=$month&day=$day&Itemid=$Itemid",false),"IcalEvent : New published state Saved"); $this->setRedirect(JRoute::_('index.php?option=' . JEV_COM_COMPONENT . "&task={$rettask}&year={$year}&month={$month}&day={$day}&Itemid={$Itemid}", false), "IcalEvent : New published state Saved"); } }