function handleDate($key, $value) { $rawvalue = $value; // we have an array of exdates if (JString::strpos($key, "EXDATE") === 0 && JString::strpos($value, ",") > 0) { $parts = explode(",", $value); $value = array(); foreach ($parts as $val) { $value[] = $this->unixTime($val); } } else { $tz = false; if (JString::strpos($key, "TZID=") > 0) { $parts = explode(";", $key); if (count($parts) >= 2 && JString::strpos($parts[1], "TZID=") !== false) { $tz = str_replace("TZID=", "", $parts[1]); $tz = iCalImport::convertWindowsTzid($tz); } } $value = $this->unixTime($value, $tz); } $parts = explode(";", $key); if (count($parts) < 2 || JString::strlen($parts[1]) == 0) { $rawkey = $key . "RAW"; return array($key, $value, $rawkey, $rawvalue); } $key = $parts[0]; $rawkey = $key . "RAW"; return array($key, $value, $rawkey, $rawvalue); }
/** * function that adjusts instances in the repetitions table * */ function adjustRepetition($matchingEvent) { $eventid = $this->ev_id; $tz = false; if (JString::stristr($this->recurrence_id, "TZID")) { list($tz, $this->recurrence_id) = explode(";", $this->recurrence_id); $tz = str_replace("TZID=", "", $tz); $tz = iCalImport::convertWindowsTzid($tz); } $start = iCalImport::unixTime($this->recurrence_id, $tz); $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(); }