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
21 * This class is to build the form for Deleting Group
23 class CRM_Custom_Form_DeleteGroup
extends CRM_Core_Form
{
33 * The title of the group being deleted.
40 * Set up variables to build the form.
45 public function preProcess() {
46 $this->_id
= $this->get('id');
49 $params = ['id' => $this->_id
];
50 CRM_Core_BAO_CustomGroup
::retrieve($params, $defaults);
51 $this->_title
= $defaults['title'];
53 //check wheter this contain any custom fields
54 $customField = new CRM_Core_DAO_CustomField();
55 $customField->custom_group_id
= $this->_id
;
57 if ($customField->find(TRUE)) {
58 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');
59 $url = CRM_Utils_System
::url('civicrm/admin/custom/group', "reset=1");
60 CRM_Utils_System
::redirect($url);
63 $this->assign('title', $this->_title
);
65 CRM_Utils_System
::setTitle(ts('Confirm Custom Group Delete'));
69 * Build the form object.
73 public function buildQuickForm() {
78 'name' => ts('Delete Custom Group'),
83 'name' => ts('Cancel'),
89 * Process the form when submitted.
93 public function postProcess() {
94 $group = new CRM_Core_DAO_CustomGroup();
95 $group->id
= $this->_id
;
98 $wt = CRM_Utils_Weight
::delWeight('CRM_Core_DAO_CustomGroup', $this->_id
);
99 CRM_Core_BAO_CustomGroup
::deleteGroup($group);
100 CRM_Core_Session
::setStatus(ts("The Group '%1' has been deleted.", [1 => $group->title
]), '', 'success');