/** * This just updates the details not the content of the calendar * */ function savedetails() { $authorised = false; if (JFactory::getApplication()->isAdmin()) { $redirect_task = "icals.list"; } else { $redirect_task = "month.calendar"; } $user =& JFactory::getUser(); if (!($authorised || JEVHelper::isAdminUser($user))) { $this->setRedirect("index.php?option=" . JEV_COM_COMPONENT . "&task={$redirect_task}", "Not Authorised - must be super admin"); return; } $icsid = intval(JRequest::getVar('icsid', 0)); $cid = JRequest::getVar('cid', array(0)); JArrayHelper::toInteger($cid); if (is_array($cid) && count($cid) > 0) { $cid = $cid[0]; } else { $cid = 0; } $db =& JFactory::getDBO(); // include ical files if ($icsid > 0 || $cid != 0) { $icsid = $icsid > 0 ? $icsid : $cid; $query = "SELECT icsf.* FROM #__jevents_icsfile as icsf WHERE ics_id={$icsid}"; $db->setQuery($query); $currentICS = $db->loadObjectList(); if (count($currentICS) > 0) { $currentICS = $currentICS[0]; } else { $this->setRedirect("index.php?option=" . JEV_COM_COMPONENT . "&task={$redirect_task}", "Invalid Ical Details"); $this->redirect(); } $catid = JRequest::getInt('catid', $currentICS->catid); if ($catid <= 0 && $currentICS->catid > 0) { $catid = intval($currentICS->catid); } $access = intval(JRequest::getVar('access', $currentICS->access)); if ($access < 0 && $currentICS->access >= 0) { $access = intval($currentICS->access); } $state = intval(JRequest::getVar('state', $currentICS->state)); if ($state < 0 && $currentICS->state >= 0) { $state = intval($currentICS->state); } $icsLabel = JRequest::getVar('icsLabel', $currentICS->label); if ($icsLabel == "" && strlen($currentICS->icsLabel) >= 0) { $icsLabel = $currentICS->icsLabel; } $uploadURL = JRequest::getVar('uploadURL', $currentICS->srcURL); if ($uploadURL == "" && strlen($currentICS->srcURL) >= 0) { $uploadURL = $currentICS->srcURL; } $isdefault = JRequest::getInt('isdefault', $currentICS->isdefault); $autorefresh = JRequest::getInt('autorefresh', $currentICS->autorefresh); $ignoreembed = JRequest::getInt('ignoreembedcat', $currentICS->ignoreembedcat); // We are only updating identifiers etc $ics = new iCalICSFile($db); $ics->load($icsid); $ics->catid = $catid; $ics->isdefault = $isdefault; $ics->created_by = JRequest::getInt("created_by", $currentICS->created_by); $ics->state = $state; $ics->access = $access; $ics->label = $icsLabel; $ics->srcURL = $uploadURL; $ics->ignoreembedcat = $ignoreembed; // TODO update access and state $ics->updateDetails(); $this->setRedirect("index.php?option=" . JEV_COM_COMPONENT . "&task={$redirect_task}", JText::_('ICS_SAVED')); $this->redirect(); } }
/** * Used to create Ical from raw strring */ function newICSFileFromString($rawtext, $icsid, $catid, $access = 0, $state = 1, $label = "", $autorefresh = 0, $ignoreembedcat = 0) { $db = JFactory::getDBO(); $temp = null; $temp = new iCalICSFile($db); if ($icsid > 0) { $temp->load($icsid); $temp->icaltype = 2; // i.e. from file } else { $temp->_setup($icsid, $catid, $access, $state, $autorefresh, $ignoreembedcat); $temp->srcURL = ""; $temp->filename = "_from_events_cat" . $catid; $temp->icaltype = 2; // i.e. from file if ($label != "") { $temp->label = $label; } else { $temp->label = $temp->filename; } } $temp->_icalInfo =& JEVHelper::iCalInstance("", $rawtext); return $temp; }