post permission
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
"roles": "Roles",
|
||||
"assignmentPermission": "Assignment Permission",
|
||||
"userPermission": "User Permission",
|
||||
"messagePermission": "Message Permission",
|
||||
"portalPermission": "Portal Permission",
|
||||
"groupEmailAccountPermission": "Group Email Account Permission",
|
||||
"exportPermission": "Export Permission",
|
||||
@@ -18,6 +19,7 @@
|
||||
"teams": "Teams"
|
||||
},
|
||||
"tooltips": {
|
||||
"messagePermission": "Allows to send messages to other users.\n\n* all – can send to all\n* team – can send only to teammates\n* no – cannot send",
|
||||
"assignmentPermission": "Allows to assign records to other users.\n\n* all – no restriction\n* team – can assign only to teammates\n* no – can assign only to self",
|
||||
"userPermission": "Allows view activities, calendar and stream of other users.\n\n* all – can view all\n* team – can view activities of teammates only\n* no – can't view",
|
||||
"portalPermission": "Access to portal information, the ability to post messages to portal users.",
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
[
|
||||
{"name": "massUpdatePermission"},
|
||||
{"name": "followerManagementPermission"},
|
||||
false
|
||||
{"name": "messagePermission"}
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@
|
||||
"valuePermissionList": [
|
||||
"assignmentPermission",
|
||||
"userPermission",
|
||||
"messagePermission",
|
||||
"portalPermission",
|
||||
"groupEmailAccountPermission",
|
||||
"exportPermission",
|
||||
@@ -165,6 +166,7 @@
|
||||
"valuePermissionHighestLevels": {
|
||||
"assignmentPermission": "all",
|
||||
"userPermission": "all",
|
||||
"messagePermission": "all",
|
||||
"portalPermission": "yes",
|
||||
"groupEmailAccountPermission": "all",
|
||||
"exportPermission": "yes",
|
||||
@@ -175,6 +177,7 @@
|
||||
"permissionsStrictDefaults": {
|
||||
"assignmentPermission": "no",
|
||||
"userPermission": "no",
|
||||
"messagePermission": "no",
|
||||
"portalPermission": "no",
|
||||
"groupEmailAccountPermission": "no",
|
||||
"exportPermission": "no",
|
||||
|
||||
@@ -20,6 +20,13 @@
|
||||
"tooltip": true,
|
||||
"translation": "Role.options.levelList"
|
||||
},
|
||||
"messagePermission": {
|
||||
"type": "enum",
|
||||
"options": ["not-set", "all", "team", "no"],
|
||||
"default": "not-set",
|
||||
"tooltip": true,
|
||||
"translation": "Role.options.levelList"
|
||||
},
|
||||
"portalPermission": {
|
||||
"type": "enum",
|
||||
"options": ["not-set", "yes", "no"],
|
||||
|
||||
@@ -277,9 +277,9 @@ class Note extends Record
|
||||
}
|
||||
}
|
||||
|
||||
$assignmentPermission = $this->acl->getPermissionLevel('assignment');
|
||||
$messagePermission = $this->acl->getPermissionLevel('message');
|
||||
|
||||
if ($assignmentPermission === AclTable::LEVEL_NO) {
|
||||
if ($messagePermission === AclTable::LEVEL_NO) {
|
||||
if (
|
||||
$targetType !== NoteEntity::TARGET_SELF &&
|
||||
$targetType !== NoteEntity::TARGET_PORTALS &&
|
||||
@@ -327,14 +327,14 @@ class Note extends Record
|
||||
}
|
||||
}
|
||||
|
||||
if ($assignmentPermission === AclTable::LEVEL_TEAM) {
|
||||
if ($messagePermission === AclTable::LEVEL_TEAM) {
|
||||
if ($targetType === NoteEntity::TARGET_ALL) {
|
||||
throw new Forbidden('Not permitted to post to all.');
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
$assignmentPermission === AclTable::LEVEL_TEAM &&
|
||||
$messagePermission === AclTable::LEVEL_TEAM &&
|
||||
$targetType === NoteEntity::TARGET_TEAMS
|
||||
) {
|
||||
if (empty($userTeamIdList)) {
|
||||
@@ -349,7 +349,7 @@ class Note extends Record
|
||||
}
|
||||
|
||||
if (
|
||||
$assignmentPermission === AclTable::LEVEL_TEAM &&
|
||||
$messagePermission === AclTable::LEVEL_TEAM &&
|
||||
$targetType === NoteEntity::TARGET_USERS
|
||||
) {
|
||||
if (empty($userTeamIdList)) {
|
||||
|
||||
@@ -31,10 +31,10 @@ define('views/note/fields/users', ['views/fields/link-multiple'], function (Dep)
|
||||
return Dep.extend({
|
||||
|
||||
init: function () {
|
||||
this.assignmentPermission = this.getAcl().get('assignmentPermission');
|
||||
this.portalPermission = this.getAcl().get('portalPermission');
|
||||
this.messagePermission = this.getAcl().getPermissionLevel('message');
|
||||
this.portalPermission = this.getAcl().getPermissionLevel('portal');
|
||||
|
||||
if (this.assignmentPermission === 'no' && this.portalPermission === 'no') {
|
||||
if (this.messagePermission === 'no' && this.portalPermission === 'no') {
|
||||
this.readOnly = true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ define('views/note/fields/users', ['views/fields/link-multiple'], function (Dep)
|
||||
},
|
||||
|
||||
getSelectBoolFilterList: function () {
|
||||
if (this.assignmentPermission === 'team') {
|
||||
if (this.messagePermission === 'team') {
|
||||
return ['onlyMyTeam'];
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ define('views/note/fields/users', ['views/fields/link-multiple'], function (Dep)
|
||||
},
|
||||
|
||||
getSelectPrimaryFilterName: function () {
|
||||
if (this.portalPermission === 'yes' && this.assignmentPermission === 'no') {
|
||||
if (this.portalPermission === 'yes' && this.messagePermission === 'no') {
|
||||
return 'activePortal';
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ define('views/note/fields/users', ['views/fields/link-multiple'], function (Dep)
|
||||
getSelectFilterList: function () {
|
||||
|
||||
if (this.portalPermission === 'yes') {
|
||||
if (this.assignmentPermission === 'no') {
|
||||
if (this.messagePermission === 'no') {
|
||||
return ['activePortal'];
|
||||
}
|
||||
|
||||
|
||||
@@ -146,20 +146,20 @@ define('views/stream/record/edit', ['views/record/base'], function (Dep) {
|
||||
};
|
||||
}
|
||||
|
||||
var optionList = ['self'];
|
||||
let optionList = ['self'];
|
||||
|
||||
this.model.set('type', 'Post');
|
||||
this.model.set('targetType', 'self');
|
||||
|
||||
var assignmentPermission = this.getAcl().get('assignmentPermission');
|
||||
var portalPermission = this.getAcl().get('portalPermission');
|
||||
let messagePermission = this.getAcl().getPermissionLevel('message');
|
||||
let portalPermission = this.getAcl().getPermissionLevel('portal');
|
||||
|
||||
if (assignmentPermission === 'team' || assignmentPermission === 'all') {
|
||||
if (messagePermission === 'team' || messagePermission === 'all') {
|
||||
optionList.push('users');
|
||||
optionList.push('teams');
|
||||
}
|
||||
|
||||
if (assignmentPermission === 'all') {
|
||||
if (messagePermission === 'all') {
|
||||
optionList.push('all');
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ define('views/stream/record/edit', ['views/record/base'], function (Dep) {
|
||||
}
|
||||
|
||||
this.createField('targetType', 'views/fields/enum', {
|
||||
options: optionList
|
||||
options: optionList,
|
||||
});
|
||||
|
||||
this.createField('users', 'views/note/fields/users', {});
|
||||
@@ -210,9 +210,11 @@ define('views/stream/record/edit', ['views/record/base'], function (Dep) {
|
||||
this.$el.find('.post-control').removeClass('hidden');
|
||||
|
||||
if (!this.postingMode) {
|
||||
$('body').off('click.stream-create-post');
|
||||
let $body = $('body');
|
||||
|
||||
$('body').on('click.stream-create-post', (e) => {
|
||||
$body.off('click.stream-create-post');
|
||||
|
||||
$body.on('click.stream-create-post', e => {
|
||||
if (
|
||||
$.contains(window.document.body, e.target) &&
|
||||
!$.contains(this.$el.get(0), e.target) &&
|
||||
|
||||
@@ -33,7 +33,7 @@ define('views/user/record/panels/stream', ['views/stream/panel'], function (Dep)
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
var assignmentPermission = this.getAcl().checkAssignmentPermission(this.model);
|
||||
let assignmentPermission = this.getAcl().checkPermission('message', this.model);
|
||||
|
||||
if (this.model.id === this.getUser().id) {
|
||||
this.placeholderText = this.translate('writeMessageToSelf', 'messages');
|
||||
@@ -45,14 +45,14 @@ define('views/user/record/panels/stream', ['views/stream/panel'], function (Dep)
|
||||
if (!assignmentPermission) {
|
||||
this.postDisabled = true;
|
||||
|
||||
if (this.getAcl().get('assignmentPermission') === 'team') {
|
||||
if (this.getAcl().getPermissionLevel('message') === 'team') {
|
||||
if (!this.model.has('teamsIds')) {
|
||||
this.listenToOnce(this.model, 'sync', () => {
|
||||
assignmentPermission = this.getAcl().checkUserPermission(this.model);
|
||||
|
||||
if (assignmentPermission) {
|
||||
this.postDisabled = false;
|
||||
this.$el.find('.post-container').removeClass('hidden');;
|
||||
this.$el.find('.post-container').removeClass('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2022 Yurii Kuznietsov, Taras Machyshyn, Oleksii Avramenko
|
||||
* Website: https://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.
|
||||
************************************************************************/
|
||||
|
||||
use Espo\Core\Container;
|
||||
use Espo\Entities\Role;
|
||||
use Espo\ORM\EntityManager;
|
||||
use Espo\ORM\Query\Part\Expression;
|
||||
use Espo\ORM\Query\UpdateBuilder;
|
||||
|
||||
class AfterUpgrade
|
||||
{
|
||||
public function run(Container $container): void
|
||||
{
|
||||
$this->updateRoles(
|
||||
$container->getByClass(EntityManager::class)
|
||||
);
|
||||
}
|
||||
|
||||
private function updateRoles(EntityManager $entityManager): void
|
||||
{
|
||||
$query = UpdateBuilder::create()
|
||||
->in(Role::ENTITY_TYPE)
|
||||
->set(['messagePermission' => Expression::column('assignmentPermission')])
|
||||
->build();
|
||||
|
||||
$entityManager->getQueryExecutor()->execute($query);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user