CRM-18181 Get all mailings that use mailings that an acled user can see
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 8 Mar 2016 01:03:39 +0000 (01:03 +0000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 8 Mar 2016 01:10:44 +0000 (01:10 +0000)
CRM/Mailing/BAO/Mailing.php

index 58d4f00de22f4205608eb4ba76497c8c5194ee1c..99f05dcafacaf885dd24b25265a736191aa8ce6e 100644 (file)
@@ -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;