3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * Page for displaying list of Gender.
21 class CRM_Admin_Page_Options
extends CRM_Core_Page_Basic
{
23 public $useLivePageJS = TRUE;
26 * The action links that we need to display for the browse screen.
30 public static $_links = NULL;
33 * The option group name.
37 public static $_gName = NULL;
40 * The option group name in display format (capitalized, without underscores...etc)
44 public static $_gLabel = NULL;
47 * The option group id.
51 public static $_gId = NULL;
54 * A boolean determining if you can add options to this group in the GUI.
58 public static $_isLocked = FALSE;
61 * Obtains the group name from url string or id from $_GET['gid'].
65 public function preProcess() {
66 if (!self
::$_gName && !empty($this->urlPath
[3])) {
67 self
::$_gName = $this->urlPath
[3];
68 self
::$_isLocked = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gName, 'is_locked', 'name');
70 // If an id arg is passed instead of a group name in the path
71 elseif (!self
::$_gName && !empty($_GET['gid'])) {
72 self
::$_gId = $_GET['gid'];
73 self
::$_gName = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'name');
74 self
::$_isLocked = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'is_locked');
76 'title' => ts('Option Groups'),
77 'url' => CRM_Utils_System
::url('civicrm/admin/options', 'reset=1'),
79 CRM_Utils_System
::appendBreadCrumb(array($breadCrumb));
82 self
::$_gName = $this->get('gName');
84 // If we don't have a group we will browse all groups
88 $this->set('gName', self
::$_gName);
90 self
::$_gId = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gName, 'id', 'name');
93 self
::$_gLabel = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_OptionGroup', self
::$_gId, 'title');
94 if (!self
::$_gLabel) {
95 self
::$_gLabel = ts('Option');
98 $this->assign('gName', self
::$_gName);
99 $this->assign('gLabel', self
::$_gLabel);
101 if (self
::$_gName == 'acl_role') {
102 CRM_Utils_System
::setTitle(ts('Manage ACL Roles'));
103 // set breadcrumb to append to admin/access
106 'title' => ts('Access Control'),
107 'url' => CRM_Utils_System
::url('civicrm/admin/access',
112 CRM_Utils_System
::appendBreadCrumb($breadCrumb);
115 CRM_Utils_System
::setTitle(ts("%1 Options", array(1 => self
::$_gLabel)));
117 if (in_array(self
::$_gName,
119 'from_email_address',
123 'communication_style',
127 'payment_instrument',
132 $this->assign('showIsDefault', TRUE);
135 if (self
::$_gName == 'participant_role') {
136 $this->assign('showCounted', TRUE);
138 $this->assign('isLocked', self
::$_isLocked);
139 $this->assign('allowLoggedIn', Civi
::settings()->get('allow_mail_from_logged_in_contact'));
140 $config = CRM_Core_Config
::singleton();
141 if (self
::$_gName == 'activity_type') {
142 $this->assign('showComponent', TRUE);
152 public function getBAOName() {
153 return self
::$_gName ?
'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup';
160 * (reference) of action links
162 public function &links() {
163 if (!(self
::$_links)) {
164 self
::$_links = array(
165 CRM_Core_Action
::UPDATE
=> array(
166 'name' => ts('Edit'),
167 'url' => 'civicrm/admin/options/' . self
::$_gName,
168 'qs' => 'action=update&id=%%id%%&reset=1',
169 'title' => ts('Edit %1', array(1 => self
::$_gName)),
171 CRM_Core_Action
::DISABLE
=> array(
172 'name' => ts('Disable'),
173 'ref' => 'crm-enable-disable',
174 'title' => ts('Disable %1', array(1 => self
::$_gName)),
176 CRM_Core_Action
::ENABLE
=> array(
177 'name' => ts('Enable'),
178 'ref' => 'crm-enable-disable',
179 'title' => ts('Enable %1', array(1 => self
::$_gName)),
181 CRM_Core_Action
::DELETE
=> array(
182 'name' => ts('Delete'),
183 'url' => 'civicrm/admin/options/' . self
::$_gName,
184 'qs' => 'action=delete&id=%%id%%',
185 'title' => ts('Delete %1 Type', array(1 => self
::$_gName)),
189 if (self
::$_gName == 'custom_search') {
191 CRM_Core_Action
::FOLLOWUP
=> array(
193 'url' => 'civicrm/contact/search/custom',
194 'qs' => 'reset=1&csid=%%value%%',
195 'title' => ts('Run %1', array(1 => self
::$_gName)),
196 'class' => 'no-popup',
199 self
::$_links = $runLink + self
::$_links;
202 return self
::$_links;
206 * Run the basic page (run essentially starts execution for that page).
208 public function run() {
210 return parent
::run();
214 * Browse all options.
216 public function browse() {
217 if (!self
::$_gName) {
218 return parent
::browse();
220 $groupParams = array('name' => self
::$_gName);
221 $optionValue = CRM_Core_OptionValue
::getRows($groupParams, $this->links(), 'component_id,weight');
222 $gName = self
::$_gName;
223 $returnURL = CRM_Utils_System
::url("civicrm/admin/options/$gName",
224 "reset=1&group=$gName"
226 $filter = "option_group_id = " . self
::$_gId;
227 CRM_Utils_Weight
::addOrder($optionValue, 'CRM_Core_DAO_OptionValue',
228 'id', $returnURL, $filter
231 // retrieve financial account name for the payment method page
232 if ($gName = "payment_instrument") {
233 foreach ($optionValue as $key => $option) {
234 $optionValue[$key]['financial_account'] = CRM_Contribute_PseudoConstant
::getRelationalFinancialAccount($key, NULL, 'civicrm_option_value', 'financial_account_id.name');
237 $this->assign('rows', $optionValue);
241 * Get name of edit form.
244 * Classname of edit form.
246 public function editForm() {
247 return self
::$_gName ?
'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup';
251 * Get edit form name.
256 public function editName() {
257 return self
::$_gLabel;
268 public function userContext($mode = NULL) {
269 return 'civicrm/admin/options' . (self
::$_gName ?
'/' . self
::$_gName : '');