stream notifications
This commit is contained in:
@@ -316,6 +316,11 @@ class Config
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getSiteUrl()
|
||||
{
|
||||
return rtrim($this->get('siteUrl'), '/');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -100,6 +100,8 @@ return array (
|
||||
'assignmentEmailNotifications' => false,
|
||||
'assignmentEmailNotificationsEntityList' => ['Lead', 'Opportunity', 'Task', 'Case'],
|
||||
'assignmentNotificationsEntityList' => ['Meeting', 'Call', 'Task', 'Email'],
|
||||
"portalStreamEmailNotifications" => true,
|
||||
'streamEmailNotificationsEntityList' => ['Case'],
|
||||
'emailMessageMaxSize' => 10,
|
||||
'notificationsCheckInterval' => 10,
|
||||
'disabledCountQueryEntityList' => ['Email'],
|
||||
|
||||
@@ -18,8 +18,9 @@
|
||||
"smtpPassword": "Password",
|
||||
"smtpEmailAddress": "Email Address",
|
||||
"exportDelimiter": "Export Delimiter",
|
||||
"receiveAssignmentEmailNotifications": "Receive email notifications upon assignment",
|
||||
"receiveMentionEmailNotifications": "Receive email notifications about mentions in posts",
|
||||
"receiveAssignmentEmailNotifications": "Email notifications upon assignment",
|
||||
"receiveMentionEmailNotifications": "Email notifications about mentions in posts",
|
||||
"receiveStreamEmailNotifications": "Email notifications about posts and status updates",
|
||||
"autoFollowEntityTypeList": "Auto-Follow",
|
||||
"signature": "Email Signature",
|
||||
"dashboardTabList": "Tab List",
|
||||
|
||||
@@ -47,8 +47,11 @@
|
||||
"ldapOptReferrals": "Opt Referrals",
|
||||
"exportDisabled": "Disable Export (only admin is allowed)",
|
||||
"assignmentNotificationsEntityList": "Entities to notify about upon assignment",
|
||||
"assignmentEmailNotifications": "Send email notifications upon assignment",
|
||||
"assignmentEmailNotificationsEntityList": "Entities to notify about with email upon assignment",
|
||||
"assignmentEmailNotifications": "Notifications upon assignment",
|
||||
"assignmentEmailNotificationsEntityList": "Assignment email notifications scopes",
|
||||
"streamEmailNotifications": "Notifications about updates in Stream for internal users",
|
||||
"portalStreamEmailNotifications": "Notifications about updates in Stream for portal users",
|
||||
"streamEmailNotificationsEntityList": "Stream email notifications scopes",
|
||||
"b2cMode": "B2C Mode",
|
||||
"avatarsDisabled": "Disable Avatars",
|
||||
"followCreatedEntities": "Follow Created Entities",
|
||||
|
||||
@@ -78,7 +78,8 @@
|
||||
"label": "Notifications",
|
||||
"name": "notifications",
|
||||
"rows": [
|
||||
[{"name": "receiveAssignmentEmailNotifications"}, {"name": "receiveMentionEmailNotifications"}]
|
||||
[{"name": "receiveAssignmentEmailNotifications"}, {"name": "receiveMentionEmailNotifications"}],
|
||||
[{"name": "receiveStreamEmailNotifications"}, false]
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
"label": "Email Notifications",
|
||||
"rows": [
|
||||
[{"name": "assignmentEmailNotifications"}, {"name": "mentionEmailNotifications"}],
|
||||
[{"name": "assignmentEmailNotificationsEntityList"}]
|
||||
[{"name": "assignmentEmailNotificationsEntityList"}],
|
||||
[{"name": "streamEmailNotifications"}, {"name": "portalStreamEmailNotifications"}],
|
||||
[{"name": "streamEmailNotificationsEntityList"}]
|
||||
]
|
||||
}
|
||||
]
|
||||
@@ -102,6 +102,10 @@
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"receiveStreamEmailNotifications": {
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"autoFollowEntityTypeList": {
|
||||
"type": "multiEnum",
|
||||
"view": "views/preferences/fields/auto-follow-entity-type-list",
|
||||
|
||||
@@ -235,6 +235,19 @@
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"streamEmailNotifications": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
},
|
||||
"portalStreamEmailNotifications": {
|
||||
"type": "bool",
|
||||
"default": true
|
||||
},
|
||||
"streamEmailNotificationsEntityList": {
|
||||
"type": "multiEnum",
|
||||
"translation": "Global.scopeNamesPlural",
|
||||
"view": "views/settings/fields/stream-email-notifications-entity-list"
|
||||
},
|
||||
"b2cMode": {
|
||||
"type": "bool",
|
||||
"default": false
|
||||
|
||||
@@ -1 +1 @@
|
||||
{{entityType}}: {{name}}
|
||||
Assigned to you: [{{{entityType}}}] {{{name}}}
|
||||
@@ -0,0 +1,3 @@
|
||||
<p>{{userName}} posted on {{entityTypeLowerFirst}} {{parentName}}.</p>
|
||||
<p>{{{post}}}</p>
|
||||
<p><a href="{{url}}">View</a></p>
|
||||
@@ -0,0 +1 @@
|
||||
Post: [{{{entityType}}}] {{{name}}}
|
||||
@@ -0,0 +1,2 @@
|
||||
<p>{{userName}} changed {{{fieldTranslatedLowerCase}}} of {{entityTypeLowerFirst}} '{{name}}' to {{valueTranslated}}.</p>
|
||||
<p><a href="{{url}}">View</a></p>
|
||||
@@ -0,0 +1 @@
|
||||
{{{valueTranslated}}}: [{{{entityType}}}] {{{name}}}
|
||||
@@ -46,10 +46,13 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
'language',
|
||||
'dateTime',
|
||||
'number',
|
||||
'fileManager'
|
||||
'fileManager',
|
||||
'selectManagerFactory'
|
||||
]);
|
||||
}
|
||||
|
||||
protected $noteNotificationTypeList = ['Post', 'Status'];
|
||||
|
||||
protected function getMailSender()
|
||||
{
|
||||
return $this->getInjection('mailSender');
|
||||
@@ -185,16 +188,19 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
protected function getMentionTemplate($name)
|
||||
protected function getTemplate($type, $name, $entityType = null)
|
||||
{
|
||||
$fileName = $this->getMentionTemplateFileName($name);
|
||||
if ($entityType) {
|
||||
$fileName = $this->getEntityTemplateFileName($entityType, $type, $name);
|
||||
} else {
|
||||
$fileName = $this->getTemplateFileName($type, $name);
|
||||
}
|
||||
return file_get_contents($fileName);
|
||||
}
|
||||
|
||||
protected function getMentionTemplateFileName($name)
|
||||
protected function getTemplateFileName($type, $name)
|
||||
{
|
||||
$language = $this->getConfig()->get('language');
|
||||
$type = 'mention';
|
||||
|
||||
$fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
@@ -211,6 +217,48 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
protected function getEntityTemplateFileName($entityType, $type, $name)
|
||||
{
|
||||
$language = $this->getConfig()->get('language');
|
||||
$moduleName = $this->getMetadata()->getScopeModuleName($entityType);
|
||||
|
||||
$fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
if ($moduleName) {
|
||||
$fileName = "application/Espo/Modules/{$moduleName}/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
}
|
||||
|
||||
$fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
$fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
$fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
$language = 'en_US';
|
||||
|
||||
$fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
if ($moduleName) {
|
||||
$fileName = "application/Espo/Modules/{$moduleName}/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
}
|
||||
|
||||
$fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$entityType}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
$fileName = "custom/Espo/Custom/Resources/templates/{$type}/{$language}/{$name}.tpl";
|
||||
if (file_exists($fileName)) return $fileName;
|
||||
|
||||
$fileName = "application/Espo/Resources/templates/{$type}/{$language}/{$name}.tpl";
|
||||
return $fileName;
|
||||
}
|
||||
|
||||
public function process()
|
||||
{
|
||||
$dateTime = new \DateTime();
|
||||
@@ -218,22 +266,38 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
|
||||
$mentionEmailNotifications = $this->getConfig()->get('mentionEmailNotifications');
|
||||
|
||||
$streamEmailNotifications = $this->getConfig()->get('streamEmailNotifications');
|
||||
$portalStreamEmailNotifications = $this->getConfig()->get('portalStreamEmailNotifications');
|
||||
|
||||
$typeList = [];
|
||||
if ($mentionEmailNotifications) {
|
||||
$typeList[] = 'MentionInPost';
|
||||
}
|
||||
|
||||
if (!$mentionEmailNotifications) return;
|
||||
if ($streamEmailNotifications || $portalStreamEmailNotifications) {
|
||||
$typeList[] = 'Note';
|
||||
}
|
||||
|
||||
if (empty($typeList)) return;
|
||||
|
||||
$where = array(
|
||||
'createdAt' > $dateTime,
|
||||
'createdAt>' => $dateTime->format('Y-m-d H:i:s'),
|
||||
'read' => false,
|
||||
'emailIsProcessed' => false
|
||||
);
|
||||
|
||||
$where['type'] = $typeList;
|
||||
$sqlArr = [];
|
||||
foreach ($typeList as $type) {
|
||||
$methodName = 'getNotificationSelectParams' . $type;
|
||||
$selectParams = $this->$methodName();
|
||||
$selectParams['whereClause'][] = $where;
|
||||
|
||||
$notificationList = $this->getEntityManager()->getRepository('Notification')->where($where)->order('createdAt')->find();
|
||||
$sqlArr[] = $this->getEntityManager()->getQuery()->createSelectQuery('Notification', $selectParams);
|
||||
}
|
||||
|
||||
$sql = '' . implode(' UNION ', $sqlArr) . ' ORDER BY number';
|
||||
|
||||
$notificationList = $this->getEntityManager()->getRepository('Notification')->findByQuery($sql);
|
||||
|
||||
foreach ($notificationList as $notification) {
|
||||
$notification->set('emailIsProcessed', true);
|
||||
@@ -249,14 +313,57 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
}
|
||||
}
|
||||
|
||||
public function processNotificationMentionInPost(Entity $notification)
|
||||
protected function getNotificationSelectParamsMentionInPost()
|
||||
{
|
||||
$userId = $notification->get('userId');
|
||||
$selectManager = $this->getInjection('selectManagerFactory')->create('Notification');
|
||||
|
||||
$selectParams = $selectManager->getEmptySelectParams();
|
||||
|
||||
$selectParams['whereClause']['type'] = 'MentionInPost';
|
||||
|
||||
return $selectParams;
|
||||
}
|
||||
|
||||
protected function getNotificationSelectParamsNote()
|
||||
{
|
||||
$selectManager = $this->getInjection('selectManagerFactory')->create('Notification');
|
||||
|
||||
$selectParams = $selectManager->getEmptySelectParams();
|
||||
|
||||
$selectParams['whereClause']['type'] = 'Note';
|
||||
$selectParams['whereClause']['relatedType'] = 'Note';
|
||||
|
||||
$selectParams['customJoin'] .= ' JOIN note ON notification.related_id = note.id';
|
||||
|
||||
$selectParams['whereClause']['note.type'] = $this->noteNotificationTypeList;
|
||||
|
||||
$entityList = $this->getConfig()->get('streamEmailNotificationsEntityList');
|
||||
|
||||
if (empty($entityList)) {
|
||||
$selectParams['whereClause']['relatedParentType'] = null;
|
||||
} else {
|
||||
$selectParams['whereClause']['relatedParentType'] = $entityList;
|
||||
}
|
||||
|
||||
$forInternal = $this->getConfig()->get('streamEmailNotifications');
|
||||
$forPortal = $this->getConfig()->get('portalStreamEmailNotifications');
|
||||
|
||||
if ($forInternal && !$forPortal) {
|
||||
$selectParams['whereClause']['user.isPortalUser'] = false;
|
||||
} else if (!$forInternal && $forPortal) {
|
||||
$selectParams['whereClause']['user.isPortalUser'] = true;
|
||||
}
|
||||
|
||||
return $selectParams;
|
||||
}
|
||||
|
||||
protected function processNotificationMentionInPost(Entity $notification)
|
||||
{
|
||||
if (!$notification->get('userId')) return;
|
||||
$userId = $notification->get('userId');
|
||||
$user = $this->getEntityManager()->getEntity('User', $userId);
|
||||
|
||||
$emailAddress = $user->get('emailAddress');
|
||||
|
||||
if (!$emailAddress) return;
|
||||
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $userId);
|
||||
@@ -278,20 +385,20 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!$parent) return;
|
||||
|
||||
$data['url'] = rtrim($this->getConfig()->get('siteUrl'), '/') . '/#' . $parentType . '/' . $parentId;
|
||||
$data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId;
|
||||
$data['parentName'] = $parent->get('name');
|
||||
$data['parentType'] = $parentType;
|
||||
$data['parentId'] = $parentId;
|
||||
} else {
|
||||
$data['url'] = rtrim($this->getConfig()->get('siteUrl'), '/') . '/#Notification';
|
||||
$data['url'] = $this->getConfig()->getSiteUrl() . '/#Notification';
|
||||
}
|
||||
|
||||
$data['userName'] = $note->get('createdByName');
|
||||
|
||||
$data['post'] = $note->get('post');
|
||||
|
||||
$subjectTpl = $this->getMentionTemplate('subject');
|
||||
$bodyTpl = $this->getMentionTemplate('body');
|
||||
$subjectTpl = $this->getTemplate('mention', 'subject');
|
||||
$bodyTpl = $this->getTemplate('mention', 'body');
|
||||
$subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl);
|
||||
|
||||
$subject = $this->getHtmlizer()->render($note, $subjectTpl, 'mention-email-subject', $data, true);
|
||||
@@ -312,4 +419,145 @@ class EmailNotification extends \Espo\Core\Services\Base
|
||||
$GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function processNotificationNote(Entity $notification)
|
||||
{
|
||||
if ($notification->get('relatedType') !== 'Note') return;
|
||||
if (!$notification->get('relatedId')) return;
|
||||
|
||||
$note = $this->getEntityManager()->getEntity('Note', $notification->get('relatedId'));
|
||||
if (!$note) return;
|
||||
if (!in_array($note->get('type'), $this->noteNotificationTypeList)) return;
|
||||
|
||||
if (!$notification->get('userId')) return;
|
||||
$userId = $notification->get('userId');
|
||||
$user = $this->getEntityManager()->getEntity('User', $userId);
|
||||
|
||||
$emailAddress = $user->get('emailAddress');
|
||||
if (!$emailAddress) return;
|
||||
|
||||
$preferences = $this->getEntityManager()->getEntity('Preferences', $userId);
|
||||
if (!$preferences) return;
|
||||
if (!$preferences->get('receiveStreamEmailNotifications')) return;
|
||||
|
||||
$methodName = 'processNotificationNote' . $note->get('type');
|
||||
|
||||
if (!method_exists($this, $methodName)) return;
|
||||
|
||||
$this->$methodName($note, $user);
|
||||
}
|
||||
|
||||
protected function processNotificationNotePost($note, $user)
|
||||
{
|
||||
$post = $note->get('post');
|
||||
$parentId = $note->get('parentId');
|
||||
$parentType = $note->get('parentType');
|
||||
|
||||
$emailAddress = $user->get('emailAddress');
|
||||
if (!$emailAddress) return;
|
||||
|
||||
$data = array();
|
||||
|
||||
if (!$parentId || !$parentType) return;
|
||||
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!$parent) return;
|
||||
|
||||
$data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId;
|
||||
$data['parentName'] = $parent->get('name');
|
||||
$data['parentType'] = $parentType;
|
||||
$data['parentId'] = $parentId;
|
||||
|
||||
$data['name'] = $data['parentName'];
|
||||
|
||||
$data['entityType'] = $this->getLanguage()->translate($data['parentType'], 'scopeNames');
|
||||
$data['entityTypeLowerFirst'] = lcfirst($data['entityType']);
|
||||
|
||||
$data['userName'] = $note->get('createdByName');
|
||||
|
||||
$data['post'] = $note->get('post');
|
||||
|
||||
$subjectTpl = $this->getTemplate('notePost', 'subject', $parentType);
|
||||
$bodyTpl = $this->getTemplate('notePost', 'body', $parentType);
|
||||
$subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl);
|
||||
|
||||
$subject = $this->getHtmlizer()->render($note, $subjectTpl, 'note-post-email-subject', $data, true);
|
||||
$body = $this->getHtmlizer()->render($note, $bodyTpl, 'note-post-email-body', $data, true);
|
||||
|
||||
$email = $this->getEntityManager()->getEntity('Email');
|
||||
|
||||
$email->set(array(
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
'isHtml' => true,
|
||||
'to' => $emailAddress,
|
||||
'isSystem' => true
|
||||
));
|
||||
try {
|
||||
$this->getMailSender()->send($email);
|
||||
} catch (\Exception $e) {
|
||||
$GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
protected function processNotificationNoteStatus($note, $user)
|
||||
{
|
||||
$post = $note->get('post');
|
||||
$parentId = $note->get('parentId');
|
||||
$parentType = $note->get('parentType');
|
||||
|
||||
$emailAddress = $user->get('emailAddress');
|
||||
if (!$emailAddress) return;
|
||||
|
||||
$data = array();
|
||||
|
||||
if (!$parentId || !$parentType) return;
|
||||
|
||||
$parent = $this->getEntityManager()->getEntity($parentType, $parentId);
|
||||
if (!$parent) return;
|
||||
|
||||
$data['url'] = $this->getConfig()->getSiteUrl() . '/#' . $parentType . '/view/' . $parentId;
|
||||
$data['parentName'] = $parent->get('name');
|
||||
$data['parentType'] = $parentType;
|
||||
$data['parentId'] = $parentId;
|
||||
|
||||
$data['name'] = $data['parentName'];
|
||||
|
||||
$data['entityType'] = $this->getLanguage()->translate($data['parentType'], 'scopeNames');
|
||||
$data['entityTypeLowerFirst'] = lcfirst($data['entityType']);
|
||||
|
||||
$noteData = $note->get('data');
|
||||
if (empty($noteData)) return;
|
||||
|
||||
|
||||
$data['value'] = $noteData->value;
|
||||
$data['field'] = $noteData->field;
|
||||
$data['valueTranslated'] = $this->getLanguage()->translateOption($data['value'], $data['field'], $parentType);
|
||||
$data['fieldTranslated'] = $this->getLanguage()->translate($data['field'], 'fields', $parentType);
|
||||
$data['fieldTranslatedLowerCase'] = lcfirst($data['fieldTranslated']);
|
||||
|
||||
$data['userName'] = $note->get('createdByName');
|
||||
|
||||
$subjectTpl = $this->getTemplate('noteStatus', 'subject', $parentType);
|
||||
$bodyTpl = $this->getTemplate('noteStatus', 'body', $parentType);
|
||||
$subjectTpl = str_replace(array("\n", "\r"), '', $subjectTpl);
|
||||
|
||||
$subject = $this->getHtmlizer()->render($note, $subjectTpl, 'note-status-email-subject', $data, true);
|
||||
$body = $this->getHtmlizer()->render($note, $bodyTpl, 'note-status-email-body', $data, true);
|
||||
|
||||
$email = $this->getEntityManager()->getEntity('Email');
|
||||
|
||||
$email->set(array(
|
||||
'subject' => $subject,
|
||||
'body' => $body,
|
||||
'isHtml' => true,
|
||||
'to' => $emailAddress,
|
||||
'isSystem' => true
|
||||
));
|
||||
try {
|
||||
$this->getMailSender()->send($email);
|
||||
} catch (\Exception $e) {
|
||||
$GLOBALS['log']->error('EmailNotification: [' . $e->getCode() . '] ' .$e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,21 @@ Espo.define('views/admin/notifications', 'views/settings/record/edit', function
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
this.controlStreamEmailNotificationsEntityList();
|
||||
this.listenTo(this.model, 'change', function (model) {
|
||||
if (model.hasChanged('streamEmailNotifications') || model.hasChanged('portalStreamEmailNotifications')) {
|
||||
this.controlStreamEmailNotificationsEntityList();
|
||||
}
|
||||
}, this);
|
||||
},
|
||||
|
||||
controlStreamEmailNotificationsEntityList: function () {
|
||||
if (this.model.get('streamEmailNotifications') || this.model.get('portalStreamEmailNotifications')) {
|
||||
this.showField('streamEmailNotificationsEntityList');
|
||||
} else {
|
||||
this.hideField('streamEmailNotificationsEntityList');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -50,7 +50,9 @@ Espo.define('views/fields/entity-type-list', 'views/fields/multi-enum', function
|
||||
},
|
||||
|
||||
setup: function () {
|
||||
this.params.translation = 'Global.scopeNames';
|
||||
if (!this.params.translation) {
|
||||
this.params.translation = 'Global.scopeNames';
|
||||
}
|
||||
this.setupOptions();
|
||||
Dep.prototype.setup.call(this);
|
||||
}
|
||||
|
||||
@@ -114,6 +114,14 @@ Espo.define('views/preferences/record/edit', 'views/record/edit', function (Dep)
|
||||
hideNotificationPanel = false;
|
||||
}
|
||||
|
||||
if (!this.getConfig().get('streamEmailNotifications') && !this.model.get('isPortalUser')) {
|
||||
this.hideField('receiveStreamEmailNotifications');
|
||||
} else if (!this.getConfig().get('portalStreamEmailNotifications') && this.model.get('isPortalUser')) {
|
||||
this.hideField('receiveStreamEmailNotifications');
|
||||
} else {
|
||||
hideNotificationPanel = false;
|
||||
}
|
||||
|
||||
if (hideNotificationPanel) {
|
||||
this.hidePanel('notifications');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/************************************************************************
|
||||
* 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('views/settings/fields/stream-email-notifications-entity-list', 'views/fields/entity-type-list', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
setupOptions: function () {
|
||||
|
||||
Dep.prototype.setupOptions.call(this);
|
||||
|
||||
this.params.options = this.params.options.filter(function (scope) {
|
||||
if (this.getMetadata().get('scopes.' + scope + '.disabled')) return;
|
||||
if (!this.getMetadata().get('scopes.' + scope + '.object')) return;
|
||||
if (!this.getMetadata().get('scopes.' + scope + '.stream')) return;
|
||||
return true;
|
||||
}, this)
|
||||
},
|
||||
|
||||
});
|
||||
});
|
||||
@@ -26,12 +26,12 @@
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) {
|
||||
Espo.define('views/settings/record/edit', 'views/record/edit', function (Dep) {
|
||||
|
||||
return Dep.extend({
|
||||
|
||||
sideView: null,
|
||||
|
||||
|
||||
layoutName: 'settings',
|
||||
|
||||
buttons: [
|
||||
@@ -45,10 +45,10 @@ Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) {
|
||||
label: 'Cancel',
|
||||
}
|
||||
],
|
||||
|
||||
|
||||
setup: function () {
|
||||
Dep.prototype.setup.call(this);
|
||||
|
||||
|
||||
this.listenTo(this.model, 'after:save', function () {
|
||||
this.getConfig().set(this.model.toJSON());
|
||||
this.getConfig().storeToCache();
|
||||
@@ -57,7 +57,7 @@ Espo.define('Views.Settings.Record.Edit', 'Views.Record.Edit', function (Dep) {
|
||||
|
||||
afterRender: function () {
|
||||
Dep.prototype.afterRender.call(this);
|
||||
|
||||
|
||||
var currencyListField = this.getFieldView('currencyList');
|
||||
var defaultCurrencyField = this.getFieldView('defaultCurrency');
|
||||
if (currencyListField && defaultCurrencyField) {
|
||||
|
||||
Reference in New Issue
Block a user