/** * 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'); }
/** * Use this API to delete an existing group. * * @param array $params * * @return array */ function civicrm_api3_custom_group_delete($params) { $values = new CRM_Core_DAO_CustomGroup(); $values->id = $params['id']; $values->find(TRUE); $result = CRM_Core_BAO_CustomGroup::deleteGroup($values, TRUE); return $result ? civicrm_api3_create_success() : civicrm_api3_create_error('Error while deleting custom group'); }
/** * Function to test deleteGroup() */ function testDeleteGroup() { $customGrouptitle = 'My Custom Group'; $groupParams = array('title' => $customGrouptitle, 'name' => 'my_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'is_active' => 1); $customGroup = Custom::createGroup($groupParams); $customGroupId = $customGroup->id; //get the custom group title $dbCustomGroupTitle = $this->assertDBNotNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.'); //check for group title $this->assertEquals($customGrouptitle, $dbCustomGroupTitle); require_once 'CRM/Core/BAO/CustomGroup.php'; //delete the group $isDelete = CRM_Core_BAO_CustomGroup::deleteGroup($customGroup); //check for delete $this->assertEquals(true, $isDelete); //check the DB $this->assertDBNull('CRM_Core_DAO_CustomGroup', $customGroupId, 'title', 'id', 'Database check for custom group record.'); }
/** * Process the form when submitted * * @return void * @access public */ function postProcess() { $group =& new CRM_Core_DAO_CustomGroup(); $group->id = $this->_id; $group->find(); $group->fetch(); if (CRM_Core_BAO_CustomGroup::deleteGroup($this->_id)) { CRM_Core_Session::setStatus(ts('The Group "%1" has been deleted.', array(1 => $group->title))); } else { CRM_Core_Session::setStatus(ts('The Group "%1" has not been deleted! You must Delete all custom fields in this group prior to deleting the group', array(1 => $group->title))); } }
/** * Helper function to delete custom group * @deprecated use function on parent class * @param object Custom Group to delete * @return boolean true if Group deleted, false otherwise */ static function deleteGroup($params) { require_once 'CRM/Core/BAO/CustomGroup.php'; $deleteCustomGroup = CRM_Core_BAO_CustomGroup::deleteGroup($params, TRUE); return $deleteCustomGroup; }
/** * Test deleteGroup. */ public function testDeleteGroup() { $customGroupTitle = 'My Custom Group'; $groupParams = array('title' => $customGroupTitle, 'name' => 'my_custom_group', 'style' => 'Tab', 'extends' => 'Individual', 'is_active' => 1); $customGroup = $this->customGroupCreate($groupParams); $groupObject = new CRM_Core_BAO_CustomGroup(); $groupObject->id = $customGroup['id']; $groupObject->find(TRUE); $isDelete = CRM_Core_BAO_CustomGroup::deleteGroup($groupObject); // Check it worked! $this->assertEquals(TRUE, $isDelete); $this->assertDBNull('CRM_Core_DAO_CustomGroup', $customGroup['id'], 'title', 'id', 'Database check for custom group record.'); }
/** * Use this API to delete an existing group. * * @param array id of the group to be deleted * * @return Null if success * @access public **/ function civicrm_custom_group_delete($params) { _civicrm_initialize(); if (!is_array($params)) { return civicrm_create_error('Params is not an array'); } if (!CRM_Utils_Array::value('id', $params)) { return civicrm_create_error('Invalid or no value for Custom group ID'); } // convert params array into Object require_once 'CRM/Core/DAO/CustomGroup.php'; $values = new CRM_Core_DAO_CustomGroup(); $values->id = $params['id']; $values->find(true); require_once 'CRM/Core/BAO/CustomGroup.php'; $result = CRM_Core_BAO_CustomGroup::deleteGroup($values); return $result ? civicrm_create_success() : civicrm_error('Error while deleting custom group'); }
/** * Helper function to delete custom group. * * @deprecated use function on parent class * * @param $params * * @return bool * true if Group deleted, false otherwise */ public static function deleteGroup($params) { $deleteCustomGroup = CRM_Core_BAO_CustomGroup::deleteGroup($params, TRUE); return $deleteCustomGroup; }