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