- $checksumValue = "";
-
- if ($entityID && $entity == 'membership') {
- if (!$userId) {
- $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
- $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
- $checksumValue = "&cs={$checksumValue}";
- }
- return CRM_Utils_System::url($url, "reset=1&mid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
- }
-
- if ($entityID && $entity == 'contribution') {
- if (!$userId) {
- $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id");
- $checksumValue = CRM_Contact_BAO_Contact_Utils::generateChecksum($contactID, NULL, 'inf');
- $checksumValue = "&cs={$checksumValue}";
- }
- return CRM_Utils_System::url($url, "reset=1&coid={$entityID}{$checksumValue}", TRUE, NULL, FALSE, TRUE);
- }
-
- if ($entityID && $entity == 'recur') {
- if (!$userId) {
- $sql = "
+ $contactID = 0;
+ $checksumValue = '';
+ $entityArg = '';
+
+ // Find related Contact
+ if ($entityID) {
+ switch ($entity) {
+ case 'membership' :
+ $contactID = CRM_Core_DAO::getFieldValue("CRM_Member_DAO_Membership", $entityID, "contact_id");
+ $entityArg = 'mid';
+ break;
+
+ case 'contribution' :
+ $contactID = CRM_Core_DAO::getFieldValue("CRM_Contribute_DAO_Contribution", $entityID, "contact_id");
+ $entityArg = 'coid';
+ break;
+
+ case 'recur' :
+ $sql = "