Commit | Line | Data |
---|---|---|
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 | */ |
17 | ||
18 | /** | |
3819f101 | 19 | * This class generates form components for relationship. |
6a488035 | 20 | */ |
31aaf096 | 21 | class CRM_Campaign_Form_Task extends CRM_Core_Form_Task { |
6a488035 TO |
22 | |
23 | /** | |
24 | * The array that holds all the voter ids | |
25 | * | |
26 | * @var array | |
27 | */ | |
28 | protected $_voterIds; | |
29 | ||
30 | /** | |
fe482240 | 31 | * Build all the data structures needed to build the form. |
95ea96be | 32 | */ |
87a890cc | 33 | public function preProcess() { |
6a488035 TO |
34 | $values = $this->controller->exportValues('Search'); |
35 | ||
353ffa53 | 36 | $this->_task = $values['task']; |
6a488035 | 37 | |
f60ff053 | 38 | $ids = $this->getSelectedIDs($values); |
56752ec0 | 39 | |
40 | if (!$ids) { | |
353ffa53 | 41 | $qfKey = CRM_Utils_Request::retrieve('qfKey', 'String', $this); |
6a488035 | 42 | $cacheKey = "civicrm search {$qfKey}"; |
b7994703 | 43 | $allCids = Civi::service('prevnext')->getSelection($cacheKey, "getall"); |
6a488035 TO |
44 | $ids = array_keys($allCids[$cacheKey]); |
45 | $this->assign('totalSelectedVoters', count($ids)); | |
46 | } | |
47 | ||
48 | if (!empty($ids)) { | |
49 | $this->_componentClause = 'contact_a.id IN ( ' . implode(',', $ids) . ' ) '; | |
50 | $this->assign('totalSelectedVoters', count($ids)); | |
51 | } | |
52 | $this->_voterIds = $this->_contactIds = $this->_componentIds = $ids; | |
53 | ||
54 | $this->assign('totalSelectedContacts', count($this->_contactIds)); | |
188bf7c3 | 55 | $this->setNextUrl('survey'); |
6a488035 TO |
56 | } |
57 | ||
58 | /** | |
59 | * Given the voter id, compute the contact id | |
60 | * since its used for things like send email | |
61 | */ | |
62 | public function setContactIDs() { | |
63 | $this->_contactIds = $this->_voterIds; | |
64 | } | |
65 | ||
66 | /** | |
fe482240 | 67 | * Simple shell that derived classes can call to add buttons to. |
6a488035 TO |
68 | * the form with a customized title for the main Submit |
69 | * | |
7aaf6db0 TO |
70 | * @param string $title |
71 | * Title of the main button. | |
72 | * @param string $nextType | |
73 | * Button type for the form after processing. | |
da6b46f4 EM |
74 | * @param string $backType |
75 | * @param bool $submitOnce | |
6a488035 | 76 | */ |
00be9182 | 77 | public function addDefaultButtons($title, $nextType = 'next', $backType = 'back', $submitOnce = FALSE) { |
be2fb01f | 78 | $this->addButtons([ |
5d4fcf54 TO |
79 | [ |
80 | 'type' => $nextType, | |
81 | 'name' => $title, | |
82 | 'isDefault' => TRUE, | |
83 | ], | |
84 | [ | |
85 | 'type' => $backType, | |
86 | 'name' => ts('Cancel'), | |
87 | ], | |
88 | ]); | |
6a488035 | 89 | } |
96025800 | 90 | |
6a488035 | 91 | } |