X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FMailing%2FBAO%2FMailing.php;h=42c3281e6fa0eec8cd8cc16e639e8e8184255385;hb=6e7a0954a880cf1f6fc7c88ecb976366dba365b6;hp=3c76c6c0a7138fcbe5e4f2913a36923bcfbb4d84;hpb=ecaa82003d46edf98d72a9cf3ed4e471d21e6ab2;p=civicrm-core.git
diff --git a/CRM/Mailing/BAO/Mailing.php b/CRM/Mailing/BAO/Mailing.php
index 3c76c6c0a7..42c3281e6f 100644
--- a/CRM/Mailing/BAO/Mailing.php
+++ b/CRM/Mailing/BAO/Mailing.php
@@ -1,34 +1,18 @@
query(
- "CREATE TEMPORARY TABLE $excludeTempTablename
- (contact_id int primary key)
- ENGINE=HEAP"
- );
+ $excludeTempTable = CRM_Utils_SQL_TempTable::build()->setCategory('exrecipient')->setMemory()->createWithColumns('contact_id int primary key');
+ $excludeTempTablename = $excludeTempTable->getName();
// populate exclude temp-table with recipients to be excluded from the list
// on basis of selected recipients groups and/or previous mailing
if (!empty($recipientsGroup['Exclude'])) {
@@ -237,11 +216,8 @@ class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing {
$entityColumn = $isSMSmode ? 'phone_id' : 'email_id';
$entityTable = $isSMSmode ? CRM_Core_DAO_Phone::getTableName() : CRM_Core_DAO_Email::getTableName();
// Get all the group contacts we want to include.
- $mailingGroup->query(
- "CREATE TEMPORARY TABLE $includedTempTablename
- (contact_id int primary key, $entityColumn int)
- ENGINE=HEAP"
- );
+ $includedTempTable = CRM_Utils_SQL_TempTable::build()->setCategory('inrecipient')->setMemory()->createWithColumns('contact_id int primary key, ' . $entityColumn . ' int');
+ $includedTempTablename = $includedTempTable->getName();
if ($isSMSmode) {
$criteria = [
@@ -405,8 +381,8 @@ class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing {
// Delete the temp table.
$mailingGroup->reset();
- $mailingGroup->query(" DROP TEMPORARY TABLE $excludeTempTablename ");
- $mailingGroup->query(" DROP TEMPORARY TABLE $includedTempTablename ");
+ $excludeTempTable->drop();
+ $includedTempTable->drop();
CRM_Utils_Hook::alterMailingRecipients($mailingObj, $criteria, 'post');
}
@@ -713,6 +689,7 @@ class CRM_Mailing_BAO_Mailing extends CRM_Mailing_DAO_Mailing {
$this->templates['subject'] = implode("\n", $template);
}
+ $this->templates['mailingID'] = $this->id;
CRM_Utils_Hook::alterMailContent($this->templates);
}
return $this->templates;
@@ -1163,8 +1140,8 @@ ORDER BY civicrm_email.is_bulkmail DESC
// push the tracking url on to the html email if necessary
if ($this->open_tracking && $html) {
- array_push($html, "\n" . '"
+ array_push($html, "\n" . ''
);
}
@@ -1538,7 +1515,9 @@ ORDER BY civicrm_email.is_bulkmail DESC
*
* @return object
* $mailing The new mailing object
- * @throws \Exception
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public static function create(&$params, $ids = []) {
@@ -1570,8 +1549,7 @@ ORDER BY civicrm_email.is_bulkmail DESC
$domain_name = 'EXAMPLE.ORG';
}
if (!isset($params['created_id'])) {
- $session =& CRM_Core_Session::singleton();
- $params['created_id'] = $session->get('userID');
+ $params['created_id'] = CRM_Core_Session::getLoggedInContactID();
}
$defaults = [
// load the default config settings for each