acl fixes

This commit is contained in:
yuri
2015-12-14 11:58:14 +02:00
parent dc0a616ec8
commit 7fe08f1669
11 changed files with 149 additions and 36 deletions
+3
View File
@@ -130,6 +130,9 @@ class Base implements Injectable
if ($data === true) {
return true;
}
if (is_string($data)) {
return true;
}
if (!is_null($action)) {
if (array_key_exists($action, $data)) {
+14 -8
View File
@@ -70,10 +70,8 @@ class Table
if ($config && $config->get('useCache') && file_exists($this->cacheFile)) {
$cached = include $this->cacheFile;
$this->data = $cached;
$this->initSolid();
} else {
$this->load();
$this->initSolid();
if ($config && $fileManager && $config->get('useCache')) {
$this->buildCache();
}
@@ -127,7 +125,6 @@ class Table
$userPermissionList = [];
if (!$this->user->isAdmin()) {
$userRoles = $this->user->get('roles');
foreach ($userRoles as $role) {
@@ -154,7 +151,7 @@ class Table
}
}
$this->data['table'] = $aclTable;
$this->applySolid($aclTable);
} else {
$aclTable = array();
foreach ($this->getScopeList() as $scope) {
@@ -169,9 +166,18 @@ class Table
}
}
}
$this->data['table'] = $aclTable;
}
foreach ($aclTable as $scope => $data) {
if (is_string($data)) {
if (array_key_exists($data, $aclTable)) {
$aclTable[$scope] = $aclTable[$data];
}
}
}
$this->data['table'] = $aclTable;
if (!$this->user->isAdmin()) {
$this->data['assignmentPermission'] = $this->mergeValues($assignmentPermissionList, $this->metadata->get('app.acl.valueDefaults.assignmentPermission', 'all'));
$this->data['userPermission'] = $this->mergeValues($userPermissionList, $this->metadata->get('app.acl.valueDefaults.userPermission', 'no'));
@@ -181,7 +187,7 @@ class Table
}
}
private function initSolid()
private function applySolid(&$table)
{
if (!$this->metadata) {
return;
@@ -193,8 +199,8 @@ class Table
$data = $this->metadata->get('app.acl.solid', array());
foreach ($data as $entityType => $item) {
$this->data['table'][$entityType] = $item;
foreach ($data as $scope => $item) {
$table[$scope] = $item;
}
}
@@ -46,7 +46,7 @@ class CampaignLogRecord extends \Espo\Core\Acl\Base
return true;
}
}
return;
return false;
}
public function checkInTeam(User $user, Entity $entity)
@@ -60,7 +60,7 @@ class CampaignLogRecord extends \Espo\Core\Acl\Base
return true;
}
}
return;
return false;
}
}
@@ -46,7 +46,7 @@ class CampaignTrackingUrl extends \Espo\Core\Acl\Base
return true;
}
}
return;
return false;
}
public function checkInTeam(User $user, Entity $entity)
@@ -60,7 +60,7 @@ class CampaignTrackingUrl extends \Espo\Core\Acl\Base
return true;
}
}
return;
return false;
}
}
@@ -45,8 +45,9 @@ class MassEmail extends \Espo\Core\Acl\Base
if ($campaign && $this->getAclManager()->getImplementation('Campaign')->checkIsOwner($user, $campaign)) {
return true;
}
} else {
return parent::checkIsOwner($user, $entity);
}
return;
}
public function checkInTeam(User $user, Entity $entity)
@@ -59,8 +60,9 @@ class MassEmail extends \Espo\Core\Acl\Base
if ($campaign && $this->getAclManager()->getImplementation('Campaign')->checkInTeam($user, $campaign)) {
return true;
}
} else {
return parent::checkInTeam($user, $entity);
}
return;
}
}
@@ -0,0 +1,3 @@
{
"acl": "crm:acl/campaign-tracking-url"
}
@@ -1,3 +1,4 @@
{
"controller": "controllers/record"
"controller": "controllers/record",
"acl": "crm:acl/campaign-tracking-url"
}
@@ -1,5 +1,6 @@
{
"controller": "controllers/record",
"acl": "crm:acl/mass-email",
"recordViews": {
"detail": "crm:views/mass-email/record/detail"
},
@@ -0,0 +1,49 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('crm:acl/campaign-tracking-url', 'acl', function (Dep) {
return Dep.extend({
checkIsOwner: function (model) {
if (model.has('campaignId')) {
return true;
}
return false;
},
checkInTeam: function (model) {
if (model.has('campaignId')) {
return true;
}
return false;
}
});
});
@@ -0,0 +1,51 @@
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM - Open Source CRM application.
* Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
* Website: http://www.espocrm.com
*
* EspoCRM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EspoCRM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
Espo.define('crm:acl/mass-email', 'acl', function (Dep) {
return Dep.extend({
checkIsOwner: function (model) {
if (model.has('campaignId')) {
return true;
} else {
return Dep.prototype.checkIsOwner.call(this, model);
}
},
checkInTeam: function (model) {
if (model.has('campaignId')) {
return true;
} else {
return Dep.prototype.checkInTeam.call(this, model);
}
}
});
});
+18 -21
View File
@@ -26,15 +26,6 @@
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
************************************************************************/
/** * Example:
* Lead: {
* edit: 'own',
* read: 'team',
* delete: 'no',
* }
*/
Espo.define('acl', [], function () {
var Acl = function (user, scope) {
@@ -78,7 +69,7 @@ Espo.define('acl', [], function () {
return true;
}
if (value == 'no') {
if (value === 'no') {
return false;
}
@@ -96,33 +87,39 @@ Espo.define('acl', [], function () {
}
}
var result = false;
if (value === 'team') {
result = inTeam;
if (inTeam === null) {
if (precise) {
return null;
result = null;
} else {
return true;
}
} else if (inTeam) {
return true;
}
}
if (isOwner === null) {
if (precise) {
result = null;
} else {
return inTeam;
return true;
}
}
if (value === 'own' || value === 'team') {
if (isOwner === null) {
if (precise) {
return null;
}
}
}
return false;
return result;
}
}
return true;
},
checkModel: function (model, data, action, precise) {
if (this.getUser().isAdmin()) {
return true;
}
return this.checkScope(data, action, precise, this.checkIsOwner(model), this.checkInTeam(model));
},