/**
  * Returns a state object.
  * 
  * @return	ContestState
  */
 public function getState()
 {
     require_once WCF_DIR . 'lib/data/contest/state/ContestState.class.php';
     return ContestState::get($this->state);
 }
 /**
  * 'invited', 'accepted', 'declined', 'applied'
  */
 public static function getStates($current = '', $flag = 0)
 {
     require_once WCF_DIR . 'lib/data/contest/state/ContestState.class.php';
     $arr = array($current);
     switch ($current) {
         case 'invited':
             if ($flag & (ContestState::FLAG_USER | ContestState::FLAG_CREW)) {
                 $arr[] = 'accepted';
                 $arr[] = 'declined';
             }
             break;
         case 'accepted':
         case 'declined':
         case 'applied':
             if ($flag & (ContestState::FLAG_CONTESTOWNER | ContestState::FLAG_CREW)) {
                 $arr[] = 'accepted';
                 $arr[] = 'declined';
             }
             break;
     }
     return ContestState::translateArray($arr);
 }
 /**
  * 'private', 'applied', 'accepted', 'declined', 'scheduled', 'closed'
  */
 public static function getStates($current = '', $flag = 0, $isClosable = false)
 {
     require_once WCF_DIR . 'lib/data/contest/state/ContestState.class.php';
     $arr = array($current);
     switch ($current) {
         case 'private':
             if ($flag & (ContestState::FLAG_USER | ContestState::FLAG_CREW)) {
                 $arr[] = 'applied';
             }
             break;
         case 'accepted':
         case 'declined':
         case 'applied':
             if ($flag & ContestState::FLAG_CREW) {
                 $arr[] = 'accepted';
                 $arr[] = 'declined';
                 $arr[] = 'applied';
                 $arr[] = 'scheduled';
             }
         case 'scheduled':
         case 'closed':
             if ($flag & ContestState::FLAG_CREW) {
                 $arr[] = 'scheduled';
                 $arr[] = 'accepted';
             }
             break;
         default:
             $arr = array();
             $arr[] = 'private';
             break;
     }
     if ($isClosable && !in_array('closed', $arr)) {
         $arr[] = 'closed';
     }
     $canSchedule = WCF::getUser()->getPermission('user.contest.canScheduleOwnContest');
     if ($flag & ContestState::FLAG_USER && $canSchedule) {
         if (in_array($current, array('private', 'accepted', 'applied'))) {
             $arr[] = 'scheduled';
         }
     }
     return ContestState::translateArray($arr);
 }
 /**
  * current may be 'applied', 'accepted', 'declined', 'sent', 'received'
  *
  * flag may be bitmask of ContestState::FLAG_USER, ContestState::FLAG_CONTESTOWNER, 
  * ContestState::FLAG_CREW, ContestPriceEditor::STATE_FLAG_WINNER, ContestPriceEditor::STATE_FLAG_SPONSOR
  */
 public static function getStates($current = '', $flag = 0)
 {
     require_once WCF_DIR . 'lib/data/contest/state/ContestState.class.php';
     $arr = array($current);
     switch ($current) {
         case 'applied':
         case 'accepted':
         case 'declined':
             if ($flag & (ContestState::FLAG_CONTESTOWNER | ContestState::FLAG_CREW)) {
                 $arr[] = 'applied';
                 $arr[] = 'accepted';
                 $arr[] = 'declined';
             }
             if ($current == 'accepted' && $flag & (self::STATE_FLAG_SPONSOR | ContestState::FLAG_CREW)) {
                 $arr[] = 'sent';
             }
             break;
         case 'sent':
             if ($flag & (self::STATE_FLAG_WINNER | ContestState::FLAG_CREW)) {
                 $arr[] = 'received';
             }
             if ($flag & (self::STATE_FLAG_SPONSOR | ContestState::FLAG_CREW)) {
                 $arr[] = 'accepted';
             }
             break;
     }
     return ContestState::translateArray($arr);
 }
 /**
  * 'private', 'applied', 'accepted', 'declined'
  */
 public static function getStates($current = '', $flag = 0)
 {
     require_once WCF_DIR . 'lib/data/contest/state/ContestState.class.php';
     $arr = array($current);
     switch ($current) {
         case 'private':
             if ($flag & (ContestState::FLAG_USER | ContestState::FLAG_CREW)) {
                 $arr[] = $flag & self::FLAG_OPENSOLUTION ? 'accepted' : 'applied';
             }
             break;
         case 'accepted':
         case 'declined':
         case 'applied':
             if ($flag & (ContestState::FLAG_CONTESTOWNER | ContestState::FLAG_CREW)) {
                 $arr[] = 'accepted';
                 $arr[] = 'declined';
             }
             break;
         default:
             $arr = array();
             // reset array
             $arr[] = $flag & self::FLAG_OPENSOLUTION ? 'accepted' : 'applied';
             $arr[] = 'private';
             break;
     }
     return ContestState::translateArray($arr);
 }