Merge pull request #22255 from MegaphoneJon/membership-14-2021
[civicrm-core.git] / CRM / Mailing / Form / Task / AdhocMailing.php
CommitLineData
36c74cd6
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
bc77d7c0 4 | Copyright CiviCRM LLC. All rights reserved. |
36c74cd6 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 |
36c74cd6
TO
9 +--------------------------------------------------------------------+
10 */
11
12/**
13 *
14 * @package CRM
ca5cec67 15 * @copyright CiviCRM LLC https://civicrm.org/licensing
36c74cd6
TO
16 */
17
18/**
19 * Given the selected contacts, prepare a mailing with a hidden group.
20 */
21class CRM_Mailing_Form_Task_AdhocMailing extends CRM_Contact_Form_Task {
22
23 public function preProcess() {
24 parent::preProcess();
0051bad3 25 $templateTypes = CRM_Mailing_BAO_Mailing::getTemplateTypes();
36c74cd6 26 list ($groupId, $ssId) = $this->createHiddenGroup();
be2fb01f 27 $mailing = civicrm_api3('Mailing', 'create', [
36c74cd6
TO
28 'name' => "",
29 'campaign_id' => NULL,
30 'replyto_email' => "",
0051bad3 31 'template_type' => $templateTypes[0]['name'],
be2fb01f 32 'template_options' => ['nonce' => 1],
36c74cd6
TO
33 'subject' => "",
34 'body_html' => "",
35 'body_text' => "",
be2fb01f
CW
36 'groups' => [
37 'include' => [$groupId],
38 'exclude' => [],
39 'base' => [],
40 ],
41 'mailings' => [
42 'include' => [],
43 'exclude' => [],
44 ],
45 ]);
36c74cd6
TO
46
47 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/a/', NULL, TRUE, '/mailing/' . $mailing['id']));
48 }
49
50}