/**
  * thats how the states are implemented
  *
  * - invited
  *    first jurytalk entry can be viewn
  *
  * - accepted
  *    all jurytalk entries can be viewn
  */
 public static function getStateConditions()
 {
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     return "(\n\t\t\t-- accepted jury\n\t\t\tSELECT  COUNT(contestID) \n\t\t\tFROM \twcf" . WCF_N . "_contest_jury contest_jury\n\t\t\tWHERE\tcontest_jury.contestID = contest_jurytalk.contestID\n\t\t\tAND (\tcontest_jury.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tcontest_jury.userID = " . $userID . "\n\t\t\t)\n\t\t\tAND\tcontest_jury.state = 'accepted'\n\t\t) OR (\n\t\t\t-- contest owner\n\t\t\tSELECT  COUNT(contestID) \n\t\t\tFROM \twcf" . WCF_N . "_contest contest\n\t\t\tWHERE\tcontest.contestID = contest_jurytalk.contestID\n\t\t\tAND (\tcontest.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tcontest.userID = " . $userID . "\n\t\t\t)\n\t\t) > 0\n\t\tOR (\n\t\t\t(\n\t\t\t\t-- invited jury and current entry is first entry\n\t\t\t\tSELECT  COUNT(contestID) \n\t\t\t\tFROM \twcf" . WCF_N . "_contest_jury contest_jury\n\t\t\t\tWHERE\tcontest_jury.contestID = contest_jurytalk.contestID\n\t\t\t\tAND (\tcontest_jury.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t\t  OR\tcontest_jury.userID = " . $userID . "\n\t\t\t\t)\n\t\t\t\tAND\tcontest_jury.state = 'invited'\n\t\t\t) AND (\n\t\t\t\t-- invited and currenty entry is first entry\n\t\t\t\tSELECT  MIN(jurytalkID)\n\t\t\t\tFROM \twcf" . WCF_N . "_contest_jurytalk x\n\t\t\t\tWHERE\tx.contestID = contest_jurytalk.contestID\n\t\t\t) = contest_jurytalk.jurytalkID\n\t\t)";
 }
 /**
  * @see DatabaseObjectList::readObjects()
  */
 public function readObjects()
 {
     // get currently active user or group
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     $sql = "SELECT\t\t" . (!empty($this->sqlSelects) ? $this->sqlSelects . ',' : '') . "\n\t\t\t\t\t'participant.solution.private' AS action,\n\t\t\t\t\tcontest_participant.participantID\n\t\t\tFROM\t\twcf" . WCF_N . "_contest_participant contest_participant\n\n\t\t\tINNER JOIN\twcf" . WCF_N . "_contest_solution contest_solution\n\t\t\tON\t\tcontest_solution.contestID = contest_participant.contestID\n\t\t\t" . $this->sqlJoins . "\n\n\t\t\tWHERE\t\tIF(\n\t\t\t\tcontest_participant.groupID > 0,\n\t\t\t\tcontest_participant.groupID IN (" . implode(",", $groupIDs) . "), \n\t\t\t\tcontest_participant.userID > 0 AND contest_participant.userID = " . $userID . "\n\t\t\t)\n\t\t\tAND\t\tcontest_solution.state = 'private'\n\t\t\t" . (!empty($this->sqlConditions) ? "AND " . $this->sqlConditions : '') . "\n\t\t\t" . (!empty($this->sqlOrderBy) ? "ORDER BY " . $this->sqlOrderBy : '');
     $result = WCF::getDB()->sendQuery($sql, $this->sqlLimit, $this->sqlOffset);
     while ($row = WCF::getDB()->fetchArray($result)) {
         $this->todos[] = new ViewableContestParticipantTodo($row);
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if ($this->ownerID != 0) {
         $this->availableGroups = ContestUtil::readAvailableGroups();
         // validate group ids
         if (!array_key_exists($this->ownerID, $this->availableGroups)) {
             throw new UserInputException('ownerID');
         }
     } else {
         if ($this->userid == 0) {
             throw new UserInputException('ownerID');
         }
     }
     if (!array_key_exists($this->state, $this->getStates())) {
         throw new UserInputException('state');
     }
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->subject)) {
         throw new UserInputException('subject');
     }
     if (empty($this->text)) {
         throw new UserInputException('text');
     }
     if (StringUtil::length($this->text) > WCF::getUser()->getPermission('user.contest.maxSolutionLength')) {
         throw new UserInputException('text', 'tooLong');
     }
     if (StringUtil::length($this->secretMessage) > WCF::getUser()->getPermission('user.contest.maxSolutionLength')) {
         throw new UserInputException('secretMessage', 'tooLong');
     }
     if ($this->groupID) {
         $this->ownerGroups = ContestUtil::readAvailableGroups();
         // validate group ids
         if (!array_key_exists($this->groupID, $this->ownerGroups)) {
             throw new UserInputException('ownerID');
         }
     }
     if ($this->sponsorID) {
         if (!$this->contest->isOwner() && !ContestCrew::isMember()) {
             throw new UserInputException('ownerID');
         }
         $this->ownerSponsors = array();
         if ($this->contest->isOwner() || ContestCrew::isMember()) {
             foreach ($this->contest->getSponsors() as $sponsor) {
                 $this->ownerSponsors[$sponsor->sponsorID] = $sponsor;
             }
         }
         // validate group ids
         if (!array_key_exists($this->sponsorID, $this->ownerSponsors)) {
             throw new UserInputException('ownerID');
         }
     }
     if (!array_key_exists($this->state, $this->getStates())) {
         throw new UserInputException('state');
     }
 }
