email 2
This commit is contained in:
@@ -213,7 +213,7 @@ class Acl
|
||||
'delete' => 'own',
|
||||
);
|
||||
$this->data['EmailAddress'] = array(
|
||||
'read' => 'all',
|
||||
'read' => 'no',
|
||||
'edit' => 'no',
|
||||
'delete' => 'no',
|
||||
);
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
"attachments": "Attachments",
|
||||
"selectTemplate": "Select Template",
|
||||
"fromEmailAddress": "Email From",
|
||||
"toEmailAddresses": "Email To"
|
||||
"toEmailAddresses": "Email To",
|
||||
"emailAddress": "Email Address"
|
||||
},
|
||||
"links": {
|
||||
},
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
"Role": "Role",
|
||||
"EmailTemplate": "Email Template",
|
||||
"OutboundEmail": "Outbound Email",
|
||||
"EmailAddress": "Email Address",
|
||||
"ScheduledJob": "Scheduled Job"
|
||||
},
|
||||
"scopeNamesPlural": {
|
||||
@@ -16,8 +15,7 @@
|
||||
"Role": "Roles",
|
||||
"EmailTemplate": "Email Templates",
|
||||
"OutboundEmail": "Outbound Emails",
|
||||
"ScheduledJob": "Scheduled Jobs",
|
||||
"EmailAddress": "Email Addresses"
|
||||
"ScheduledJob": "Scheduled Jobs"
|
||||
},
|
||||
"labels": {
|
||||
"Merge": "Merge",
|
||||
|
||||
@@ -2,6 +2,5 @@
|
||||
"dateSent",
|
||||
"parent",
|
||||
"body",
|
||||
"fromEmailAddress",
|
||||
"toEmailAddresses"
|
||||
"emailAddress"
|
||||
]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[
|
||||
{"name":"name","width":30,"link":true},
|
||||
{"name":"dateSent"},
|
||||
{"name":"from"},
|
||||
{"name":"fromEmailAddress"},
|
||||
{"name":"status"}
|
||||
]
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"controller": "Controllers.Record"
|
||||
}
|
||||
@@ -16,13 +16,7 @@
|
||||
"type": "varchar",
|
||||
"db": false,
|
||||
"required": true
|
||||
},
|
||||
"fromEmailAddress": {
|
||||
"type": "link"
|
||||
},
|
||||
"toEmailAddresses": {
|
||||
"type": "linkMultiple"
|
||||
},
|
||||
"to": {
|
||||
"type": "varchar",
|
||||
"db": false,
|
||||
@@ -36,6 +30,19 @@
|
||||
"type": "varchar",
|
||||
"db": false
|
||||
},
|
||||
"emailAddress": {
|
||||
"type": "base",
|
||||
"db": false
|
||||
},
|
||||
"fromEmailAddress": {
|
||||
"type": "link"
|
||||
},
|
||||
"toEmailAddresses": {
|
||||
"type": "linkMultiple"
|
||||
},
|
||||
"ccEmailAddresses": {
|
||||
"type": "linkMultiple"
|
||||
},
|
||||
"bodyPlain": {
|
||||
"type": "text",
|
||||
"readOnly": true
|
||||
|
||||
@@ -115,5 +115,62 @@ class Email extends Record
|
||||
}
|
||||
return $entity;
|
||||
}
|
||||
|
||||
public function findEntities($params)
|
||||
{
|
||||
$searchByEmailAddress = false;
|
||||
if (!empty($params['where']) && is_array($params['where'])) {
|
||||
foreach ($params['where'] as $i => $p) {
|
||||
if ($p['field'] == 'emailAddress') {
|
||||
$searchByEmailAddress = true;
|
||||
$emailAddress = $this->getEntityManager()->getRepository('EmailAddress')->where(array(
|
||||
'lower' => strtolower($p['value'])
|
||||
))->findOne();
|
||||
unset($params['where'][$i]);
|
||||
$emailAddressId = null;
|
||||
if ($emailAddress) {
|
||||
$emailAddressId = $emailAddress->id;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$selectParams = $this->getSelectManager($this->entityName)->getSelectParams($params, true);
|
||||
|
||||
if ($searchByEmailAddress) {
|
||||
if ($emailAddressId) {
|
||||
$pdo = $this->getEntityManager()->getPDO();
|
||||
|
||||
$selectParams['customJoin'] = "
|
||||
LEFT JOIN email_email_address
|
||||
ON
|
||||
email_email_address.email_id = email.id AND
|
||||
email_email_address.deleted = 0
|
||||
";
|
||||
$selectParams['customWhere'] = "
|
||||
AND
|
||||
(
|
||||
email.from_email_address_id = ".$pdo->quote($emailAddressId)." OR
|
||||
email_email_address.email_address_id = ".$pdo->quote($emailAddressId)."
|
||||
)
|
||||
";
|
||||
} else {
|
||||
$selectParams['customWhere'] = ' AND 0';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$collection = $this->getRepository()->find($selectParams);
|
||||
|
||||
foreach ($collection as $e) {
|
||||
$this->loadParentNameFields($e);
|
||||
}
|
||||
|
||||
return array(
|
||||
'total' => $this->getRepository()->count($selectParams),
|
||||
'collection' => $collection,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user