/** * Updates this price and set the solution winner. * * @param integer $solutionID */ public function pick($solutionID, $position) { $sql = "UPDATE\twcf" . WCF_N . "_contest_price\n\t\t\tSET\tsolutionID = " . intval($solutionID) . ",\n\t\t\t\tposition = " . intval($position) . "\n\t\t\tWHERE\tpriceID = " . intval($this->priceID); WCF::getDB()->sendQuery($sql); // update pick times require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php'; $solution = new ContestSolutionEditor($solutionID); $solution->updatePickTime(TIME_NOW); // update price expirations, next winner may only have 24 hours from now on require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php'; $contest = new ContestEditor($this->contestID); $contest->updatePickTimes(); // TODO: send secretMessage to winner if ($this->secretMessage) { // use notification api if (false) { require_once WCF_DIR . 'lib/data/contest/event/ContestEventEditor.class.php'; $owner = $this->getOwner(); ContestEventEditor::create($this->contestID, $owner->userID, $owner->groupID, 'ContestPriceSecretMessage', array('priceID' => $this->priceID, 'owner' => $owner->getName())); } // TODO: remove after notification api is implemented // TODO: missing translation if ($solution->getOwner()->userID) { $mail = new Mail($solution->getOwner()->email, 'easy-coding Gewinnspiel - du hast gewonnen', 'Hallo ' . $solution->getOwner()->getName() . ', du hast soeben einen Preis beim easy-coding Gewinnspiel gewählt. Der Sponsor hat dir dazu einen Hinweis mit folgendem Inhalt hinterlassen: ' . $this->secretMessage . ' Vielen Dank für die Teilnahme beim Gewinnspiel, Torben Brodt'); $mail->addBCC(MAIL_ADMIN_ADDRESS); $mail->send(); } } // TODO: pricepick: send event to sponsor if (false) { require_once WCF_DIR . 'lib/data/contest/event/ContestEventEditor.class.php'; $owner = $this->getOwner(); ContestEventEditor::create($this->contestID, $owner->userID, $owner->groupID, 'ContestPricePick', array('priceID' => $this->priceID, 'owner' => $owner->getName())); } }