Ejemplo n.º 5
0
 /**
  * thats how the states are implemented
  * - private
  *    only the owner can view and edit the entry
  *    invited jurys can view the first entry of jurytalk
  *    invited sponsors can view the first entry of sponsortalk
  *    invited participants can view the first comment
  *    all invited people can view basis data (without the real entry)
  *    accepting an invitation enabled the users to reply to the talks
  *    the state can be changed by the owner
  *
  * - applied
  *    owner can view and edit the entry
  *    accepted jurys can see the full entry
  *    admin team should review the entry and schedule a time
  *    the state can be changed by the admin team
  *
  * - accepted
  *    owner cannot change the entry any more
  *    entry can be shown if start_time is over
  *    state cannot be changed any longer
  *
  * - scheduled
  *    upcoming
  *
  * - closed
  *    no ratings can be given, no jurys can be added
  */
 public static function getStateConditions()
 {
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     return "(\n\t\t\t-- owner\n\t\t\tIF(\n\t\t\t\tcontest.groupID > 0,\n\t\t\t\tcontest.groupID IN (" . implode(",", $groupIDs) . "),\n\t\t\t\tcontest.userID > 0 AND contest.userID = " . $userID . "\n\t\t\t)\n\t\t) OR (\n\t\t\tcontest.state = 'scheduled'\n\t\t\tAND contest.fromTime <= UNIX_TIMESTAMP(NOW())\n\t\t) OR (\n\t\t\tcontest.state = 'closed'\n\t\t) OR (\n\t\t\t-- jury, sponsor, participant\n\t\t\tSELECT \tCOUNT(x.contestID)\n\t\t\tFROM (\n\t\t\t\tSELECT contestID, userID, groupID FROM wcf" . WCF_N . "_contest_jury\n\t\t\t\tUNION\n\t\t\t\tSELECT contestID, userID, groupID FROM wcf" . WCF_N . "_contest_sponsor\n\t\t\t\tUNION\n\t\t\t\tSELECT contestID, userID, groupID FROM wcf" . WCF_N . "_contest_participant\n\t\t\t) x\n\t\t\tWHERE\tx.contestID = contest.contestID\n\t\t\tAND (\tx.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tx.userID = " . $userID . "\n\t\t\t)\n\t\t) > 0";
 }
