From 926e243aa3d0b0a56ea0d7f9bf5d264a762bf5da Mon Sep 17 00:00:00 2001 From: yuri Date: Mon, 1 Feb 2016 17:36:53 +0200 Subject: [PATCH] Notification remove --- application/Espo/Acl/Notification.php | 45 ++++++++++++++++++ application/Espo/AclPortal/Notification.php | 45 ++++++++++++++++++ application/Espo/Controllers/Note.php | 2 +- application/Espo/Controllers/Notification.php | 27 ++++++++++- .../Espo/Resources/metadata/app/acl.json | 6 +++ .../Resources/metadata/app/aclPortal.json | 6 +++ application/Espo/Services/Notification.php | 9 +--- application/Espo/Services/Stream.php | 2 +- .../notification/fields/read-with-menu.tpl | 13 +++++ .../notification/fields/read-with-menu.js | 47 +++++++++++++++++++ .../client/src/views/notification/list.js | 2 +- frontend/client/src/views/record/list.js | 2 +- 12 files changed, 193 insertions(+), 13 deletions(-) create mode 100644 application/Espo/Acl/Notification.php create mode 100644 application/Espo/AclPortal/Notification.php create mode 100644 frontend/client/res/templates/notification/fields/read-with-menu.tpl create mode 100644 frontend/client/src/views/notification/fields/read-with-menu.js diff --git a/application/Espo/Acl/Notification.php b/application/Espo/Acl/Notification.php new file mode 100644 index 0000000000..47261e7b88 --- /dev/null +++ b/application/Espo/Acl/Notification.php @@ -0,0 +1,45 @@ +id === $entity->get('userId')) { + return true; + } + return false; + } +} + diff --git a/application/Espo/AclPortal/Notification.php b/application/Espo/AclPortal/Notification.php new file mode 100644 index 0000000000..385faec4c7 --- /dev/null +++ b/application/Espo/AclPortal/Notification.php @@ -0,0 +1,45 @@ +id === $entity->get('userId')) { + return true; + } + return false; + } +} + diff --git a/application/Espo/Controllers/Note.php b/application/Espo/Controllers/Note.php index d19f0d1cc7..88883839b9 100644 --- a/application/Espo/Controllers/Note.php +++ b/application/Espo/Controllers/Note.php @@ -25,7 +25,7 @@ * * 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. - ************************************************************************/ + ************************************************************************/ namespace Espo\Controllers; diff --git a/application/Espo/Controllers/Notification.php b/application/Espo/Controllers/Notification.php index 9ec5c1f3f4..b37726e03f 100644 --- a/application/Espo/Controllers/Notification.php +++ b/application/Espo/Controllers/Notification.php @@ -31,7 +31,7 @@ namespace Espo\Controllers; use \Espo\Core\Exceptions\Error; -class Notification extends \Espo\Core\Controllers\Base +class Notification extends \Espo\Core\Controllers\Record { public static $defaultAction = 'list'; @@ -71,5 +71,30 @@ class Notification extends \Espo\Core\Controllers\Base $userId = $this->getUser()->id; return $this->getService('Notification')->markAllRead($userId); } + + public function actionExport($params, $data, $request) + { + throw new Error(); + } + + public function actionMassUpdate($params, $data, $request) + { + throw new Error(); + } + + public function actionCreateLink($params, $data, $request) + { + throw new Error(); + } + + public function actionRemoveLink($params, $data, $request) + { + throw new Error(); + } + + public function actionMerge($params, $data, $request) + { + throw new Error(); + } } diff --git a/application/Espo/Resources/metadata/app/acl.json b/application/Espo/Resources/metadata/app/acl.json index 3f167d0894..3dc7867d1b 100644 --- a/application/Espo/Resources/metadata/app/acl.json +++ b/application/Espo/Resources/metadata/app/acl.json @@ -50,6 +50,12 @@ "delete": "no", "create": "no" }, + "Notification": { + "read": "own", + "edit": "no", + "delete": "own", + "create": "no" + }, "Role": false, "PortalRole": false }, diff --git a/application/Espo/Resources/metadata/app/aclPortal.json b/application/Espo/Resources/metadata/app/aclPortal.json index 252a253355..7ca873b030 100644 --- a/application/Espo/Resources/metadata/app/aclPortal.json +++ b/application/Espo/Resources/metadata/app/aclPortal.json @@ -15,6 +15,12 @@ "delete": "own", "create": "yes" }, + "Notification": { + "read": "own", + "edit": "no", + "delete": "own", + "create": "no" + }, "Portal": false, "Attachment": { "read": "own", diff --git a/application/Espo/Services/Notification.php b/application/Espo/Services/Notification.php index f91b87d9e8..e8371eb010 100644 --- a/application/Espo/Services/Notification.php +++ b/application/Espo/Services/Notification.php @@ -36,15 +36,8 @@ use Espo\ORM\Entity; use Espo\Core\Utils\Json; -class Notification extends \Espo\Core\Services\Base +class Notification extends \Espo\Services\Record { - protected $dependencies = array( - 'entityManager', - 'user', - 'metadata', - 'aclManager' - ); - protected function getEntityManager() { return $this->injections['entityManager']; diff --git a/application/Espo/Services/Stream.php b/application/Espo/Services/Stream.php index ce86181ea2..c7047f5856 100644 --- a/application/Espo/Services/Stream.php +++ b/application/Espo/Services/Stream.php @@ -50,7 +50,7 @@ class Stream extends \Espo\Core\Services\Base 'container', ); - protected $emailsWithContentEntityList = array('Case'); + protected $emailsWithContentEntityList = ['Case']; protected $auditedFieldsCache = array(); diff --git a/frontend/client/res/templates/notification/fields/read-with-menu.tpl b/frontend/client/res/templates/notification/fields/read-with-menu.tpl new file mode 100644 index 0000000000..a287ed4673 --- /dev/null +++ b/frontend/client/res/templates/notification/fields/read-with-menu.tpl @@ -0,0 +1,13 @@ +
+
+ + +
+
+{{#unless isRead}} + +{{/unless}} diff --git a/frontend/client/src/views/notification/fields/read-with-menu.js b/frontend/client/src/views/notification/fields/read-with-menu.js new file mode 100644 index 0000000000..a7778163ae --- /dev/null +++ b/frontend/client/src/views/notification/fields/read-with-menu.js @@ -0,0 +1,47 @@ +/************************************************************************ + * 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/notification/fields/read-with-menu', 'views/fields/base', function (Dep) { + + return Dep.extend({ + + type: 'read', + + listTemplate: 'notification/fields/read-with-menu', + + detailTemplate: 'notification/fields/read-with-menu', + + data: function () { + return { + isRead: this.model.get('read') + }; + }, + + }); +}); + diff --git a/frontend/client/src/views/notification/list.js b/frontend/client/src/views/notification/list.js index 4ce087e10a..82ba3d091a 100644 --- a/frontend/client/src/views/notification/list.js +++ b/frontend/client/src/views/notification/list.js @@ -76,7 +76,7 @@ Espo.define('views/notification/list', 'view', function (Dep) { ], right: { name: 'read', - view: 'views/notification/fields/read', + view: 'views/notification/fields/read-with-menu', width: '10px' } } diff --git a/frontend/client/src/views/record/list.js b/frontend/client/src/views/record/list.js index 3c68da449b..1449fe6917 100644 --- a/frontend/client/src/views/record/list.js +++ b/frontend/client/src/views/record/list.js @@ -1024,7 +1024,7 @@ Espo.define('views/record/list', 'view', function (Dep) { if (!id) return; var model = this.collection.get(id); - if (!this.getAcl().checkModel(model, 'delete')) { + if (!this.getAcl().checkScope(this.scope, 'delete')) { this.notify('Access denied', 'error'); return false; }