From 398615cc5cd6d406ddee18dbe912e19bcc1d439e Mon Sep 17 00:00:00 2001 From: Exodus4D Date: Sun, 28 May 2017 15:00:00 +0200 Subject: [PATCH] - system alias no longer persists after system delete - reset some character table columns on corp change or character sold --- app/main/controller/api/system.php | 5 +---- app/main/model/charactermodel.php | 28 +++++++++++++++++++++++++++- app/main/model/systemmodel.php | 2 ++ public/templates/modules/sso.html | 2 +- 4 files changed, 31 insertions(+), 6 deletions(-) diff --git a/app/main/controller/api/system.php b/app/main/controller/api/system.php index 3c4f0a05..aed82056 100644 --- a/app/main/controller/api/system.php +++ b/app/main/controller/api/system.php @@ -429,10 +429,7 @@ class System extends Controller\AccessController { foreach($systemIds as $systemId){ if( $system = $map->getSystemById($systemId) ){ // check whether system should be deleted OR set "inactive" - if( - !empty($system->description) || - ( !empty($system->alias) && ($system->alias != $system->name) ) - ){ + if( !empty($system->description) ){ // keep data -> set "inactive" $system->setActive(false); $system->save(); diff --git a/app/main/model/charactermodel.php b/app/main/model/charactermodel.php index e8b12083..93d1bf6e 100644 --- a/app/main/model/charactermodel.php +++ b/app/main/model/charactermodel.php @@ -200,6 +200,22 @@ class CharacterModel extends BasicModel { return $characterData; } + /** + * set corporation for this character + * -> corp change resets admin actions (e.g. kick/ban) + * @param $corporationId + * @return mixed + */ + public function set_corporationId($corporationId){ + $currentCorporationId = (int)$this->get('corporationId', true); + + if($currentCorporationId !== $corporationId){ + $this->resetAdminColumns(); + } + + return $corporationId; + } + /** * set unique "ownerHash" for this character * -> Hash will change when character is transferred (sold) @@ -207,9 +223,12 @@ class CharacterModel extends BasicModel { * @return string */ public function set_ownerHash($ownerHash){ - if( $this->ownerHash !== $ownerHash ){ if( $this->hasUserCharacter() ){ + // reset admin actions (e.g. kick/ban) + $this->resetAdminColumns(); + + // new ownerHash -> new user (reset) $this->userCharacter->erase(); } @@ -365,6 +384,13 @@ class CharacterModel extends BasicModel { parent::clearCacheDataWithPrefix(self::DATA_CACHE_KEY_LOG); } + /** + * resets some columns that could have changed by admins (e.g. kick/ban) + */ + private function resetAdminColumns(){ + $this->kick(); + } + /** * check whether this character has already a user assigned to it * @return bool diff --git a/app/main/model/systemmodel.php b/app/main/model/systemmodel.php index f3fd8941..a8b786f1 100644 --- a/app/main/model/systemmodel.php +++ b/app/main/model/systemmodel.php @@ -394,6 +394,8 @@ class SystemModel extends BasicModel { if( !$self->isActive()){ // system becomes inactive + $self->alias = ''; + // reset "rally point" fields $self->rallyUpdated = 0; $self->rallyPoke = false; diff --git a/public/templates/modules/sso.html b/public/templates/modules/sso.html index c23a87f3..eac51634 100644 --- a/public/templates/modules/sso.html +++ b/public/templates/modules/sso.html @@ -1,5 +1,5 @@ -
+