2c77fb696231803af68a694fc21b90a026b1a797
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
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
37 * This class generates form components for relationship
40 class CRM_Mailing_Form_Task
extends CRM_Core_Form
{
43 * The task being performed.
50 * The additional clause that we restrict the search with.
54 protected $_componentClause = NULL;
57 * The array that holds all the component ids.
61 protected $_componentIds;
64 * Build all the data structures needed to build the form.
70 public function preProcess() {
71 self
::preProcessCommon($this);
75 * @param CRM_Core_Form $form
76 * @param bool $useTable
78 public static function preProcessCommon(&$form, $useTable = FALSE) {
79 $values = $form->controller
->exportValues($form->get('searchFormName'));
81 $form->_task
= CRM_Utils_Array
::value('task', $values);
82 $mailingTasks = CRM_Mailing_Task
::tasks();
83 $form->assign('taskName', CRM_Utils_Array
::value('task', $values));
85 // ids are mailing event queue ids
87 if ($values['radio_ts'] == 'ts_sel') {
88 foreach ($values as $name => $value) {
89 if (substr($name, 0, CRM_Core_Form
::CB_PREFIX_LEN
) == CRM_Core_Form
::CB_PREFIX
) {
90 $ids[] = substr($name, CRM_Core_Form
::CB_PREFIX_LEN
);
95 $queryParams = $form->get('queryParams');
97 if ($form->get(CRM_Utils_Sort
::SORT_ORDER
)) {
98 $sortOrder = $form->get(CRM_Utils_Sort
::SORT_ORDER
);
101 $query = new CRM_Contact_BAO_Query($queryParams, NULL, NULL, FALSE, FALSE,
102 CRM_Contact_BAO_Query
::MODE_MAILING
105 $result = $query->searchQuery(0, 0, $sortOrder);
106 while ($result->fetch()) {
107 $ids[] = $result->mailing_recipients_id
;
109 $form->assign('totalSelectedMailingRecipients', $form->get('rowCount'));
113 $form->_componentClause
= ' civicrm_mailing_recipients.id IN ( ' . implode(',', $ids) . ' ) ';
116 //set the context for redirection for any task actions
117 $session = CRM_Core_Session
::singleton();
119 $fragment = 'search';
120 if ($form->_action
== CRM_Core_Action
::ADVANCED
) {
121 $fragment .= '/advanced';
124 $qfKey = CRM_Utils_Request
::retrieve('qfKey', 'String', $form);
125 $urlParams = 'force=1';
126 if (CRM_Utils_Rule
::qfKey($qfKey)) {
127 $urlParams .= "&qfKey=$qfKey";
130 $url = CRM_Utils_System
::url('civicrm/contact/' . $fragment, $urlParams);
131 $session = CRM_Core_Session
::singleton();
132 $session->replaceUserContext($url);
136 * Simple shell that derived classes can call to add buttons to
137 * the form with a customized title for the main Submit
139 * @param string $title
140 * Title of the main button.
141 * @param string $nextType
142 * @param string $backType
143 * @param bool $submitOnce
148 public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) {
149 $this->addButtons(array(
157 'name' => ts('Cancel'),