/** * Delete the payment identified by $pmtid. * @param $pmtid The payment id. */ function payment_delete($pmtid) { $payment = crm_get_one('payment', array('pmtid' => $pmtid)); $payment = module_invoke_api('payment', $payment, 'delete'); // Query database $esc_pmtid = mysql_real_escape_string($pmtid); $sql = "\n DELETE FROM `payment`\n WHERE `pmtid`='{$esc_pmtid}'"; $res = mysql_query($sql); if (!$res) { crm_error(mysql_error()); } if (mysql_affected_rows() > 0) { message_register('Deleted payment with id ' . $pmtid); } }
/** * Delete a contact. * @param $cid The contact id. */ function contact_delete($cid) { $contact = crm_get_one('contact', array('cid' => $cid)); if (empty($contact)) { error_register("No contact with cid {$cid}"); return; } // Notify other modules the contact is being deleted $contact = module_invoke_api('contact', $contact, 'delete'); // Remove the contact from the database $esc_cid = mysql_real_escape_string($cid); $sql = "DELETE FROM `contact` WHERE `cid`='{$esc_cid}'"; $res = mysql_query($sql); if (!$res) { crm_error(mysql_error()); } message_register('Deleted contact: ' . theme('contact_name', $contact)); }