CustomField Admin - Decouple page code from form code
authorColeman Watts <coleman@civicrm.org>
Sun, 16 Jan 2022 01:50:30 +0000 (20:50 -0500)
committerColeman Watts <coleman@civicrm.org>
Tue, 25 Jan 2022 15:12:44 +0000 (10:12 -0500)
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.

17 files changed:
CRM/Campaign/Form/Survey/Questions.php
CRM/Core/DAO/CustomField.php
CRM/Core/DAO/CustomGroup.php
CRM/Core/xml/Menu/Admin.xml
CRM/Custom/Form/DeleteField.php
CRM/Custom/Form/DeleteGroup.php
CRM/Custom/Form/Field.php
CRM/Custom/Form/Group.php
CRM/Custom/Form/Preview.php
CRM/Custom/Page/Field.php
CRM/Custom/Page/Group.php
CRM/Dedupe/Merger.php
templates/CRM/Custom/Form/Group.hlp [moved from templates/CRM/Custom/Page/Group.hlp with 98% similarity]
templates/CRM/Custom/Page/Field.tpl
templates/CRM/Custom/Page/Group.tpl
xml/schema/Core/CustomField.xml
xml/schema/Core/CustomGroup.xml

index 1879f022c542107348636db22bce954f01e52a88..3dae1e4917b0d9fb3298aeee5d6e1d32cec8722b 100644 (file)
@@ -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',
           ]
         )
index b28303a25e8891e6410c13f1423ab1e89def74e5..f7f8aab92213c2dd15acd3985b82bdef51ea1ef7 100644 (file)
@@ -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]',
   ];
 
index e15adbf24a33686a7a0ce89728cf2a148d9c70a6..6bb2ce18e0df8373910f260e20bd02ccdc38d0df 100644 (file)
@@ -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]',
   ];
 
   /**
index be6af284ad0b382e71ea55ff732d9efc22db84ca..596018228addb6c86791eee51003e92414f3ba84 100644 (file)
      <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>
      <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>
index 993ed6138e86a128a27dafcca1a729339ad8421f..7793b9ac3953054377b6c67bee21ae4fc0379174 100644 (file)
@@ -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];
index d3b9169fb02b28f23c3345f622e38e0ce3412d2c..1fed29e919ce7be5faa53b40d85ddcd8edd0a244 100644 (file)
@@ -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];
index 0e026ff654e8c8e2c266ef01c76991bbd5bcd2bb..3a4db3b7e55442941c985c26d498c09f65bc011f 100644 (file)
@@ -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');
index cf4c37cdac40dd3312f9163d9eab3a4e5ad5d97d..46dde5f9b2182aa065f8f82bf8be4ec08851f807 100644 (file)
@@ -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');
index 102712d94d0d87a49d8f44c4885e6a67c5a7ab5a..7d59ba18282ffc8c360b8506310dd1fb2d62436c 100644 (file)
  */
 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');
index 58c44f752546f667042048b895c473cd09e01fad..b11cd85b188aea9bfd94db4c8a1daab3157cafd6 100644 (file)
@@ -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();
-  }
-
 }
index ec7b742edef248cf8600426f745ca23dd2169886..919e5260e2a35d5b45a82405a1f012a5bcddd3b2 100644 (file)
@@ -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
     );
index 48e000f2a8cace9352699647acfec8fbf5c4c5f8..147dd905182019f428170bbb2e466b53b324be71 100644 (file)
@@ -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'),
similarity index 98%
rename from templates/CRM/Custom/Page/Group.hlp
rename to templates/CRM/Custom/Form/Group.hlp
index 05cd658563ba75aee3ef9b74063dceb0c460b63a..3e9df92edeaad9fabe205b7132ce4ff69cbaa272 100644 (file)
   {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}
index 39b40c802bef3949a5f81d4ecbfa114692fd66ef..83609a7b8c0e8a79f5715ae0526126b3735ac893 100644 (file)
@@ -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}
      </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}
index be07b3f2406a53a136bf15892731ae9a014fba07..6652165b7d2a13fef53bbba284424f773c4b96c7 100644 (file)
@@ -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>
         </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}"/> &nbsp;
-         {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}
index 8fb1c82c10b0115454bff015afd9498d0de4ca4a..c5a4a2f617facc47d23cc1e20614c25a3892657e 100644 (file)
@@ -11,8 +11,8 @@
   <paths>
     <add>civicrm/admin/custom/group/field/add?reset=1&amp;action=add&amp;gid=[custom_group_id]</add>
     <update>civicrm/admin/custom/group/field/update?action=update&amp;reset=1&amp;id=[id]&amp;gid=[custom_group_id]</update>
-    <preview>civicrm/admin/custom/group/field?action=preview&amp;reset=1&amp;id=[id]&amp;gid=[custom_group_id]</preview>
-    <delete>civicrm/admin/custom/group/field?action=delete&amp;reset=1&amp;id=[id]&amp;gid=[custom_group_id]</delete>
+    <preview>civicrm/admin/custom/group/preview&amp;reset=1&amp;fid=[id]</preview>
+    <delete>civicrm/admin/custom/group/field/delete?reset=1&amp;id=[id]</delete>
     <move>civicrm/admin/custom/group/field/move?reset=1&amp;fid=[id]</move>
   </paths>
   <field>
index 853a106e3263e247bbf5a71a530ccbc4588055a1..3fd5522cdf1cc5d8391a6b1dd210483172ba3bb5 100644 (file)
   <title>Custom Field Group</title>
   <labelField>title</labelField>
   <paths>
-    <add>civicrm/admin/custom/group?action=add&amp;reset=1</add>
-    <update>civicrm/admin/custom/group?action=update&amp;reset=1&amp;id=[id]</update>
-    <preview>civicrm/admin/custom/group?action=preview&amp;reset=1&amp;id=[id]</preview>
-    <delete>civicrm/admin/custom/group?action=delete&amp;reset=1&amp;id=[id]</delete>
+    <add>civicrm/admin/custom/group/edit?action=add&amp;reset=1</add>
+    <update>civicrm/admin/custom/group/edit?action=update&amp;reset=1&amp;id=[id]</update>
+    <preview>civicrm/admin/custom/group/preview?reset=1&amp;gid=[id]</preview>
+    <delete>civicrm/admin/custom/group/delete?reset=1&amp;id=[id]</delete>
   </paths>
   <field>
     <name>id</name>