/** * @see Form::readData() */ public function readData() { parent::readData(); // read objects $this->solutionList->sqlOffset = ($this->pageNo - 1) * $this->itemsPerPage; $this->solutionList->sqlLimit = $this->itemsPerPage; $this->solutionList->readObjects(); // init todo list require_once WCF_DIR . 'lib/data/contest/participant/todo/ContestParticipantTodoList.class.php'; $this->todoList = new ContestParticipantTodoList(); $this->todoList->sqlConditions .= 'contest_participant.contestID = ' . intval($this->contestID); $this->todoList->readObjects(); // init sidebar $this->sidebar = new ContestSidebar($this->entry); }
/** * fills cache * * @param integer $contestID */ public static function getWinners($contestID) { if (isset(self::$winners[$contestID])) { return self::$winners[$contestID]; } // get ordered list of winners require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionList.class.php'; $solutionList = new ContestSolutionList(); $solutionList->debug = true; $solutionList->sqlConditions .= 'contest_solution.contestID = ' . intval($contestID); $solutionList->sqlLimit = ContestPrice::getMaxPosition($contestID); $solutionList->readObjects(); self::$winners[$contestID] = array(); foreach ($solutionList->getObjects() as $solution) { self::$winners[$contestID][] = $solution; } return self::$winners[$contestID]; }
/** * @see Form::assignVariables() */ public function assignVariables() { parent::assignVariables(); if ($this->success) { $l = 'wcf.contest.price.' . StringUtil::encodeHTML($this->success) . '.success'; WCF::getTPL()->append('userMessages', '<p class="success">' . WCF::getLanguage()->get($l) . '</p>'); } // display branding require_once WCF_DIR . 'lib/util/ContestUtil.class.php'; ContestUtil::assignVariablesBranding(); // save price position if ($this->entry->isOwner()) { require_once WCF_DIR . 'lib/form/ContestPricePositionForm.class.php'; new ContestPricePositionForm($this->entry); } // init form if ($this->action == 'edit') { require_once WCF_DIR . 'lib/form/ContestPriceEditForm.class.php'; new ContestPriceEditForm($this->entry); } else { if ($this->entry->isPriceable()) { require_once WCF_DIR . 'lib/form/ContestPriceAddForm.class.php'; new ContestPriceAddForm($this->entry); } } // become sponsor if ($this->entry->enableSponsorCheck && !$this->entry->isSponsor() && $this->entry->isSponsorable(false)) { WCF::getTPL()->append('additionalContentBecomeSponsor', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.enableSponsorCheck.info') . '</p>'); } // if contest is finished, show todo list // who is able to pick the prices $isWinner = false; if ($this->entry->state == 'closed') { // need winners require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionList.class.php'; $solutionList = new ContestSolutionList(); $solutionList->sqlConditions .= 'contest_solution.contestID = ' . intval($this->contestID); $solutionList->sqlLimit = $this->countItems(); $solutionList->readObjects(); $winners = array(); foreach ($solutionList->getObjects() as $solution) { $winners[] = $solution->participantID; $isWinner = $isWinner || $solution->isOwner(); } if (count($winners)) { // init todo list require_once WCF_DIR . 'lib/data/contest/price/todo/ContestPriceTodoList.class.php'; $this->todoList = new ContestPriceTodoList(); $this->todoList->sqlConditions .= ' contest_solution.participantID IN (' . implode(',', $winners) . ') AND contest_solution.contestID = ' . intval($this->contestID); $this->todoList->sqlOrderBy = 'FIND_IN_SET(contest_solution.participantID, \'' . implode(',', $winners) . '\')'; $this->todoList->sqlLimit = $this->countItems(); $this->todoList->readObjects(); } } // which price is pickable be the current user NOW? $solution = null; $didPick = false; if ($isWinner) { foreach ($this->priceList->getObjects() as $price) { if ($price->isPickable()) { $solution = $price->pickableByWinner(); break; } else { if ($price->isOwner()) { $didPick = true; } } } } else { if ($this->entry->state == 'scheduled' && $this->entry->untilTime > TIME_NOW) { WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.price.closed.info') . '</p>'); } else { if ($this->entry->enablePricechoice) { WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.price.pick.info') . '</p>'); } } } $this->sidebar->assignVariables(); WCF::getTPL()->assign(array('entry' => $this->entry, 'isSponsor' => $this->isSponsor, 'contestID' => $this->contestID, 'userID' => $this->entry->userID, 'solution' => $solution, 'isWinner' => $isWinner, 'didPick' => $didPick, 'prices' => $this->priceList->getObjects(), 'todos' => $this->todoList ? $this->todoList->getObjects() : array(), 'templateName' => $this->templateName, 'allowSpidersToIndexThisPage' => true, 'contestmenu' => ContestMenu::getInstance())); }
/** * returns all sidebar data in format, which can be cached */ protected function _init() { // get classes $classList = new ContestClassTree(); $classList->readObjects(); // get jurys if (!$this->contest || $this->contest->isEnabledJury()) { $juryList = new ContestJuryList(); if ($this->contest !== null) { $juryList->sqlConditions .= 'contest_jury.contestID = ' . $this->contest->contestID . ' AND contest_jury.state = "accepted" '; } else { $juryList->sqlJoins .= " INNER JOIN wcf" . WCF_N . "_contest contest ON contest.contestID = contest_jury.contestID "; $juryList->sqlConditions .= 'contest.state IN ("scheduled", "closed") AND contest_jury.state = "accepted" '; } $juryList->sqlOrderBy = 'juryID DESC'; $juryList->readObjects(); } else { $juryList = null; } // get participants $participantList = new ContestParticipantList(); if ($this->contest !== null) { $participantList->sqlConditions .= 'contest_participant.contestID = ' . $this->contest->contestID . ' AND contest_participant.state = "accepted" '; } else { $participantList->sqlJoins .= " INNER JOIN wcf" . WCF_N . "_contest contest ON contest.contestID = contest_participant.contestID "; $participantList->sqlConditions .= 'contest.state IN ("scheduled", "closed") AND contest_participant.state = "accepted" '; } $participantList->sqlLimit = 10; $participantList->sqlOrderBy = 'participantID DESC'; $participantList->readObjects(); // get sponsors $sponsorList = new ContestSponsorList(); if ($this->contest !== null) { $sponsorList->sqlConditions .= 'contest_sponsor.contestID = ' . $this->contest->contestID . ' AND contest_sponsor.state = "accepted" '; } else { $sponsorList->sqlJoins .= " INNER JOIN wcf" . WCF_N . "_contest contest ON contest.contestID = contest_sponsor.contestID "; $sponsorList->sqlConditions .= 'contest.state IN ("scheduled", "closed") AND contest_sponsor.state = "accepted" '; } $sponsorList->sqlOrderBy = 'sponsorID DESC'; $sponsorList->readObjects(); // get prices $priceList = new ContestPriceList(); if ($this->contest !== null) { $priceList->sqlConditions .= 'contest_price.contestID = ' . $this->contest->contestID . ' AND contest_price.state != "declined" '; } else { $priceList->sqlJoins .= " INNER JOIN wcf" . WCF_N . "_contest contest ON contest.contestID = contest_price.contestID "; $priceList->sqlConditions .= 'contest.state IN ("scheduled", "closed") AND contest_price.state != "declined" '; } $priceList->sqlOrderBy = 'position ASC'; $priceList->readObjects(); // get tag cloud $tagList = null; if (MODULE_TAGGING) { $tagList = new ContestTagList($this->contest, WCF::getSession()->getVisibleLanguageIDArray()); $tagList->readObjects(); } // get latest entries $latestEntryList = new ContestList(); if ($this->contest !== null) { $latestEntryList->sqlConditions .= 'contest.contestID != ' . $this->contest->contestID; } $latestEntryList->sqlLimit = 10; $latestEntryList->readObjects(); // get latest solutions if (!$this->contest || $this->contest->enableSolution) { $latestSolutionList = new ContestSolutionList(); if ($this->contest !== null) { $latestSolutionList->sqlConditions .= 'contest_solution.contestID = ' . $this->contest->contestID; } $latestSolutionList->sqlOrderBy = 'solutionID DESC'; $latestSolutionList->sqlLimit = 5; $latestSolutionList->readObjects(); } else { $latestSolutionList = null; } return array('classList' => $classList, 'juryList' => $juryList, 'participantList' => $participantList, 'sponsorList' => $sponsorList, 'priceList' => $priceList, 'tagList' => $tagList, 'latestEntryList' => $latestEntryList, 'latestSolutionList' => $latestSolutionList); }