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_Survey
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, 'survey');
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('surveyTypes', json_encode($this->get('surveyTypes')));
44 $this->assign('surveyCampaigns', json_encode($this->get('surveyCampaigns')));
45 $this->assign('suppressForm', TRUE);
48 CRM_Utils_System
::setTitle(ts('Find Survey'));
52 * Build the form object.
54 public function buildQuickForm() {
59 $attributes = CRM_Core_DAO
::getAttribute('CRM_Campaign_DAO_Survey');
60 $this->add('text', 'survey_title', ts('Title'), $attributes['title']);
63 $surveyTypes = CRM_Campaign_BAO_Survey
::getSurveyActivityType();
64 $this->add('select', 'activity_type_id',
65 ts('Activity Type'), [
66 '' => ts('- select -'),
69 $this->set('surveyTypes', $surveyTypes);
70 $this->assign('surveyTypes', json_encode($surveyTypes));
73 $campaigns = CRM_Campaign_BAO_Campaign
::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
74 $this->add('select', 'survey_campaign_id', ts('Campaign'), ['' => ts('- select -')] +
$campaigns);
75 $this->set('surveyCampaigns', $campaigns);
76 $this->assign('surveyCampaigns', json_encode($campaigns));
78 //build the array of all search params.
79 $this->_searchParams
= [];
80 foreach ($this->_elements
as $element) {
81 $name = $element->_attributes
['name'];
82 $label = $element->_label
;
83 if ($name == 'qfKey') {
86 $this->_searchParams
[$name] = ($label) ?
$label : $name;
88 $this->set('searchParams', $this->_searchParams
);
89 $this->assign('searchParams', json_encode($this->_searchParams
));