From db52fb3f0e8aeb79166fd01a25884478273246c7 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 4 Nov 2014 10:34:38 +0200 Subject: [PATCH] acl report dashlets --- application/Espo/Core/Acl.php | 13 +++++++++++++ .../Espo/Modules/Crm/Controllers/Opportunity.php | 12 ++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/application/Espo/Core/Acl.php b/application/Espo/Core/Acl.php index 03e09c6490..c1c45155f1 100644 --- a/application/Espo/Core/Acl.php +++ b/application/Espo/Core/Acl.php @@ -125,6 +125,19 @@ class Acl return $this->data; } + public function getLevel($scope, $action) + { + if ($this->user->isAdmin()) { + return 'all'; + } + if (array_key_exists($scope, $this->data)) { + if (array_key_exists($action, $this->data[$scope])) { + return $this->data[$scope][$action]; + } + } + return false; + } + public function check($subject, $action = null, $isOwner = null, $inTeam = null) { if ($this->user->isAdmin()) { diff --git a/application/Espo/Modules/Crm/Controllers/Opportunity.php b/application/Espo/Modules/Crm/Controllers/Opportunity.php index cebd678e57..95024765db 100644 --- a/application/Espo/Modules/Crm/Controllers/Opportunity.php +++ b/application/Espo/Modules/Crm/Controllers/Opportunity.php @@ -29,7 +29,8 @@ class Opportunity extends \Espo\Core\Controllers\Record { public function actionReportByLeadSource($params, $data, $request) { - if (!$this->getAcl()->check('Lead', 'read')) { + $level = $this->getAcl()->getLevel('Lead', 'read'); + if (!$level || $level == 'own') { throw new Forbidden(); } @@ -41,7 +42,8 @@ class Opportunity extends \Espo\Core\Controllers\Record public function actionReportByStage($params, $data, $request) { - if (!$this->getAcl()->check('Opportunity', 'read')) { + $level = $this->getAcl()->getLevel('Opportunity', 'read'); + if (!$level || $level == 'own') { throw new Forbidden(); } @@ -53,7 +55,8 @@ class Opportunity extends \Espo\Core\Controllers\Record public function actionReportSalesByMonth($params, $data, $request) { - if (!$this->getAcl()->check('Opportunity', 'read')) { + $level = $this->getAcl()->getLevel('Opportunity', 'read'); + if (!$level || $level == 'own') { throw new Forbidden(); } @@ -65,7 +68,8 @@ class Opportunity extends \Espo\Core\Controllers\Record public function actionReportSalesPipeline($params, $data, $request) { - if (!$this->getAcl()->check('Opportunity', 'read')) { + $level = $this->getAcl()->getLevel('Opportunity', 'read'); + if (!$level || $level == 'own') { throw new Forbidden(); }