本文整理汇总了PHP中CRM_Core_BAO_UFMatch::deleteContact方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFMatch::deleteContact方法的具体用法?PHP CRM_Core_BAO_UFMatch::deleteContact怎么用?PHP CRM_Core_BAO_UFMatch::deleteContact使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFMatch
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFMatch::deleteContact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteContact
/**
* Delete a contact and all its associated records
*
* @param int $id id of the contact to delete
*
* @return boolean true if contact deleted, false otherwise
* @access public
* @static
*/
function deleteContact($id)
{
require_once 'CRM/Core/BAO/EmailHistory.php';
require_once 'CRM/Core/BAO/Meeting.php';
require_once 'CRM/Core/BAO/Phonecall.php';
// make sure we have edit permission for this contact
// before we delete
if (!CRM_Contact_BAO_Contact::permissionedContact($id, CRM_CORE_PERMISSION_EDIT)) {
return false;
}
require_once 'CRM/Utils/Hook.php';
$contact =& new CRM_Contact_DAO_Contact();
$contact->id = $id;
if (!$contact->find(true)) {
return false;
}
$contactType = $contact->contact_type;
CRM_Utils_Hook::pre('delete', $contactType, $id);
CRM_Core_DAO::transaction('BEGIN');
// do a top down deletion
CRM_Mailing_Event_BAO_Subscribe::deleteContact($id);
CRM_Contact_BAO_GroupContact::deleteContact($id);
CRM_Contact_BAO_SubscriptionHistory::deleteContact($id);
CRM_Contact_BAO_Relationship::deleteContact($id);
CRM_Contribute_BAO_Contribution::deleteContact($id);
CRM_Core_BAO_Note::deleteContact($id);
CRM_Core_DAO::deleteEntityContact('CRM_Core_DAO_CustomValue', $id);
CRM_Core_DAO::deleteEntityContact('CRM_Core_DAO_ActivityHistory', $id);
require_once 'CRM/Core/BAO/UFMatch.php';
CRM_Core_BAO_UFMatch::deleteContact($id);
// need to remove them from email, meeting and phonecall
CRM_Core_BAO_EmailHistory::deleteContact($id);
CRM_Core_BAO_Meeting::deleteContact($id);
CRM_Core_BAO_Phonecall::deleteContact($id);
// location shld be deleted after phonecall, since fields in phonecall are
// fkeyed into location/phone.
CRM_Core_BAO_Location::deleteContact($id);
// fix household and org primary contact ids
foreach ($GLOBALS['_CRM_CONTACT_BAO_CONTACT']['misc'] as $name) {
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_DAO_" . $name) . ".php";
eval('$object =& new CRM_Contact_DAO_' . $name . '( );');
$object->primary_contact_id = $id;
$object->find();
while ($object->fetch()) {
// we need to set this to null explicitly
$object->primary_contact_id = 'null';
$object->save();
}
}
require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contactType) . ".php";
eval('$object =& new CRM_Contact_BAO_' . $contactType . '( );');
$object->contact_id = $contact->id;
$object->delete();
$contact->delete();
//delete the contact id from recently view
CRM_Utils_Recent::del($id);
CRM_Core_DAO::transaction('COMMIT');
CRM_Utils_Hook::post('delete', $contactType, $contact->id, $contact);
return true;
}