This commit is contained in:
yuri
2016-06-29 13:10:36 +03:00
parent ea5f6300f3
commit 935ba7d4e4
5 changed files with 39 additions and 12 deletions
+14
View File
@@ -207,6 +207,7 @@ class Table
$this->applyDefault($aclTable, $fieldTable);
$this->applyDisabled($aclTable, $fieldTable);
$this->applyMandatory($aclTable, $fieldTable);
$this->applyAdditional($aclTable, $fieldTable, $valuePermissionLists);
} else {
$aclTable = (object) [];
foreach ($this->getScopeList() as $scope) {
@@ -524,6 +525,19 @@ class Table
}
}
protected function applyAdditional(&$table, &$fieldTable, &$valuePermissionLists)
{
if ($this->getUser()->get('isPortalUser')) {
foreach ($this->getScopeList() as $scope) {
$table->$scope = false;
unset($fieldTable->$scope);
}
foreach ($this->valuePermissionList as $permission) {
$valuePermissionLists->{$permission}[] = 'no';
}
}
}
private function mergeValueList(array $list, $defaultValue)
{
$result = null;
@@ -127,5 +127,9 @@ class Table extends \Espo\Core\Acl\Table
}
}
}
protected function applyAdditional(&$table, &$fieldTable, &$valuePermissionLists)
{
}
}
@@ -118,8 +118,10 @@ class Preferences extends \Espo\Core\ORM\Repository
$entity->set($this->data[$id]);
$this->fetchAutoFollowEntityTypeList($entity);
$entity->setAsFetched($this->data[$id]);
$d = $entity->toArray();
@@ -152,8 +154,6 @@ class Preferences extends \Espo\Core\ORM\Repository
{
$id = $entity->id;
$isChanged = false;
$was = $entity->getFetched('autoFollowEntityTypeList');
$became = $entity->get('autoFollowEntityTypeList');
@@ -200,7 +200,10 @@ class Preferences extends \Espo\Core\ORM\Repository
$fileName = $this->getFilePath($entity->id);
$this->getFileManager()->putContents($fileName, Json::encode($data, \JSON_PRETTY_PRINT));
$this->storeAutoFollowEntityTypeList($entity);
$user = $this->getEntityManger()->getEntity('User', $entity->id);
if ($user && !$user->get('isPortalUser')) {
$this->storeAutoFollowEntityTypeList($entity);
}
return $entity;
}
@@ -53,7 +53,8 @@
"smtpPassword": false,
"smtpAuth": false,
"receiveAssignmentEmailNotifications": false,
"defaultReminders": false
"defaultReminders": false,
"autoFollowEntityTypeList": false
},
"Call": {
"reminders": false
+13 -8
View File
@@ -81,13 +81,13 @@ class Notification extends \Espo\Services\Record
$sql = "INSERT INTO `notification` (`id`, `data`, `type`, `user_id`, `created_at`, `related_id`, `related_type`, `related_parent_id`, `related_parent_type`) VALUES ";
$arr = [];
foreach ($userIdList as $userId) {
if (empty($userId)) continue;
$user = $this->getEntityManager()->getEntity('User');
$user->id = $userId;
$user->setIsNew(false);
$user->setAsFetched();
$userList = $this->getEntityManager()->getRepository('User')->where(array(
'isActive' => true,
'id' => $userIdList
))->find();
foreach ($userList as $user) {
$userId = $user->id;
if (!$this->checkUserNoteAccess($user, $note)) {
continue;
}
@@ -105,11 +105,16 @@ class Notification extends \Espo\Services\Record
public function checkUserNoteAccess(\Espo\Entities\User $user, \Espo\Entities\Note $note)
{
if (in_array($note->get('type'), ['EmailSent', 'EmailReceived'])) {
if (!$this->getAclManager()->checkScope($user, 'Email')) {
if ($user->get('isPortalUser')) {
if ($note->get('relatedType')) {
if ($note->get('relatedType') === 'Email' && $note->get('parentType') === 'Case') {
return true;
}
return false;
}
return true;
}
if ($note->get('relatedType')) {
if (!$this->getAclManager()->checkScope($user, $note->get('relatedType'))) {
return false;