acl report dashlets

This commit is contained in:
Yuri Kuznetsov
2014-11-04 10:34:38 +02:00
parent 16963fdc58
commit db52fb3f0e
2 changed files with 21 additions and 4 deletions
+13
View File
@@ -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()) {
@@ -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();
}