From 36ee2fb229cc219e3db104d803bdb1a2b71b8fad Mon Sep 17 00:00:00 2001 From: Seamus Lee Date: Tue, 8 Mar 2016 01:03:39 +0000 Subject: [PATCH] CRM-18181 Get all mailings that use mailings that an acled user can see --- CRM/Mailing/BAO/Mailing.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php index 58d4f00de2..99f05dcafa 100644 --- a/CRM/Mailing/BAO/Mailing.php +++ b/CRM/Mailing/BAO/Mailing.php @@ -2454,6 +2454,17 @@ LEFT JOIN civicrm_mailing_group g ON g.mailing_id = m.id while ($dao->fetch()) { $mailingIDs[] = $dao->id; } + //CRM-18181 Get all mailings that use the mailings found earlier as receipients + $mailings = implode(',', $mailingIDs); + $mailingQuery = " + SELECT DISTINCT ( m.id ) as id + FROM civicrm_mailing m + LEFT JOIN civicrm_mailing_group g ON g.mailing_id = m.id + WHERE g.entity_table like 'civicrm_mailing%' AND g.entity_id IN ($mailings)"; + $mailingDao = CRM_Core_DAO::executeQuery($mailingQuery); + while ($mailingDao->fetch()) { + $mailingIDs[] = $mailingDao->id; + } } return $mailingIDs; -- 2.25.1