Exemplo n.º 1
0
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     parent::readData();
     if (!empty($this->allianceID)) {
         $this->alliance = new Alliance($this->allianceID);
     } else {
         $this->alliance = Alliance::getByUserID(WCF::getUser()->userID);
     }
     // no such alliance
     if ($this->alliance === null || $this->alliance->id <= 0) {
         require_once WCF_DIR . 'lib/system/exception/NamedUserException.class.php';
         //$_SERVER['HTTP_ACCEPT'] = str_replace('platzhalter', 'application/xhtml+xml', $_SERVER['HTTP_ACCEPT']);
         // user has no alliance
         if (empty($this->allianceID)) {
             // waiting for a answer to the application
             if (WCF::getUser()->ally_request) {
                 $alliance = new Alliance(WCF::getUser()->ally_request);
                 throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.waitingForApplicationAnswer', array('allianceID' => $alliance->allianceID, 'allianceTag' => $alliance->ally_tag, 'userID' => WCF::getUser()->userID)));
             }
             throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.notMember'));
         }
         // requested alliance does not exist
         throw new NamedUserException(WCF::getLanguage()->get('wot.alliance.notExisting'));
     }
     // applications
     if ($this->alliance->getRank(true, 3)) {
         $sql = "SELECT COUNT(*) AS count\n\t\t\t\t\tFROM ugml_users\n\t\t\t\t\tWHERE ally_request = " . $this->alliance->allianceID;
         $result = WCF::getDB()->getFirstRow($sql);
         $this->applicationsCount = $result['count'];
     }
 }
 /**
  * @see Action::readParameters()
  */
 public function readParameters()
 {
     parent::readParameters();
     if (isset($_REQUEST['allianceID'])) {
         $this->allianceID = intval($_REQUEST['allianceID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if (isset($_REQUEST['userID'])) {
         $this->userID = intval($_REQUEST['userID']);
     } else {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if ($this->allianceID != WCF::getUser()->ally_id) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     if ($this->userID != WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     $this->alliance = Alliance::getByUserID(WCF::getUser()->userID, true);
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     if (!WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->alliance = Alliance::getByUserID($this->userID, true);
     $this->user = new LWUser($this->userID);
     if ($this->userID == WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     if ($this->user->ally_id != $this->allianceID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     if (!$this->alliance->getRank(true, 6)) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->alliance->deleteUser($this->userID);
     $this->executed();
     header('Location: index.php?page=AllianceMembersList');
     exit;
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     // alliance
     $this->alliance = Alliance::getByUserID(WCF::getUser()->userID, true);
     $this->interrelations = $this->alliance->getInterrelation();
     $this->interrelations[$this->alliance->allianceID] = $this->alliance;
     parent::readData();
 }
 /**
  * @see Page::readData()
  */
 public function readData()
 {
     // alliance
     $this->alliance = Alliance::getByUserID(WCF::getUser()->userID, true);
     // user
     if (empty($this->userID)) {
         require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
         throw new IllegalLinkException();
     }
     $this->user = new LWUser($this->userID);
     parent::readData();
 }
Exemplo n.º 6
0
 /**
  * @see Mission::check()
  */
 public static function check(FleetQueue $fleetQueue)
 {
     $alliance = Alliance::getByUserID($fleetQueue->getTargetPlanet()->id_owner);
     $foreignPlanet = $fleetQueue->getTargetPlanet()->id_owner != WCF::getUser()->userID;
     $isBuddy = WCF::getUser()->hasBuddy($fleetQueue->getTargetPlanet()->id_owner);
     $isInAlliance = $alliance !== null && LWCore::getAlliance() !== null && $alliance->allianceID == LWCore::getAlliance()->allianceID;
     if ($fleetQueue->pageNo == 2) {
         WCF::getTPL()->assign('availableTimes', self::$availableTimes);
     }
     if ($fleetQueue->pageNo == 3) {
         $selectedTime = intval(@$_REQUEST['standByTime']);
         if (!in_array($selectedTime, self::$availableTimes)) {
             return false;
         }
     }
     if ($foreignPlanet && ($isBuddy || $isInAlliance)) {
         return true;
     }
     return false;
 }
 /**
  * @see Action::execute()
  */
 public function execute()
 {
     parent::execute();
     // check permission
     if (!WCF::getUser()->userID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     $this->alliance = Alliance::getByUserID($this->userID, true);
     $this->user = new LWUser($this->userID);
     // can not edit users of other alliances
     if ($this->user->ally_id != $this->allianceID) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     // not allowed
     if (!$this->alliance->getRank(true, 6)) {
         require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
         throw new PermissionDeniedException();
     }
     // change leader
     if ($this->rankID == -1) {
         if (WCF::getUser()->userID != $this->alliance->ally_owner) {
             require_once WCF_DIR . 'lib/system/exception/PermissionDeniedException.class.php';
             throw new PermissionDeniedException();
         }
         $this->alliance->changeLeader($this->userID);
     } else {
         if ($this->alliance->getRank($this->rankID - 1) === null && $this->rankID != 0) {
             require_once WCF_DIR . 'lib/system/exception/IllegalLinkException.class.php';
             throw new IllegalLinkException();
         }
         $sql = "UPDATE ugml_users\n\t\t\t\t\tSET ally_rank_id = " . $this->rankID . "\n\t\t\t\t\tWHERE id = " . $this->userID;
         WCF::getDB()->sendQuery($sql);
         $sql = "DELETE FROM wcf" . WCF_N . "_session\n\t\t\t\t\tWHERE userID = " . $this->userID;
         WCF::getDB()->sendQuery($sql);
     }
     $this->executed();
     header('Location: index.php?page=AllianceMembersList');
     exit;
 }
 /**
  * @see Page::readParameters
  */
 public function readParameters()
 {
     parent::readParameters();
     $this->alliance = Alliance::getByUserID(WCF::getUser()->userID);
 }
Exemplo n.º 9
0
 /**
  * Return the actual alliance.
  * 
  * @param	bool	Editor
  * @return	Alliance
  */
 public static function getAlliance($editor = false)
 {
     if ($editor) {
         if (self::$allianceEditor === null) {
             require_once LW_DIR . 'lib/data/user/alliance/AllianceEditor.class.php';
             self::$allianceEditor = Alliance::getByUserID(self::getUser()->userID, true);
         }
         return self::$allianceEditor;
     } else {
         if (self::$alliance === null) {
             require_once LW_DIR . 'lib/data/user/alliance/Alliance.class.php';
             self::$alliance = Alliance::getByUserID(self::getUser()->userID, false);
         }
         return self::$alliance;
     }
 }
Exemplo n.º 10
0
 /**
  * Makes a user to leader
  * 
  * @param	int		user id
  * @param	string	owner name
  */
 public function changeLeader($userID, $rankName = null)
 {
     if (Alliance::getByUserID($userID)->allianceID != $this->allianceID && $userID !== null) {
         return;
     }
     if ($userID !== $this->ally_owner && $userID !== null) {
         $sql = "SELECT ally_rank_id\n\t\t\t\t\tFROM ugml_users\n\t\t\t\t\tWHERE id = " . $userID;
         $result = WCF::getDB()->getFirstRow($sql);
         $oldLeaderRank = $result['ally_rank_id'];
         $sql = "UPDATE ugml_users\n\t\t\t\t\tSET ally_rank_id = " . $oldLeaderRank . "\n\t\t\t\t\tWHERE id = " . $this->ally_owner;
         $result = WCF::getDB()->sendQuery($sql);
         $sql = "UPDATE ugml_users\n\t\t\t\t\tSET ally_rank_id = 0\n\t\t\t\t\tWHERE id = " . $userID;
         $result = WCF::getDB()->sendQuery($sql);
         // set to leader
         $this->ally_owner = $userID;
         Session::resetSessions($userID);
     }
     if ($rankName !== null) {
         $this->ally_owner_range = $rankName;
     }
     $sql = "UPDATE ugml_alliance\n\t\t\t\tSET ally_owner = " . $this->ally_owner . ",\n\t\t\t\t\tally_owner_range = '" . escapeString($this->ally_owner_range) . "'\n\t\t\t\tWHERE id = " . $this->allianceID;
     WCF::getDB()->sendQuery($sql);
 }