From 6c2473d59d02d2f20f1c7b3b499eac191a8ad59a Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Tue, 4 Feb 2014 10:34:23 -0800 Subject: [PATCH] CRM-13970 - Remove redundant option group page/form --- CRM/Admin/Form/OptionValue.php | 295 ------------------ CRM/Admin/Form/Options.php | 12 +- CRM/Admin/Page/OptionGroup.php | 126 -------- CRM/Admin/Page/OptionValue.php | 246 --------------- CRM/Admin/Page/Options.php | 70 +++-- CRM/Campaign/BAO/Petition.php | 1 - CRM/Campaign/xml/Menu/Campaign.xml | 3 - CRM/Case/xml/Menu/Case.xml | 4 - CRM/Contribute/xml/Menu/Contribute.xml | 5 +- CRM/Core/Invoke.php | 2 +- CRM/Core/xml/Menu/Admin.xml | 25 +- CRM/Core/xml/Menu/Misc.xml | 1 - CRM/Event/xml/Menu/Event.xml | 3 - CRM/Mailing/xml/Menu/Mailing.xml | 3 +- .../Incremental/sql/4.5.alpha1.mysql.tpl | 4 + templates/CRM/Admin/Form/Options.tpl | 4 +- templates/CRM/Admin/Page/OptionGroup.tpl | 2 +- templates/CRM/Admin/Page/Options.tpl | 11 +- .../Form/ContributionPage/Settings.tpl | 2 +- tools/CRM/Auction/xml/Menu/Auction.xml | 1 - 20 files changed, 62 insertions(+), 758 deletions(-) delete mode 100644 CRM/Admin/Form/OptionValue.php delete mode 100644 CRM/Admin/Page/OptionGroup.php delete mode 100644 CRM/Admin/Page/OptionValue.php diff --git a/CRM/Admin/Form/OptionValue.php b/CRM/Admin/Form/OptionValue.php deleted file mode 100644 index bf4290c354..0000000000 --- a/CRM/Admin/Form/OptionValue.php +++ /dev/null @@ -1,295 +0,0 @@ -_gid = CRM_Utils_Request::retrieve('gid', 'Positive', - $this, FALSE, 0 - ); - //get optionGroup name in case of email/postal greeting or addressee, CRM-4575 - if (!empty($this->_gid)) { - $this->_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'name'); - } - $session = CRM_Core_Session::singleton(); - $url = CRM_Utils_System::url('civicrm/admin/optionValue', 'reset=1&action=browse&gid=' . $this->_gid); - $session->replaceUserContext($url); - - $this->assign('id', $this->_id); - - if ($this->_id && in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups)) { - $domainID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'domain_id', 'id'); - if (CRM_Core_Config::domainID() != $domainID) { - CRM_Core_Error::fatal(ts('You do not have permission to access this page')); - } - } - } - - /** - * This function sets the default values for the form. - * the default values are retrieved from the database - * - * @access public - * - * @return void - */ - function setDefaultValues() { - $defaults = array(); - $defaults = parent::setDefaultValues(); - if (empty($defaults['weight'])) { - $query = "SELECT max( `weight` ) as weight FROM `civicrm_option_value` where option_group_id=" . $this->_gid; - $dao = new CRM_Core_DAO(); - $dao->query($query); - $dao->fetch(); - $defaults['weight'] = ($dao->weight + 1); - } - - // CRM-11516 - if ($this->_gName == 'payment_instrument' && $this->_id) { - $defaults['financial_account_id'] = CRM_Financial_BAO_FinancialTypeAccount::getFinancialAccount($this->_id, 'civicrm_option_value', 'financial_account_id'); - } - //setDefault of contact types for email greeting, postal greeting, addressee, CRM-4575 - if (in_array($this->_gName, array( - 'email_greeting', 'postal_greeting', 'addressee'))) { - $defaults['contactOptions'] = CRM_Utils_Array::value('filter', $defaults); - } - return $defaults; - } - - /** - * Function to build the form - * - * @return void - * @access public - */ - public function buildQuickForm() { - //CRM-4575 - $isReserved = FALSE; - if ($this->_id) { - $isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved'); - } - parent::buildQuickForm(); - if ($this->_action & CRM_Core_Action::DELETE) { - return; - } - - $this->applyFilter('__ALL__', 'trim'); - $this->add('text', 'label', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), TRUE); - $this->add('text', 'value', ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE); - $this->add('text', 'name', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name')); - if ($this->_gName == 'custom_search') { - $this->add('text', - 'description', - ts('Description'), - CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description') - ); - } - else { - $this->addWysiwyg('description', - ts('Description'), - CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description') - ); - } - - if ($this->_gName == 'case_status') { - $grouping = $this->add('select', 'grouping', ts('Option Grouping Name'), array('Opened' => ts('Opened'), - 'Closed' => ts('Closed'), - )); - if ($isReserved) { - $grouping->freeze(); - } - } - else { - $this->add('text', 'grouping', ts('Grouping'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'grouping')); - } - - $this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE); - $this->add('checkbox', 'is_active', ts('Enabled?')); - $this->add('checkbox', 'is_default', ts('Default Option?')); - $this->add('checkbox', 'is_optgroup', ts('Is OptGroup?')); - - // CRM-11516 - if ($this->_gName == 'payment_instrument') { - $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' "); - $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType)); - - $this->add('select', 'financial_account_id', ts('Financial Account'), - array('' => ts('- select -')) + $financialAccount - ); - } - // CRM-9953 - // we dont display this in the template, but the form sets the default values which are then saved - // this allow us to retain the previous values - $this->add('text', 'filter', ts('Filter')); - - if ($this->_action & CRM_Core_Action::UPDATE && $isReserved) { - $this->freeze(array('name', 'description', 'is_active')); - } - //get contact type for which user want to create a new greeting/addressee type, CRM-4575 - if (in_array($this->_gName, array( - 'email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) { - $values = array(1 => ts('Individual'), - 2 => ts('Household'), - 3 => ts('Organization'), - 4 => ts('Multiple Contact Merge'), - ); - - $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE); - } - - $this->add('hidden', 'gid', $this->_gid); - $this->addFormRule(array('CRM_Admin_Form_OptionValue', 'formRule'), $this); - $this->addButtons( - array( - array( - 'type' => 'next', - 'name' => ts('Save'), - 'isDefault' => TRUE, - ), - array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - ), - ) - ); - } - - function cancelAction() { - parent::cancelAction(); - - $gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, FALSE, 0); - $cancelURL = CRM_Utils_System::url('civicrm/admin/optionValue', "gid={$gid}&reset=1"); - - $session = CRM_Core_Session::singleton(); - $session->pushUserContext($cancelURL); - } - - /** - * global form rule - * - * @param array $fields the input form values - * @param array $files the uploaded files if any - * @param array $self this object. - * - * @return true if no errors, else an array of errors - * @access public - * @static - */ - static function formRule($fields, $files, $self) { - $errors = array(); - - //don't allow duplicate value within group. - $optionValues = array(); - CRM_Core_OptionValue::getValues(array('id' => $self->_gid), $optionValues); - foreach ($optionValues as $values) { - if ($values['id'] != $self->_id) { - if ($fields['value'] == $values['value']) { - $errors['value'] = ts('Value already exist in database.'); - break; - } - } - } - - return empty($errors) ? TRUE : $errors; - } - - /** - * Function to process the form - * - * @access public - * - * @return void - */ - public function postProcess() { - CRM_Utils_System::flushCache(); - - $params = $this->exportValues(); - if ($this->_action & CRM_Core_Action::DELETE) { - CRM_Core_BAO_OptionValue::del($this->_id); - CRM_Core_Session::setStatus(ts('Selected option value has been deleted.'), ts('Record Deleted'), 'success'); - } - else { - - $params = $ids = array(); - // store the submitted values in an array - $params = $this->exportValues(); - $params['option_group_id'] = $this->_gid; - - if ($this->_action & CRM_Core_Action::UPDATE) { - $ids['optionValue'] = $this->_id; - } - - //set defaultGreeting option in params to save default value as per contactOption-defaultValue mapping - if (!empty($params['contactOptions'])) { - $params['filter'] = CRM_Utils_Array::value('contactOptions', $params); - $params['defaultGreeting'] = 1; - } - - $optionValue = CRM_Core_BAO_OptionValue::add($params, $ids); - // CRM-11516 - if (!empty($params['financial_account_id'])) { - $relationTypeId = key(CRM_Core_PseudoConstant::accountOptionValues('account_relationship', NULL, " AND v.name LIKE 'Asset Account is' ")); - $params = array( - 'entity_table' => 'civicrm_option_value', - 'entity_id' => $optionValue->id, - 'account_relationship' => $relationTypeId, - 'financial_account_id' => $params['financial_account_id'] - ); - CRM_Financial_BAO_FinancialTypeAccount::add($params); - } - CRM_Core_Session::setStatus(ts('The Option Value \'%1\' has been saved.', array(1 => $optionValue->label)), ts('Saved'), 'success'); - } - } -} diff --git a/CRM/Admin/Form/Options.php b/CRM/Admin/Form/Options.php index d6ced2669a..ef2b883a9d 100644 --- a/CRM/Admin/Form/Options.php +++ b/CRM/Admin/Form/Options.php @@ -53,7 +53,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { * @var array * @static */ - protected $_GName; + protected $_gLabel; /** * Function to pre-process @@ -78,7 +78,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { else { $this->_gName = $this->get('gName'); } - $this->_GName = ucwords(str_replace('_', ' ', $this->_gName)); + $this->_gLabel = ucwords(str_replace('_', ' ', $this->_gName)); $url = "civicrm/admin/options/{$this->_gName}"; $params = "group={$this->_gName}&reset=1"; @@ -93,7 +93,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { $isInUse = CRM_Core_DAO::singleValueQuery($sql, $queryParam); if ($isInUse) { $scriptURL = "" . ts('Learn more about a script that can automatically update contact addressee and greeting options.') . ""; - CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(1 => $this->_GName, 2 => $scriptURL)), ts('Sorry'), 'error'); + CRM_Core_Session::setStatus(ts('The selected %1 option has not been deleted because it is currently in use. Please update these contacts to use a different format before deleting this option. %2', array(1 => $this->_gLabel, 2 => $scriptURL)), ts('Sorry'), 'error'); $redirect = CRM_Utils_System::url($url, $params); CRM_Utils_System::redirect($redirect); } @@ -376,10 +376,10 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { CRM_Core_BAO_Phone::setOptionToNull(CRM_Utils_Array::value('value', $this->_defaultValues)); } - CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_GName)), ts('Record Deleted'), 'success'); + CRM_Core_Session::setStatus(ts('Selected %1 type has been deleted.', array(1 => $this->_gLabel)), ts('Record Deleted'), 'success'); } else { - CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_GName)), ts('Sorry'), 'error'); + CRM_Core_Session::setStatus(ts('Selected %1 type has not been deleted.', array(1 => $this->_gLabel)), ts('Sorry'), 'error'); CRM_Utils_Weight::correctDuplicateWeights('CRM_Core_DAO_OptionValue', $fieldValues); } } @@ -428,7 +428,7 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form { CRM_Financial_BAO_FinancialTypeAccount::add($params); } - CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_GName, 2 => $optionValue->label)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts('The %1 \'%2\' has been saved.', array(1 => $this->_gLabel, 2 => $optionValue->label)), ts('Saved'), 'success'); } } } diff --git a/CRM/Admin/Page/OptionGroup.php b/CRM/Admin/Page/OptionGroup.php deleted file mode 100644 index 0d39c0816d..0000000000 --- a/CRM/Admin/Page/OptionGroup.php +++ /dev/null @@ -1,126 +0,0 @@ - array( - 'name' => ts('Options'), - 'url' => 'civicrm/admin/optionValue', - 'qs' => 'reset=1&action=browse&gid=%%id%%', - 'title' => ts('View and Edit Options'), - ), - CRM_Core_Action::UPDATE => array( - 'name' => ts('Edit Group'), - 'url' => 'civicrm/admin/optionGroup', - 'qs' => 'action=update&id=%%id%%&reset=1', - 'title' => ts('Edit Option'), - ), - CRM_Core_Action::DISABLE => array( - 'name' => ts('Disable'), - 'ref' => 'crm-enable-disable', - 'title' => ts('Disable Option'), - ), - CRM_Core_Action::ENABLE => array( - 'name' => ts('Enable'), - 'ref' => 'crm-enable-disable', - 'title' => ts('Enable Option'), - ), - CRM_Core_Action::DELETE => array( - 'name' => ts('Delete'), - 'url' => 'civicrm/admin/optionGroup', - 'qs' => 'action=delete&id=%%id%%', - 'title' => ts('Delete Option'), - ), - ); - } - return self::$_links; - } - - /** - * Get name of edit form - * - * @return string Classname of edit form. - */ - function editForm() { - return 'CRM_Admin_Form_OptionGroup'; - } - - /** - * Get edit form name - * - * @return string name of this page. - */ - function editName() { - return 'Options'; - } - - /** - * Get user context. - * - * @return string user context. - */ - function userContext($mode = NULL) { - return 'civicrm/admin/optionGroup'; - } -} - diff --git a/CRM/Admin/Page/OptionValue.php b/CRM/Admin/Page/OptionValue.php deleted file mode 100644 index 7f28c87ce9..0000000000 --- a/CRM/Admin/Page/OptionValue.php +++ /dev/null @@ -1,246 +0,0 @@ - array( - 'name' => ts('Edit'), - 'url' => 'civicrm/admin/optionValue', - 'qs' => 'action=update&id=%%id%%&gid=%%gid%%&reset=1', - 'title' => ts('Edit Option Value'), - ), - CRM_Core_Action::DISABLE => array( - 'name' => ts('Disable'), - 'ref' => 'crm-enable-disable', - 'title' => ts('Disable Option Value'), - ), - CRM_Core_Action::ENABLE => array( - 'name' => ts('Enable'), - 'ref' => 'crm-enable-disable', - 'title' => ts('Enable Option Value'), - ), - CRM_Core_Action::DELETE => array( - 'name' => ts('Delete'), - 'url' => 'civicrm/admin/optionValue', - 'qs' => 'action=delete&id=%%id%%&gid=%%gid%%', - 'title' => ts('Delete Option Value'), - ), - ); - } - return self::$_links; - } - - /** - * Run the page. - * - * This method is called after the page is created. It checks for the - * type of action and executes that action. - * Finally it calls the parent's run method. - * - * @return void - * @access public - * - */ - function run() { - $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', - $this, FALSE, 0 - ); - $this->assign('gid', $this->_gid); - - if ($this->_gid) { - //get optionGroup name in case of email/postal greeting or addressee, CRM-4575 - $this->_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'name'); - - $groupTitle = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'title', 'id'); - // Some option groups do not have a title set - if (!$groupTitle) { - $groupTitle = $this->_gName; - } - CRM_Utils_System::setTitle(ts('%1 - Option Values', array(1 => $groupTitle))); - } - $breadCrumb = array(array('title' => ts('Option Groups'), - 'url' => CRM_Utils_System::url('civicrm/admin/options', - 'reset=1' - ), - )); - CRM_Utils_System::appendBreadCrumb($breadCrumb); - - return parent::run(); - } - - /** - * Browse all options value. - * - * - * @return void - * @access public - * @static - */ - function browse() { - CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js'); - $dao = new CRM_Core_DAO_OptionValue(); - - $dao->option_group_id = $this->_gid; - - if (in_array($this->_gName, CRM_Core_OptionGroup::$_domainIDGroups)) { - $dao->domain_id = CRM_Core_Config::domainID(); - } - - if ($this->_gName == 'encounter_medium') { - $mediumIds = CRM_Case_BAO_Case::getUsedEncounterMediums(); - } - elseif ($this->_gName == 'case_status') { - $caseStatusIds = CRM_Case_BAO_Case::getUsedCaseStatuses(); - } - elseif ($this->_gName == 'case_type') { - $caseTypeIds = CRM_Case_BAO_Case::getUsedCaseType(); - } - - $dao->orderBy('name'); - $dao->find(); - - $optionValue = array(); - while ($dao->fetch()) { - $optionValue[$dao->id] = array(); - CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]); - // form all action links - $action = array_sum(array_keys($this->links())); - if ($dao->is_default) { - $optionValue[$dao->id]['default_value'] = '[x]'; - } - //do not show default option for email/postal greeting and addressee, CRM-4575 - if (!in_array($this->_gName, array( - 'email_greeting', 'postal_greeting', 'addressee'))) { - $this->assign('showIsDefault', TRUE); - } - // update enable/disable links depending on if it is is_reserved or is_active - if ($dao->is_reserved) { - $action = CRM_Core_Action::UPDATE; - } - else { - if ($dao->is_active) { - $action -= CRM_Core_Action::ENABLE; - } - else { - $action -= CRM_Core_Action::DISABLE; - } - - if ((($this->_gName == 'encounter_medium') && in_array($dao->value, $mediumIds)) || - (($this->_gName == 'case_status') && in_array($dao->value, $caseStatusIds)) || - (($this->_gName == 'case_type') && in_array($dao->value, $caseTypeIds)) - ) { - $action -= CRM_Core_Action::DELETE; - } - } - - $optionValue[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, - array('id' => $dao->id, 'gid' => $this->_gid), - ts('more'), - FALSE, - 'optionValue.admin.actions', - 'optionValue', - $dao->id - ); - } - - $this->assign('rows', $optionValue); - } - - /** - * Get name of edit form - * - * @return string Classname of edit form. - */ - function editForm() { - return 'CRM_Admin_Form_OptionValue'; - } - - /** - * Get edit form name - * - * @return string name of this page. - */ - function editName() { - return 'Options Values'; - } - - /** - * Get user context. - * - * @return string user context. - */ - function userContext($mode = NULL) { - return 'civicrm/admin/optionValue'; - } -} - diff --git a/CRM/Admin/Page/Options.php b/CRM/Admin/Page/Options.php index de748d0e6c..c2f4f79d35 100644 --- a/CRM/Admin/Page/Options.php +++ b/CRM/Admin/Page/Options.php @@ -60,7 +60,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @var array * @static */ - static $_GName = NULL; + static $_gLabel = NULL; /** * The option group id @@ -71,33 +71,46 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { 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')); @@ -110,7 +123,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { 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( @@ -143,7 +156,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @return string Classname of BAO. */ function getBAOName() { - return 'CRM_Core_BAO_OptionValue'; + return self::$_gName ? 'CRM_Core_BAO_OptionValue' : 'CRM_Core_BAO_OptionGroup'; } /** @@ -156,7 +169,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { self::$_links = array( CRM_Core_Action::UPDATE => array( 'name' => ts('Edit'), - 'url' => 'civicrm/admin/options/' . self::$_gName, + 'url' => 'civicrm/admin/options', 'qs' => 'group=' . self::$_gName . '&action=update&id=%%id%%&reset=1', 'title' => ts('Edit %1', array(1 => self::$_gName)), ), @@ -172,7 +185,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { ), CRM_Core_Action::DELETE => array( 'name' => ts('Delete'), - 'url' => 'civicrm/admin/options/' . self::$_gName, + 'url' => 'civicrm/admin/options', 'qs' => 'group=' . self::$_gName . '&action=delete&id=%%id%%', 'title' => ts('Delete %1 Type', array(1 => self::$_gName)), ), @@ -211,7 +224,10 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @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; @@ -239,7 +255,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @return string Classname of edit form. */ function editForm() { - return 'CRM_Admin_Form_Options'; + return self::$_gName ? 'CRM_Admin_Form_Options' : 'CRM_Admin_Form_OptionGroup'; } /** @@ -248,7 +264,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @return string name of this page. */ function editName() { - return self::$_GName; + return self::$_gLabel; } /** @@ -257,19 +273,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic { * @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 : ''); } } diff --git a/CRM/Campaign/BAO/Petition.php b/CRM/Campaign/BAO/Petition.php index ec01af5130..937b2fb5ec 100644 --- a/CRM/Campaign/BAO/Petition.php +++ b/CRM/Campaign/BAO/Petition.php @@ -194,7 +194,6 @@ SELECT petition.id as id, $surveyInfo = CRM_Campaign_BAO_Petition::getSurveyInfo($params['sid']); // create activity - // activity status id (from /civicrm/admin/optionValue?reset=1&action=browse&gid=25) // 1-Schedule, 2-Completed $activityParams = array( diff --git a/CRM/Campaign/xml/Menu/Campaign.xml b/CRM/Campaign/xml/Menu/Campaign.xml index b846b1afaa..a5c673f24e 100644 --- a/CRM/Campaign/xml/Menu/Campaign.xml +++ b/CRM/Campaign/xml/Menu/Campaign.xml @@ -43,7 +43,6 @@ civicrm/admin/options/campaign_type Campaign Types categorize your campaigns using campaign types. - group=campaign_type CRM_Admin_Page_Options CiviCampaign admin/small/05.png @@ -54,7 +53,6 @@ civicrm/admin/options/campaign_status Campaign Status Define statuses for campaign here. - group=campaign_status CRM_Admin_Page_Options CiviCampaign admin/small/05.png @@ -65,7 +63,6 @@ civicrm/admin/options/engagement_index Engagement Index Engagement levels. - group=engagement_index CRM_Admin_Page_Options CiviCampaign admin/small/05.png diff --git a/CRM/Case/xml/Menu/Case.xml b/CRM/Case/xml/Menu/Case.xml index 6c59d6edca..aefab0c2b8 100644 --- a/CRM/Case/xml/Menu/Case.xml +++ b/CRM/Case/xml/Menu/Case.xml @@ -68,7 +68,6 @@ civicrm/admin/options/case_type Case Types List of types which can be assigned to Cases. (Enable the Cases tab from System Settings - Enable Components if you want to track cases.) - group=case_type administer CiviCase CRM_Admin_Page_Options CiviCase @@ -79,7 +78,6 @@ civicrm/admin/options/redaction_rule Redaction Rules List of rules which can be applied to user input strings so that the redacted output can be recognized as repeated instances of the same string or can be identified as a "semantic type of the data element" within case data. - group=redaction_rule CRM_Admin_Page_Options administer CiviCase CiviCase @@ -90,7 +88,6 @@ civicrm/admin/options/case_status Case Statuses List of statuses that can be assigned to a case. - group=case_status CRM_Admin_Page_Options administer CiviCase CiviCase @@ -101,7 +98,6 @@ civicrm/admin/options/encounter_medium Encounter Mediums List of encounter mediums. - group=encounter_medium CRM_Admin_Page_Options administer CiviCase CiviCase diff --git a/CRM/Contribute/xml/Menu/Contribute.xml b/CRM/Contribute/xml/Menu/Contribute.xml index 7fd6301f76..d95d5ad9b4 100644 --- a/CRM/Contribute/xml/Menu/Contribute.xml +++ b/CRM/Contribute/xml/Menu/Contribute.xml @@ -144,7 +144,6 @@ Payment Instruments CRM_Admin_Page_Options You may choose to record the payment instrument used for each contribution. Common payment methods are installed by default (e.g. Check, Cash, Credit Card...). If your site requires additional payment methods, add them here. - group=payment_instrument CiviContribute admin/small/payment_instruments.png 380 @@ -154,7 +153,6 @@ Accepted Credit Cards CRM_Admin_Page_Options Credit card options that will be offered to contributors using your Online Contribution pages. - group=accept_creditcard CiviContribute admin/small/accepted_creditcards.png 395 @@ -164,7 +162,6 @@ Soft Credit Types CRM_Admin_Page_Options Soft Credit Types that will be offered to contributors during soft credit contribution - group=soft_credit_type CiviContribute admin/small/soft_credit_type.png @@ -300,4 +297,4 @@ 1 CiviContribute - \ No newline at end of file + diff --git a/CRM/Core/Invoke.php b/CRM/Core/Invoke.php index 837dda2ef2..bb0e17b38a 100644 --- a/CRM/Core/Invoke.php +++ b/CRM/Core/Invoke.php @@ -307,7 +307,7 @@ class CRM_Core_Invoke { $title = CRM_Utils_Array::value('title', $item); if (strstr($item['page_callback'], '_Page')) { $object = new $item['page_callback'] ($title, $mode ); - $object->urlPath = $_GET[$config->userFrameworkURLVar]; + $object->urlPath = explode('/', $_GET[$config->userFrameworkURLVar]); } elseif (strstr($item['page_callback'], '_Controller')) { $addSequence = 'false'; diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index 9d6d9a2ea1..fc11fa2c04 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -107,7 +107,6 @@ civicrm/admin/options/activity_type Activity Types CiviCRM has several built-in activity types (meetings, phone calls, emails sent). Track other types of interactions by creating custom activity types here. - group=activity_type CRM_Admin_Page_Options Customize Data and Screens admin/small/05.png @@ -134,7 +133,6 @@ civicrm/admin/options/gender Gender Options Options for assigning gender to individual contacts (e.g. Male, Female, Transgender). - group=gender CRM_Admin_Page_Options Customize Data and Screens admin/small/01.png @@ -144,7 +142,6 @@ civicrm/admin/options/individual_prefix Individual Prefixes (Ms, Mr...) Options for individual contact prefixes (e.g. Ms., Mr., Dr. etc.). - group=individual_prefix CRM_Admin_Page_Options Customize Data and Screens admin/small/title.png @@ -154,7 +151,6 @@ civicrm/admin/options/individual_suffix Individual Suffixes (Jr, Sr...) Options for individual contact suffixes (e.g. Jr., Sr. etc.). - group=individual_suffix CRM_Admin_Page_Options Customize Data and Screens admin/small/10.png @@ -173,7 +169,6 @@ civicrm/admin/options/website_type Website Types Options for assigning website types to contacts. - group=website_type CRM_Admin_Page_Options Customize Data and Screens 65 @@ -182,7 +177,6 @@ civicrm/admin/options/instant_messenger_service Instant Messenger Services List of IM services which can be used when recording screen-names for contacts. - group=instant_messenger_service CRM_Admin_Page_Options Customize Data and Screens admin/small/07.png @@ -192,7 +186,6 @@ civicrm/admin/options/mobile_provider Mobile Phone Providers List of mobile phone providers which can be assigned when recording contact phone numbers. - group=mobile_provider CRM_Admin_Page_Options Customize Data and Screens admin/small/08.png @@ -203,7 +196,6 @@ Phone Type Options for assigning phone type to contacts (e.g Phone, Mobile, Fax, Pager) - group=phone_type CRM_Admin_Page_Options Customize Data and Screens tel.gif @@ -246,7 +238,6 @@ civicrm/admin/options/custom_search Manage Custom Searches Developers and accidental techies with a bit of PHP and SQL knowledge can create new search forms to handle specific search and reporting needs which aren't covered by the built-in Advanced Search and Search Builder features. - group=custom_search CRM_Admin_Page_Options Customize Data and Screens admin/small/template.png @@ -266,7 +257,6 @@ civicrm/admin/options/from_email_address From Email Addresses List of Email Addresses which can be used when sending emails to contacts. - group=from_email_address CRM_Admin_Page_Options Communications admin/small/title.png @@ -305,7 +295,6 @@ civicrm/admin/options/preferred_communication_method Preferred Communication Methods One or more preferred methods of communication can be assigned to each contact. Customize the available options here. - group=preferred_communication_method CRM_Admin_Page_Options Communications admin/small/communication.png @@ -333,7 +322,6 @@ civicrm/admin/options/communication_style Communication Style Options Options for Communication Style selection. - group=communication_style CRM_Admin_Page_Options Communications admin/small/01.png @@ -343,7 +331,6 @@ civicrm/admin/options/email_greeting Email Greeting Formats Options for assigning email greetings to individual and household contacts. - group=email_greeting CRM_Admin_Page_Options Communications admin/small/01.png @@ -353,7 +340,6 @@ civicrm/admin/options/postal_greeting Postal Greeting Formats Options for assigning postal greetings to individual and household contacts. - group=postal_greeting CRM_Admin_Page_Options Communications admin/small/01.png @@ -363,7 +349,6 @@ civicrm/admin/options/addressee Addressee Formats Options for assigning addressee to individual, household and organization contacts. - group=addressee CRM_Admin_Page_Options Communications admin/small/01.png @@ -397,7 +382,6 @@ civicrm/admin/options/languages Preferred Languages Options for contact languages. - group=languages CRM_Admin_Page_Options Localization admin/small/36.png @@ -535,7 +519,6 @@ civicrm/admin/options/safe_file_extension Safe File Extension Options File Extensions that can be considered safe. - group=safe_file_extension CRM_Admin_Page_Options System Settings admin/small/01.png @@ -545,7 +528,7 @@ civicrm/admin/options Option Groups Access all meta-data option groups. - CRM_Admin_Page_OptionGroup + CRM_Admin_Page_Options System Settings admin/small/01.png 105 @@ -631,7 +614,6 @@ civicrm/admin/options/grant_type Grant Types List of types which can be assigned to Grants. (Enable CiviGrant from Administer > Systme Settings > Enable Components if you want to track grants.) - group=grant_type CRM_Admin_Page_Options Option Lists admin/small/grant_type.png @@ -653,11 +635,6 @@ true 9000 - - civicrm/admin/optionValue - Option Values - CRM_Admin_Page_OptionValue - civicrm/ajax/menujs CRM_Admin_Page_AJAX::getNavigationMenu diff --git a/CRM/Core/xml/Menu/Misc.xml b/CRM/Core/xml/Menu/Misc.xml index f54ef23bec..274c6fc946 100644 --- a/CRM/Core/xml/Menu/Misc.xml +++ b/CRM/Core/xml/Menu/Misc.xml @@ -20,7 +20,6 @@ civicrm/admin/options/acl_role ACL Roles - group=acl_role CRM_Admin_Page_Options administer CiviCRM,access CiviCRM diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index be95ac376b..2906d3c473 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -82,7 +82,6 @@ Event Types CRM_Admin_Page_Options Use Event Types to categorize your events. Event feeds can be filtered by Event Type and participant searches can use Event Type as a criteria. - group=event_type administer CiviCRM,access CiviEvent CiviEvent admin/small/event_type.png @@ -103,7 +102,6 @@ Participant Role CRM_Admin_Page_Options Define participant roles for events here (e.g. Attendee, Host, Speaker...). You can then assign roles and search for participants by role. - group=participant_role administer CiviCRM,access CiviEvent CiviEvent admin/small/parti_role.png @@ -113,7 +111,6 @@ civicrm/admin/options/participant_listing Participant Listing Templates Template to control participant listing display. - group=participant_listing CRM_Admin_Page_Options CiviEvent admin/small/01.png diff --git a/CRM/Mailing/xml/Menu/Mailing.xml b/CRM/Mailing/xml/Menu/Mailing.xml index b6808487a6..0e2fa2272c 100644 --- a/CRM/Mailing/xml/Menu/Mailing.xml +++ b/CRM/Mailing/xml/Menu/Mailing.xml @@ -31,10 +31,9 @@ 410 - civicrm/admin/options/from_email + civicrm/admin/options/from_email_address/civimail From Email Addresses List of Email Addresses which can be used when sending emails to contacts. - group=from_email_address CRM_Admin_Page_Options CiviMail admin/small/title.png diff --git a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 1a89f39ea6..85596b024b 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@ -192,3 +192,7 @@ VALUES (@option_group_id_act, {localize}'{ts escape="sql"}Refund{/ts}'{/localize}, @option_group_id_act_val+2, 'Refund', NULL, 1, NULL, @option_group_id_act_wt+2, {localize}'{ts escape="sql"}Refund recorded for event or membership fee.{/ts}'{/localize}, 0, 1, 1, @contributeCompId, NULL), (@option_group_id_act, {localize}'{ts escape="sql"}Change Registration{/ts}'{/localize}, @option_group_id_act_val+3, 'Change Registration', NULL, 1, NULL, @option_group_id_act_wt+3, {localize}'{ts escape="sql"}Changes to an existing event registration.{/ts}'{/localize}, 0, 1, 1, @eventCompId, NULL); +-- CRM-13970 +UPDATE civicrm_navigation set url = 'civicrm/admin/options/from_email_address&reset=1' WHERE url LIKE 'civicrm/admin/options/from_email%'; +UPDATE civicrm_navigation set url = 'civicrm/admin/option_groups&reset=1' WHERE url LIKE 'civicrm/admin/options&%'; +UPDATE civicrm_navigation set url = CONCAT(SUBSTRING_INDEX(url, '&', 1), '&reset=1') WHERE url LIKE 'civicrm/admin/options/%'; diff --git a/templates/CRM/Admin/Form/Options.tpl b/templates/CRM/Admin/Form/Options.tpl index e8a5dbe11a..62707560a7 100644 --- a/templates/CRM/Admin/Form/Options.tpl +++ b/templates/CRM/Admin/Form/Options.tpl @@ -24,13 +24,13 @@ +--------------------------------------------------------------------+ *} {* this template is used for adding/editing options *} -

