3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
15 * @copyright CiviCRM LLC https://civicrm.org/licensing
19 * This class is to build the form for Deleting Group
21 class CRM_Custom_Form_DeleteGroup
extends CRM_Core_Form
{
31 * The title of the group being deleted.
38 * Set up variables to build the form.
43 public function preProcess() {
44 $this->_id
= $this->get('id');
47 $params = ['id' => $this->_id
];
48 CRM_Core_BAO_CustomGroup
::retrieve($params, $defaults);
49 $this->_title
= $defaults['title'];
51 //check wheter this contain any custom fields
52 $customField = new CRM_Core_DAO_CustomField();
53 $customField->custom_group_id
= $this->_id
;
55 if ($customField->find(TRUE)) {
56 CRM_Core_Session
::setStatus(ts("The Group '%1' cannot be deleted! You must Delete all custom fields in this group prior to deleting the group.", [1 => $this->_title
]), ts('Deletion Error'), 'error');
57 $url = CRM_Utils_System
::url('civicrm/admin/custom/group', "reset=1");
58 CRM_Utils_System
::redirect($url);
61 $this->assign('title', $this->_title
);
63 CRM_Utils_System
::setTitle(ts('Confirm Custom Group Delete'));
67 * Build the form object.
71 public function buildQuickForm() {
76 'name' => ts('Delete Custom Group'),
81 'name' => ts('Cancel'),
87 * Process the form when submitted.
91 public function postProcess() {
92 $group = new CRM_Core_DAO_CustomGroup();
93 $group->id
= $this->_id
;
96 $wt = CRM_Utils_Weight
::delWeight('CRM_Core_DAO_CustomGroup', $this->_id
);
97 CRM_Core_BAO_CustomGroup
::deleteGroup($group);
98 CRM_Core_Session
::setStatus(ts("The Group '%1' has been deleted.", [1 => $group->title
]), '', 'success');