case 'edit': $page->addElement(UIText::exactText(displayClueDetails($clue))->setTitle('Clue Details')); $page->addElement(UIText::exactText(displayClueEditForm($clue))->setTitle('Edit Clue')); break; default: require_js('jquery-1.5.1.min'); require_js('jquery.form'); require_js('checkin'); require_js('answering'); require_js('sjcl'); $team = Session::currentPerson()->getTeam(); if ($team) { $team->doRefreshClueStates(); } $displayed = 0; $clues = Clue::getAllClues(); $curClue = $team ? $team->getCurrentClue() : null; $all_clues = ''; $past_clues = ''; $clueState = $curClue ? $curClue->getClueState($team) : null; $state = $clueState ? $clueState->getState() : STATE_HIDDEN; if ($state >= STATE_UNLOCKED) { $page->addElement(UIText::exactText(displayCurrentClue($curClue, $team, $state))); } else { $page->addElement('No clues are available. Check back soon!'); } foreach (array_reverse($clues) as $clue) { $clueState = $team ? $clue->getClueState($team) : null; $state = $clueState ? $clueState->getState() : STATE_HIDDEN; if ($state >= STATE_UNLOCKED && ($curClue == null || $curClue->getID() != $clue->getID())) { $past_clues .= displayPastClue($clue, $team, $state);
public function getCurrentClue() { Clue::getAllClues(); $clueStates = query('ClueState')->where(array('team' => $this->id))->selectMultiple(); if (!$clueStates) { return query('Clue')->where(array('year' => Year::current()))->sort('time')->limit(1)->selectSingle(); } $currentClue = head($clueStates)->getClue(); foreach ($clueStates as $clueState) { $clue = $clueState->getClue(); if ($clue && (!$currentClue || $clue->getRawTime() > $currentClue->getRawTime())) { $currentClue = $clue; } } return $currentClue; }