function delete(){
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
$cid = JRequest::getVar( 'cid', array(0) );
JArrayHelper::toInteger($cid);
$db = JFactory::getDBO();
// check this won't create orphan events
$query = "SELECT ev_id FROM #__jevents_vevent WHERE icsid in (".implode(",",$cid).")";
$db->setQuery( $query );
$kids = $db->loadObjectList();
if (count($kids)>0){
$this->setRedirect( "index.php?option=".JEV_COM_COMPONENT."&task=icals.list", JText::_("DELETE_CREATES_ORPHAN_EVENTS") );
return;
}
$icsids = $this->_deleteICal($cid);
$query = "DELETE FROM #__jevents_icsfile WHERE ics_id IN ($icsids)";
$db->setQuery( $query);
$db->query();
$this->setRedirect( "index.php?option=".JEV_COM_COMPONENT."&task=icals.list", "ICal deleted" );
}
function _deleteICal($cid){
$db = JFactory::getDBO();
$icsids = implode(",",$cid);
$query = "SELECT ev_id FROM #__jevents_vevent WHERE icsid IN ($icsids)";
$db->setQuery( $query);
$veventids = $db->loadColumn();
$veventidstring = implode(",",$veventids);
if ($veventidstring) {
// TODO the ruccurences should take care of all of these??
// This would fail if all recurrances have been 'adjusted'
$query = "SELECT DISTINCT (eventdetail_id) FROM #__jevents_repetition WHERE eventid IN ($veventidstring)";
$db->setQuery( $query);
$detailids = $db->loadColumn();
$detailidstring = implode(",",$detailids);
$query = "DELETE FROM #__jevents_rrule WHERE eventid IN ($veventidstring)";
$db->setQuery( $query);
$db->query();
$query = "DELETE FROM #__jevents_repetition WHERE eventid IN ($veventidstring)";
$db->setQuery( $query);
$db->query();
if ($detailidstring) {
$query = "DELETE FROM #__jevents_vevdetail WHERE evdet_id IN ($detailidstring)";
$db->setQuery( $query);
$db->query();
}
}
if ($icsids) {
$query = "DELETE FROM #__jevents_vevent WHERE icsid IN ($icsids)";
$db->setQuery( $query);
$db->query();
}
return $icsids;
}
$query = "SELECT ev_id FROM #__jevents_vevent WHERE icsid in (".implode(",",$cid).")";
$db->setQuery( $query );
$kids = $db->loadObjectList();
if (count($kids)>0){
if ($icsids) {
$query = "DELETE FROM #__jevents_vevent WHERE icsid IN ($icsids)";
$db->setQuery( $query);
$db->query();
}
Unlike many Joomla calendars we do not charge to download JEvents - please show your support for this project by becoming a member of the JEvents Club Club members get access to early releases, exclusive member support forums, and Silver and Gold members can use many exciting JEvents addons
Your membership will ensure that JEvents continues to be the best events calendar for Joomla.
GWE Systems Ltd, the company behind JEvents, is excited to announce the preview release of EasyLayouts - the tool that makes it easy to create layouts for your Joomla content and custom fields.
See our blog post for an exciting special offer to our Gold Members