private function processCat($cat) { $blocksize = 10; $db = JFactory::getDBO(); $query = "SELECT ev.*, cc.name AS category, " . "\n UNIX_TIMESTAMP(ev.publish_up) AS dtstart ," . "\n UNIX_TIMESTAMP(ev.publish_down) AS dtend " . "\n FROM #__events AS ev" . "\n LEFT JOIN #__categories AS cc ON ev.catid = cc.id" . "\n WHERE cc.id = {$cat->id}" . "\n AND migrated = 0" . "\n LIMIT {$blocksize}"; $db->setQuery($query); $detevents = null; $detevents = $db->loadObjectList(); if (count($detevents) == 0) { return 0; } $showBR = intval(JRequest::getVar('showBR', '0')); // get vCal with HTML encoded descriptions global $cal; $cal = new vCal("", true); if (count($detevents) > 0) { foreach ($detevents as $event) { $cal->addEvent($event); // mark as migrated $query = "UPDATE #__events set migrated=1 WHERE id=" . $event->id; $db->setQuery($query); $db->query(); } $detevents = null; global $output; $output = $cal->getVCal(); $cal = null; if ($showBR) { echo "Processing cat {$cat->title}<br/>"; echo $output; echo "<hr/>"; } // Map them to the new cat id $catid = $cat->newid; $access = $cat->access; $state = $cat->published; // find the default icsfile - if none then create a new one $sql = "SELECT * FROM #__jevents_icsfile WHERE icaltype=2 AND isdefault=1"; $db->setQuery($sql); $ics = $db->loadObject(); if (!$ics || is_null($ics)) { $icsid = 0; // new $icsLabel = "{$cat->title} (imp)"; } else { $icsid = $ics->ics_id; $icsLabel = $ics->label; if ($ics->catid == 0) { $sql = "UPDATE #__jevents_icsfile SET catid=" . $cat->newid . " WHERE ics_id=" . $icsid; $db->setQuery($sql); $db->query(); } } $icsFile = iCalICSFile::newICSFileFromString($output, $icsid, $catid, $access, $state, $icsLabel); // DO NOT CLEAN OUT EXISTING EVENTS $icsFileid = $icsFile->store($catid, false); $icsFile = null; } $query = "SELECT count(ev.id)" . "\n FROM #__events AS ev" . "\n LEFT JOIN #__categories AS cc ON ev.catid = cc.id" . "\n WHERE cc.id = {$cat->id}" . "\n AND migrated = 0"; $db->setQuery($query); $detevents = null; $eventsleft = $db->loadResult(); return $eventsleft; }
loader_import('siteevent.Event'); loader_import('saf.Date'); loader_import('saf.Date.vCalendar'); if (!isset($parameters['limit'])) { $parameters['limit'] = 50; } $e = new SiteEvent_Event(); $list = $e->getUpcoming($parameters['limit'], $parameters['category'], $parameters['audience']); $cal = new vCal(); $cal->addProperty('METHOD', 'PUBLISH'); $cal->addProperty('CALSCALE', 'GREGORIAN'); $cal->addProperty('PRODID', '-//SIMIAN systems//NONSGML SiteEvent//EN'); $cal->addProperty('VERSION', '2.0'); foreach (array_keys($list) as $k) { $item =& $list[$k]; $e =& $cal->addEvent('VEVENT'); $e->addProperty('UID', site_domain() . '/siteevent/' . $item->id); $e->addProperty('SEQUENCE', $k + 1); $p =& $e->addProperty('URL', 'http://' . site_domain() . site_prefix() . '/index/siteevent-details-action/id.' . $item->id . '/title.' . siteevent_filter_link_title($item->title)); $p->addParameter('VALUE', 'URI'); $e->addProperty('STATUS', 'CONFIRMED'); if ($item->time && $item->time > '00:00:00') { $e->addProperty('DTSTART', Date::timestamp($item->date . ' ' . $item->time, 'Ymd\\THis')); } else { $p =& $e->addProperty('DTSTART', Date::format($item->date, 'Ymd')); $p->addParameter('VALUE', 'DATE'); } if ($item->until_date && $item->until_date > '0000-00-00') { if ($item->until_time && $item->until_time > '00:00:00') { $e->addProperty('DTEND', Date::timestamp($item->until_date . ' ' . $item->until_time, 'Ymd\\THis')); } else {