3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2014
37 * Page for displaying list of Gender
39 class CRM_Admin_Page_Options
extends CRM_Core_Page_Basic
{
41 public $useLivePageJS = TRUE;
44 * The action links that we need to display for the browse screen
48 static $_links = NULL;
51 * The option group name
55 static $_gName = NULL;
58 * The option group name in display format (capitalized, without underscores...etc)
62 static $_gLabel = NULL;
72 * A boolean determining if you can add options to this group in the GUI
76 static $_isLocked = FALSE;
79 * Obtains the group name from url string or id from $_GET['gid'].
84 public function preProcess() {
85 if (!self
::$_gName && !empty($this->urlPath
[3])) {
86 self
::$_gName = $this->urlPath
[3];
88 // If an id arg is passed instead of a group name in the path
89 elseif (!self
::$_gName && !empty($_GET['gid'])) {
90 self
::$_gId = $_GET['gid'];
91 self
::$_gName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'name');
92 self
::$_isLocked = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'is_locked');
94 'title' => ts('Option Groups'),
95 'url' => CRM_Utils_System
::url('civicrm/admin/options', 'reset=1'),
97 CRM_Utils_System
::appendBreadCrumb(array($breadCrumb));
100 self
::$_gName = $this->get('gName');
102 // If we don't have a group we will browse all groups
103 if (!self
::$_gName) {
106 $this->set('gName', self
::$_gName);
108 self
::$_gId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gName, 'id', 'name');
111 self
::$_gLabel = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'title');
112 if (!self
::$_gLabel) {
113 self
::$_gLabel = ts('Option');
116 $this->assign('gName', self
::$_gName);
117 $this->assign('gLabel', self
::$_gLabel);
119 if (self
::$_gName == 'acl_role') {
120 CRM_Utils_System
::setTitle(ts('Manage ACL Roles'));
121 // set breadcrumb to append to admin/access
124 'title' => ts('Access Control'),
125 'url' => CRM_Utils_System
::url('civicrm/admin/access',
130 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
133 CRM_Utils_System
::setTitle(ts("%1 Options", array(1 => self
::$_gLabel)));
135 if (in_array(self
::$_gName,
137 'from_email_address',
141 'communication_style',
145 'payment_instrument',
150 $this->assign('showIsDefault', TRUE);
153 if (self
::$_gName == 'participant_role') {
154 $this->assign('showCounted', TRUE);
156 $this->assign('isLocked', self
::$_isLocked);
157 $config = CRM_Core_Config
::singleton();
158 if (self
::$_gName == 'activity_type') {
159 $this->assign('showComponent', TRUE);
169 public function getBAOName() {
170 return self
::$_gName ?
'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup';
177 * (reference) of action links
179 public function &links() {
180 if (!(self
::$_links)) {
181 self
::$_links = array(
182 CRM_Core_Action
::UPDATE
=> array(
183 'name' => ts('Edit'),
184 'url' => 'civicrm/admin/options/' . self
::$_gName,
185 'qs' => 'action=update&id=%%id%%&reset=1',
186 'title' => ts('Edit %1', array(1 => self
::$_gName)),
188 CRM_Core_Action
::DISABLE
=> array(
189 'name' => ts('Disable'),
190 'ref' => 'crm-enable-disable',
191 'title' => ts('Disable %1', array(1 => self
::$_gName)),
193 CRM_Core_Action
::ENABLE
=> array(
194 'name' => ts('Enable'),
195 'ref' => 'crm-enable-disable',
196 'title' => ts('Enable %1', array(1 => self
::$_gName)),
198 CRM_Core_Action
::DELETE
=> array(
199 'name' => ts('Delete'),
200 'url' => 'civicrm/admin/options/' . self
::$_gName,
201 'qs' => 'action=delete&id=%%id%%',
202 'title' => ts('Delete %1 Type', array(1 => self
::$_gName)),
206 if (self
::$_gName == 'custom_search') {
208 CRM_Core_Action
::FOLLOWUP
=> array(
210 'url' => 'civicrm/contact/search/custom',
211 'qs' => 'reset=1&csid=%%value%%',
212 'title' => ts('Run %1', array(1 => self
::$_gName)),
215 self
::$_links = $runLink + self
::$_links;
218 return self
::$_links;
222 * Run the basic page (run essentially starts execution for that page).
226 public function run() {
228 return parent
::run();
237 public function browse() {
238 if (!self
::$_gName) {
239 return parent
::browse();
241 $groupParams = array('name' => self
::$_gName);
242 $optionValue = CRM_Core_OptionValue
::getRows($groupParams, $this->links(), 'component_id,weight');
243 $gName = self
::$_gName;
244 $returnURL = CRM_Utils_System
::url("civicrm/admin/options/$gName",
245 "reset=1&group=$gName"
247 $filter = "option_group_id = " . self
::$_gId;
248 CRM_Utils_Weight
::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
249 'id', $returnURL, $filter
252 // retrieve financial account name for the payment instrument page
253 if ($gName = "payment_instrument") {
254 foreach ($optionValue as $key => $option) {
255 $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount
::getFinancialAccount($key, 'civicrm_option_value');
258 $this->assign('rows', $optionValue);
262 * Get name of edit form
265 * Classname of edit form.
267 public function editForm() {
268 return self
::$_gName ?
'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup';
277 public function editName() {
278 return self
::$_gLabel;
289 public function userContext($mode = NULL) {
290 return 'civicrm/admin/options' . (self
::$_gName ?
'/' . self
::$_gName : '');