public function testContestPage()
 {
     $user = $this->user;
     $contest = $this->contest;
     // save two sponsortalk entries
     require_once WCF_DIR . 'lib/data/contest/sponsortalk/ContestSponsortalkEditor.class.php';
     $this->deleteArray[] = $sponsortalk = ContestSponsortalkEditor::create($contestID = $contest->contestID, $sponsortalk = __METHOD__ . ' sponsortalk #1', $userID = $user->userID, $username = $user->username);
     $this->deleteArray[] = $sponsortalk = ContestSponsortalkEditor::create($contestID = $contest->contestID, $sponsortalk = __METHOD__ . ' sponsortalk #2', $userID = $user->userID, $username = $user->username);
     $raised = false;
     try {
         $this->runHTTP('page=ContestSponsortalk&contestID=' . $contest->contestID);
     } catch (Exception $e) {
         $raised = true;
     }
     $this->assertTrue($raised, "user should not be allowed to access a private contest");
     // now try with owner
     $this->setCurrentUser($user);
     $this->runHTTP('page=ContestSponsortalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('sponsortalks')), 2);
     // now try with sponsor member who was invited
     $this->deleteArray[] = $sponsoruser = $this->createUser();
     require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
     $this->deleteArray[] = $sponsor = ContestSponsorEditor::create($contestID = $contest->contestID, $userID = $sponsoruser->userID, $groupID = 0, $state = 'invited');
     $this->setCurrentUser($sponsoruser);
     $this->runHTTP('page=ContestSponsortalk&contestID=' . $contest->contestID);
     // invited members should only see first entry
     $this->assertEquals(count(WCF::getTPL()->get('sponsortalks')), 1);
     // accepted members should have 2 entries
     $sponsor->update($contestID, $userID, $groupID, 'accepted');
     $this->runHTTP('page=ContestSponsortalk&contestID=' . $contest->contestID);
     $this->assertEquals(count(WCF::getTPL()->get('sponsortalks')), 2);
 }
Esempio n. 2
0
 public function testReflectionAPI()
 {
     require_once WCF_DIR . 'lib/data/contest/price/ContestPriceEditor.class.php';
     require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
     $this->deleteArray[] = $user = $this->createUser();
     $this->deleteArray[] = $sponsor = ContestSponsorEditor::create($contestID = 0, $userID = $user->userID, $groupID = 0, $state = 'private');
     $this->deleteArray[] = $price = ContestPriceEditor::create($contestID = 0, $sponsorID = $sponsor->sponsorID, $subject = __METHOD__ . ' subject', $message = __METHOD__ . ' message');
     $this->callAllMethodsWithoutRequiredParameters($price);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save sponsor
     $inserts = '';
     foreach ($this->sponsors as $sponsor) {
         $userID = $groupID = 0;
         switch ($sponsor['type']) {
             case 'user':
                 $userID = intval($sponsor['id']);
                 break;
             case 'group':
                 $groupID = intval($sponsor['id']);
                 break;
         }
         ContestSponsorEditor::create($this->contest->contestID, $userID, $groupID, 'invited');
     }
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestSponsor&contestID=' . $this->contest->contestID . SID_ARG_2ND_NOT_ENCODED);
     exit;
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     if ($this->sponsorID) {
         $sponsor = new ContestSponsor($this->sponsorID);
     } else {
         $sponsor = ContestSponsor::find($this->contest->contestID, $this->userID, $this->groupID);
     }
     if ($sponsor === null) {
         require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
         $state = $this->contest->enableSponsorCheck ? 'applied' : 'accepted';
         $sponsor = ContestSponsorEditor::create($this->contest->contestID, $this->userID, $this->groupID, $state);
     }
     // save price
     $price = ContestPriceEditor::create($this->contest->contestID, $sponsor->sponsorID, $this->subject, $this->text, $this->secretMessage, $this->attachmentListEditor);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestPrice&contestID=' . $this->contest->contestID . '&priceID=' . $price->priceID . SID_ARG_2ND_NOT_ENCODED . '#priceObj' . $price->priceID);
     exit;
 }
 /**
  * Saves sponsors.
  */
 public function setSponsors($sponsors = array(), $userID = 0, $groupID = 0)
 {
     $sponsorID = 0;
     require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
     foreach ($sponsors as $sponsor) {
         $sponsorObj = ContestSponsorEditor::create($this->contestID, $sponsor['type'] == 'user' ? intval($sponsor['id']) : 0, $sponsor['type'] == 'group' ? intval($sponsor['id']) : 0, 'invited');
         // did i create my own user? then remember sponsorID
         if ($sponsorID == 0 && ($userID || $groupID)) {
             if ($userID > 0 && $sponsor['type'] == 'user' && $sponsor['id'] == $userID || $groupID > 0 && $sponsor['type'] == 'group' && $sponsor['id'] == $groupID) {
                 $sponsorID = $sponsorObj->sponsorID;
             }
         }
     }
     if ($sponsorID == 0 && ($userID || $groupID)) {
         $sponsorObj = ContestSponsorEditor::create($this->contestID, $userID, $groupID, 'accepted');
         $sponsorID = $sponsorObj->sponsorID;
     }
     return $sponsorID;
 }
 public function testReflectionAPI()
 {
     require_once WCF_DIR . 'lib/data/contest/sponsor/ContestSponsorEditor.class.php';
     $this->deleteArray[] = $sponsor = ContestSponsorEditor::create($contestID = 0, $userID = 0, $groupID = 0, $state = 'private');
     $this->callAllMethodsWithoutRequiredParameters($sponsor);
 }
 /**
  * @see Form::save()
  */
 public function save()
 {
     parent::save();
     // save sponsor
     $sponsor = ContestSponsorEditor::create($this->contest->contestID, WCF::getUser()->userID, $this->groupID, $this->state);
     $this->saved();
     // forward
     HeaderUtil::redirect('index.php?page=ContestSponsor&contestID=' . $this->contest->contestID . '&sponsorID=' . $sponsor->sponsorID . SID_ARG_2ND_NOT_ENCODED . '#sponsor' . $sponsor->sponsorID);
     exit;
 }