3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2015
35 class CRM_Mailing_Form_ForwardMailing
extends CRM_Core_Form
{
36 public function preProcess() {
37 $job_id = CRM_Utils_Request
::retrieve('jid', 'Positive',
40 $queue_id = CRM_Utils_Request
::retrieve('qid', 'Positive',
43 $hash = CRM_Utils_Request
::retrieve('h', 'String',
47 $q = CRM_Mailing_Event_BAO_Queue
::verify($job_id, $queue_id, $hash);
52 CRM_Core_Error
::fatal(ts('Invalid form parameters.'));
53 CRM_Core_Error
::statusBounce(ts('Invalid form parameters.'));
55 $mailing = &$q->getMailing();
58 $emailId = CRM_Core_DAO
::getfieldValue('CRM_Mailing_Event_DAO_Queue', $hash, 'email_id', 'hash');
59 $this->_fromEmail
= $fromEmail = CRM_Core_DAO
::getfieldValue('CRM_Core_DAO_Email', $emailId, 'email');
60 $this->assign('fromEmail', $fromEmail);
63 /* Show the subject instead of the name here, since it's being
64 * displayed to external contacts/users */
66 CRM_Utils_System
::setTitle(ts('Forward Mailing: %1', array(1 => $mailing->subject
)));
68 $this->set('queue_id', $queue_id);
69 $this->set('job_id', $job_id);
70 $this->set('hash', $hash);
74 * Build the form object.
78 public function buildQuickForm() {
79 for ($i = 0; $i < 5; $i++
) {
80 $this->add('text', "email_$i", ts('Email %1', array(1 => $i +
1)));
81 $this->addRule("email_$i", ts('Email is not valid.'), 'email');
84 //insert message Text by selecting "Select Template option"
85 $this->add('textarea', 'forward_comment', ts('Comment'), array('cols' => '80', 'rows' => '8'));
86 $this->add('wysiwyg', 'html_comment',
88 array('cols' => '80', 'rows' => '8')
91 $this->addButtons(array(
94 'name' => ts('Forward'),
99 'name' => ts('Cancel'),
105 * Form submission of new/edit contact is processed.
110 public function postProcess() {
111 $queue_id = $this->get('queue_id');
112 $job_id = $this->get('job_id');
113 $hash = $this->get('hash');
114 $timeStamp = date('YmdHis');
116 $formValues = $this->controller
->exportValues($this->_name
);
118 $params['body_text'] = $formValues['forward_comment'];
119 $html_comment = $formValues['html_comment'];
120 $params['body_html'] = str_replace('%7B', '{', str_replace('%7D', '}', $html_comment));
123 for ($i = 0; $i < 5; $i++
) {
124 $email = $this->controller
->exportValue($this->_name
, "email_$i");
125 if (!empty($email)) {
131 foreach ($emails as $email) {
135 'event_queue_id' => $queue_id,
138 'time_stamp' => $timeStamp,
139 'fromEmail' => $this->_fromEmail
,
142 $result = civicrm_api('Mailing', 'event_forward', $params);
143 if (!civicrm_error($result)) {
148 $status = ts('Mailing is not forwarded to the given email address.', array(
149 'count' => count($emails),
150 'plural' => 'Mailing is not forwarded to the given email addresses.',
153 $status = ts('Mailing is forwarded successfully to %count email address.', array(
154 'count' => $forwarded,
155 'plural' => 'Mailing is forwarded successfully to %count email addresses.',
159 CRM_Utils_System
::setUFMessage($status);
161 // always redirect to front page of url
162 $session = CRM_Core_Session
::singleton();
163 $config = CRM_Core_Config
::singleton();
164 $session->pushUserContext($config->userFrameworkBaseURL
);