diff --git a/CRM/Admin/Form/ContactType.php b/CRM/Admin/Form/ContactType.php index 20bedf59c5cc..77b92cb89a55 100644 --- a/CRM/Admin/Form/ContactType.php +++ b/CRM/Admin/Form/ContactType.php @@ -117,11 +117,11 @@ public function postProcess() { CRM_Utils_System::flushCache(); if ($this->_action & CRM_Core_Action::DELETE) { - $isDelete = CRM_Contact_BAO_ContactType::del($this->_id); - if ($isDelete) { + try { + CRM_Contact_BAO_ContactType::deleteRecord(['id' => $this->_id]); CRM_Core_Session::setStatus(ts('Selected contact type has been deleted.'), ts('Record Deleted'), 'success'); } - else { + catch (CRM_Core_Exception $e) { CRM_Core_Session::setStatus(ts("Selected contact type can not be deleted. Make sure contact type doesn't have any associated custom data or group."), ts('Sorry'), 'error'); } return; diff --git a/CRM/Contact/BAO/ContactType.php b/CRM/Contact/BAO/ContactType.php index d02752fe9d35..05f9177e4c2e 100644 --- a/CRM/Contact/BAO/ContactType.php +++ b/CRM/Contact/BAO/ContactType.php @@ -459,6 +459,7 @@ public static function getCreateNewList() { * @return bool */ public static function del($contactTypeId) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); if (!$contactTypeId) { return FALSE; } diff --git a/CRM/Core/Form/RecurringEntity.php b/CRM/Core/Form/RecurringEntity.php index 05435a6aa857..04d4a5e5ca29 100644 --- a/CRM/Core/Form/RecurringEntity.php +++ b/CRM/Core/Form/RecurringEntity.php @@ -364,7 +364,7 @@ public static function postProcess($params, $type, $linkedEntities = []) { 'name' ); if ($optionGroupIdExists) { - CRM_Core_BAO_OptionGroup::del($optionGroupIdExists); + CRM_Core_BAO_OptionGroup::deleteRecord(['id' => $optionGroupIdExists]); } $optionGroupParams = [ 'name' => $type . '_repeat_exclude_dates_' . $actionScheduleObj->entity_value, diff --git a/CRM/Extension/Manager/Report.php b/CRM/Extension/Manager/Report.php index 06160d34fb33..45f1adae1c60 100644 --- a/CRM/Extension/Manager/Report.php +++ b/CRM/Extension/Manager/Report.php @@ -79,7 +79,7 @@ public function onPreUninstall(CRM_Extension_Info $info) { $customReports = $this->getCustomReportsByName(); $cr = $this->getCustomReportsById(); $id = $cr[$customReports[$info->key]]; - $optionValue = CRM_Core_BAO_OptionValue::del($id); + $optionValue = CRM_Core_BAO_OptionValue::deleteRecord(['id' => $id]); return $optionValue ? TRUE : FALSE; } diff --git a/CRM/Extension/Manager/Search.php b/CRM/Extension/Manager/Search.php index 2f3910896c32..c251555bcaec 100644 --- a/CRM/Extension/Manager/Search.php +++ b/CRM/Extension/Manager/Search.php @@ -77,7 +77,7 @@ public function onPreUninstall(CRM_Extension_Info $info) { $cs = $this->getCustomSearchesById(); $id = $cs[$customSearchesByName[$info->key]]; - CRM_Core_BAO_OptionValue::del($id); + CRM_Core_BAO_OptionValue::deleteRecord(['id' => $id]); return TRUE; } diff --git a/CRM/Report/BAO/ReportInstance.php b/CRM/Report/BAO/ReportInstance.php index 930b44aad154..1554cc0cce25 100644 --- a/CRM/Report/BAO/ReportInstance.php +++ b/CRM/Report/BAO/ReportInstance.php @@ -223,6 +223,7 @@ public static function &create(&$params) { * @return mixed */ public static function del($id = NULL) { + CRM_Core_Error::deprecatedFunctionWarning('deleteRecord'); self::deleteRecord(['id' => $id]); return 1; } @@ -325,7 +326,7 @@ public static function doFormDelete($instanceId, $bounceTo = 'civicrm/report/lis CRM_Core_Error::statusBounce($statusMessage, $bounceTo); } - CRM_Report_BAO_ReportInstance::del($instanceId); + CRM_Report_BAO_ReportInstance::deleteRecord(['id' => $instanceId]); CRM_Core_Session::setStatus(ts('Selected report has been deleted.'), ts('Deleted'), 'success'); if ($successRedirect) { diff --git a/CRM/Report/Form/Register.php b/CRM/Report/Form/Register.php index c4a8f659458a..af5c12e4e3f4 100644 --- a/CRM/Report/Form/Register.php +++ b/CRM/Report/Form/Register.php @@ -158,7 +158,7 @@ public static function formRule($fields, $files, $self) { public function postProcess() { if ($this->_action & CRM_Core_Action::DELETE) { - if (CRM_Core_BAO_OptionValue::del($this->_id)) { + if (CRM_Core_BAO_OptionValue::deleteRecord(['id' => $this->_id])) { CRM_Core_Session::setStatus(ts('Selected %1 Report has been deleted.', [1 => $this->_GName]), ts('Record Deleted'), 'success'); CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/report/options/report_template', "reset=1")); } diff --git a/api/v3/ActivityType.php b/api/v3/ActivityType.php index 774e9b3101db..6880e6ae7ef2 100644 --- a/api/v3/ActivityType.php +++ b/api/v3/ActivityType.php @@ -98,7 +98,7 @@ function _civicrm_api3_activity_type_create_spec(&$params) { * @deprecated use OptionValue api */ function civicrm_api3_activity_type_delete($params) { - $result = CRM_Core_BAO_OptionValue::del($params['id']); + $result = CRM_Core_BAO_OptionValue::deleteRecord($params); if ($result) { return civicrm_api3_create_success(TRUE, $params); }