/** * @see Form::assignVariables() */ public function assignVariables() { parent::assignVariables(); // display branding require_once WCF_DIR . 'lib/util/ContestUtil.class.php'; ContestUtil::assignVariablesBranding(); // save invitations if ($this->entry->isOwner()) { require_once WCF_DIR . 'lib/form/ContestJuryInviteForm.class.php'; new ContestJuryInviteForm($this->entry); } // init form if ($this->action == 'edit') { require_once WCF_DIR . 'lib/form/ContestJuryEditForm.class.php'; new ContestJuryEditForm($this->entry); } else { if ($this->entry->isJuryable()) { require_once WCF_DIR . 'lib/form/ContestJuryAddForm.class.php'; new ContestJuryAddForm($this->entry); } } if ($this->entry->state != 'closed') { WCF::getTPL()->append('userMessages', '<p class="info">' . WCF::getLanguage()->get('wcf.contest.jury.closed.info') . '</p>'); // init todo list require_once WCF_DIR . 'lib/data/contest/jury/todo/ContestJuryTodoList.class.php'; $this->todoList = new ContestJuryTodoList(); $this->todoList->sqlConditions .= 'contest_jury.contestID = ' . $this->contestID; $this->todoList->readObjects(); } $this->sidebar->assignVariables(); WCF::getTPL()->assign(array('entry' => $this->entry, 'isJury' => $this->isJury, 'contestID' => $this->contestID, 'userID' => $this->entry->userID, 'jurys' => $this->juryList->getObjects(), 'todos' => $this->todoList ? $this->todoList->getObjects() : array(), 'templateName' => $this->templateName, 'allowSpidersToIndexThisPage' => true, 'contestmenu' => ContestMenu::getInstance())); }
/** * @see Page::readData() */ public function readData() { parent::readData(); if ($this->classID) { $class = new ContestClass($this->classID); $val = WCF::getLanguage()->get($class->description); if (!empty($val)) { $this->description[] = $val; } } // read entries $this->entryList->sqlLimit = $this->itemsPerPage; $this->entryList->sqlOffset = ($this->pageNo - 1) * $this->itemsPerPage; $this->entryList->readObjects(); // init todo list require_once WCF_DIR . 'lib/data/contest/crew/todo/ContestCrewTodoList.class.php'; $this->todoList = new ContestCrewTodoList(); $this->todoList->readObjects(); // init sidebar $this->sidebar = new ContestSidebar(); // read tags if (MODULE_TAGGING) { $this->tagList->readObjects(); $this->tags = $this->tagList->getObjects(); } }
/** * @see Page::readData() */ public function readData() { parent::readData(); // show 5 entries on first page, but 20 on the following pages $this->eventmixList->sqlLimit = $this->pageNo <= 1 ? $this->itemsOnLandingpage : $this->itemsPerPage; $this->eventmixList->sqlOffset = $this->pageNo <= 1 ? 0 : ($this->pageNo - 2) * $this->itemsPerPage + $this->itemsOnLandingpage; // fire sql query $this->eventmixList->readObjects(); // get previous entry $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest\n\t\t\tWHERE\t\tuserID = " . intval($this->entry->userID) . "\n\t\t\t\t\tAND (\n\t\t\t\t\t\ttime > " . intval($this->entry->time) . "\n\t\t\t\t\t\tOR (time = " . intval($this->entry->time) . " AND contestID < " . intval($this->entry->contestID) . ")\n\t\t\t\t\t)\n\t\t\tORDER BY\ttime ASC, contestID DESC"; $this->previousEntry = new Contest(null, WCF::getDB()->getFirstRow($sql)); if (!$this->previousEntry->contestID) { $this->previousEntry = null; } // get next entry $sql = "SELECT\t\t*\n\t\t\tFROM\t\twcf" . WCF_N . "_contest\n\t\t\tWHERE\t\tuserID = " . intval($this->entry->userID) . "\n\t\t\t\t\tAND (\n\t\t\t\t\t\ttime < " . intval($this->entry->time) . "\n\t\t\t\t\t\tOR (time = " . intval($this->entry->time) . " AND contestID > " . intval($this->entry->contestID) . ")\n\t\t\t\t\t)\n\t\t\tORDER BY\ttime DESC, contestID ASC"; $this->nextEntry = new Contest(null, WCF::getDB()->getFirstRow($sql)); if (!$this->nextEntry->contestID) { $this->nextEntry = null; } // read attachments if (MODULE_ATTACHMENT == 1 && $this->entry->attachments > 0) { require_once WCF_DIR . 'lib/data/attachment/MessageAttachmentList.class.php'; $this->attachmentList = new MessageAttachmentList($this->contestID, 'contestEntry', '', WCF::getPackageID('de.easy-coding.wcf.contest')); $this->attachmentList->readObjects(); $this->attachments = $this->attachmentList->getSortedAttachments(WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')); // set embedded attachments if (WCF::getUser()->getPermission('user.contest.canViewAttachmentPreview')) { require_once WCF_DIR . 'lib/data/message/bbcode/AttachmentBBCode.class.php'; AttachmentBBCode::setAttachments($this->attachments); } // remove embedded attachments from list if (count($this->attachments) > 0) { MessageAttachmentList::removeEmbeddedAttachments($this->attachments); } } if ($this->entry->isOwner()) { // init todo list require_once WCF_DIR . 'lib/data/contest/owner/todo/ContestOwnerTodoList.class.php'; $this->todoList = new ContestOwnerTodoList(); $this->todoList->sqlConditions .= 'contest.contestID = ' . intval($this->contestID); $this->todoList->readObjects(); } // init sidebar $this->sidebar = new ContestSidebar($this->entry); }
/** * @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())); }