From ed673dbe0d2960974caa70ec66d76ed78537a7f1 Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 15 Feb 2016 10:29:27 +0200 Subject: [PATCH] fix portal isDefault --- application/Espo/Repositories/Portal.php | 7 +++++-- application/Espo/Services/Portal.php | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/application/Espo/Repositories/Portal.php b/application/Espo/Repositories/Portal.php index cccd61b3ea..2993c046fd 100644 --- a/application/Espo/Repositories/Portal.php +++ b/application/Espo/Repositories/Portal.php @@ -52,10 +52,13 @@ class Portal extends \Espo\Core\ORM\Repositories\RDB if ($entity->has('isDefault')) { if ($entity->get('isDefault')) { $this->getConfig()->set('defaultPortalId', $entity->id); + $this->getConfig()->save(); } else { - $this->getConfig()->set('defaultPortalId', null); + if ($entity->isAttributeChanged('isDefault')) { + $this->getConfig()->set('defaultPortalId', null); + $this->getConfig()->save(); + } } - $this->getConfig()->save(); } } } diff --git a/application/Espo/Services/Portal.php b/application/Espo/Services/Portal.php index 844865eb5f..afed86bb18 100644 --- a/application/Espo/Services/Portal.php +++ b/application/Espo/Services/Portal.php @@ -33,6 +33,8 @@ use \Espo\ORM\Entity; class Portal extends Record { + protected $getEntityBeforeUpdate = true; + public function loadAdditionalFields(Entity $entity) { parent::loadAdditionalFields($entity); @@ -51,8 +53,10 @@ class Portal extends Record $url = $siteUrl . '?entryPoint=portal'; if ($entity->id === $this->getConfig()->get('defaultPortalId')) { $entity->set('isDefault', true); + $entity->setFetched('isDefault', true); } else { $url .= '&id=' . $entity->id; + $entity->setFetched('isDefault', false); } $entity->set('url', $url); }