本文整理汇总了PHP中CRM_Contact_DAO_Contact::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Contact::delete方法的具体用法?PHP CRM_Contact_DAO_Contact::delete怎么用?PHP CRM_Contact_DAO_Contact::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_DAO_Contact
的用法示例。
在下文中一共展示了CRM_Contact_DAO_Contact::delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteContact
/**
* Delete a contact and all its associated records
*
* @param int $id id of the contact to delete
* @param bool $restore whether to actually restore, not delete
* @param bool $skipUndelete whether to force contact delete or not
*
* @return boolean true if contact deleted, false otherwise
* @access public
* @static
*/
function deleteContact($id, $restore = false, $skipUndelete = false)
{
require_once 'CRM/Activity/BAO/Activity.php';
if (!$id) {
return false;
}
// make sure we have edit permission for this contact
// before we delete
require_once 'CRM/Contact/BAO/Contact/Permission.php';
if ($skipUndelete && !CRM_Core_Permission::check('delete contacts') || $restore && !CRM_Core_Permission::check('access deleted contacts')) {
return false;
}
// make sure this contact_id does not have any membership types
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $id, 'id', 'member_of_contact_id');
if ($membershipTypeID) {
return false;
}
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $id;
if (!$contact->find(true)) {
return false;
}
if ($restore) {
self::contactTrashRestore($contact->id, true);
return true;
}
$contactType = $contact->contact_type;
// currently we only clear employer cache.
// we are not deleting inherited membership if any.
if ($contact->contact_type == 'Organization') {
require_once 'CRM/Contact/BAO/Contact/Utils.php';
CRM_Contact_BAO_Contact_Utils::clearAllEmployee($id);
}
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::pre('delete', $contactType, $id, CRM_Core_DAO::$_nullArray);
// start a new transaction
require_once 'CRM/Core/Transaction.php';
$transaction = new CRM_Core_Transaction();
$config =& CRM_Core_Config::singleton();
if ($skipUndelete or !$config->contactUndelete) {
//delete billing address if exists.
require_once 'CRM/Contribute/BAO/Contribution.php';
CRM_Contribute_BAO_Contribution::deleteAddress(null, $id);
// delete the log entries since we dont have triggers enabled as yet
require_once 'CRM/Core/DAO/Log.php';
$logDAO =& new CRM_Core_DAO_Log();
$logDAO->entity_table = 'civicrm_contact';
$logDAO->entity_id = $id;
$logDAO->delete();
// do activity cleanup, CRM-5604
require_once 'CRM/Activity/BAO/Activity.php';
CRM_Activity_BAO_activity::cleanupActivity($id);
$contact->delete();
} else {
self::contactTrashRestore($contact->id);
}
//delete the contact id from recently view
require_once 'CRM/Utils/Recent.php';
CRM_Utils_Recent::delContact($id);
// reset the group contact cache for this group
require_once 'CRM/Contact/BAO/GroupContactCache.php';
CRM_Contact_BAO_GroupContactCache::remove();
$transaction->commit();
CRM_Utils_Hook::post('delete', $contactType, $contact->id, $contact);
// also reset the DB_DO global array so we can reuse the memory
// http://issues.civicrm.org/jira/browse/CRM-4387
CRM_Core_DAO::freeResult();
return true;
}
示例2: tearDown
protected function tearDown()
{
$this->contact->delete();
}