diff --git a/application/Espo/Entities/User.php b/application/Espo/Entities/User.php index 5eae30659b..bad4f58ef4 100644 --- a/application/Espo/Entities/User.php +++ b/application/Espo/Entities/User.php @@ -36,11 +36,21 @@ class User extends \Espo\Core\Entities\Person return $this->get('isAdmin'); } + public function isSystem() + { + return $this->id === 'system'; + } + public function isActive() { return $this->get('isActive'); } + public function isPortal() + { + return $this->isPortalUser(); + } + public function isPortalUser() { return $this->get('isPortalUser'); diff --git a/application/Espo/Hooks/Common/Stream.php b/application/Espo/Hooks/Common/Stream.php index 39aed27732..c6dcb862bf 100644 --- a/application/Espo/Hooks/Common/Stream.php +++ b/application/Espo/Hooks/Common/Stream.php @@ -56,6 +56,11 @@ class Stream extends \Espo\Core\Hooks\Base return $this->getInjection('serviceFactory'); } + protected function getPreferences() + { + return $this->getInjection('container')->get('preferences'); + } + protected function checkHasStream(Entity $entity) { $entityType = $entity->getEntityType(); @@ -185,9 +190,23 @@ class Stream extends \Espo\Core\Hooks\Base $createdById = $entity->get('createdById'); if ( - ($this->getConfig()->get('followCreatedEntities') || $this->getUser()->get('isPortalUser')) + !$this->getUser()->isSystem() && - !empty($createdById) + $createdById + && + $createdById === $this->getUser()->id + && + ( + $this->getUser()->isPortalUser() + || + $this->getPreferences()->get('followCreatedEntities') + || + ( + is_array($this->getPreferences()->get('followCreatedEntityTypeList')) + && + in_array($entityType, $this->getPreferences()->get('followCreatedEntityTypeList')) + ) + ) ) { $userIdList[] = $createdById; } diff --git a/application/Espo/Repositories/Preferences.php b/application/Espo/Repositories/Preferences.php index 2a5c0997e0..ff0d1d34f3 100644 --- a/application/Espo/Repositories/Preferences.php +++ b/application/Espo/Repositories/Preferences.php @@ -34,11 +34,12 @@ use Espo\Core\Utils\Json; class Preferences extends \Espo\Core\ORM\Repository { - protected $defaultAttributeListFromSettings = array( + protected $defaultAttributeListFromSettings = [ 'decimalMark', 'thousandSeparator', - 'exportDelimiter' - ); + 'exportDelimiter', + 'followCreatedEntities' + ]; protected $data = array(); diff --git a/application/Espo/Resources/i18n/de_DE/Preferences.json b/application/Espo/Resources/i18n/de_DE/Preferences.json index 2f43c877ad..fd13916561 100644 --- a/application/Espo/Resources/i18n/de_DE/Preferences.json +++ b/application/Espo/Resources/i18n/de_DE/Preferences.json @@ -31,7 +31,8 @@ "emailReplyToAllByDefault": "Standardmäßig Allen antworten", "dashboardLayout": "Dashboard Layout", "emailReplyForceHtml": "E-Mail Antwort als HTML", - "doNotFillAssignedUserIfNotRequired": "Zugwiesenen Benutzer nicht ausfüllen wenn optional" + "doNotFillAssignedUserIfNotRequired": "Zugwiesenen Benutzer nicht ausfüllen wenn optional", + "followCreatedEntities": "Eigene Einträge abonnieren" }, "options": { "weekStart": { diff --git a/application/Espo/Resources/i18n/en_US/Preferences.json b/application/Espo/Resources/i18n/en_US/Preferences.json index d68a28a9c4..7c61201c04 100644 --- a/application/Espo/Resources/i18n/en_US/Preferences.json +++ b/application/Espo/Resources/i18n/en_US/Preferences.json @@ -21,18 +21,20 @@ "receiveAssignmentEmailNotifications": "Email notifications upon assignment", "receiveMentionEmailNotifications": "Email notifications about mentions in posts", "receiveStreamEmailNotifications": "Email notifications about posts and status updates", - "autoFollowEntityTypeList": "Auto-Follow", + "autoFollowEntityTypeList": "Global Auto-Follow", "signature": "Email Signature", "dashboardTabList": "Tab List", "defaultReminders": "Default Reminders", "theme": "Theme", "useCustomTabList": "Custom Tab List", "tabList": "Tab List", - "emailReplyToAllByDefault": "Email Reply to All by Default", + "emailReplyToAllByDefault": "Email Reply to all by default", "dashboardLayout": "Dashboard Layout", "emailReplyForceHtml": "Email Reply in HTML", - "doNotFillAssignedUserIfNotRequired": "Do not fill Assigned User if not required", - "followEntityOnStreamPost": "Auto-follow entity after posting in Stream" + "doNotFillAssignedUserIfNotRequired": "Do not pre-fill assigned user on record creation", + "followEntityOnStreamPost": "Auto-follow record after posting in Stream", + "followCreatedEntities": "Auto-follow created records", + "followCreatedEntityTypeList": "Auto-follow created records of specific entity types" }, "links": { }, @@ -50,6 +52,9 @@ "Locale": "Locale" }, "tooltips": { - "autoFollowEntityTypeList": "User will automatically follow all new records of the selected entity types, will see information in the stream and receive notifications." + "autoFollowEntityTypeList": "Automatically follow ALL new records (created by any user) of the selected entity types. To be able to see information in the stream and receive notifications about all records in the system.", + "doNotFillAssignedUserIfNotRequired": "When create record assigned user won't be filled with own user unless the field is required.", + "followCreatedEntities": "When create new records they will be automatically followed even if assigned to another user.", + "followCreatedEntityTypeList": "When create new records of selected entity types they will be followed automatically even if assigned to another user." } } diff --git a/application/Espo/Resources/i18n/en_US/Settings.json b/application/Espo/Resources/i18n/en_US/Settings.json index 95bbf753e5..7e3335ca3e 100644 --- a/application/Espo/Resources/i18n/en_US/Settings.json +++ b/application/Espo/Resources/i18n/en_US/Settings.json @@ -63,7 +63,7 @@ "streamEmailNotificationsEntityList": "Stream email notifications scopes", "b2cMode": "B2C Mode", "avatarsDisabled": "Disable Avatars", - "followCreatedEntities": "Follow Created Entities", + "followCreatedEntities": "Follow created records", "displayListViewRecordCount": "Display Total Count (on List View)", "theme": "Theme", "userThemesDisabled": "Disable User Themes", diff --git a/application/Espo/Resources/layouts/Preferences/detail.json b/application/Espo/Resources/layouts/Preferences/detail.json index da8e45b3ca..c292fbe0c3 100644 --- a/application/Espo/Resources/layouts/Preferences/detail.json +++ b/application/Espo/Resources/layouts/Preferences/detail.json @@ -59,6 +59,18 @@ { "name": "followEntityOnStreamPost" } + ], + [ + false, + { + "name": "followCreatedEntities" + } + ], + [ + false, + { + "name": "followCreatedEntityTypeList" + } ] ] }, diff --git a/application/Espo/Resources/metadata/app/aclPortal.json b/application/Espo/Resources/metadata/app/aclPortal.json index 08e0edb680..c4319e9bcb 100644 --- a/application/Espo/Resources/metadata/app/aclPortal.json +++ b/application/Espo/Resources/metadata/app/aclPortal.json @@ -60,7 +60,10 @@ "autoFollowEntityTypeList": false, "emailReplyForceHtml": false, "emailReplyToAllByDefault": false, - "signature": false + "signature": false, + "followCreatedEntities": false, + "followEntityOnStreamPost": false, + "doNotFillAssignedUserIfNotRequired": false }, "Call": { "reminders": false diff --git a/application/Espo/Resources/metadata/entityDefs/Preferences.json b/application/Espo/Resources/metadata/entityDefs/Preferences.json index aa5a236542..d1cafa0bfb 100644 --- a/application/Espo/Resources/metadata/entityDefs/Preferences.json +++ b/application/Espo/Resources/metadata/entityDefs/Preferences.json @@ -150,11 +150,22 @@ "notStorable": true }, "doNotFillAssignedUserIfNotRequired": { - "type": "bool" + "type": "bool", + "tooltip": true }, "followEntityOnStreamPost": { "type": "bool", "default": true + }, + "followCreatedEntities": { + "type": "bool", + "tooltip": true + }, + "followCreatedEntityTypeList": { + "type": "multiEnum", + "view": "views/preferences/fields/auto-follow-entity-type-list", + "translation": "Global.scopeNamesPlural", + "tooltip": true } } } diff --git a/client/src/views/preferences/record/edit.js b/client/src/views/preferences/record/edit.js index 028ade0ec8..a34df1126d 100644 --- a/client/src/views/preferences/record/edit.js +++ b/client/src/views/preferences/record/edit.js @@ -100,6 +100,8 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep) this.hideField('dashboardLayout'); } + this.controlFollowCreatedEntityListVisibility(); + this.listenTo(this.model, 'change:followCreatedEntities', this.controlFollowCreatedEntityListVisibility); var hideNotificationPanel = true; if (!this.getConfig().get('assignmentEmailNotifications') || this.model.get('isPortalUser')) { @@ -153,6 +155,14 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep) }, this); }, + controlFollowCreatedEntityListVisibility: function () { + if (!this.model.get('followCreatedEntities')) { + this.showField('followCreatedEntityTypeList'); + } else { + this.hideField('followCreatedEntityTypeList'); + } + }, + actionReset: function () { this.confirm(this.translate('resetPreferencesConfirmation', 'messages'), function () { $.ajax({