<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
*/
require_once 'Mail/mime.php';
}
// Create a temp table for contact exclusion.
- $excludeTempTablename = "excluded_recipients_temp" . substr(sha1(rand()), 0, 4);
- $includedTempTablename = "included_recipients_temp" . substr(sha1(rand()), 0, 4);
- $mailingGroup->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'])) {
$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 = [
// 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');
}
$this->templates['subject'] = implode("\n", $template);
}
+ $this->templates['mailingID'] = $this->id;
CRM_Utils_Hook::alterMailContent($this->templates);
}
return $this->templates;
// push the tracking url on to the html email if necessary
if ($this->open_tracking && $html) {
- array_push($html, "\n" . '<img src="' . $config->userFrameworkResourceURL .
- "extern/open.php?q=$event_queue_id\" width='1' height='1' alt='' border='0'>"
+ array_push($html, "\n" . '<img src="' . CRM_Utils_System::externUrl('extern/open', "q=$event_queue_id")
+ . '" width="1" height="1" alt="" border="0">'
);
}
*
* @return object
* $mailing The new mailing object
- * @throws \Exception
+ *
+ * @throws \CRM_Core_Exception
+ * @throws \CiviCRM_API3_Exception
*/
public static function create(&$params, $ids = []) {
$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