3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * Page for displaying list of Gender
39 class CRM_Admin_Page_Options
extends CRM_Core_Page_Basic
{
42 * The action links that we need to display for the browse screen
47 static $_links = NULL;
50 * The option group name
55 static $_gName = NULL;
58 * The option group name in display format (capitalized, without underscores...etc)
63 static $_gLabel = NULL;
74 * Obtains the group name from url string or id from $_GET['gid'].
81 function preProcess() {
82 if (!self
::$_gName && !empty($this->urlPath
[3])) {
83 self
::$_gName = $this->urlPath
[3];
85 // If an id arg is passed instead of a group name in the path
86 elseif (!self
::$_gName && !empty($_GET['gid'])) {
87 self
::$_gId = $_GET['gid'];
88 self
::$_gName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'name');
90 'title' => ts('Option Groups'),
91 'url' => CRM_Utils_System
::url('civicrm/admin/options', 'reset=1'),
93 CRM_Utils_System
::appendBreadCrumb(array($breadCrumb));
96 self
::$_gName = $this->get('gName');
98 // If we don't have a group we will browse all groups
102 $this->set('gName', self
::$_gName);
104 self
::$_gId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gName, 'id', 'name');
107 self
::$_gLabel = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'title');
108 if (!self
::$_gLabel) {
109 self
::$_gLabel = ts('Option');
112 $this->assign('gName', self
::$_gName);
113 $this->assign('gLabel', self
::$_gLabel);
115 if (self
::$_gName == 'acl_role') {
116 CRM_Utils_System
::setTitle(ts('Manage ACL Roles'));
117 // set breadcrumb to append to admin/access
118 $breadCrumb = array(array('title' => ts('Access Control'),
119 'url' => CRM_Utils_System
::url('civicrm/admin/access',
123 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
126 CRM_Utils_System
::setTitle(ts("%1 Options", array(1 => self
::$_gLabel)));
128 if (in_array(self
::$_gName,
130 'from_email_address', 'email_greeting',
131 'postal_greeting', 'addressee',
132 'communication_style',
133 'case_status', 'encounter_medium',
134 'case_type', 'payment_instrument'
137 $this->assign('showIsDefault', TRUE);
139 if (self
::$_gName == 'participant_status') {
140 $this->assign('showCounted', TRUE);
141 $this->assign('showVisibility', TRUE);
144 if (self
::$_gName == 'participant_role') {
145 $this->assign('showCounted', TRUE);
147 $config = CRM_Core_Config
::singleton();
148 if (self
::$_gName == 'activity_type') {
149 $this->assign('showComponent', TRUE);
156 * @return string Classname of BAO.
158 function getBAOName() {
159 return self
::$_gName ?
'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup';
165 * @return array (reference) of action links
168 if (!(self
::$_links)) {
169 self
::$_links = array(
170 CRM_Core_Action
::UPDATE
=> array(
171 'name' => ts('Edit'),
172 'url' => 'civicrm/admin/options',
173 'qs' => 'group=' . self
::$_gName . '&action=update&id=%%id%%&reset=1',
174 'title' => ts('Edit %1', array(1 => self
::$_gName)),
176 CRM_Core_Action
::DISABLE
=> array(
177 'name' => ts('Disable'),
178 'ref' => 'crm-enable-disable',
179 'title' => ts('Disable %1', array(1 => self
::$_gName)),
181 CRM_Core_Action
::ENABLE
=> array(
182 'name' => ts('Enable'),
183 'ref' => 'crm-enable-disable',
184 'title' => ts('Enable %1', array(1 => self
::$_gName)),
186 CRM_Core_Action
::DELETE
=> array(
187 'name' => ts('Delete'),
188 'url' => 'civicrm/admin/options',
189 'qs' => 'group=' . self
::$_gName . '&action=delete&id=%%id%%',
190 'title' => ts('Delete %1 Type', array(1 => self
::$_gName)),
194 if (self
::$_gName == 'custom_search') {
196 CRM_Core_Action
::FOLLOWUP
=> array(
198 'url' => 'civicrm/contact/search/custom',
199 'qs' => 'reset=1&csid=%%value%%',
200 'title' => ts('Run %1', array(1 => self
::$_gName)),
202 self
::$_links = $runLink + self
::$_links;
205 return self
::$_links;
209 * Run the basic page (run essentially starts execution for that page).
215 return parent
::run();
227 if (!self
::$_gName) {
228 return parent
::browse();
230 CRM_Core_Resources
::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
231 $groupParams = array('name' => self
::$_gName);
232 $optionValue = CRM_Core_OptionValue
::getRows($groupParams, $this->links(), 'component_id,weight');
233 $gName = self
::$_gName;
234 $returnURL = CRM_Utils_System
::url("civicrm/admin/options/$gName",
235 "reset=1&group=$gName"
237 $filter = "option_group_id = " . self
::$_gId;
238 CRM_Utils_Weight
::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
239 'id', $returnURL, $filter
242 // retrieve financial account name for the payment instrument page
243 if ($gName = "payment_instrument") {
244 foreach ($optionValue as $key => $option) {
245 $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount
::getFinancialAccount($key, 'civicrm_option_value');
248 $this->assign('includeWysiwygEditor', TRUE);
249 $this->assign('rows', $optionValue);
253 * Get name of edit form
255 * @return string Classname of edit form.
257 function editForm() {
258 return self
::$_gName ?
'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup';
264 * @return string name of this page.
266 function editName() {
267 return self
::$_gLabel;
273 * @return string user context.
275 function userContext($mode = NULL) {
276 return 'civicrm/admin/options' . (self
::$_gName ?
'/' . self
::$_gName : '');