/**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // delete entry
     $this->entry->delete();
     $this->executed();
     // forward
     if (empty($_REQUEST['ajax'])) {
         HeaderUtil::redirect('index.php?page=ContestOverview' . SID_ARG_2ND_NOT_ENCODED);
     }
     exit;
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $this->user = $this->createUser();
     $this->deleteArray[] = $this->contest = ContestEditor::create($userID = $this->user->userID, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
 }
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     parent::setUp();
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     $this->deleteArray[] = $this->contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $this->user = $this->createUser();
     $this->deleteArray[] = $this->participant = ContestParticipantEditor::create($contestID = $this->contest->contestID, $userID = $this->user->userID, $groupID = 0, $state = 'accepted');
     $this->deleteArray[] = $this->solution = ContestSolutionEditor::create($contestID = $this->contest->contestID, $participantID = $this->participant->participantID, $message = __METHOD__ . ' message', $state = 'private');
 }
Exemplo n.º 4
0
 /**
  * 
  */
 public function testCreate()
 {
     require_once WCF_DIR . 'lib/data/contest/crew/ContestCrew.class.php';
     // create group
     $this->deleteArray[] = $group = $this->createGroup(array(array('optionID' => ContestCrew::getOptionID(), 'optionValue' => true)));
     $this->deleteArray[] = $user = $this->createUser($group->groupID);
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $contest = ContestEditor::create($userID = $user->userID, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array(), $state = 'applied');
     require_once WCF_DIR . 'lib/data/contest/jury/ContestJuryEditor.class.php';
     $this->deleteArray[] = $jury = ContestJuryEditor::create($contestID = 0, $userID = $user->userID, $groupID = 0, $state = 'private');
 }
Exemplo n.º 5
0
 public function testContestsCounter()
 {
     require_once WCF_DIR . 'lib/data/contest/class/ContestClassEditor.class.php';
     $this->deleteArray[] = $class = ContestClassEditor::create($title = __METHOD__ . ' title');
     $this->assertEquals($class->contests, 0);
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array(), $state = 'private', $classIDArray = array($class->classID));
     // increase
     $class = new ContestClass($class->classID);
     $this->assertEquals($class->contests, 1);
     // decrease
     $contest->delete();
     $class = new ContestClass($class->classID);
     $this->assertEquals($class->contests, 0);
 }
 public function testSolutionCounter()
 {
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/solution/rating/ContestSolutionRatingEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $solution = ContestSolutionEditor::create($contestID = $contest->contestID, $participantID = 0, $message = __METHOD__ . ' message', $state = 'accepted');
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $rating = ContestSolutionRatingEditor::create($solution->solutionID, $optionID = 0, $score = 3, $user->userID);
     // increase
     $solution = new ContestSolutionEditor($solution->solutionID);
     $this->assertEquals($solution->ratings, 1);
     // decrease
     $rating->delete();
     $solution = new ContestSolutionEditor($solution->solutionID);
     $this->assertEquals($solution->ratings, 0);
 }
Exemplo n.º 7
0
 public function testCreate()
 {
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/ContestEditor.class.php';
     $this->deleteArray[] = $contest = ContestEditor::create($userID = 0, $groupID = 0, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message', $options = array());
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $participant = ContestParticipantEditor::create($contestID = $contest->contestID, $userID = $user->userID, $groupID = 0, $state = 'accepted');
     $this->deleteArray[] = $solution = ContestSolutionEditor::create($contestID = $contest->contestID, $participantID = $participant->participantID, $message = __METHOD__ . ' message', $state = 'private');
     // basic checks
     $this->assertType('ContestSolution', $solution);
     $this->assertGreaterThan(0, $solution->solutionID);
     // owner check
     $this->assertFalse($solution->isOwner());
     $this->setCurrentUser($user);
     $this->assertTrue($solution->isOwner());
     // solution owner should have task to publish his private solution
     require_once WCF_DIR . 'lib/data/contest/participant/todo/ContestParticipantTodoList.class.php';
     $todo = new ContestParticipantTodoList();
     $todo->sqlConditions .= 'contest_participant.contestID = ' . intval($contest->contestID);
     $todo->readObjects();
     $task = array_pop($todo->getObjects());
     $this->assertEquals($task->action, 'participant.solution.private');
 }
    /**
     * 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()));
        }
    }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $state = 'private';
     // save entry
     $entry = ContestEditor::create($this->userID, $this->groupID, $this->subject, $this->text, $this->getOptions(), $state, $this->classIDArray, $this->participants, $this->jurys, $this->prices, $this->sponsors, $this->attachmentListEditor);
     $this->saved();
     $contestID = $entry->contestID;
     if ($this->sponsortalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/sponsortalk/ContestSponsortalkEditor.class.php';
         $sponsortalk = ContestSponsortalkEditor::create($contestID, $this->sponsortalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->jurytalk_trigger) {
         require_once WCF_DIR . 'lib/data/contest/jurytalk/ContestJurytalkEditor.class.php';
         $jurytalk = ContestJurytalkEditor::create($contestID, $this->jurytalk_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     if ($this->comment_trigger) {
         require_once WCF_DIR . 'lib/data/contest/comment/ContestCommentEditor.class.php';
         $comment = ContestCommentEditor::create($contestID, $this->comment_message, WCF::getUser()->userID, WCF::getUser()->username);
     }
     // save tags
     if (MODULE_TAGGING) {
         $tagArray = TaggingUtil::splitString($this->tags);
         if (count($tagArray)) {
             $entry->updateTags($tagArray);
         }
     }
     // forward
     HeaderUtil::redirect('index.php?page=Contest&contestID=' . $entry->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
Exemplo n.º 10
0
 /**
  * returns available states
  */
 protected function getStates()
 {
     $flags = ($this->entry->isOwner() ? ContestState::FLAG_USER : 0) | ($this->entry->isOwner() ? ContestState::FLAG_CONTESTOWNER : 0) | (ContestCrew::isMember() ? ContestState::FLAG_CREW : 0);
     return ContestEditor::getStates($this->state, $flags, $this->entry->isClosable());
 }