Merge pull request #4621 from atif-shaikh/CRM-15589
[civicrm-core.git] / CRM / Utils / DeprecatedUtils.php
index eff034adaf9ef02fb0bf9608421f3829dcd87253..85effe9287b184f17a9fc54602b14904483470b3 100644 (file)
@@ -285,11 +285,13 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
         }
         $dao = new CRM_Core_DAO();
         $qParams = array();
-        $svq = $dao->singleValueQuery("SELECT id FROM civicrm_contact WHERE id = $value",
+        $svq = $dao->singleValueQuery("SELECT is_deleted FROM civicrm_contact WHERE id = $value",
           $qParams
         );
-        if (!$svq) {
+        if (!isset($svq)) {
           return civicrm_api3_create_error("Invalid Contact ID: There is no contact record with contact_id = $value.");
+        } else if ($svq == 1) {
+          return civicrm_api3_create_error("Invalid Contact ID: contact_id $value is a soft-deleted contact.");
         }
 
         $values['contact_id'] = $values['contribution_contact_id'];
@@ -594,7 +596,7 @@ function _civicrm_api3_deprecated_formatted_param($params, &$values, $create = F
 }
 
 /**
- *  Function to check duplicate contacts based on de-deupe parameters
+ * check duplicate contacts based on de-deupe parameters
  */
 function _civicrm_api3_deprecated_check_contact_dedupe($params) {
   static $cIndieFields = NULL;
@@ -1210,12 +1212,9 @@ function _civicrm_api3_deprecated_validate_formatted_contact(&$params) {
 /**
  * @deprecated - this is part of the import parser not the API & needs to be moved on out
  *
- * @param $params
+ * @param array $params
  * @param $onDuplicate
  *
- * @internal param $ <type> $params
- * @internal param $ <type> $onDuplicate
- *
  * @return array|bool <type>
  */
 function _civicrm_api3_deprecated_create_participant_formatted($params, $onDuplicate) {
@@ -1263,7 +1262,7 @@ function _civicrm_api3_deprecated_participant_check_params($params, $checkDuplic
   if (!empty($params['event_id'])) {
     $isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $params['event_id'], 'is_template');
     if (!empty($isTemplate)) {
-      return civicrm_api3_create_error(ts('Event templates are not meant to be registered'));
+      return civicrm_api3_create_error(ts('Event templates are not meant to be registered.'));
     }
   }
 
@@ -1328,7 +1327,7 @@ function _civicrm_api3_deprecated_contact_check_custom_params($params, $csType =
 }
 
 /**
- * @param $params
+ * @param array $params
  * @param bool $dupeCheck
  * @param bool $dupeErrorArray
  * @param bool $requiredCheck
@@ -1374,7 +1373,7 @@ function _civicrm_api3_deprecated_contact_check_params(
 
     if ($csType = CRM_Utils_Array::value('contact_sub_type', $params)) {
       if (!(CRM_Contact_BAO_ContactType::isExtendsContactType($csType, $params['contact_type']))) {
-        return civicrm_api3_create_error("Invalid or Mismatched Contact SubType: " . implode(', ', (array)$csType));
+        return civicrm_api3_create_error("Invalid or Mismatched Contact Subtype: " . implode(', ', (array)$csType));
       }
     }
 
@@ -1468,9 +1467,6 @@ function _civicrm_api3_deprecated_contact_check_params(
  * @param $result
  * @param $activityTypeID
  *
- * @internal param $ <type> $result
- * @internal param $ <type> $activityTypeID
- *
  * @return array <type> $params
  */
 function _civicrm_api3_deprecated_activity_buildmailparams($result, $activityTypeID) {