/** * 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(); }
/** * Converts $data into class values * */ function convertData() { $this->_rawdata = serialize($this->_data); $this->processField("dtstart", 0); $this->processField("dtstartraw", ""); $this->processField("duration", 0); $this->processField("durationraw", ""); $this->processField("dtend", 0); $this->processField("dtendraw", ""); $this->processField("dtstamp", ""); $this->processField("class", ""); $this->processField("categories", ""); $this->processField("description", ""); if (strpos($this->description, "##migration##") === 0) { $this->description = substr($this->description, strlen("##migration##")); $this->description = base64_decode($this->description); } else { $this->description = str_replace('\\n', "<br/>", $this->description); $this->description = stripslashes($this->description); } $this->processField("geolon", "0"); $this->processField("geolat", "0"); $this->processField("location", ""); $this->processField("priority", "0"); $this->processField("status", ""); $this->processField("summary", ""); $this->processField("contact", ""); $this->processField("organizer", ""); $this->processField("url", ""); $this->processField("created", ""); $this->processField("sequence", "0"); // Fix some stupid Microsoft IIS driven calendars which don't encode the data properly! // see section 2 of http://www.the-art-of-web.com/html/character-codes/ // moved to ical import code directly since this can cause problems with some editor based content (remember strange hyphen in MyEarthHour) //$this->description =str_replace(array("\205","\221","\222","\223","\224","\225","\226","\227","\240"),array("...","'","'",'"','"',"*","-","--"," "),$this->description); //$this->summary =str_replace(array("\205","\221","\222","\223","\224","\225","\226","\227","\240"),array("...","'","'",'"','"',"*","-","--"," "),$this->summary); // The description and summary may need escaping !!! // But this will be done by the SQL update function as part of the store so don't do it twice /* $db = JFactory::getDBO(); $this->description = $db->escape($this->description); $this->summary = $db->escape($this->summary); */ // get default value for multiday from params $cfg = JEVConfig::getInstance(); $this->processField("multiday", $cfg->get('multiday', 1)); $this->processField("noendtime", 0); $this->processField("x-extrainfo", "", "extra_info"); $this->processField("x-color", "", "color"); // To make DB searches easier I set the dtend regardless if ($this->dtend == 0 && $this->duration > 0) { $this->dtend = $this->dtstart + $this->duration; } else { if ($this->dtend == 0) { // if no dtend or duration (e.g. from imported iCal) - set no end time $this->noendtime = 1; $icimport = new iCalImport(); $this->dtend = $icimport->unixTime($this->dtstartraw); // an all day event if ($this->dtend == $this->dtstart && strlen($this->dtstartraw) == 8) { // convert to JEvents all day event mode! //$this->allday = 1; $this->dtend += 86399; } } } if ($this->dtend < $this->dtstart && strlen($this->dtstartraw) == 8) { // convert to JEvents all day event mode! $this->noendtime = 1; //$this->allday = 1; $this->dtend = $this->dtstart + 86399; } // Process any custom fields $this->processCustom(); }