diff --git a/includes/class.worldevent.php b/includes/class.worldevent.php index 709682d0..002cc7d4 100644 --- a/includes/class.worldevent.php +++ b/includes/class.worldevent.php @@ -57,6 +57,10 @@ class WorldEventList extends BaseType else if ($sT == -1) $this->curTpl['category'] = 1; + // preparse requisites + if ($this->curTpl['requires']) + $this->curTpl['requires'] = explode(' ', $this->curTpl['requires']); + // change Ids if holiday is set if ($this->curTpl['holidayId'] > 0) { @@ -101,6 +105,16 @@ class WorldEventList extends BaseType public static function updateDates($start, $end, $occurence, $final = 5000000000) // in the far far FAR future.. { + if (!$start) + { + return array( + 'start' => 0, + 'end' => 0, + 'nextStart' => 0, + 'nextEnd' => 0 + ); + } + // Convert everything to seconds $start = intVal($start); $end = intVal($end); diff --git a/pages/events.php b/pages/events.php index e9eae803..f036a532 100644 --- a/pages/events.php +++ b/pages/events.php @@ -42,14 +42,21 @@ if (!$smarty->loadCache($cacheKey, $pageData)) $events = new WorldEventList($condition); + $events->addGlobalsToJScript($pageData); + + $deps = []; + while ($events->iterate()) + if ($d = $events->getField('requires')) + $deps[$events->id] = $d; + $pageData = array( 'page' => $events->getListviewData(), + 'deps' => $deps, 'params' => array( 'tabs' => '$myTabs' ) ); - $events->addGlobalsToJScript($pageData); $smarty->saveCache($cacheKey, $pageData); } @@ -57,9 +64,16 @@ if (!$smarty->loadCache($cacheKey, $pageData)) // recalculate dates with now(); can't be cached, obviously foreach ($pageData['page'] as &$data) { + // is a followUp-event + if (!empty($pageData['deps'][$data['id']])) + { + $data['startDate'] = $data['endDate'] = false; + continue; + } + $updated = WorldEventList::updateDates($data['startDate'], $data['endDate'], $data['rec']); - $data['startDate'] = date(Util::$dateFormatLong, $updated['start']); - $data['endDate'] = date(Util::$dateFormatLong, $updated['end']); + $data['startDate'] = $updated['start'] ? date(Util::$dateFormatLong, $updated['start']) : false; + $data['endDate'] = $updated['end' ] ? date(Util::$dateFormatLong, $updated['end']) : false; }