예제 #1
0
 /**
  * function that adjusts instances in the repetitions table
  *
  */
 function adjustRepetition($matchingEvent)
 {
     $eventid = $this->ev_id;
     $start = iCalImport::unixTime($this->recurrence_id);
     $duplicatecheck = md5($eventid . $start);
     // find the existing repetition in order to get the detailid
     $db =& JFactory::getDBO();
     $sql = "SELECT * FROM #__jevents_repetition WHERE duplicatecheck='{$duplicatecheck}'";
     $db->setQuery($sql);
     $matchingRepetition = $db->loadObject();
     if (!isset($matchingRepetition)) {
         return false;
     }
     // I now create a new evdetail instance
     $newDetail = iCalEventDetail::iCalEventDetailFromData($this->data);
     if (isset($matchingRepetition) && isset($matchingRepetition->eventdetail_id)) {
         // This traps the first time through since the 'global id has not been overwritten
         if ($matchingEvent->detail_id != $matchingRepetition->eventdetail_id) {
             //$newDetail->evdet_id = $matchingRepetition->eventdetail_id;
         }
     }
     if (!$newDetail->store()) {
         return false;
     }
     // clumsy - add in the new version with the correct times (does not deal with modified descriptions and sequence)
     $start = JevDate::strftime('%Y-%m-%d %H:%M:%S', $newDetail->dtstart);
     if ($newDetail->dtend != 0) {
         $end = $newDetail->dtend;
     } else {
         $end = $start + $newDetail->duration;
     }
     // iCal for whole day uses 00:00:00 on the next day JEvents uses 23:59:59 on the same day
     list($h, $m, $s) = explode(":", JevDate::strftime("%H:%M:%S", $end));
     if ($h + $m + $s == 0) {
         $end = JevDate::strftime('%Y-%m-%d 23:59:59', $end - 86400);
     } else {
         $end = JevDate::strftime('%Y-%m-%d %H:%M:%S', $end);
     }
     $duplicatecheck = md5($eventid . $start);
     $db =& JFactory::getDBO();
     $sql = "UPDATE #__jevents_repetition SET eventdetail_id=" . $newDetail->evdet_id . ", startrepeat='" . $start . "'" . ", endrepeat='" . $end . "'" . ", duplicatecheck='" . $duplicatecheck . "'" . " WHERE rp_id=" . $matchingRepetition->rp_id;
     $db->setQuery($sql);
     return $db->query();
 }
예제 #2
0
 function savefuture()
 {
     // experimentaal code disabled for count (startthe time being
     throw new Exception(JText::_('ALERTNOTAUTH'), 403);
     return false;
     if (!JEVHelper::isEventCreator()) {
         throw new Exception(JText::_('ALERTNOTAUTH'), 403);
         return false;
     }
     // clean out the cache
     $cache = JFactory::getCache('com_jevents');
     $cache->clean(JEV_COM_COMPONENT);
     echo "<pre>";
     $rpid = JRequest::getInt("rp_id", 0);
     $event = $this->queryModel->listEventsById($rpid, 1, "icaldb");
     $data = array();
     foreach (get_object_vars($event) as $key => $val) {
         if (strpos($key, "_") == 0) {
             $data[substr($key, 1)] = $val;
         }
     }
     echo var_export($data, true);
     echo "\n\n";
     // Change the underlying event repeat rule details  !!
     $query = "SELECT * FROM #__jevents_rrule WHERE rr_id=" . $event->_rr_id;
     $db = JFactory::getDBO();
     $db->setQuery($query);
     $this->rrule = null;
     $this->rrule = $db->loadObject();
     $this->rrule = iCalRRule::iCalRRuleFromDB(get_object_vars($this->rrule));
     echo var_export($this->rrule, true);
     // TODO *** I must save the modified repeat rule
     // Create the copy of the event and reset the repeat rule to the new values
     foreach ($this->rrule->data as $key => $val) {
         $key = "_" . $key;
         $event->{$key} = $val;
     }
     $event->eventid = 0;
     $event->ev_id = 0;
     // create copy of rrule by resetting id and saving
     $this->rrule->rr_id = 0;
     $this->rrule->eventid = 0;
     if (intval($this->rrule->until) > 0) {
         // The until date is in the future so no need to do anything here
     } else {
         // count prior matching repetition
         $query = "SELECT count(startrepeat) FROM #__jevents_repetition WHERE eventid=" . $repeatdata->eventid . " AND startrepeat<'" . $repeatdata->startrepeat;
         $db->setQuery($query);
         $countrepeat = $db->loadResult();
         $this->rrule->count -= $countrepeat;
     }
     //$this->rrule->store();
     $event->_rr_id = $this->rrule->rr_id;
     //I must copy the event detail and its id too
     $eventDetail = new iCalEventDetail($db);
     $eventDetail->load($event->_eventdetail_id);
     $eventDetail->evdet_id = 0;
     $eventDetail->store();
     $event->_detail_id = $eventDetail->evdet_id;
     $event->_eventdetail_id = $eventDetail->evdet_id;
     // TODO I must now regenerate the repetitions
     $event->_rp_id = 0;
     $event->store();
     echo "</pre>";
     // TODO I must store a copy of the event id in the rrule table
     exit;
     // now delete exising current and future repeats - this resets the rrule for the truncated event
     $this->_deleteFuture();
     if (JFactory::getApplication()->isAdmin()) {
         $this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . '&task=icalrepeat.list&cid[]=' . $rpt->eventid, "" . JText::_("JEV_ICAL_RPT_UPDATED") . "");
     } else {
         list($year, $month, $day) = JEVHelper::getYMD();
         $rettask = JRequest::getString("rettask", "day.listevents");
         $this->setRedirect('index.php?option=' . JEV_COM_COMPONENT . "&task={$rettask}&evid=" . $rpt->rp_id . "&Itemid=" . JEVHelper::getItemid() . "&year={$year}&month={$month}&day={$day}", "" . JText::_("JEV_ICAL_RPT_UPDATED") . "");
     }
 }
예제 #3
0
 /**
  * Pseudo Constructor
  *
  * @param iCal Event parsed from ICS file as an array $ice
  * @return n/a
  */
 public static function iCalEventDetailFromDB($icalrowAsArray)
 {
     $db = JFactory::getDBO();
     $temp = new iCalEventDetail($db);
     $temp->_data = $icalrowAsArray;
     $temp->convertData();
     return $temp;
 }