diff --git a/application/Espo/Resources/i18n/en_US/Role.json b/application/Espo/Resources/i18n/en_US/Role.json index a6b9fcb3b5..272d885b4f 100644 --- a/application/Espo/Resources/i18n/en_US/Role.json +++ b/application/Espo/Resources/i18n/en_US/Role.json @@ -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.", diff --git a/application/Espo/Resources/layouts/Role/detail.json b/application/Espo/Resources/layouts/Role/detail.json index a463ef2352..ac8b833d31 100644 --- a/application/Espo/Resources/layouts/Role/detail.json +++ b/application/Espo/Resources/layouts/Role/detail.json @@ -23,7 +23,7 @@ [ {"name": "massUpdatePermission"}, {"name": "followerManagementPermission"}, - false + {"name": "messagePermission"} ] ] } diff --git a/application/Espo/Resources/metadata/app/acl.json b/application/Espo/Resources/metadata/app/acl.json index ef01a14ee9..24bc9143d7 100644 --- a/application/Espo/Resources/metadata/app/acl.json +++ b/application/Espo/Resources/metadata/app/acl.json @@ -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", diff --git a/application/Espo/Resources/metadata/entityDefs/Role.json b/application/Espo/Resources/metadata/entityDefs/Role.json index 6fc7ca4394..466f35879d 100644 --- a/application/Espo/Resources/metadata/entityDefs/Role.json +++ b/application/Espo/Resources/metadata/entityDefs/Role.json @@ -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"], diff --git a/application/Espo/Services/Note.php b/application/Espo/Services/Note.php index 35b0e06d32..365e2cfb6a 100644 --- a/application/Espo/Services/Note.php +++ b/application/Espo/Services/Note.php @@ -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)) { diff --git a/client/src/views/note/fields/users.js b/client/src/views/note/fields/users.js index 7a04ec65a9..9efc9762d4 100644 --- a/client/src/views/note/fields/users.js +++ b/client/src/views/note/fields/users.js @@ -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']; } diff --git a/client/src/views/stream/record/edit.js b/client/src/views/stream/record/edit.js index 511e58f927..77578880ce 100644 --- a/client/src/views/stream/record/edit.js +++ b/client/src/views/stream/record/edit.js @@ -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) && diff --git a/client/src/views/user/record/panels/stream.js b/client/src/views/user/record/panels/stream.js index 732fa4188d..c1759f6276 100644 --- a/client/src/views/user/record/panels/stream.js +++ b/client/src/views/user/record/panels/stream.js @@ -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'); } }); } diff --git a/upgrades/7.6/scripts/AfterUpgrade.php b/upgrades/7.6/scripts/AfterUpgrade.php new file mode 100644 index 0000000000..acdf5015b2 --- /dev/null +++ b/upgrades/7.6/scripts/AfterUpgrade.php @@ -0,0 +1,54 @@ +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); + } +}