Merge pull request #22488 from mattwire/deprecateipnprocesstransaction
[civicrm-core.git] / CRM / Mailing / Controller / Send.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
6a488035 5 | |
bc77d7c0
TO
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
6a488035 9 +--------------------------------------------------------------------+
d25dd0ee 10 */
6a488035
TO
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
6a488035
TO
16 */
17class CRM_Mailing_Controller_Send extends CRM_Core_Controller {
18
19 /**
fe482240 20 * Class constructor.
ab432335 21 *
3fd42bb5 22 * @param string $title
ab432335
EM
23 * @param bool|int $action
24 * @param bool $modal
25 *
26 * @throws \Exception
6a488035 27 */
00be9182 28 public function __construct($title = NULL, $action = CRM_Core_Action::NONE, $modal = TRUE) {
6a488035
TO
29 parent::__construct($title, $modal, NULL, FALSE, TRUE);
30
0083c73f
TO
31 // New: civicrm/mailing/send?reset=1
32 // Re-use: civicrm/mailing/send?reset=1&mid=%%mid%%
33 // Continue: civicrm/mailing/send?reset=1&mid=%%mid%%&continue=true
34 $mid = CRM_Utils_Request::retrieve('mid', 'Positive');
35 $continue = CRM_Utils_Request::retrieve('continue', 'String');
36 if (!$mid) {
37 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/new'));
38 }
39 if ($mid && $continue) {
40 //CRM-15979 - check if abtest exist for mailing then redirect accordingly
41 $abtest = CRM_Mailing_BAO_MailingAB::getABTest($mid);
42 if (!empty($abtest) && !empty($abtest->id)) {
43 $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/abtest/' . $abtest->id);
a9f5ff17 44 }
0083c73f
TO
45 else {
46 $redirect = CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mid);
a9f5ff17 47 }
0083c73f 48 CRM_Utils_System::redirect($redirect);
a9f5ff17 49 }
0083c73f 50 if ($mid && !$continue) {
be2fb01f 51 $clone = civicrm_api3('Mailing', 'clone', ['id' => $mid]);
5ebfe248
LS
52 civicrm_api3('Mailing', 'create', [
53 'id' => $clone['id'],
b1a7daf0 54 'name' => ts('Copy of %1', [1 => $clone['values'][$clone['id']]['name']]),
5ebfe248 55 ]);
0083c73f 56 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $clone['id']));
6a488035 57 }
6a488035 58 }
96025800 59
6a488035 60}