_id = $this->get('id'); $defaults = array(); $params = array('id' => $this->_id); CRM_Core_BAO_CustomGroup::retrieve($params, $defaults); $this->_title = $defaults['title']; //check wheter this contain any custom fields $customField = new CRM_Core_DAO_CustomField(); $customField->custom_group_id = $this->_id; if ($customField->find(TRUE)) { 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.", array(1 => $this->_title)), ts('Deletion Error'), 'error'); $url = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1"); CRM_Utils_System::redirect($url); return TRUE; } $this->assign('title', $this->_title); CRM_Utils_System::setTitle(ts('Confirm Custom Group Delete')); } /** * Build the form object * * @return void * @access public */ public function buildQuickForm() { $this->addButtons(array( array( 'type' => 'next', 'name' => ts('Delete Custom Group'), 'isDefault' => TRUE, ), array( 'type' => 'cancel', 'name' => ts('Cancel'), ), ) ); } /** * Process the form when submitted * * @return void * @access public */ public function postProcess() { $group = new CRM_Core_DAO_CustomGroup(); $group->id = $this->_id; $group->find(TRUE); $wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_CustomGroup', $this->_id); CRM_Core_BAO_CustomGroup::deleteGroup($group); CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", array(1 => $group->title)), '', 'success'); } }