Skip to content

Commit

Permalink
opted out fields: allow foreign access
Browse files Browse the repository at this point in the history
  • Loading branch information
yurikuzn committed May 1, 2020
1 parent 782f223 commit 83e0d92
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
22 changes: 22 additions & 0 deletions application/Espo/Core/Utils/Database/Orm/Fields/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ protected function load($fieldName, $entityType)
'type' => 'bool',
'notStorable' => true,
'select' => 'emailAddresses.opt_out',
'selectForeign' => [
'sql' => "{$foreignJoinAlias}.opt_out",
'leftJoins' => [
[
'EntityEmailAddress',
$foreignJoinMiddleAlias,
[
"{$foreignJoinMiddleAlias}.entityId:" => "{alias}.id",
"{$foreignJoinMiddleAlias}.primary" => 1,
"{$foreignJoinMiddleAlias}.deleted" => 0,
]
],
[
'EmailAddress',
$foreignJoinAlias,
[
"{$foreignJoinAlias}.id:" => "{$foreignJoinMiddleAlias}.emailAddressId",
"{$foreignJoinAlias}.deleted" => 0,
]
]
],
],
'where' => [
'= TRUE' => [
'sql' => 'emailAddresses.opt_out = true AND emailAddresses.opt_out IS NOT NULL',
Expand Down
22 changes: 22 additions & 0 deletions application/Espo/Core/Utils/Database/Orm/Fields/Phone.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,28 @@ protected function load($fieldName, $entityType)
'type' => 'bool',
'notStorable' => true,
'select' => 'phoneNumbers.opt_out',
'selectForeign' => [
'sql' => "{$foreignJoinAlias}.opt_out",
'leftJoins' => [
[
'EntityPhoneNumber',
$foreignJoinMiddleAlias,
[
"{$foreignJoinMiddleAlias}.entityId:" => "{alias}.id",
"{$foreignJoinMiddleAlias}.primary" => 1,
"{$foreignJoinMiddleAlias}.deleted" => 0,
]
],
[
'PhoneNumber',
$foreignJoinAlias,
[
"{$foreignJoinAlias}.id:" => "{$foreignJoinMiddleAlias}.phoneNumberId",
"{$foreignJoinAlias}.deleted" => 0,
]
]
],
],
'where' => [
'= TRUE' => [
'sql' => 'phoneNumbers.opt_out = true AND phoneNumbers.opt_out IS NOT NULL',
Expand Down
1 change: 0 additions & 1 deletion application/Espo/Resources/metadata/fields/email.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"layoutDetailDisabled": true,
"layoutDefaultSidePanelDisabled": true,
"mergeDisabled": true,
"foreignAccessDisabled": true,
"customizationDefaultDisabled": true,
"customizationReadOnlyDisabled": true
}
Expand Down
1 change: 0 additions & 1 deletion application/Espo/Resources/metadata/fields/phone.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
"notStorable": true,
"layoutDetailDisabled": true,
"layoutDefaultSidePanelDisabled": true,
"foreignAccessDisabled": true,
"mergeDisabled": true,
"customizationDefaultDisabled": true,
"customizationReadOnlyDisabled": true
Expand Down

0 comments on commit 83e0d92

Please sign in to comment.