Merge branch 'hotfix/5.5.5'

This commit is contained in:
yuri
2019-01-09 15:09:54 +02:00
9 changed files with 92 additions and 40 deletions
+5
View File
@@ -124,6 +124,11 @@ class Acl
return $this->getAclManager()->getScopeForbiddenFieldList($this->getUser(), $scope, $action, $thresholdLevel);
}
public function getScopeForbiddenLinkList($scope, $action = 'read', $thresholdLevel = 'no')
{
return $this->getAclManager()->getScopeForbiddenLinkList($this->getUser(), $scope, $action, $thresholdLevel);
}
public function checkUserPermission($target, $permissionType = 'userPermission')
{
return $this->getAclManager()->checkUserPermission($this->getUser(), $target, $permissionType);
+16
View File
@@ -309,6 +309,22 @@ class AclManager
return $list;
}
public function getScopeForbiddenLinkList(User $user, $scope, $action = 'read', $thresholdLevel = 'no')
{
$list = [];
if ($thresholdLevel === 'no') {
$list = array_merge(
$list,
$this->getScopeRestrictedLinkList($scope, $this->getGlobalRestrictionTypeList($user, $action))
);
$list = array_values($list);
}
return $list;
}
public function checkUserPermission(User $user, $target, $permissionType = 'userPermission')
{
$permission = $this->get($user, $permissionType);
@@ -101,6 +101,10 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base
$selectParams['groupBy'] = [$foreignLink . '.id'];
$selectParams['whereClause'][] = [
$foreignLink . '.id' => $entity->id
];
$entityManager->getRepository($foreignEntityType)->handleSelectParams($selectParams);
$sql = $entityManager->getQuery()->createSelectQuery($foreignEntityType, $selectParams);
+37 -8
View File
@@ -782,13 +782,42 @@ class Base
if (isset($w['attribute'])) {
$attribute = $w['attribute'];
}
$type = null;
if (isset($w['type'])) {
$type = $w['type'];
}
$entityType = $this->getEntityType();
if ($attribute) {
if (isset($w['type']) && in_array($w['type'], ['isLinked', 'isNotLinked', 'linkedWith', 'notLinkedWith', 'isUserFromTeams'])) {
if (in_array($attribute, $this->getAcl()->getScopeForbiddenFieldList($this->getEntityType()))) {
if (strpos($attribute, '.')) {
list($link, $attribute) = explode('.', $attribute);
if (!$this->getSeed()->hasRelation($link)) {
throw new Forbidden("SelectManager::checkWhere: Unknow relation '{$link}' in where.");
}
$entityType = $this->getSeed($this->getEntityType())->getRelationParam($link, 'entity');
if (!$entityType) {
throw new Forbidden("SelectManager::checkWhere: Bad relation.");
}
if (!$this->getAcl()->checkScope($entityType)) {
throw new Forbidden();
}
}
if ($type && in_array($type, ['isLinked', 'isNotLinked', 'linkedWith', 'notLinkedWith', 'isUserFromTeams'])) {
if (in_array($attribute, $this->getAcl()->getScopeForbiddenFieldList($entityType))) {
throw new Forbidden();
}
if (
$this->getSeed()->hasRelation($attribute)
&&
in_array($attribute, $this->getAcl()->getScopeForbiddenLinkList($entityType))
) {
throw new Forbidden();
}
} else {
if (in_array($attribute, $this->getAcl()->getScopeForbiddenAttributeList($this->getEntityType()))) {
if (in_array($attribute, $this->getAcl()->getScopeForbiddenAttributeList($entityType))) {
throw new Forbidden();
}
}
@@ -2075,13 +2104,13 @@ class Base
}
}
$attibute = null;
if (!empty($item['attribute'])) $attibute = $item['attribute'];
if (!$attibute) return;
$attribute = null;
if (!empty($item['attribute'])) $attribute = $item['attribute'];
if (!$attribute) return;
$attributeType = $this->getSeed()->getAttributeType($attibute);
$attributeType = $this->getSeed()->getAttributeType($attribute);
if ($attributeType === 'foreign') {
$relation = $this->getSeed()->getAttributeParam($attibute, 'relation');
$relation = $this->getSeed()->getAttributeParam($attribute, 'relation');
if ($relation) {
$this->addLeftJoin($relation, $result);
}
+19 -19
View File
@@ -306,7 +306,7 @@ class EmailAddress extends \Espo\Core\ORM\Repositories\RDB
if ($emailAddressValue) {
$key = strtolower($emailAddressValue);
if ($key && isset($hash->$key)) {
$hash->$key['optOut'] = $entity->get('emailAddressIsOptedOut');
$hash->{$key}['optOut'] = $entity->get('emailAddressIsOptedOut');
}
}
}
@@ -337,19 +337,19 @@ class EmailAddress extends \Espo\Core\ORM\Repositories\RDB
$new = true;
$changed = false;
if ($hash->$key['primary']) {
if ($hash->{$key}['primary']) {
$primary = $key;
}
if (property_exists($hashPrevious, $key)) {
$new = false;
$changed =
$hash->$key['optOut'] != $hashPrevious->$key['optOut'] ||
$hash->$key['invalid'] != $hashPrevious->$key['invalid'] ||
$hash->$key['emailAddress'] !== $hashPrevious->$key['emailAddress'];
$hash->{$key}['optOut'] != $hashPrevious->$key['optOut'] ||
$hash->{$key}['invalid'] != $hashPrevious->$key['invalid'] ||
$hash->{$key}['emailAddress'] !== $hashPrevious->$key['emailAddress'];
if ($hash->$key['primary']) {
if ($hash->$key['primary'] == $hashPrevious->$key['primary']) {
if ($hash->{$key}['primary']) {
if ($hash->{$key}['primary'] == $hashPrevious->$key['primary']) {
$primary = false;
}
}
@@ -390,9 +390,9 @@ class EmailAddress extends \Espo\Core\ORM\Repositories\RDB
$skipSave = $this->checkChangeIsForbidden($emailAddress, $entity);
if (!$skipSave) {
$emailAddress->set([
'optOut' => $hash->$address['optOut'],
'invalid' => $hash->$address['invalid'],
'name' => $hash->$address['emailAddress']
'optOut' => $hash->{$address}['optOut'],
'invalid' => $hash->{$address}['invalid'],
'name' => $hash->{$address}['emailAddress']
]);
$this->save($emailAddress);
} else {
@@ -410,23 +410,23 @@ class EmailAddress extends \Espo\Core\ORM\Repositories\RDB
$emailAddress = $this->get();
$emailAddress->set([
'name' => $hash->$address['emailAddress'],
'optOut' => $hash->$address['optOut'],
'invalid' => $hash->$address['invalid'],
'name' => $hash->{$address}['emailAddress'],
'optOut' => $hash->{$address}['optOut'],
'invalid' => $hash->{$address}['invalid'],
]);
$this->save($emailAddress);
} else {
$skipSave = $this->checkChangeIsForbidden($emailAddress, $entity);
if (!$skipSave) {
if (
$emailAddress->get('optOut') != $hash->$address['optOut'] ||
$emailAddress->get('invalid') != $hash->$address['invalid'] ||
$emailAddress->get('emailAddress') != $hash->$address['emailAddress']
$emailAddress->get('optOut') != $hash->{$address}['optOut'] ||
$emailAddress->get('invalid') != $hash->{$address}['invalid'] ||
$emailAddress->get('emailAddress') != $hash->{$address}['emailAddress']
) {
$emailAddress->set([
'optOut' => $hash->$address['optOut'],
'invalid' => $hash->$address['invalid'],
'name' => $hash->$address['emailAddress']
'optOut' => $hash->{$address}['optOut'],
'invalid' => $hash->{$address}['invalid'],
'name' => $hash->{$address}['emailAddress']
]);
$this->save($emailAddress);
}
@@ -252,15 +252,15 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB
$new = true;
$changed = false;
if ($hash->$key['primary']) {
if ($hash->{$key}['primary']) {
$primary = $key;
}
if (property_exists($hashPrevious, $key)) {
$new = false;
$changed = $hash->$key['type'] != $hashPrevious->$key['type'];
if ($hash->$key['primary']) {
if ($hash->$key['primary'] == $hashPrevious->$key['primary']) {
$changed = $hash->{$key}['type'] != $hashPrevious->$key['type'];
if ($hash->{$key}['primary']) {
if ($hash->{$key}['primary'] == $hashPrevious->$key['primary']) {
$primary = false;
}
}
@@ -301,7 +301,7 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB
$skipSave = $this->checkChangeIsForbidden($phoneNumber, $entity);
if (!$skipSave) {
$phoneNumber->set([
'type' => $hash->$number['type'],
'type' => $hash->{$number}['type'],
]);
$this->save($phoneNumber);
} else {
@@ -319,15 +319,15 @@ class PhoneNumber extends \Espo\Core\ORM\Repositories\RDB
$phoneNumber->set([
'name' => $number,
'type' => $hash->$number['type'],
'type' => $hash->{$number}['type'],
]);
$this->save($phoneNumber);
} else {
$skipSave = $this->checkChangeIsForbidden($phoneNumber, $entity);
if (!$skipSave) {
if ($phoneNumber->get('type') != $hash->$number['type']) {
if ($phoneNumber->get('type') != $hash->{$number}['type']) {
$phoneNumber->set([
'type' => $hash->$number['type'],
'type' => $hash->{$number}['type'],
]);
$this->save($phoneNumber);
}
+1 -2
View File
@@ -13,7 +13,7 @@
<button class="btn btn-default btn-icon email-property{{#if invalid}} active{{/if}}" type="button" tabindex="-1" data-action="switchEmailProperty" data-property-type="invalid" data-toggle="tooltip" data-placement="top" title="{{translate 'Invalid' scope='EmailAddress'}}">
<span class="fa fa-exclamation-circle{{#unless invalid}} text-muted{{/unless}}"></span>
</button>
<button class="btn btn-link btn-icon hidden" style="margin-left: 5px;" type="button" tabindex="-1" data-action="removeEmailAddress" data-property-type="invalid" data-toggle="tooltip" data-placement="top" title="{{translate 'Remove'}}">
<button class="btn btn-link btn-icon hidden" type="button" tabindex="-1" data-action="removeEmailAddress" data-property-type="invalid" data-toggle="tooltip" data-placement="top" title="{{translate 'Remove'}}">
<span class="fas fa-times"></span>
</button>
</span>
@@ -22,4 +22,3 @@
</div>
<button class="btn btn-default btn-icon" type="button" data-action="addEmailAddress"><span class="fa fa-plus"></span></button>
+1 -2
View File
@@ -10,7 +10,7 @@
<button class="btn btn-default btn-icon phone-property{{#if primary}} active{{/if}} hidden" type="button" tabindex="-1" data-action="switchPhoneProperty" data-property-type="primary" data-toggle="tooltip" data-placement="top" title="{{translate 'Primary' scope='PhoneNumber'}}">
<span class="fa fa-star fa-sm{{#unless primary}} text-muted{{/unless}}"></span>
</button>
<button class="btn btn-link btn-icon hidden" style="margin-left: 5px;" type="button" tabindex="-1" data-action="removePhoneNumber" data-property-type="invalid" data-toggle="tooltip" data-placement="top" title="{{translate 'Remove'}}">
<button class="btn btn-link btn-icon hidden" type="button" tabindex="-1" data-action="removePhoneNumber" data-property-type="invalid" data-toggle="tooltip" data-placement="top" title="{{translate 'Remove'}}">
<span class="fas fa-times"></span>
</button>
</span>
@@ -19,4 +19,3 @@
</div>
<button class="btn btn-default btn-icon" type="button" data-action="addPhoneNumber"><span class="fa fa-plus"></span></button>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "espocrm",
"version": "5.5.4",
"version": "5.5.5",
"description": "",
"main": "index.php",
"repository": {