public function testReflectionAPI()
 {
     require_once WCF_DIR . 'lib/data/contest/solution/ContestSolutionEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $participant = ContestParticipantEditor::create($contestID = 0, $userID = $user->userID, $groupID = 0, $state = 'private');
     $this->deleteArray[] = $solution = ContestSolutionEditor::create($contestID = 0, $participantID = $participant->participantID, $message = __METHOD__ . ' message', $state = 'private');
     $this->callAllMethodsWithoutRequiredParameters($solution);
 }
 /**
  * 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');
 }
 /**
  * 
  */
 public function giveToParticipant($participantID)
 {
     $this->validate();
     // user is not a participant yet, need to create entry
     if ($participantID == 0) {
         $state = $this->contest->enableParticipantCheck ? 'applied' : 'accepted';
         // add participant
         require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
         $participant = ContestParticipantEditor::create($this->contest->contestID, WCF::getUser()->userID, 0, $state);
         $participantID = $participant->participantID;
     }
     require_once WCF_DIR . 'lib/data/contest/coupon/participant/ContestCouponParticipantEditor.class.php';
     ContestCouponParticipantEditor::create($this->couponID, $participantID);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save participant
     $inserts = '';
     foreach ($this->participants as $participant) {
         $userID = $groupID = 0;
         switch ($participant['type']) {
             case 'user':
                 $userID = intval($participant['id']);
                 break;
             case 'group':
                 $groupID = intval($participant['id']);
                 break;
         }
         ContestParticipantEditor::create($this->contest->contestID, $userID, $groupID, 'invited');
     }
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestParticipant&contestID=' . $this->contest->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // remember
     ContestPromotionUtil::updateList($this->contestID);
     $this->executed();
     switch ($this->contestAction) {
         case 'participate':
             if (WCF::getUser()->userID == 0) {
                 // forward
                 HeaderUtil::redirect('index.php?page=Contest' . '&contestID=' . $this->contestID . SID_ARG_2ND_NOT_ENCODED);
             } else {
                 $state = $this->contest->enableParticipantCheck ? 'applied' : 'accepted';
                 // add participant
                 require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
                 $participant = ContestParticipantEditor::create($this->contestID, WCF::getUser()->userID, 0, $state);
                 // forward
                 HeaderUtil::redirect('index.php?page=ContestParticipant' . '&contestID=' . $this->contestID . '&participantID=' . $participant->participantID . SID_ARG_2ND_NOT_ENCODED . '#participant' . $participant->participantID);
             }
             break;
     }
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save participant
     $participant = ContestParticipantEditor::create($this->contest->contestID, WCF::getUser()->userID, $this->groupID, $this->state);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestParticipant' . '&contestID=' . $this->contest->contestID . '&participantID=' . $participant->participantID . SID_ARG_2ND_NOT_ENCODED . '#participant' . $participant->participantID);
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     $participant = ContestParticipant::find($this->contest->contestID, $this->userID, $this->groupID);
     if ($participant === null) {
         require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
         $state = $this->contest->enableParticipantCheck ? 'applied' : 'accepted';
         $participant = ContestParticipantEditor::create($this->contest->contestID, $this->userID, $this->groupID, $state);
     }
     // save solution
     $solution = ContestSolutionEditor::create($this->contest->contestID, $participant->participantID, $this->text, $this->state, $this->getOptions(), $this->attachmentListEditor);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestSolutionEntry&contestID=' . $this->contest->contestID . '&solutionID=' . $solution->solutionID . SID_ARG_2ND_NOT_ENCODED . '#solution' . $solution->solutionID);
     exit;
 }
 /**
  * Saves participants.
  */
 public function setParticipants($participants = array())
 {
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     foreach ($participants as $participant) {
         ContestParticipantEditor::create($this->contestID, $participant['type'] == 'user' ? intval($participant['id']) : 0, $participant['type'] == 'group' ? intval($participant['id']) : 0, 'invited');
     }
 }
 public function testReflectionAPI()
 {
     require_once WCF_DIR . 'lib/data/contest/participant/ContestParticipantEditor.class.php';
     $this->deleteArray[] = $participant = ContestParticipantEditor::create($contestID = 0, $userID = 0, $groupID = 0, $state = 'private');
     $this->callAllMethodsWithoutRequiredParameters($participant);
 }