Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-10-23-19-26-23
[civicrm-core.git] / CRM / Campaign / Page / SurveyType.php
CommitLineData
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 * Page for displaying list of Gender
38 */
39class CRM_Campaign_Page_SurveyType extends CRM_Core_Page_Basic {
40
41 /**
42 * The action links that we need to display for the browse screen
43 *
44 * @var array
45 * @static
46 */
47 static $_links = NULL;
48
49 /**
50 * The option group name
51 *
52 * @var array
53 * @static
54 */
55 protected $_gName;
56
57 /**
58 * The option group name in display format (capitalized, without underscores...etc)
59 *
60 * @var array
61 * @static
62 */
63 protected $_GName;
64
65 /**
66 * The option group id
67 *
68 * @var array
69 * @static
70 */
71 protected $_gid = NULL;
72
73 /**
74 * Obtains the group name from url and sets the title.
75 *
76 * @return void
77 * @access public
78 *
79 */
80 function preProcess() {
81 $this->_gName = 'activity_type';
82
83 $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gName, 'id', 'name');
84
85 $this->_GName = 'Survey Type';
86
87 $this->assign('gName', $this->_gName);
88 $this->assign('GName', $this->_GName);
89
90 CRM_Utils_System::setTitle(ts('%1 Options', array(1 => $this->_GName)));
91
92 $this->assign('addSurveyType', CRM_Utils_System::url("civicrm/admin/campaign/surveyType", 'reset=1&action=add'));
93 }
94
95 /**
96 * Get BAO Name
97 *
98 * @return string Classname of BAO.
99 */
100 function getBAOName() {
101 return 'CRM_Core_BAO_OptionValue';
102 }
103
104 /**
105 * Get action Links
106 *
107 * @return array (reference) of action links
108 */
109 function &links() {
110 if (!(self::$_links)) {
111 self::$_links = array(
112 CRM_Core_Action::UPDATE => array(
113 'name' => ts('Edit'),
114 'url' => 'civicrm/admin/campaign/surveyType',
115 'qs' => 'action=update&id=%%id%%&reset=1',
116 'title' => ts('Edit %1', array(1 => $this->_gName)),
117 ),
118 CRM_Core_Action::DISABLE => array(
119 'name' => ts('Disable'),
120 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_OptionValue' . '\',\'' . 'enable-disable' . '\' );"',
121 'ref' => 'disable-action',
122 'title' => ts('Disable %1', array(1 => $this->_gName)),
123 ),
124 CRM_Core_Action::ENABLE => array(
125 'name' => ts('Enable'),
126 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_OptionValue' . '\',\'' . 'disable-enable' . '\' );"',
127 'ref' => 'enable-action',
128 'title' => ts('Enable %1', array(1 => $this->_gName)),
129 ),
130 CRM_Core_Action::DELETE => array(
131 'name' => ts('Delete'),
132 'url' => 'civicrm/admin/campaign/surveyType',
133 'qs' => 'action=delete&id=%%id%%',
134 'title' => ts('Delete %1 Type', array(1 => $this->_gName)),
135 ),
136 );
137 }
138 return self::$_links;
139 }
140
141 /**
142 * Run the basic page (run essentially starts execution for that page).
143 *
144 * @return void
145 */
146 function run() {
147 $this->preProcess();
148 return parent::run();
149 }
150
151 /**
152 * Browse all options
153 *
154 *
155 * @return void
156 * @access public
157 * @static
158 */
159 function browse() {
160
161 $campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
162 $groupParams = array('name' => $this->_gName);
163 $optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
164
165 foreach ($optionValues as $key => $optionValue) {
166 if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) {
167 unset($optionValues[$key]);
168 }
169 }
170
171 $returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType",
172 "reset=1"
173 );
174 $filter = "option_group_id = " . $this->_gid;
175 CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue',
176 'id', $returnURL, $filter
177 );
178 $this->assign('rows', $optionValues);
179 }
180
181 /**
182 * Get name of edit form
183 *
184 * @return string Classname of edit form.
185 */
186 function editForm() {
187 return 'CRM_Campaign_Form_SurveyType';
188 }
189
190 /**
191 * Get edit form name
192 *
193 * @return string name of this page.
194 */
195 function editName() {
196 return $this->_GName;
197 }
198
199 /**
200 * Get user context.
201 *
202 * @return string user context.
203 */
204 function userContext($mode = NULL) {
205 return 'civicrm/admin/campaign/surveyType';
206 }
207
208 /**
209 * function to get userContext params
210 *
211 * @param int $mode mode that we are in
212 *
213 * @return string
214 * @access public
215 */
216 function userContextParams($mode = NULL) {
217 return 'reset=1';
218 }
219}
220