From 9d316da4e00b4ce3fdbf0eccb3930b8f18f32eb3 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 3 Dec 2014 15:50:00 +0200 Subject: [PATCH] fix meeting/call attendees --- .../Espo/Modules/Crm/Repositories/Call.php | 25 +++---------------- .../Espo/Modules/Crm/Repositories/Meeting.php | 25 ++++++++++++++++--- .../Espo/Modules/Crm/Services/Meeting.php | 21 ---------------- 3 files changed, 24 insertions(+), 47 deletions(-) diff --git a/application/Espo/Modules/Crm/Repositories/Call.php b/application/Espo/Modules/Crm/Repositories/Call.php index d3747be783..92a6cae3a2 100644 --- a/application/Espo/Modules/Crm/Repositories/Call.php +++ b/application/Espo/Modules/Crm/Repositories/Call.php @@ -24,27 +24,8 @@ namespace Espo\Modules\Crm\Repositories; use Espo\ORM\Entity; -class Call extends \Espo\Core\ORM\Repositories\RDB -{ - protected function beforeSave(Entity $entity) - { - parent::beforeSave($entity); - - $parentId = $entity->get('parentId'); - $parentType = $entity->get('parentType'); - if (!empty($parentId) || !empty($parentType)) { - $parent = $this->getEntityManager()->getEntity($parentType, $parentId); - if (!empty($parent)) { - if ($parent->getEntityName() == 'Account') { - $accountId = $parent->id; - } else if ($parent->has('accountId')) { - $accountId = $parent->get('accountId'); - } - if (!empty($accountId)) { - $entity->set('accountId', $accountId); - } - } - } - } +class Call extends Meeting +{ + } diff --git a/application/Espo/Modules/Crm/Repositories/Meeting.php b/application/Espo/Modules/Crm/Repositories/Meeting.php index c1591433f1..61195e0e70 100644 --- a/application/Espo/Modules/Crm/Repositories/Meeting.php +++ b/application/Espo/Modules/Crm/Repositories/Meeting.php @@ -18,16 +18,16 @@ * * You should have received a copy of the GNU General Public License * along with EspoCRM. If not, see http://www.gnu.org/licenses/. - ************************************************************************/ + ************************************************************************/ namespace Espo\Modules\Crm\Repositories; use Espo\ORM\Entity; class Meeting extends \Espo\Core\ORM\Repositories\RDB -{ +{ protected function beforeSave(Entity $entity) - { + { parent::beforeSave($entity); $parentId = $entity->get('parentId'); @@ -44,7 +44,24 @@ class Meeting extends \Espo\Core\ORM\Repositories\RDB $entity->set('accountId', $accountId); } } - } + } + + $assignedUserId = $entity->get('assignedUserId'); + if ($assignedUserId && $entity->has('usersIds')) { + $usersIds = $entity->get('usersIds'); + if (!is_array($usersIds)) { + $usersIds = array(); + } + if (!in_array($assignedUserId, $usersIds)) { + $usersIds[] = $assignedUserId; + $entity->set('usersIds', $usersIds); + $hash = $entity->get('usersNames'); + if ($hash instanceof \stdClass) { + $hash->$assignedUserId = $entity->get('assignedUserName'); + $entity->set('usersNames', $hash); + } + } + } } } diff --git a/application/Espo/Modules/Crm/Services/Meeting.php b/application/Espo/Modules/Crm/Services/Meeting.php index d35b0074e1..cffa016af1 100644 --- a/application/Espo/Modules/Crm/Services/Meeting.php +++ b/application/Espo/Modules/Crm/Services/Meeting.php @@ -98,26 +98,5 @@ class Meeting extends \Espo\Services\Record return true; } - - protected function storeEntity(Entity $entity) - { - $assignedUserId = $entity->get('assignedUserId'); - if ($assignedUserId && $entity->has('usersIds')) { - $usersIds = $entity->get('usersIds'); - if (!is_array($usersIds)) { - $usersIds = array(); - } - if (!in_array($assignedUserId, $usersIds)) { - $usersIds[] = $assignedUserId; - $entity->set('usersIds', $usersIds); - $hash = $entity->get('usersNames'); - if ($hash instanceof \stdClass) { - $hash->assignedUserId = $entity->get('assignedUserName'); - $entity->set('usersNames', $hash); - } - } - } - return parent::storeEntity($entity); - } }