Ejemplo n.º 6
0
 /**
  * thats how the states are implemented
  *
  * - invited
  * - declined
  * - applied
  *    contest owner, the rest of the jury and the user/group itself can view entry
  *
  * - accepted
  *    everybody can see the entry
  */
 public static function getStateConditions()
 {
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     return "(\n\t\t\t-- entry is accepted\n\t\t\tcontest_jury.state = 'accepted'\n\t\t) OR (\n\t\t\t-- entry owner\n\t\t\tIF(\n\t\t\t\tcontest_jury.groupID > 0,\n\t\t\t\tcontest_jury.groupID IN (" . implode(",", $groupIDs) . "), \n\t\t\t\tcontest_jury.userID = " . $userID . "\n\t\t\t)\n\t\t) OR (\n\t\t\t-- contest owner\n\t\t\tSELECT  COUNT(contestID) \n\t\t\tFROM \twcf" . WCF_N . "_contest contest\n\t\t\tWHERE\tcontest.contestID = contest_jury.contestID\n\t\t\tAND (\tcontest.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tcontest.userID = " . $userID . "\n\t\t\t)\n\t\t) > 0\n\t\tOR (\n\t\t\t-- in the jury\n\t\t\tSELECT  COUNT(contestID) \n\t\t\tFROM \twcf" . WCF_N . "_contest_jury x\n\t\t\tWHERE\tx.contestID = contest_jury.contestID\n\t\t\tAND (\tx.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tx.userID = " . $userID . "\n\t\t\t)\n\t\t\tAND\tx.state = 'accepted'\n\t\t) > 0";
 }
 /**
  * thats how the states are implemented
  *
  * - private
  *    the solution can be viewn by the owner
  *
  * - applied
  *    jury has to accept or decline answer
  *
  * - accepted
  *    the solution cannot be changed by anybody
  *    the state can be changed by the jury
  *
  * - declined
  *    the solution cannot be changed by anybody
  *    the state can be changed by the jury
  */
 public static function getStateConditions()
 {
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     return "(\n\t\t\t-- owner\n\t\t\tIF(\n\t\t\t\tcontest_participant.groupID > 0,\n\t\t\t\tcontest_participant.groupID IN (" . implode(",", $groupIDs) . "), \n\t\t\t\tcontest_participant.userID > 0 AND contest_participant.userID = " . $userID . "\n\t\t\t)\n\t\t) OR (\n\t\t\t-- solution has been submitted, and user is jury\n\t\t\tcontest_solution.state IN ('applied', 'accepted', 'declined')\n\n\t\t\tAND (\n\t\t\t\tSELECT  COUNT(contestID) FROM wcf" . WCF_N . "_contest_jury contest_jury\n\t\t\t\tWHERE\tcontest_jury.contestID = contest_solution.contestID\n\t\t\t\tAND (\tcontest_jury.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t\t  OR\tcontest_jury.userID = " . $userID . "\n\t\t\t\t)\n\t\t\t) > 0\n\n\t\t) OR (\n\t\t\t-- solution has been submitted, and contest is finished\n\t\t\tcontest_solution.state IN ('accepted', 'declined')\n\n\t\t\tAND (\n\t\t\t\tSELECT  COUNT(contestID) FROM wcf" . WCF_N . "_contest contest\n\t\t\t\tWHERE\tcontest.contestID = contest_solution.contestID\n\t\t\t\tAND ( \tcontest.state = 'closed'\n\t\t\t\t  OR (\n\t\t\t\t\tcontest.state = 'scheduled'\n\t\t\t\t\tAND \tcontest.untilTime < UNIX_TIMESTAMP(NOW())\n\t\t\t\t  )\n\t\t\t\t)\n\t\t\t) > 0\n\t\t)";
 }
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     if (empty($this->text)) {
         throw new UserInputException('text');
     }
     if (StringUtil::length($this->text) > WCF::getUser()->getPermission('user.contest.maxSolutionLength')) {
         throw new UserInputException('text', 'tooLong');
     }
     if ($this->ownerID != 0) {
         $this->availableGroups = ContestUtil::readAvailableGroups();
         // validate group ids
         if (!array_key_exists($this->ownerID, $this->availableGroups)) {
             throw new UserInputException('ownerID');
         }
     } else {
         if ($this->userid == 0) {
             throw new UserInputException('ownerID');
         }
     }
     if (!array_key_exists($this->state, $this->getStates())) {
         throw new UserInputException('state');
     }
 }
Ejemplo n.º 9
0
 /**
  * thats how the states are implemented
  */
 public static function getStateConditions()
 {
     $userID = WCF::getUser()->userID;
     $userID = $userID ? $userID : -1;
     $groupIDs = array_keys(ContestUtil::readAvailableGroups());
     $groupIDs = empty($groupIDs) ? array(-1) : $groupIDs;
     // makes easier sql queries
     return "(\n\t\t\t-- entry is accepted\n\t\t\tcontest_price.state IN ('accepted', 'sent', 'received')\n\t\t) OR (\n\t\t\t-- sponsor\n\t\t\tIF(\n\t\t\t\tcontest_sponsor.groupID > 0,\n\t\t\t\tcontest_sponsor.groupID IN (" . implode(",", $groupIDs) . "), \n\t\t\t\tcontest_sponsor.userID = " . $userID . "\n\t\t\t)\n\t\t) OR (\n\t\t\t-- is owner\n\t\t\tSELECT  COUNT(contestID) \n\t\t\tFROM \twcf" . WCF_N . "_contest contest\n\t\t\tWHERE\tcontest.contestID = contest_price.contestID\n\t\t\tAND (\tcontest.groupID IN (" . implode(",", $groupIDs) . ")\n\t\t\t  OR\tcontest.userID = " . $userID . "\n\t\t\t)\n\t\t) > 0";
 }
Ejemplo n.º 10
0
 /**
  * @see Form::validate()
  */
 public function validate()
 {
     parent::validate();
     $this->availableClasses = ContestClass::getClasses();
     // validate class ids
     foreach ($this->classIDArray as $key => $classID) {
         if (!isset($this->availableClasses[$classID])) {
             unset($this->classIDArray[$key]);
         }
     }
     if (count($this->classIDArray) == 0) {
         throw new UserInputException('classes');
     }
     if ($this->ownerID != 0) {
         $this->availableGroups = ContestUtil::readAvailableGroups();
         // validate group ids
         if (!array_key_exists($this->ownerID, $this->availableGroups)) {
             throw new UserInputException('ownerID');
         }
     } else {
         if ($this->userID == 0) {
             throw new UserInputException('ownerID');
         }
     }
     if (!array_key_exists($this->state, $this->getStates())) {
         throw new UserInputException('state');
     }
 }