From: Coleman Watts <coleman@civicrm.org> Date: Sun, 16 Jan 2022 01:50:30 +0000 (-0500) Subject: CustomField Admin - Decouple page code from form code X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=aca7613bf2dfff87077b3c78b20f0ff46e3aa451;p=civicrm-core.git CustomField Admin - Decouple page code from form code This moves the forms for creating/editing/previewing/deleting custom data to their own url paths instead of sharing the same path as the page. --- diff --git a/CRM/Campaign/Form/Survey/Questions.php b/CRM/Campaign/Form/Survey/Questions.php index 1879f022c5..3dae1e4917 100644 --- a/CRM/Campaign/Form/Survey/Questions.php +++ b/CRM/Campaign/Form/Survey/Questions.php @@ -58,7 +58,7 @@ class CRM_Campaign_Form_Survey_Questions extends CRM_Campaign_Form_Survey { 'There are no custom data sets for activity type "%1". To create one, <a href="%2" target="%3">click here</a>.', [ 1 => $activityTypes[$subTypeId], - 2 => CRM_Utils_System::url('civicrm/admin/custom/group', 'action=add&reset=1'), + 2 => CRM_Utils_System::url('civicrm/admin/custom/group/edit', 'action=add&reset=1'), 3 => '_blank', ] ) diff --git a/CRM/Core/DAO/CustomField.php b/CRM/Core/DAO/CustomField.php index b28303a25e..f7f8aab922 100644 --- a/CRM/Core/DAO/CustomField.php +++ b/CRM/Core/DAO/CustomField.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/CustomField.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:6273bed0debfe48b5b7caf40b3ea78b2) + * (GenCodeChecksum:6653fe86552a321a498736c14cabc41d) */ /** @@ -45,8 +45,8 @@ class CRM_Core_DAO_CustomField extends CRM_Core_DAO { protected static $_paths = [ 'add' => 'civicrm/admin/custom/group/field/add?reset=1&action=add&gid=[custom_group_id]', 'update' => 'civicrm/admin/custom/group/field/update?action=update&reset=1&id=[id]&gid=[custom_group_id]', - 'preview' => 'civicrm/admin/custom/group/field?action=preview&reset=1&id=[id]&gid=[custom_group_id]', - 'delete' => 'civicrm/admin/custom/group/field?action=delete&reset=1&id=[id]&gid=[custom_group_id]', + 'preview' => 'civicrm/admin/custom/group/preview&reset=1&fid=[id]', + 'delete' => 'civicrm/admin/custom/group/field/delete?reset=1&id=[id]', 'move' => 'civicrm/admin/custom/group/field/move?reset=1&fid=[id]', ]; diff --git a/CRM/Core/DAO/CustomGroup.php b/CRM/Core/DAO/CustomGroup.php index e15adbf24a..6bb2ce18e0 100644 --- a/CRM/Core/DAO/CustomGroup.php +++ b/CRM/Core/DAO/CustomGroup.php @@ -6,7 +6,7 @@ * * Generated from xml/schema/CRM/Core/CustomGroup.xml * DO NOT EDIT. Generated by CRM_Core_CodeGen - * (GenCodeChecksum:e2730dbbc3151ef18d9aeba73577fa96) + * (GenCodeChecksum:0c41f19103b41d2f82bcd3b60aaf2165) */ /** @@ -43,10 +43,10 @@ class CRM_Core_DAO_CustomGroup extends CRM_Core_DAO { * @var string[] */ protected static $_paths = [ - 'add' => 'civicrm/admin/custom/group?action=add&reset=1', - 'update' => 'civicrm/admin/custom/group?action=update&reset=1&id=[id]', - 'preview' => 'civicrm/admin/custom/group?action=preview&reset=1&id=[id]', - 'delete' => 'civicrm/admin/custom/group?action=delete&reset=1&id=[id]', + 'add' => 'civicrm/admin/custom/group/edit?action=add&reset=1', + 'update' => 'civicrm/admin/custom/group/edit?action=update&reset=1&id=[id]', + 'preview' => 'civicrm/admin/custom/group/preview?reset=1&gid=[id]', + 'delete' => 'civicrm/admin/custom/group/delete?reset=1&id=[id]', ]; /** diff --git a/CRM/Core/xml/Menu/Admin.xml b/CRM/Core/xml/Menu/Admin.xml index be6af284ad..596018228a 100644 --- a/CRM/Core/xml/Menu/Admin.xml +++ b/CRM/Core/xml/Menu/Admin.xml @@ -10,6 +10,21 @@ <access_arguments>administer CiviCRM data</access_arguments> <weight>10</weight> </item> + <item> + <path>civicrm/admin/custom/group/edit</path> + <title>Configure Custom Set</title> + <page_callback>CRM_Custom_Form_Group</page_callback> + </item> + <item> + <path>civicrm/admin/custom/group/preview</path> + <title>Custom Field Preview</title> + <page_callback>CRM_Custom_Form_Preview</page_callback> + </item> + <item> + <path>civicrm/admin/custom/group/delete</path> + <title>Delete Custom Set</title> + <page_callback>CRM_Custom_Form_DeleteGroup</page_callback> + </item> <item> <path>civicrm/admin/custom/group/field</path> <title>Custom Data Fields</title> @@ -17,6 +32,11 @@ <skipBreadcrumb>true</skipBreadcrumb> <weight>11</weight> </item> + <item> + <path>civicrm/admin/custom/group/field/delete</path> + <title>Delete Custom Field</title> + <page_callback>CRM_Custom_Form_DeleteField</page_callback> + </item> <item> <path>civicrm/admin/custom/group/field/option</path> <title>Custom Field - Options</title> diff --git a/CRM/Custom/Form/DeleteField.php b/CRM/Custom/Form/DeleteField.php index 993ed6138e..7793b9ac39 100644 --- a/CRM/Custom/Form/DeleteField.php +++ b/CRM/Custom/Form/DeleteField.php @@ -41,7 +41,7 @@ class CRM_Custom_Form_DeleteField extends CRM_Core_Form { * @access protected */ public function preProcess() { - $this->_id = $this->get('id'); + $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $defaults = []; $params = ['id' => $this->_id]; diff --git a/CRM/Custom/Form/DeleteGroup.php b/CRM/Custom/Form/DeleteGroup.php index d3b9169fb0..1fed29e919 100644 --- a/CRM/Custom/Form/DeleteGroup.php +++ b/CRM/Custom/Form/DeleteGroup.php @@ -41,7 +41,7 @@ class CRM_Custom_Form_DeleteGroup extends CRM_Core_Form { * @access protected */ public function preProcess() { - $this->_id = $this->get('id'); + $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE); $defaults = []; $params = ['id' => $this->_id]; diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 0e026ff654..3a4db3b7e5 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -78,8 +78,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { * @return void */ public function preProcess() { - //custom field id $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); + $this->setAction($this->_id ? CRM_Core_Action::UPDATE : CRM_Core_Action::ADD); $this->assign('dataToHTML', self::$_dataToHTML); @@ -97,13 +97,13 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this); } - if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { + if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved')) { CRM_Core_Error::statusBounce("You cannot add or edit fields in a reserved custom field-set."); } if ($this->_gid) { $url = CRM_Utils_System::url('civicrm/admin/custom/group/field', - "reset=1&action=browse&gid={$this->_gid}" + "reset=1&gid={$this->_gid}" ); $session = CRM_Core_Session::singleton(); @@ -192,8 +192,8 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { if ($this->_gid) { $this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'title'); $this->setTitle($this->_title . ' - ' . ($this->_id ? ts('Edit Field') : ts('New Field'))); - $this->assign('gid', $this->_gid); } + $this->assign('gid', $this->_gid); // lets trim all the whitespace $this->applyFilter('__ALL__', 'trim'); @@ -476,7 +476,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { // if view mode pls freeze it with the done button. if ($this->_action & CRM_Core_Action::VIEW) { $this->freeze(); - $url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid); + $url = CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&gid=' . $this->_gid); $this->addElement('xbutton', 'done', ts('Done'), @@ -892,12 +892,12 @@ AND option_group_id = %2"; if ($buttonName == $this->getButtonName('next', 'new')) { $msg .= '<p>' . ts("Ready to add another.") . '</p>'; $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/add', - 'reset=1&action=add&gid=' . $this->_gid + 'reset=1&gid=' . $this->_gid )); } else { $session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', - 'reset=1&action=browse&gid=' . $this->_gid + 'reset=1&gid=' . $this->_gid )); } $session->setStatus($msg, ts('Saved'), 'success'); diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index cf4c37cdac..46dde5f9b2 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -51,25 +51,16 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { Civi::resources()->addScriptFile('civicrm', 'js/jquery/jquery.crmIconPicker.js'); // current set id - $this->_id = $this->get('id'); + $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this); + $this->setAction($this->_id ? CRM_Core_Action::UPDATE : CRM_Core_Action::ADD); - if ($this->_id && $isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_id, 'is_reserved', 'id')) { + if ($this->_id && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_id, 'is_reserved', 'id')) { CRM_Core_Error::statusBounce("You cannot edit the settings of a reserved custom field-set."); } - // setting title for html page - if ($this->_action == CRM_Core_Action::UPDATE) { + + if ($this->_id) { $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); $this->setTitle(ts('Edit %1', [1 => $title])); - } - elseif ($this->_action == CRM_Core_Action::VIEW) { - $title = CRM_Core_BAO_CustomGroup::getTitle($this->_id); - $this->setTitle(ts('Preview %1', [1 => $title])); - } - else { - $this->setTitle(ts('New Custom Field Set')); - } - - if (isset($this->_id)) { $params = ['id' => $this->_id]; CRM_Core_BAO_CustomGroup::retrieve($params, $this->_defaults); @@ -78,6 +69,9 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $this->_subtypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subExtends, 1, -1)); } } + else { + $this->setTitle(ts('New Custom Field Set')); + } } /** @@ -405,7 +399,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { else { // Jump directly to adding a field if popups are disabled $action = CRM_Core_Resources::singleton()->ajaxPopupsEnabled ? '' : '/add'; - $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&new=1&gid=' . $group['id'] . '&action=' . ($action ? 'add' : 'browse')); + $url = CRM_Utils_System::url("civicrm/admin/custom/group/field$action", 'reset=1&new=1&gid=' . $group['id']); CRM_Core_Session::setStatus(ts("Your custom field set '%1' has been added. You can add custom fields now.", [1 => $group['title']] ), ts('Saved'), 'success'); diff --git a/CRM/Custom/Form/Preview.php b/CRM/Custom/Form/Preview.php index 102712d94d..7d59ba1828 100644 --- a/CRM/Custom/Form/Preview.php +++ b/CRM/Custom/Form/Preview.php @@ -25,6 +25,16 @@ */ class CRM_Custom_Form_Preview extends CRM_Core_Form { + /** + * @var int + */ + protected $_groupId; + + /** + * @var int + */ + protected $_fieldId; + /** * The group tree data. * @@ -40,15 +50,15 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { * @return void */ public function preProcess() { - // get the controller vars - $this->_groupId = $this->get('groupId'); - $this->_fieldId = $this->get('fieldId'); + // Get field id if previewing a single field + $this->_fieldId = CRM_Utils_Request::retrieve('fid', 'Positive', $this); + + // Single field preview if ($this->_fieldId) { - // field preview $defaults = []; $params = ['id' => $this->_fieldId]; - $fieldDAO = new CRM_Core_DAO_CustomField(); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $params, $defaults); + $this->_groupId = $defaults['custom_group_id']; if (!empty($defaults['is_view'])) { CRM_Core_Error::statusBounce(ts('This field is view only so it will not display on edit form.')); @@ -64,7 +74,9 @@ class CRM_Custom_Form_Preview extends CRM_Core_Form { $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $this); $this->assign('preview_type', 'field'); } + // Group preview else { + $this->_groupId = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE); $groupTree = CRM_Core_BAO_CustomGroup::getGroupDetail($this->_groupId); $this->_groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, TRUE, $this); $this->assign('preview_type', 'group'); diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index 58c44f7525..b11cd85b18 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -64,8 +64,8 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { ], CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview Field Display'), - 'url' => 'civicrm/admin/custom/group/field', - 'qs' => 'action=preview&reset=1&gid=%%gid%%&id=%%id%%', + 'url' => 'civicrm/admin/custom/group/preview', + 'qs' => 'action=preview&reset=1&fid=%%id%%', 'title' => ts('Preview Custom Field'), ], CRM_Core_Action::DISABLE => [ @@ -87,8 +87,8 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { ], CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), - 'url' => 'civicrm/admin/custom/group/field', - 'qs' => 'action=delete&reset=1&gid=%%gid%%&id=%%id%%', + 'url' => 'civicrm/admin/custom/group/field/delete', + 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Delete Custom Field'), ], ]; @@ -174,30 +174,6 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { $this->assign('customField', $customField); } - /** - * Edit custom data. - * - * editing would involved modifying existing fields + adding data to new fields. - * - * @param string $action - * The action to be invoked. - * - * @return void - */ - public function edit($action) { - // create a simple controller for editing custom dataCRM/Custom/Page/Field.php - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_Field', ts('Custom Field'), $action); - - // set the userContext stack - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid)); - - $controller->set('gid', $this->_gid); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - } - /** * Run the page. * @@ -207,92 +183,22 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { * @return void */ public function run() { + $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, TRUE); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - if ($id) { - $values = civicrm_api3('custom_field', 'getsingle', ['id' => $id]); - $this->_gid = $values['custom_group_id']; - } - // get the group id - else { - $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', - $this - ); - } - - if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) { + if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved')) { CRM_Core_Error::statusBounce("You cannot add or edit fields in a reserved custom field-set."); } - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - if ($action & CRM_Core_Action::DELETE) { - - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid)); - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_DeleteField', "Delete Custom Field", ''); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - $controller->set('id', $id); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - $fieldValues = ['custom_group_id' => $this->_gid]; - $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_CustomField', $id, $fieldValues); - } - - if ($this->_gid) { - $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_gid); - $this->assign('gid', $this->_gid); - $this->assign('groupTitle', $groupTitle); - if ($action & CRM_Core_Action::BROWSE) { - CRM_Utils_System::setTitle(ts('%1 - Custom Fields', [1 => $groupTitle])); - } - } + $groupTitle = CRM_Core_BAO_CustomGroup::getTitle($this->_gid); + $this->assign('gid', $this->_gid); + $this->assign('groupTitle', $groupTitle); // assign vars to templates - $this->assign('action', $action); + $this->assign('action', 'browse'); - // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - // no browse for edit/update/view - $this->edit($action); - } - elseif ($action & CRM_Core_Action::PREVIEW) { - $this->preview($id); - } - else { - $this->browse(); - } + $this->browse(); - // Call the parents run method return parent::run(); } - /** - * Preview custom field. - * - * @param int $id - * Custom field id. - * - * @return void - */ - public function preview($id) { - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_Preview', ts('Preview Custom Data'), CRM_Core_Action::PREVIEW); - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field', 'reset=1&action=browse&gid=' . $this->_gid)); - $controller->set('fieldId', $id); - $controller->set('groupId', $this->_gid); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - } - } diff --git a/CRM/Custom/Page/Group.php b/CRM/Custom/Page/Group.php index ec7b742ede..919e5260e2 100644 --- a/CRM/Custom/Page/Group.php +++ b/CRM/Custom/Page/Group.php @@ -51,13 +51,13 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { ], CRM_Core_Action::PREVIEW => [ 'name' => ts('Preview'), - 'url' => 'civicrm/admin/custom/group', - 'qs' => 'action=preview&reset=1&id=%%id%%', + 'url' => 'civicrm/admin/custom/group/preview', + 'qs' => 'reset=1&gid=%%id%%', 'title' => ts('Preview Custom Data Set'), ], CRM_Core_Action::UPDATE => [ 'name' => ts('Settings'), - 'url' => 'civicrm/admin/custom/group', + 'url' => 'civicrm/admin/custom/group/edit', 'qs' => 'action=update&reset=1&id=%%id%%', 'title' => ts('Edit Custom Set'), ], @@ -73,8 +73,8 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { ], CRM_Core_Action::DELETE => [ 'name' => ts('Delete'), - 'url' => 'civicrm/admin/custom/group', - 'qs' => 'action=delete&reset=1&id=%%id%%', + 'url' => 'civicrm/admin/custom/group/delete', + 'qs' => 'reset=1&id=%%id%%', 'title' => ts('Delete Custom Set'), ], ]; @@ -83,104 +83,17 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { } /** - * 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 */ public function run() { - // get the requested action - $action = CRM_Utils_Request::retrieve('action', 'String', - // default to 'browse' - $this, FALSE, 'browse' - ); - - if ($action & CRM_Core_Action::DELETE) { - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/', 'action=browse')); - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_DeleteGroup', "Delete Cutom Set", NULL); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - $controller->set('id', $id); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - } - // assign vars to templates - $this->assign('action', $action); - $id = CRM_Utils_Request::retrieve('id', 'Positive', - $this, FALSE, 0 - ); - - // what action to take ? - if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) { - $this->edit($id, $action); - } - elseif ($action & CRM_Core_Action::PREVIEW) { - $this->preview($id); - } - else { - // finally browse the custom groups - $this->browse(); - } - // parent run + $this->browse(); return parent::run(); } - /** - * Edit custom group. - * - * @param int $id - * Custom group id. - * @param string $action - * The action to be invoked. - * - * @return void - */ - public function edit($id, $action) { - // create a simple controller for editing custom data - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_Group', ts('Custom Set'), $action); - - // set the userContext stack - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/', 'action=browse')); - $controller->set('id', $id); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - } - - /** - * Preview custom group. - * - * @param int $id - * Custom group id. - * - * @return void - */ - public function preview($id) { - $controller = new CRM_Core_Controller_Simple('CRM_Custom_Form_Preview', ts('Preview Custom Data'), NULL); - $session = CRM_Core_Session::singleton(); - $session->pushUserContext(CRM_Utils_System::url('civicrm/admin/custom/group', 'action=browse')); - $controller->set('groupId', $id); - $controller->setEmbedded(TRUE); - $controller->process(); - $controller->run(); - } - /** * Browse all custom data groups. - * - * @param string $action - * The action to be invoked. - * - * @return void */ - public function browse($action = NULL) { + public function browse() { // get all custom groups sorted by weight $customGroup = []; $dao = new CRM_Core_DAO_CustomGroup(); @@ -300,7 +213,7 @@ class CRM_Custom_Page_Group extends CRM_Core_Page { } } - $returnURL = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1&action=browse"); + $returnURL = CRM_Utils_System::url('civicrm/admin/custom/group'); CRM_Utils_Weight::addOrder($customGroup, 'CRM_Core_DAO_CustomGroup', 'id', $returnURL ); diff --git a/CRM/Dedupe/Merger.php b/CRM/Dedupe/Merger.php index 48e000f2a8..147dd90518 100644 --- a/CRM/Dedupe/Merger.php +++ b/CRM/Dedupe/Merger.php @@ -102,7 +102,7 @@ class CRM_Dedupe_Merger { 'rel_table_custom_groups' => [ 'title' => ts('Custom Groups'), 'tables' => ['civicrm_custom_group'], - 'url' => CRM_Utils_System::url('civicrm/admin/custom/group', 'reset=1'), + 'url' => CRM_Utils_System::url('civicrm/admin/custom/group'), ], 'rel_table_uf_groups' => [ 'title' => ts('Profiles'), diff --git a/templates/CRM/Custom/Page/Group.hlp b/templates/CRM/Custom/Form/Group.hlp similarity index 98% rename from templates/CRM/Custom/Page/Group.hlp rename to templates/CRM/Custom/Form/Group.hlp index 05cd658563..3e9df92ede 100644 --- a/templates/CRM/Custom/Page/Group.hlp +++ b/templates/CRM/Custom/Form/Group.hlp @@ -25,12 +25,12 @@ {ts}Display Style{/ts} {/htxt} {htxt id="id-display_style"} - {ts}Select 'Inline' to include this set of fields in the main contact Add/Edit form and Contact Summary screens. Select 'Tab' or 'Tab with Table' to create a separate navigation tab for display and editing these values (generally for less frequently accessed and/or larger sets of fields). 'Tab with Table' is recommended for customs data sets which allow multiple records.{/ts} + {ts}Select 'Inline' to include this set of fields in the main contact Add/Edit form and Contact Summary screens. Select 'Tab' or 'Tab with Table' to create a separate navigation tab for display and editing these values (generally for less frequently accessed and/or larger sets of fields). 'Tab with Table' is recommended for customs data sets which allow multiple records.{/ts} <p class="font-italic">{ts}NOTE: This setting applies only to custom sets used for Contact records (e.g. Individuals, Households, Organizations, or ALL contact types).{/ts}</p> {/htxt} {htxt id="id-extends-title"} - {ts}Entity Type{/ts} + {ts}Used For{/ts} {/htxt} {htxt id="id-extends"} {ts}Select the type of record that this set of custom fields is applicable for. You can configure custom data for a specific type of contact (e.g. Individuals but NOT Organizations), ANY type of contact, or other record types such as activities, contributions, memberships and event participants.{/ts} @@ -64,7 +64,7 @@ {/htxt} {htxt id="id-weight-title"} - {ts}Weight{/ts} + {ts}Order{/ts} {/htxt} {htxt id="id-weight"} {ts}Weight controls the order in which custom field sets are presented when there are more than one. Enter a positive or negative integer - lower numbers are displayed ahead of higher numbers.{/ts} diff --git a/templates/CRM/Custom/Page/Field.tpl b/templates/CRM/Custom/Page/Field.tpl index 39b40c802b..83609a7b8c 100644 --- a/templates/CRM/Custom/Page/Field.tpl +++ b/templates/CRM/Custom/Page/Field.tpl @@ -7,14 +7,7 @@ | and copyright information, see https://civicrm.org/licensing | +--------------------------------------------------------------------+ *} -{if $action eq 1 or $action eq 2 or $action eq 4} - {include file="CRM/Custom/Form/Field.tpl"} -{elseif $action eq 8} - {include file="CRM/Custom/Form/DeleteField.tpl"} -{elseif $action eq 1024 } - {include file="CRM/Custom/Form/Preview.tpl"} -{else} - {if $customField} + {if $customField} <div id="field_page"> {strip} @@ -55,15 +48,12 @@ </div> {else} - {if $action eq 16} <div class="messages status no-popup crm-empty-table"> <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/> {ts}None found.{/ts} </div> - {/if} {/if} <div class="action-link"> - {crmButton p='civicrm/admin/custom/group/field/add' q="reset=1&action=add&gid=$gid" id="newCustomField" class="action-item" icon="plus-circle"}{ts}Add Custom Field{/ts}{/crmButton} + {crmButton p='civicrm/admin/custom/group/field/add' q="reset=1&gid=$gid" id="newCustomField" class="action-item" icon="plus-circle"}{ts}Add Custom Field{/ts}{/crmButton} {crmButton p="civicrm/admin/custom/group" q="reset=1" class="cancel" icon="times"}{ts}Done{/ts}{/crmButton} </div> -{/if} diff --git a/templates/CRM/Custom/Page/Group.tpl b/templates/CRM/Custom/Page/Group.tpl index be07b3f240..6652165b7d 100644 --- a/templates/CRM/Custom/Page/Group.tpl +++ b/templates/CRM/Custom/Page/Group.tpl @@ -8,13 +8,6 @@ +--------------------------------------------------------------------+ *} {* The name "custom data group" is replaced by "custom data set" *} -{if $action eq 1 or $action eq 2 or $action eq 4} - {include file="CRM/Custom/Form/Group.tpl"} -{elseif $action eq 1024} - {include file="CRM/Custom/Form/Preview.tpl"} -{elseif $action eq 8} - {include file="CRM/Custom/Form/DeleteGroup.tpl"} -{else} <div class="help"> {ts}Custom data is stored in custom fields. Custom fields are organized into logically related custom data sets (e.g. Volunteer Info). Use custom fields to collect and store custom data which are not included in the standard CiviCRM forms. You can create one or many sets of custom fields.{/ts} {docURL page="user/organising-your-data/creating-custom-fields"} </div> @@ -54,22 +47,17 @@ </tbody> </table> - {if NOT ($action eq 1 or $action eq 2) } <div class="action-link"> - {crmButton p='civicrm/admin/custom/group' q="action=add&reset=1" id="newCustomDataGroup" icon="plus-circle"}{ts}Add Set of Custom Fields{/ts}{/crmButton} + {crmButton p='civicrm/admin/custom/group/edit' q="action=add&reset=1" id="newCustomDataGroup" icon="plus-circle"}{ts}Add Set of Custom Fields{/ts}{/crmButton} </div> - {/if} {/strip} </div> </div> {else} - {if $action ne 1} {* When we are adding an item, we should not display this message *} <div class="messages status no-popup"> <img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/> - {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group' q='action=add&reset=1'}{/capture} + {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group/edit' q='action=add&reset=1'}{/capture} {ts 1=$crmURL}No custom data groups have been created yet. You can <a id="newCustomDataGroup" href='%1'>add one</a>.{/ts} </div> - {/if} {/if} -{/if} diff --git a/xml/schema/Core/CustomField.xml b/xml/schema/Core/CustomField.xml index 8fb1c82c10..c5a4a2f617 100644 --- a/xml/schema/Core/CustomField.xml +++ b/xml/schema/Core/CustomField.xml @@ -11,8 +11,8 @@ <paths> <add>civicrm/admin/custom/group/field/add?reset=1&action=add&gid=[custom_group_id]</add> <update>civicrm/admin/custom/group/field/update?action=update&reset=1&id=[id]&gid=[custom_group_id]</update> - <preview>civicrm/admin/custom/group/field?action=preview&reset=1&id=[id]&gid=[custom_group_id]</preview> - <delete>civicrm/admin/custom/group/field?action=delete&reset=1&id=[id]&gid=[custom_group_id]</delete> + <preview>civicrm/admin/custom/group/preview&reset=1&fid=[id]</preview> + <delete>civicrm/admin/custom/group/field/delete?reset=1&id=[id]</delete> <move>civicrm/admin/custom/group/field/move?reset=1&fid=[id]</move> </paths> <field> diff --git a/xml/schema/Core/CustomGroup.xml b/xml/schema/Core/CustomGroup.xml index 853a106e32..3fd5522cdf 100644 --- a/xml/schema/Core/CustomGroup.xml +++ b/xml/schema/Core/CustomGroup.xml @@ -11,10 +11,10 @@ <title>Custom Field Group</title> <labelField>title</labelField> <paths> - <add>civicrm/admin/custom/group?action=add&reset=1</add> - <update>civicrm/admin/custom/group?action=update&reset=1&id=[id]</update> - <preview>civicrm/admin/custom/group?action=preview&reset=1&id=[id]</preview> - <delete>civicrm/admin/custom/group?action=delete&reset=1&id=[id]</delete> + <add>civicrm/admin/custom/group/edit?action=add&reset=1</add> + <update>civicrm/admin/custom/group/edit?action=update&reset=1&id=[id]</update> + <preview>civicrm/admin/custom/group/preview?reset=1&gid=[id]</preview> + <delete>civicrm/admin/custom/group/delete?reset=1&id=[id]</delete> </paths> <field> <name>id</name>