'email' => array(
'title' => ts('Email'),
'no_repeat' => TRUE,
- 'required' => TRUE,
),
'on_hold' => array(
'title' => ts('On hold'),
$this->_from .= "
INNER JOIN civicrm_mailing_event_queue
ON civicrm_mailing_event_queue.contact_id = {$this->_aliases['civicrm_contact']}.id
- INNER JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
ON civicrm_mailing_event_queue.email_id = {$this->_aliases['civicrm_email']}.id
INNER JOIN civicrm_mailing_event_bounce {$this->_aliases['civicrm_mailing_event_bounce']}
ON {$this->_aliases['civicrm_mailing_event_bounce']}.event_queue_id = civicrm_mailing_event_queue.id
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
+
+ // If the email address has been deleted
+ if (array_key_exists('civicrm_email_email', $row)) {
+ if (empty($rows[$rowNum]['civicrm_email_email'])) {
+ $rows[$rowNum]['civicrm_email_email'] = '<del>Email address deleted</del>';
+ }
+ $entryFound = TRUE;
+ }
+
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_contact_sort_name', $row) &&
'email' => array(
'title' => ts('Email'),
'no_repeat' => TRUE,
- 'required' => TRUE,
),
),
'grouping' => 'contact-fields',
$this->_from .= "
INNER JOIN civicrm_mailing_event_queue
ON civicrm_mailing_event_queue.contact_id = {$this->_aliases['civicrm_contact']}.id
- INNER JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
ON civicrm_mailing_event_queue.email_id = {$this->_aliases['civicrm_email']}.id
INNER JOIN civicrm_mailing_event_trackable_url_open
ON civicrm_mailing_event_trackable_url_open.event_queue_id = civicrm_mailing_event_queue.id
public function alterDisplay(&$rows) {
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
+
+ // If the email address has been deleted
+ if (array_key_exists('civicrm_email_email', $row)) {
+ if (empty($rows[$rowNum]['civicrm_email_email'])) {
+ $rows[$rowNum]['civicrm_email_email'] = '<del>Email address deleted</del>';
+ }
+ $entryFound = TRUE;
+ }
+
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_contact_sort_name', $row) &&
'fields' => array(
'email' => array(
'title' => ts('Email'),
- 'required' => TRUE,
),
),
'grouping' => 'contact-fields',
$this->_from .= "
INNER JOIN civicrm_mailing_event_queue
ON civicrm_mailing_event_queue.contact_id = {$this->_aliases['civicrm_contact']}.id
- INNER JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
ON civicrm_mailing_event_queue.email_id = {$this->_aliases['civicrm_email']}.id";
if (array_key_exists('delivery_id', $this->_params['fields'])) {
public function alterDisplay(&$rows) {
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
+
+ // If the email address has been deleted
+ if (array_key_exists('civicrm_email_email', $row)) {
+ if (empty($rows[$rowNum]['civicrm_email_email'])) {
+ $rows[$rowNum]['civicrm_email_email'] = '<del>Email address deleted</del>';
+ }
+ $entryFound = TRUE;
+ }
+
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_contact_sort_name', $row) &&
'email' => array(
'title' => ts('Email'),
'no_repeat' => TRUE,
- 'required' => TRUE,
),
),
'order_bys' => array(
$this->_from .= "
INNER JOIN civicrm_mailing_event_queue
ON civicrm_mailing_event_queue.contact_id = {$this->_aliases['civicrm_contact']}.id
- INNER JOIN civicrm_email {$this->_aliases['civicrm_email']}
+ LEFT JOIN civicrm_email {$this->_aliases['civicrm_email']}
ON civicrm_mailing_event_queue.email_id = {$this->_aliases['civicrm_email']}.id
INNER JOIN civicrm_mailing_event_opened
ON civicrm_mailing_event_opened.event_queue_id = civicrm_mailing_event_queue.id
public function alterDisplay(&$rows) {
$entryFound = FALSE;
foreach ($rows as $rowNum => $row) {
+
+ // If the email address has been deleted
+ if (array_key_exists('civicrm_email_email', $row)) {
+ if (empty($rows[$rowNum]['civicrm_email_email'])) {
+ $rows[$rowNum]['civicrm_email_email'] = '<del>Email address deleted</del>';
+ }
+ $entryFound = TRUE;
+ }
+
// make count columns point to detail report
// convert display name to links
if (array_key_exists('civicrm_contact_sort_name', $row) &&
{else}
ALTER TABLE civicrm_option_value CHANGE label label varchar( 512 ) DEFAULT NULL ;
{/if}
+
+-- CRM-18345: Don't delete mailing records when email address / phone is deleted
+ALTER TABLE `civicrm_mailing_event_queue`
+ DROP FOREIGN KEY `FK_civicrm_mailing_event_queue_email_id`;
+
+ALTER TABLE `civicrm_mailing_event_queue`
+ ADD CONSTRAINT `FK_civicrm_mailing_event_queue_email_id`
+ FOREIGN KEY (`email_id`)
+ REFERENCES `civicrm_email`(`id`)
+ ON DELETE SET NULL
+ ON UPDATE RESTRICT;
+
+ALTER TABLE `civicrm_mailing_event_queue`
+ DROP FOREIGN KEY `FK_civicrm_mailing_event_queue_phone_id`;
+
+ALTER TABLE `civicrm_mailing_event_queue`
+ ADD CONSTRAINT `FK_civicrm_mailing_event_queue_phone_id`
+ FOREIGN KEY (`phone_id`)
+ REFERENCES `civicrm_phone`(`id`)
+ ON DELETE SET NULL
+ ON UPDATE RESTRICT;
+
+ALTER TABLE `civicrm_mailing_recipients`
+ DROP FOREIGN KEY `FK_civicrm_mailing_recipients_email_id`;
+
+ALTER TABLE `civicrm_mailing_recipients`
+ ADD CONSTRAINT `FK_civicrm_mailing_recipients_email_id`
+ FOREIGN KEY (`email_id`)
+ REFERENCES `civicrm_email`(`id`)
+ ON DELETE SET NULL
+ ON UPDATE RESTRICT;
+
+ALTER TABLE `civicrm_mailing_recipients`
+ DROP FOREIGN KEY `FK_civicrm_mailing_recipients_phone_id`;
+
+ALTER TABLE `civicrm_mailing_recipients`
+ ADD CONSTRAINT `FK_civicrm_mailing_recipients_phone_id`
+ FOREIGN KEY (`phone_id`)
+ REFERENCES `civicrm_phone`(`id`)
+ ON DELETE SET NULL
+ ON UPDATE RESTRICT;
<name>email_id</name>
<table>civicrm_email</table>
<key>id</key>
- <onDelete>CASCADE</onDelete>
+ <onDelete>SET NULL</onDelete>
</foreignKey>
<field>
<name>contact_id</name>
<name>phone_id</name>
<table>civicrm_phone</table>
<key>id</key>
- <onDelete>CASCADE</onDelete>
+ <onDelete>SET NULL</onDelete>
</foreignKey>
</table>
<name>email_id</name>
<table>civicrm_email</table>
<key>id</key>
- <onDelete>CASCADE</onDelete>
+ <onDelete>SET NULL</onDelete>
</foreignKey>
<field>
<name>phone_id</name>
<name>phone_id</name>
<table>civicrm_phone</table>
<key>id</key>
- <onDelete>CASCADE</onDelete>
+ <onDelete>SET NULL</onDelete>
</foreignKey>
</table>