本文整理匯總了PHP中Contest::getEditor方法的典型用法代碼示例。如果您正苦於以下問題:PHP Contest::getEditor方法的具體用法?PHP Contest::getEditor怎麽用?PHP Contest::getEditor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Contest
的用法示例。
在下文中一共展示了Contest::getEditor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: close
/**
* finish the contest
*/
public function close()
{
if (!($this->contest->state == 'scheduled' && $this->contest->untilTime < time())) {
throw new Exception('contest needs to be scheduled, and time has to be over.');
}
// make a jury instance from the contst owner
$jury = ContestJury::find($this->contest->contestID, $this->contest->userID, $this->contest->groupID);
if ($jury === null) {
$jury = ContestJuryEditor::create($this->contest->contestID, $this->contest->userID, $this->contest->groupID, $state = 'accepted');
}
$userID = $this->contest->userID;
if ($userID == 0 && $this->contest->groupID > 0) {
$sql = "SELECT userID\n\t\t\t\tFROM wcf" . WCF_N . "_user_to_groups\n\t\t\t\tWHERE groupID = " . intval($this->contest->groupID);
$row = WCF::getDB()->getFirstRow($sql);
$userID = $row['userID'];
}
if (!$userID) {
throw new Exception('cannot determine a user from which the ratings will be added.');
}
$classIDs = array_keys($this->contest->getClasses());
$ratingoptionIDs = array_keys(ContestRatingoption::getByClassIDs($classIDs));
if (empty($ratingoptionIDs)) {
throw new Exception('cannot determine a ratingoption from classes [' . implode(',', $classIDs) . '] needed for contest ratings to be added.');
}
// get interactions
$interactionList = new ContestInteractionList($this->contest);
$interactionList->sqlLimit = 0;
$interactionList->readObjects();
$owners = $interactionList->getObjects();
foreach ($owners as $owner) {
$this->sum += $owner->c;
}
// get prices
$priceList = new ContestPriceList();
$priceList->sqlConditions .= 'contest_price.state = "accepted" AND contest_price.contestID = ' . intval($this->contest->contestID);
$priceList->sqlLimit = 0;
$priceList->readObjects();
$score = 5 + $priceList->countObjects();
foreach ($priceList->getObjects() as $price) {
// choose a winner
$owner = $this->chooseWinner($price, $owners);
// error, there are more prices than participants
if (!$owner) {
throw new Exception('there are more prices than participants.');
}
$lang = 'wcf.contest.interaction.tickets.solution';
$message = WCF::getLanguage()->getDynamicVariable($lang, array('tickets' => $owner->c));
// create pseudo solution
$solution = ContestSolutionEditor::create($this->contest->contestID, $owner->participantID, $message, $state = 'accepted');
foreach ($ratingoptionIDs as $ratingOptionID) {
// create pseudo rating
$rating = ContestSolutionRatingEditor::create($solution->solutionID, $ratingOptionID, $score, $userID);
}
// decrease score
$score--;
}
// close contest state
$this->contest->getEditor()->updateState('closed');
}