Merge pull request #12639 from aniesshsethh/issue_314
authorEileen McNaughton <eileen@mcnaughty.com>
Sat, 23 Mar 2019 20:43:35 +0000 (09:43 +1300)
committerGitHub <noreply@github.com>
Sat, 23 Mar 2019 20:43:35 +0000 (09:43 +1300)
dev/core#314 Event self-service Transfer picks up the deleted contact ID basically transferring to the wrong contact

1  2 
CRM/Event/Form/SelfSvcTransfer.php

index 0985d6b18ca4151adca010985012a379d92a55ac,fc1703720326d006bbccdb3736ed9864577dd17b..8fd10a2127b9416c127bb79d18ea4a5fe325c99e
@@@ -4,7 -4,7 +4,7 @@@
   +--------------------------------------------------------------------+
   | CiviCRM version 5                                            |
   +--------------------------------------------------------------------+
 - | Copyright CiviCRM LLC (c) 2004-2018                                |
 + | Copyright CiviCRM LLC (c) 2004-2019                                |
   +--------------------------------------------------------------------+
   | This file is a part of CiviCRM.                                    |
   |                                                                    |
@@@ -29,7 -29,7 +29,7 @@@
  /**
   *
   * @package CRM
 - * @copyright CiviCRM LLC (c) 2004-2018
 + * @copyright CiviCRM LLC (c) 2004-2019
   * $Id$
   *
   */
@@@ -337,10 -337,17 +337,17 @@@ class CRM_Event_Form_SelfSvcTransfer ex
      }
      else {
        //cancel 'from' participant row
-       $query = "select contact_id from civicrm_email where email = '" . $params['email'] . "'";
-       $dao = CRM_Core_DAO::executeQuery($query);
-       while ($dao->fetch()) {
-         $contact_id  = $dao->contact_id;
+       $contact_id_result = civicrm_api3('Contact', 'get', array(
+         'sequential' => 1,
+         'return' => array("id"),
+         'email' => $params['email'],
+         'options' => array('limit' => 1),
+       ));
+       $contact_id_result = $contact_id_result['values'][0];
+       $contact_id = $contact_id_result['contact_id'];
+       $contact_is_deleted = $contact_id_result['contact_is_deleted'];
+       if ($contact_is_deleted || !is_numeric($contact_id)) {
+         CRM_Core_Error::statusBounce(ts('Contact does not exist.'));
        }
      }
      $from_participant = $params = array();