phpcs - Fix error, "Expected 1 newline at end of file; XXX found".
[civicrm-core.git] / CRM / Campaign / Form / Search / Survey.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
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 */
46 protected $_force;
47
48 /**
49 * Processing needed for buildForm and later
50 *
51 * @return void
52 */ function preProcess() {
53 $this->_search = CRM_Utils_Array::value('search', $_GET);
54 $this->_force = CRM_Utils_Request::retrieve('force', 'Boolean', $this, FALSE, FALSE);
55 $this->_searchTab = CRM_Utils_Request::retrieve('type', 'String', $this, FALSE, 'survey');
56
57 //when we do load tab, lets load the default objects.
58 $this->assign('force', ($this->_force || $this->_searchTab) ? TRUE : FALSE);
59 $this->assign('searchParams', json_encode($this->get('searchParams')));
60 $this->assign('buildSelector', $this->_search);
61 $this->assign('searchFor', $this->_searchTab);
62 $this->assign('surveyTypes', json_encode($this->get('surveyTypes')));
63 $this->assign('surveyCampaigns', json_encode($this->get('surveyCampaigns')));
64 $this->assign('suppressForm', TRUE);
65
66 //set the form title.
67 CRM_Utils_System::setTitle(ts('Find Survey'));
68 }
69
70 /**
71 * Build the form object
72 *
73 *
74 * @return void
75 */
76 public function buildQuickForm() {
77 if ($this->_search) {
78 return;
79 }
80
81 $attributes = CRM_Core_DAO::getAttribute('CRM_Campaign_DAO_Survey');
82 $this->add('text', 'survey_title', ts('Title'), $attributes['title']);
83
84 //activity Type id
85 $surveyTypes = CRM_Campaign_BAO_Survey::getSurveyActivityType();
86 $this->add('select', 'activity_type_id',
87 ts('Activity Type'), array(
88 '' => ts('- select -')) + $surveyTypes
89 );
90 $this->set('surveyTypes', $surveyTypes);
91 $this->assign('surveyTypes', json_encode($surveyTypes));
92
93 //campaigns
94 $campaigns = CRM_Campaign_BAO_Campaign::getCampaigns(NULL, NULL, FALSE, FALSE, FALSE, TRUE);
95 $this->add('select', 'survey_campaign_id', ts('Campaign'), array('' => ts('- select -')) + $campaigns);
96 $this->set('surveyCampaigns', $campaigns);
97 $this->assign('surveyCampaigns', json_encode($campaigns));
98
99 //build the array of all search params.
100 $this->_searchParams = array();
101 foreach ($this->_elements as $element) {
102 $name = $element->_attributes['name'];
103 $label = $element->_label;
104 if ($name == 'qfKey') {
105 continue;
106 }
107 $this->_searchParams[$name] = ($label) ? $label : $name;
108 }
109 $this->set('searchParams', $this->_searchParams);
110 $this->assign('searchParams', json_encode($this->_searchParams));
111 }
112 }