{if $action eq 1}{ts 1=$GName}New %1 Option{/ts}{elseif $action eq 8}{ts 1=$GName}Delete %1 Option{/ts}{else}{ts 1=$GName}Edit %1 Option{/ts}{/if}

+

{if $action eq 1}{ts 1=$gLabel}New %1 Option{/ts}{elseif $action eq 8}{ts 1=$gLabel}Delete %1 Option{/ts}{else}{ts 1=$gLabel}Edit %1 Option{/ts}{/if}

{include file="CRM/common/formButtons.tpl" location="top"}
{if $action eq 8}
- {ts 1=$GName}WARNING: Deleting this option will result in the loss of all %1 related records which use the option.{/ts} {ts}This may mean the loss of a substantial amount of data, and the action cannot be undone.{/ts} {ts}Do you want to continue?{/ts} + {ts 1=$gLabel}WARNING: Deleting this option will result in the loss of all %1 related records which use the option.{/ts} {ts}This may mean the loss of a substantial amount of data, and the action cannot be undone.{/ts} {ts}Do you want to continue?{/ts}
{else} diff --git a/templates/CRM/Admin/Page/OptionGroup.tpl b/templates/CRM/Admin/Page/OptionGroup.tpl index 3054e66a39..609f629acc 100644 --- a/templates/CRM/Admin/Page/OptionGroup.tpl +++ b/templates/CRM/Admin/Page/OptionGroup.tpl @@ -50,7 +50,7 @@ - + {/foreach}
{if $row.title}{$row.title}{else}( {ts}none{/ts} ){/if} {$row.name}{ts}Options{/ts}{ts}Options{/ts}
diff --git a/templates/CRM/Admin/Page/Options.tpl b/templates/CRM/Admin/Page/Options.tpl index 8deb152735..36474d1b20 100644 --- a/templates/CRM/Admin/Page/Options.tpl +++ b/templates/CRM/Admin/Page/Options.tpl @@ -24,7 +24,10 @@ +--------------------------------------------------------------------+ *} -{if $action eq 1 or $action eq 2 or $action eq 8} +{if empty($gName)} + {include file="CRM/Admin/Page/OptionGroup.tpl"} + +{elseif $action eq 1 or $action eq 2 or $action eq 8} {include file="CRM/Admin/Form/Options.tpl"} {else} @@ -61,7 +64,7 @@ {elseif $gName eq 'from_email_address'} {ts}By default, CiviCRM uses the primary email address of the logged in user as the FROM address when sending emails to contacts. However, you can use this page to define one or more general Email Addresses that can be selected as an alternative. EXAMPLE: "Client Services" <clientservices@example.org>{/ts} {else} - {ts 1=$GName}The existing option choices for %1 group are listed below. You can add, edit or delete them from this screen.{/ts} + {ts 1=$gLabel}The existing option choices for %1 group are listed below. You can add, edit or delete them from this screen.{/ts} {/if}
@@ -69,7 +72,7 @@ {if $rows} {if $action ne 1 and $action ne 2} {/if}
@@ -152,7 +155,7 @@ {if $action ne 1 and $action ne 2} {/if}
diff --git a/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl b/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl index c6e24d5d9e..7a9d6daabc 100644 --- a/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl +++ b/templates/CRM/Contribute/Form/ContributionPage/Settings.tpl @@ -213,7 +213,7 @@ } cj('.optionvalue-link').click(function() { {/literal}"{crmAPI var='result' entity='OptionGroup' action='get' sequential=1 name='soft_credit_type'}"{literal}; - var postURL = {/literal}"{crmURL p='civicrm/admin/optionValue' q="gid="}{$result.id}"{literal}; + var postURL = {/literal}"{crmURL p='civicrm/admin/options' q="gid="}{$result.id}"{literal}; CRM.loadForm(postURL).on('crmFormSuccess', function(e, data) { cj('.ui-dialog a').click(function(){ //Todo: inline edit facility for soft_credit_type option group in jquery popup dialog diff --git a/tools/CRM/Auction/xml/Menu/Auction.xml b/tools/CRM/Auction/xml/Menu/Auction.xml index fc2fe8b5dc..c3cb3e4776 100644 --- a/tools/CRM/Auction/xml/Menu/Auction.xml +++ b/tools/CRM/Auction/xml/Menu/Auction.xml @@ -66,7 +66,6 @@ Auction Types CRM_Admin_Page_Options Use Auction Types to categorize your auction items. - group=auction_type administer CiviCRM,access CiviAuction CiviAuction admin/small/auction_type.png -- 2.25.1