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 | * Page for displaying list of Gender | |
38 | */ | |
39 | class CRM_Admin_Page_Options 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 | static $_gName = NULL; | |
56 | ||
57 | /** | |
58 | * The option group name in display format (capitalized, without underscores...etc) | |
59 | * | |
60 | * @var array | |
61 | * @static | |
62 | */ | |
63 | static $_GName = NULL; | |
64 | ||
65 | /** | |
66 | * The option group id | |
67 | * | |
68 | * @var array | |
69 | * @static | |
70 | */ | |
71 | static $_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 | if (!self::$_gName) { | |
82 | self::$_gName = CRM_Utils_Request::retrieve('group', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET'); | |
83 | } | |
84 | if (self::$_gName) { | |
85 | $this->set('gName', self::$_gName); | |
86 | } | |
87 | else { | |
88 | self::$_gName = $this->get('gName'); | |
89 | } | |
90 | if (self::$_gName) { | |
91 | self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name'); | |
92 | } | |
93 | else { | |
94 | CRM_Core_Error::fatal(); | |
95 | } | |
96 | ||
97 | self::$_GName = ucwords(str_replace('_', ' ', self::$_gName)); | |
98 | ||
99 | $this->assign('gName', self::$_gName); | |
100 | $this->assign('GName', self::$_GName); | |
101 | ||
102 | if (self::$_gName == 'acl_role') { | |
103 | CRM_Utils_System::setTitle(ts('Manage ACL Roles')); | |
104 | // set breadcrumb to append to admin/access | |
105 | $breadCrumb = array(array('title' => ts('Access Control'), | |
106 | 'url' => CRM_Utils_System::url('civicrm/admin/access', | |
107 | 'reset=1' | |
108 | ), | |
109 | )); | |
110 | CRM_Utils_System::appendBreadCrumb($breadCrumb); | |
111 | } | |
112 | else { | |
113 | CRM_Utils_System::setTitle(ts("%1 Options", array(1 => self::$_GName))); | |
114 | } | |
115 | if (in_array(self::$_gName, | |
116 | array( | |
117 | 'from_email_address', 'email_greeting', | |
118 | 'postal_greeting', 'addressee', | |
d4311a7a | 119 | 'communication_style', |
6a488035 | 120 | 'case_status', 'encounter_medium', |
d96cf288 | 121 | 'case_type', 'payment_instrument' |
6a488035 TO |
122 | ) |
123 | )) { | |
124 | $this->assign('showIsDefault', TRUE); | |
125 | } | |
126 | if (self::$_gName == 'participant_status') { | |
127 | $this->assign('showCounted', TRUE); | |
128 | $this->assign('showVisibility', TRUE); | |
129 | } | |
130 | ||
131 | if (self::$_gName == 'participant_role') { | |
132 | $this->assign('showCounted', TRUE); | |
133 | } | |
134 | $config = CRM_Core_Config::singleton(); | |
135 | if (self::$_gName == 'activity_type') { | |
136 | $this->assign('showComponent', TRUE); | |
137 | } | |
138 | } | |
139 | ||
140 | /** | |
141 | * Get BAO Name | |
142 | * | |
143 | * @return string Classname of BAO. | |
144 | */ | |
145 | function getBAOName() { | |
146 | return 'CRM_Core_BAO_OptionValue'; | |
147 | } | |
148 | ||
149 | /** | |
150 | * Get action Links | |
151 | * | |
152 | * @return array (reference) of action links | |
153 | */ | |
154 | function &links() { | |
155 | if (!(self::$_links)) { | |
156 | self::$_links = array( | |
157 | CRM_Core_Action::UPDATE => array( | |
158 | 'name' => ts('Edit'), | |
159 | 'url' => 'civicrm/admin/options/' . self::$_gName, | |
160 | 'qs' => 'group=' . self::$_gName . '&action=update&id=%%id%%&reset=1', | |
161 | 'title' => ts('Edit %1', array(1 => self::$_gName)), | |
162 | ), | |
163 | CRM_Core_Action::DISABLE => array( | |
164 | 'name' => ts('Disable'), | |
5e7dd082 | 165 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
166 | 'title' => ts('Disable %1', array(1 => self::$_gName)), |
167 | ), | |
168 | CRM_Core_Action::ENABLE => array( | |
169 | 'name' => ts('Enable'), | |
5e7dd082 | 170 | 'ref' => 'crm-enable-disable', |
6a488035 TO |
171 | 'title' => ts('Enable %1', array(1 => self::$_gName)), |
172 | ), | |
173 | CRM_Core_Action::DELETE => array( | |
174 | 'name' => ts('Delete'), | |
175 | 'url' => 'civicrm/admin/options/' . self::$_gName, | |
176 | 'qs' => 'group=' . self::$_gName . '&action=delete&id=%%id%%', | |
177 | 'title' => ts('Delete %1 Type', array(1 => self::$_gName)), | |
178 | ), | |
179 | ); | |
180 | ||
181 | if (self::$_gName == 'custom_search') { | |
182 | $runLink = array( | |
183 | CRM_Core_Action::FOLLOWUP => array( | |
184 | 'name' => ts('Run'), | |
185 | 'url' => 'civicrm/contact/search/custom', | |
186 | 'qs' => 'reset=1&csid=%%value%%', | |
187 | 'title' => ts('Run %1', array(1 => self::$_gName)), | |
188 | )); | |
189 | self::$_links = $runLink + self::$_links; | |
190 | } | |
191 | } | |
192 | return self::$_links; | |
193 | } | |
194 | ||
195 | /** | |
196 | * Run the basic page (run essentially starts execution for that page). | |
197 | * | |
198 | * @return void | |
199 | */ | |
200 | function run() { | |
201 | $this->preProcess(); | |
202 | return parent::run(); | |
203 | } | |
204 | ||
205 | /** | |
206 | * Browse all options | |
207 | * | |
208 | * | |
209 | * @return void | |
210 | * @access public | |
211 | * @static | |
212 | */ | |
213 | function browse() { | |
214 | ||
215 | $groupParams = array('name' => self::$_gName); | |
216 | $optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight'); | |
217 | $gName = self::$_gName; | |
218 | $returnURL = CRM_Utils_System::url("civicrm/admin/options/$gName", | |
219 | "reset=1&group=$gName" | |
220 | ); | |
221 | $filter = "option_group_id = " . self::$_gId; | |
222 | CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', | |
223 | 'id', $returnURL, $filter | |
224 | ); | |
225 | ||
226 | // retrieve financial account name for the payment instrument page | |
227 | if ($gName = "payment_instrument") { | |
228 | foreach ($optionValue as $key => $option) { | |
6eafcb19 CW |
229 | $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value'); |
230 | } | |
6a488035 | 231 | } |
6eafcb19 | 232 | $this->assign('includeWysiwygEditor', TRUE); |
6a488035 TO |
233 | $this->assign('rows', $optionValue); |
234 | } | |
235 | ||
236 | /** | |
237 | * Get name of edit form | |
238 | * | |
239 | * @return string Classname of edit form. | |
240 | */ | |
241 | function editForm() { | |
242 | return 'CRM_Admin_Form_Options'; | |
243 | } | |
244 | ||
245 | /** | |
246 | * Get edit form name | |
247 | * | |
248 | * @return string name of this page. | |
249 | */ | |
250 | function editName() { | |
251 | return self::$_GName; | |
252 | } | |
253 | ||
254 | /** | |
255 | * Get user context. | |
256 | * | |
257 | * @return string user context. | |
258 | */ | |
259 | function userContext($mode = NULL) { | |
260 | return 'civicrm/admin/options/' . self::$_gName; | |
261 | } | |
262 | ||
263 | /** | |
264 | * function to get userContext params | |
265 | * | |
266 | * @param int $mode mode that we are in | |
267 | * | |
268 | * @return string | |
269 | * @access public | |
270 | */ | |
271 | function userContextParams($mode = NULL) { | |
272 | return 'group=' . self::$_gName . '&reset=1&action=browse'; | |
273 | } | |
274 | } | |
275 |