From 957fda9e8e81da1a54af3a8d33ee6ad8a3fca05f Mon Sep 17 00:00:00 2001 From: yuri Date: Thu, 17 Sep 2015 11:00:21 +0300 Subject: [PATCH] clear cache if user changed roles --- application/Espo/Services/User.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/application/Espo/Services/User.php b/application/Espo/Services/User.php index ec7cde0021..518877c4c1 100644 --- a/application/Espo/Services/User.php +++ b/application/Espo/Services/User.php @@ -49,6 +49,11 @@ class User extends Record return $this->getContainer()->get('language'); } + protected function getFileManager() + { + return $this->getContainer()->get('fileManager'); + } + protected function getContainer() { return $this->injections['container']; @@ -353,5 +358,18 @@ class User extends Record } return parent::deleteEntity($id); } + + public function afterUpdate(Entity $entity, array $data) + { + parent::afterUpdate($entity, $data); + if (array_key_exists('rolesIds', $data) || array_key_exists('teamsIds', $data)) { + $this->clearRoleCache($entity->id); + } + } + + protected function clearRoleCache($id) + { + $this->getFileManager()->removeFile('data/cache/application/acl/' . $id . '.php'); + } }