3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
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 |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
21 class CRM_Campaign_Form_Search_Petition
extends CRM_Core_Form
{
24 * Are we forced to run a search.
31 * Processing needed for buildForm and later.
33 public function preProcess() {
34 $this->_search
= $_GET['search'] ??
NULL;
35 $this->_force
= CRM_Utils_Request
::retrieve('force', 'Boolean', $this, FALSE, FALSE);
36 $this->_searchTab
= CRM_Utils_Request
::retrieve('type', 'String', $this, FALSE, 'petition');
38 //when we do load tab, lets load the default objects.
39 $this->assign('force', $this->_force ||
$this->_searchTab
);
40 $this->assign('searchParams', json_encode($this->get('searchParams')));
41 $this->assign('buildSelector', $this->_search
);
42 $this->assign('searchFor', $this->_searchTab
);
43 $this->assign('petitionCampaigns', json_encode($this->get('petitionCampaigns')));
44 $this->assign('suppressForm', TRUE);
47 $this->setTitle(ts('Find Petition'));
51 * Build the form object.
53 public function buildQuickForm() {
58 $attributes = CRM_Core_DAO
::getAttribute('CRM_Campaign_DAO_Survey');
59 $this->add('text', 'petition_title', ts('Title'), $attributes['title']);
62 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
63 $this->add('select', 'petition_campaign_id', ts('Campaign'), ['' => ts('- select -')] +
$campaigns);
64 $this->set('petitionCampaigns', $campaigns);
65 $this->assign('petitionCampaigns', json_encode($campaigns));
67 //build the array of all search params.
68 $this->_searchParams
= [];
69 foreach ($this->_elements
as $element) {
70 $name = $element->_attributes
['name'];
71 $label = $element->_label
;
72 if ($name == 'qfKey') {
75 $this->_searchParams
[$name] = ($label) ?
$label : $name;
77 $this->set('searchParams', $this->_searchParams
);
78 $this->assign('searchParams', json_encode($this->_searchParams
));