email improvement
This commit is contained in:
@@ -55,6 +55,7 @@
|
||||
"presetFilters": {
|
||||
"sent": "Sent",
|
||||
"archived": "Archived",
|
||||
"inbox": "Inbox",
|
||||
"draft": "Draft"
|
||||
},
|
||||
"massActions": {
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
},
|
||||
"filterList": [
|
||||
{
|
||||
"name":"archived",
|
||||
"name":"inbox",
|
||||
"style": "primary"
|
||||
},
|
||||
{
|
||||
@@ -68,11 +68,8 @@
|
||||
}
|
||||
],
|
||||
"defaultFilterData": {
|
||||
"bool": {
|
||||
"onlyMy": true
|
||||
},
|
||||
"presetName": "archived",
|
||||
"primary": "archived"
|
||||
"presetName": "inbox",
|
||||
"primary": "inbox"
|
||||
},
|
||||
"boolFilterList": ["onlyMy"]
|
||||
"boolFilterList": []
|
||||
}
|
||||
|
||||
@@ -34,24 +34,43 @@ class Email extends \Espo\Core\SelectManagers\Base
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterArchived(&$result)
|
||||
protected function filterInbox(&$result)
|
||||
{
|
||||
$eaList = $this->getUser()->get('emailAddresses');
|
||||
$idList = [];
|
||||
foreach ($eaList as $ea) {
|
||||
$idList[] = $ea->id;
|
||||
}
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Archived'
|
||||
'fromEmailAddressId!=' => $idList
|
||||
);
|
||||
$this->boolFilterOnlyMy();
|
||||
}
|
||||
|
||||
protected function filterSent(&$result)
|
||||
{
|
||||
$eaList = $this->getUser()->get('emailAddresses');
|
||||
$idList = [];
|
||||
foreach ($eaList as $ea) {
|
||||
$idList[] = $ea->id;
|
||||
}
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Sent'
|
||||
'fromEmailAddressId=' => $idList
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterDraft(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Draft'
|
||||
'status' => 'Draft',
|
||||
'createdById' => $this->getUser()->id
|
||||
);
|
||||
}
|
||||
|
||||
protected function filterArchived(&$result)
|
||||
{
|
||||
$result['whereClause'][] = array(
|
||||
'status' => 'Archived'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -275,23 +275,13 @@ class Email extends Record
|
||||
{
|
||||
parent::loadAdditionalFieldsForList($entity);
|
||||
|
||||
$userEmailAdddressIdList = [];
|
||||
foreach ($this->getUser()->get('emailAddresses') as $ea) {
|
||||
$userEmailAdddressIdList[] = $ea->id;
|
||||
}
|
||||
|
||||
$status = $entity->get('status');
|
||||
if (in_array($status, ['Archived', 'Received'])) {
|
||||
$fromEmailAddressId = $entity->get('fromEmailAddressId');
|
||||
if (!empty($fromEmailAddressId)) {
|
||||
$person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId($fromEmailAddressId);
|
||||
if ($person) {
|
||||
$entity->set('personStringData', $person->get('name'));
|
||||
} else {
|
||||
$fromName = self::parseFromName($entity->get('fromString'));
|
||||
if (!empty($fromName)) {
|
||||
$entity->set('personStringData', $fromName);
|
||||
} else {
|
||||
$entity->set('personStringData', $entity->get('fromEmailAddressName'));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (in_array($status, ['Sent', 'Draft', 'Sending'])) {
|
||||
if (in_array($entity->get('fromEmailAddressId'), $userEmailAdddressIdList)) {
|
||||
$entity->loadLinkMultipleField('toEmailAddresses');
|
||||
$idList = $entity->get('toEmailAddressesIds');
|
||||
$names = $entity->get('toEmailAddressesNames');
|
||||
@@ -308,6 +298,21 @@ class Email extends Record
|
||||
}
|
||||
$entity->set('personStringData', 'To: ' . implode(', ', $arr));
|
||||
}
|
||||
} else {
|
||||
$fromEmailAddressId = $entity->get('fromEmailAddressId');
|
||||
if (!empty($fromEmailAddressId)) {
|
||||
$person = $this->getEntityManager()->getRepository('EmailAddress')->getEntityByAddressId($fromEmailAddressId);
|
||||
if ($person) {
|
||||
$entity->set('personStringData', $person->get('name'));
|
||||
} else {
|
||||
$fromName = self::parseFromName($entity->get('fromString'));
|
||||
if (!empty($fromName)) {
|
||||
$entity->set('personStringData', $fromName);
|
||||
} else {
|
||||
$entity->set('personStringData', $entity->get('fromEmailAddressName'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
Reference in New Issue
Block a user