* @var array
* @static
*/
- static $_GName = NULL;
+ static $_gLabel = NULL;
/**
* The option group id
static $_gId = NULL;
/**
- * Obtains the group name from url and sets the title.
+ * Obtains the group name from url string or id from $_GET['gid'].
+ * Sets the title.
*
* @return void
* @access public
*
*/
function preProcess() {
- if (!self::$_gName) {
- self::$_gName = CRM_Utils_Request::retrieve('group', 'String', CRM_Core_DAO::$_nullObject, FALSE, NULL, 'GET');
+ if (!self::$_gName && !empty($this->urlPath[3])) {
+ self::$_gName = $this->urlPath[3];
}
- if (self::$_gName) {
- $this->set('gName', self::$_gName);
+ // If an id arg is passed instead of a group name in the path
+ elseif (!self::$_gName && !empty($_GET['gid'])) {
+ self::$_gId = $_GET['gid'];
+ self::$_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gId, 'name');
+ $breadCrumb = array(
+ 'title' => ts('Option Groups'),
+ 'url' => CRM_Utils_System::url('civicrm/admin/options', 'reset=1'),
+ );
+ CRM_Utils_System::appendBreadCrumb(array($breadCrumb));
}
- else {
+ if (!self::$_gName) {
self::$_gName = $this->get('gName');
}
- if (self::$_gName) {
- self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name');
+ // If we don't have a group we will browse all groups
+ if (!self::$_gName) {
+ return;
}
- else {
- CRM_Core_Error::fatal();
+ $this->set('gName', self::$_gName);
+ if (!self::$_gId) {
+ self::$_gId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gName, 'id', 'name');
}
- self::$_GName = ucwords(str_replace('_', ' ', self::$_gName));
+ self::$_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::$_gId, 'title');
+ if (!self::$_gLabel) {
+ self::$_gLabel = ts('Option');
+ }
$this->assign('gName', self::$_gName);
- $this->assign('GName', self::$_GName);
+ $this->assign('gLabel', self::$_gLabel);
if (self::$_gName == 'acl_role') {
CRM_Utils_System::setTitle(ts('Manage ACL Roles'));
CRM_Utils_System::appendBreadCrumb($breadCrumb);
}
else {
- CRM_Utils_System::setTitle(ts("%1 Options", array(1 => self::$_GName)));
+ CRM_Utils_System::setTitle(ts("%1 Options", array(1 => self::$_gLabel)));
}
if (in_array(self::$_gName,
array(
'from_email_address', 'email_greeting',
'postal_greeting', 'addressee',
+ 'communication_style',
'case_status', 'encounter_medium',
- 'case_type',
+ 'case_type', 'payment_instrument',
+ 'soft_credit_type'
)
)) {
$this->assign('showIsDefault', TRUE);
* @return string Classname of BAO.
*/
function getBAOName() {
- return 'CRM_Core_BAO_OptionValue';
+ return self::$_gName ? 'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup';
}
/**
CRM_Core_Action::UPDATE => array(
'name' => ts('Edit'),
'url' => 'civicrm/admin/options/' . self::$_gName,
- 'qs' => 'group=' . self::$_gName . '&action=update&id=%%id%%&reset=1',
+ 'qs' => 'action=update&id=%%id%%&reset=1',
'title' => ts('Edit %1', array(1 => self::$_gName)),
),
CRM_Core_Action::DISABLE => array(
'name' => ts('Disable'),
- 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_OptionValue' . '\',\'' . 'enable-disable' . '\' );"',
- 'ref' => 'disable-action',
+ 'ref' => 'crm-enable-disable',
'title' => ts('Disable %1', array(1 => self::$_gName)),
),
CRM_Core_Action::ENABLE => array(
'name' => ts('Enable'),
- 'extra' => 'onclick = "enableDisable( %%id%%,\'' . 'CRM_Core_BAO_OptionValue' . '\',\'' . 'disable-enable' . '\' );"',
- 'ref' => 'enable-action',
+ 'ref' => 'crm-enable-disable',
'title' => ts('Enable %1', array(1 => self::$_gName)),
),
CRM_Core_Action::DELETE => array(
'name' => ts('Delete'),
'url' => 'civicrm/admin/options/' . self::$_gName,
- 'qs' => 'group=' . self::$_gName . '&action=delete&id=%%id%%',
+ 'qs' => 'action=delete&id=%%id%%',
'title' => ts('Delete %1 Type', array(1 => self::$_gName)),
),
);
* @static
*/
function browse() {
-
+ if (!self::$_gName) {
+ return parent::browse();
+ }
+ CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
$groupParams = array('name' => self::$_gName);
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
$gName = self::$_gName;
// retrieve financial account name for the payment instrument page
if ($gName = "payment_instrument") {
foreach ($optionValue as $key => $option) {
- $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value'); }
+ $optionValue[$key]['financial_account'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($key, 'civicrm_option_value');
+ }
}
-
+ $this->assign('includeWysiwygEditor', TRUE);
$this->assign('rows', $optionValue);
}
* @return string Classname of edit form.
*/
function editForm() {
- return 'CRM_Admin_Form_Options';
+ return self::$_gName ? 'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup';
}
/**
* @return string name of this page.
*/
function editName() {
- return self::$_GName;
+ return self::$_gLabel;
}
/**
* @return string user context.
*/
function userContext($mode = NULL) {
- return 'civicrm/admin/options/' . self::$_gName;
- }
-
- /**
- * function to get userContext params
- *
- * @param int $mode mode that we are in
- *
- * @return string
- * @access public
- */
- function userContextParams($mode = NULL) {
- return 'group=' . self::$_gName . '&reset=1&action=browse';
+ return 'civicrm/admin/options' . (self::$_gName ? '/' . self::$_gName : '');
}
}