Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
232624b1 | 4 | | CiviCRM version 4.4 | |
6a488035 TO |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2013 | | |
7 | +--------------------------------------------------------------------+ | |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
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. | | |
13 | | | | |
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. | | |
18 | | | | |
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 | +--------------------------------------------------------------------+ | |
26 | */ | |
27 | ||
28 | /** | |
29 | * | |
30 | * @package CRM | |
31 | * @copyright CiviCRM LLC (c) 2004-2013 | |
32 | * $Id$ | |
33 | * | |
34 | */ | |
35 | ||
36 | /** | |
37 | * Files required | |
38 | */ | |
39 | class CRM_Campaign_Form_Search_Survey extends CRM_Core_Form { | |
40 | ||
41 | /** | |
42 | * Are we forced to run a search | |
43 | * | |
44 | * @var int | |
45 | * @access protected | |
46 | */ | |
47 | protected $_force; | |
48 | ||
49 | /** | |
50 | * processing needed for buildForm and later | |
51 | * | |
52 | * @return void | |
53 | * @access public | |
54 | */ function preProcess() { | |
55 | $this->_search = CRM_Utils_Array::value('search', $_GET); | |
56 | $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE); | |
57 | $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'survey'); | |
58 | ||
59 | //when we do load tab, lets load the default objects. | |
60 | $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE); | |
61 | $this->assign('searchParams', json_encode($this->get('searchParams'))); | |
62 | $this->assign('buildSelector', $this->_search); | |
63 | $this->assign('searchFor', $this->_searchTab); | |
64 | $this->assign('surveyTypes', json_encode($this->get('surveyTypes'))); | |
65 | $this->assign('surveyCampaigns', json_encode($this->get('surveyCampaigns'))); | |
66 | $this->assign('suppressForm', TRUE); | |
67 | ||
68 | //set the form title. | |
69 | CRM_Utils_System::setTitle(ts('Find Survey')); | |
70 | } | |
71 | ||
72 | /** | |
73 | * Build the form | |
74 | * | |
75 | * @access public | |
76 | * | |
77 | * @return void | |
78 | */ | |
79 | function buildQuickForm() { | |
80 | if ($this->_search) { | |
81 | return; | |
82 | } | |
83 | ||
84 | $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey'); | |
85 | $this->add('text', 'survey_title', ts('Title'), $attributes['title']); | |
86 | ||
87 | //activity Type id | |
88 | $surveyTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType(); | |
89 | $this->add('select', 'activity_type_id', | |
90 | ts('Activity Type'), array( | |
91 | '' => ts('- select -')) + $surveyTypes | |
92 | ); | |
93 | $this->set('surveyTypes', $surveyTypes); | |
94 | $this->assign('surveyTypes', json_encode($surveyTypes)); | |
95 | ||
96 | //campaigns | |
97 | $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE); | |
98 | $this->add('select', 'survey_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns); | |
99 | $this->set('surveyCampaigns', $campaigns); | |
100 | $this->assign('surveyCampaigns', json_encode($campaigns)); | |
101 | ||
102 | //build the array of all search params. | |
103 | $this->_searchParams = array(); | |
104 | foreach ($this->_elements as $element) { | |
105 | $name = $element->_attributes['name']; | |
106 | $label = $element->_label; | |
107 | if ($name == 'qfKey') { | |
108 | continue; | |
109 | } | |
110 | $this->_searchParams[$name] = ($label) ? $label : $name; | |
111 | } | |
112 | $this->set('searchParams', $this->_searchParams); | |
113 | $this->assign('searchParams', json_encode($this->_searchParams)); | |
114 | } | |
115 | } | |
116 |