/** * @see Form::validate() */ public function validate() { parent::validate(); if ($this->action == 'rename') { if (!PlanetUtil::isValid($this->newName)) { throw new UserInputException('newName', 'notValid'); } } else { if ($this->action == 'delete') { // main planet if (LWCore::getPlanet()->planetID == WCF::getUser()->id_planet) { throw new SystemException('tried to delete main planet'); } // password if (!WCF::getUser()->checkPassword($this->password)) { throw new UserInputException('password', 'notValid'); } // check fleets (moon, if existing and planet) if (LWCore::getPlanet()->planetKind == 1 && LWCore::getPlanet()->getMoon() != null) { if (count(Fleet::getByPlanetID(LWCore::getPlanet()->getMoon()->planetID, Fleet::OFIARA | Fleet::OWNER))) { throw new UserInputException('password', 'activityMoon'); } } // check current if (count(Fleet::getByPlanetID(LWCore::getPlanet()->planetID, Fleet::OFIARA | Fleet::OWNER))) { throw new UserInputException('password', 'activity'); } } } }