当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Contact_BAO_Contact::deleteContact方法代码示例

本文整理汇总了PHP中CRM_Contact_BAO_Contact::deleteContact方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Contact::deleteContact方法的具体用法?PHP CRM_Contact_BAO_Contact::deleteContact怎么用?PHP CRM_Contact_BAO_Contact::deleteContact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Contact_BAO_Contact的用法示例。


在下文中一共展示了CRM_Contact_BAO_Contact::deleteContact方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processAction

 /**
  * Method processAction to execute the action
  *
  * @param CRM_Civirules_TriggerData_TriggerData $triggerData
  * @access public
  *
  */
 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     $contactId = $triggerData->getContactId();
     //we cannot delete domain contacts
     if (CRM_Contact_BAO_Contact::checkDomainContact($contactId)) {
         return;
     }
     CRM_Contact_BAO_Contact::deleteContact($contactId);
 }
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:16,代码来源:SoftDelete.php

示例2: delete

 /**
  * @param bool $useWhere
  *
  * @return mixed|void
  */
 public function delete($useWhere = FALSE)
 {
     $this->load_associations();
     $contacts_to_delete = array();
     foreach ($this->participants as $participant) {
         $defaults = array();
         $params = array('id' => $participant->contact_id);
         $temporary_contact = CRM_Contact_BAO_Contact::retrieve($params, $defaults);
         if ($temporary_contact->is_deleted) {
             $contacts_to_delete[$temporary_contact->id] = 1;
         }
         $participant->delete();
     }
     foreach (array_keys($contacts_to_delete) as $contact_id) {
         CRM_Contact_BAO_Contact::deleteContact($contact_id);
     }
     return parent::delete();
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:23,代码来源:EventInCart.php

示例3: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  *
  * @return void
  */
 public function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $currentUserId = $session->get('userID');
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'basic');
     $urlParams = 'force=1';
     $urlString = "civicrm/contact/search/{$context}";
     if (CRM_Utils_Rule::qfKey($this->_searchKey)) {
         $urlParams .= "&qfKey={$this->_searchKey}";
     } elseif ($context == 'search') {
         $urlParams .= "&qfKey={$this->controller->_key}";
         $urlString = 'civicrm/contact/search';
     } elseif ($context == 'smog') {
         $urlParams .= "&qfKey={$this->controller->_key}&context=smog";
         $urlString = 'civicrm/group/search';
     } else {
         $urlParams = "reset=1";
         $urlString = 'civicrm/dashboard';
     }
     // Delete/Restore Contacts. Report errors.
     $deleted = 0;
     $not_deleted = array();
     foreach ($this->_contactIds as $cid) {
         $name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $cid, 'display_name');
         if (CRM_Contact_BAO_Contact::checkDomainContact($cid)) {
             $session->setStatus(ts("'%1' cannot be deleted because the information is used for special system purposes.", array(1 => $name)), 'Cannot Delete Domain Contact', 'error');
             continue;
         }
         if ($currentUserId == $cid && !$this->_restore) {
             $session->setStatus(ts("You are currently logged in as '%1'. You cannot delete yourself.", array(1 => $name)), 'Unable To Delete', 'error');
             continue;
         }
         if (CRM_Contact_BAO_Contact::deleteContact($cid, $this->_restore, $this->_skipUndelete)) {
             $deleted++;
         } else {
             $url = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$cid}");
             $not_deleted[$cid] = "<a href='{$url}'>{$name}</a>";
         }
     }
     if ($deleted) {
         $title = ts('Deleted');
         if ($this->_restore) {
             $title = ts('Restored');
             $status = ts('%1 has been restored from the trash.', array(1 => $name, 'plural' => '%count contacts restored from trash.', 'count' => $deleted));
         } elseif ($this->_skipUndelete) {
             $status = ts('%1 has been permanently deleted.', array(1 => $name, 'plural' => '%count contacts permanently deleted.', 'count' => $deleted));
         } else {
             $status = ts('%1 has been moved to the trash.', array(1 => $name, 'plural' => '%count contacts moved to trash.', 'count' => $deleted));
         }
         $session->setStatus($status, $title, 'success');
     }
     // Alert user of any failures
     if ($not_deleted) {
         $status = ts('The contact might be the Membership Organization of a Membership Type. You will need to edit the Membership Type and change the Membership Organization before you can delete this contact.');
         $title = ts('Unable to Delete');
         $session->setStatus('<ul><li>' . implode('</li><li>', $not_deleted) . '</li></ul>' . $status, $title, 'error');
     }
     if (isset($this->_sharedAddressMessage) && $this->_sharedAddressMessage['count'] > 0 && !$this->_restore) {
         if (count($this->_sharedAddressMessage['contactList']) == 1) {
             $message = ts('The following contact had been sharing an address with a contact you just deleted. Their address will no longer be shared, but has not been removed or altered.');
         } else {
             $message = ts('The following contacts had been sharing addresses with a contact you just deleted. Their addressses will no longer be shared, but have not been removed or altered.');
         }
         $message .= '<ul><li>' . implode('</li><li>', $this->_sharedAddressMessage['contactList']) . '</li></ul>';
         $session->setStatus($message, ts('Shared Addesses Owner Deleted'), 'info', array('expires' => 0));
         $this->set('sharedAddressMessage', NULL);
     }
     if ($this->_single && empty($this->_skipUndelete)) {
         $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactIds[0]}"));
     } else {
         $session->replaceUserContext(CRM_Utils_System::url($urlString, $urlParams));
     }
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:80,代码来源:Delete.php

示例4: civicrm_api3_contact_delete

/**
 * Delete a Contact with given contact_id.
 *
 * @param array $params
 *   input parameters per getfields
 *
 * @throws \Civi\API\Exception\UnauthorizedException
 * @return array
 *   API Result Array
 */
function civicrm_api3_contact_delete($params)
{
    $contactID = CRM_Utils_Array::value('id', $params);
    if (!empty($params['check_permissions']) && !CRM_Contact_BAO_Contact_Permission::allow($contactID, CRM_Core_Permission::DELETE)) {
        throw new \Civi\API\Exception\UnauthorizedException('Permission denied to modify contact record');
    }
    $session = CRM_Core_Session::singleton();
    if ($contactID == $session->get('userID')) {
        return civicrm_api3_create_error('This contact record is linked to the currently logged in user account - and cannot be deleted.');
    }
    $restore = !empty($params['restore']) ? $params['restore'] : FALSE;
    $skipUndelete = !empty($params['skip_undelete']) ? $params['skip_undelete'] : FALSE;
    // CRM-12929
    // restrict permanent delete if a contact has financial trxn associated with it
    $error = NULL;
    if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($contactID), $error)) {
        return civicrm_api3_create_error($error['_qf_default']);
    }
    if (CRM_Contact_BAO_Contact::deleteContact($contactID, $restore, $skipUndelete, CRM_Utils_Array::value('check_permissions', $params))) {
        return civicrm_api3_create_success();
    } else {
        return civicrm_api3_create_error('Could not delete contact');
    }
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:34,代码来源:Contact.php

示例5: civicrm_contact_delete

/**
 * Delete a contact with given contact id
 *
 * @param  array   	  $params (reference ) input parameters, contact_id element required
 *
 * @return boolean        true if success, else false
 * @static void
 * @access public
 */
function civicrm_contact_delete(&$params)
{
    require_once 'CRM/Contact/BAO/Contact.php';
    $contactID = CRM_Utils_Array::value('contact_id', $params);
    if (!$contactID) {
        return civicrm_create_error(ts('Could not find contact_id in input parameters'));
    }
    $session = CRM_Core_Session::singleton();
    if ($contactID == $session->get('userID')) {
        return civicrm_create_error(ts('This contact record is linked to the currently logged in user account - and cannot be deleted.'));
    }
    $restore = CRM_Utils_Array::value('restore', $params) ? $params['restore'] : FALSE;
    $skipUndelete = CRM_Utils_Array::value('skip_undelete', $params) ? $params['skip_undelete'] : FALSE;
    if (CRM_Contact_BAO_Contact::deleteContact($contactID, $restore, $skipUndelete)) {
        return civicrm_create_success();
    } else {
        return civicrm_create_error(ts('Could not delete contact'));
    }
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:28,代码来源:Contact.php

示例6: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $session = CRM_Core_Session::singleton();
     $currentUserId = $session->get('userID');
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, false, 'basic');
     $urlParams = 'force=1';
     if (CRM_Utils_Rule::qfKey($this->_searchKey)) {
         $urlParams .= "&qfKey={$this->_searchKey}";
     } elseif ($context == 'search') {
         $urlParams .= "&qfKey={$this->controller->_key}";
     }
     $urlString = "civicrm/contact/search/{$context}";
     if ($context == 'search') {
         $urlString = 'civicrm/contact/search';
     }
     $selfDelete = false;
     $deletedContacts = 0;
     foreach ($this->_contactIds as $contactId) {
         if ($currentUserId == $contactId) {
             $selfDelete = true;
             continue;
         }
         if (CRM_Contact_BAO_Contact::deleteContact($contactId, $this->_restore, $this->_skipUndelete)) {
             $deletedContacts++;
         }
     }
     if (!$this->_single) {
         $label = $this->_restore ? ts('Restored Contact(s): %1', array(1 => $deletedContacts)) : ts('Deleted Contact(s): %1', array(1 => $deletedContacts));
         $status = array($label, ts('Total Selected Contact(s): %1', array(1 => count($this->_contactIds))));
         if ($selfDelete) {
             $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $currentUserId, 'display_name');
             $status[] = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
         }
     } else {
         if ($deletedContacts) {
             $session->replaceUserContext(CRM_Utils_System::url($urlString, $urlParams));
             if ($this->_restore) {
                 $status = ts('Selected contact was restored sucessfully.');
                 $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_contactIds[0]}"));
             } else {
                 $status = ts('Selected contact was deleted sucessfully.');
             }
         } else {
             $status = array(ts('Selected contact cannot be deleted.'));
             if ($selfDelete) {
                 $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $currentUserId, 'display_name');
                 $status[] = ts('This contact record is linked to the currently logged in user account - \'%1\' - and cannot be deleted.', array(1 => $display_name));
             } else {
                 $status[] = ts('The contact might be the Membership Organization of a Membership Type. You will need to edit the Membership Type and change the Membership Organization before you can delete this contact.');
             }
         }
     }
     if (isset($this->_sharedAddressMessage) && $this->_sharedAddressMessage['count'] > 0 && !$this->_restore) {
         if (count($this->_contactIds) > 1) {
             $sharedAddressMessage = ts('The following contact(s) have address records which were shared with the address you removed from selected contacts. These address records are no longer shared - but they have not been removed or altered.') . '<br>' . implode('<br>', $this->_sharedAddressMessage['contactList']);
         } else {
             $sharedAddressMessage = ts('The following contact(s) have address records which were shared with the address you removed from this contact. These address records are no longer shared - but they have not been removed or altered.') . '<br>' . implode('<br>', $this->_sharedAddressMessage['contactList']);
         }
         if (is_array($status)) {
             $status[] = $sharedAddressMessage;
         } else {
             $status .= $sharedAddressMessage;
         }
         $this->set('sharedAddressMessage', null);
     }
     CRM_Core_Session::setStatus($status);
     $session->replaceUserContext(CRM_Utils_System::url($urlString, $urlParams));
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:74,代码来源:Delete.php

示例7: civicrm_contact_delete

/**
 * Delete a contact with given contact id
 *
 * @param  array   	  $params (reference ) input parameters, contact_id element required
 *
 * @return boolean        true if success, else false
 * @static void
 * @access public
 */
function civicrm_contact_delete(&$params)
{
    require_once 'CRM/Contact/BAO/Contact.php';
    $contactID = CRM_Utils_Array::value('contact_id', $params);
    if (!$contactID) {
        return civicrm_create_error(ts('Could not find contact_id in input parameters'));
    }
    if (CRM_Contact_BAO_Contact::deleteContact($contactID)) {
        return civicrm_create_success();
    } else {
        return civicrm_create_error(ts('Could not delete contact'));
    }
}
开发者ID:ksecor,项目名称:civicrm,代码行数:22,代码来源:Contact.php

示例8: delete

 /**
  * Helper function to delete a contact
  *
  * @param  int  $contactID   id of the contact to delete
  * @return boolean true if contact deleted, false otherwise
  */
 static function delete($contactID)
 {
     require_once 'CRM/Contact/BAO/Contact.php';
     return CRM_Contact_BAO_Contact::deleteContact($contactID);
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:11,代码来源:Contact.php

示例9: delete

 function delete($contactID)
 {
     return CRM_Contact_BAO_Contact::deleteContact($contactID);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:4,代码来源:Contact.php

示例10: del

 /**
  * Function to delete Gender 
  * 
  * @param int $genderId  ID of the gender to be deleted.
  * 
  * @return boolean true if success, false otherwise
  * 
  * @access public
  * @static
  */
 function del($genderId)
 {
     //check dependencies
     require_once 'CRM/Contact/DAO/Individual.php';
     require_once 'CRM/Contact/BAO/Contact.php';
     $deleteContactId = array();
     $session =& CRM_Core_Session::singleton();
     $currentUserId = $session->get('userID');
     $individual =& new CRM_Contact_DAO_Individual();
     $individual->gender_id = $genderId;
     $individual->find();
     while ($individual->fetch()) {
         $contactId = $individual->contact_id;
         if ($currentUserId != $contactId) {
             $deleteContactId[] = $contactId;
         } else {
             return false;
         }
     }
     foreach ($deleteContactId as $cid) {
         CRM_Contact_BAO_Contact::deleteContact($cid);
     }
     $gender =& new CRM_Core_DAO_Gender();
     $gender->id = $genderId;
     $gender->delete();
     return true;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:37,代码来源:Gender.php

示例11: civicrm_api3_contact_delete

/**
 * Delete a contact with given contact id
 *
 * @param  array       $params (reference ) input parameters, contact_id element required
 *
 * @return array API Result Array
 * @access public
 *
 * @example ContactDelete.php
 * {@getfields contact_delete}
 */
function civicrm_api3_contact_delete($params)
{
    $contactID = CRM_Utils_Array::value('id', $params);
    $session = CRM_Core_Session::singleton();
    if ($contactID == $session->get('userID')) {
        return civicrm_api3_create_error('This contact record is linked to the currently logged in user account - and cannot be deleted.');
    }
    $restore = CRM_Utils_Array::value('restore', $params) ? $params['restore'] : FALSE;
    $skipUndelete = CRM_Utils_Array::value('skip_undelete', $params) ? $params['skip_undelete'] : FALSE;
    // CRM-12929
    // restrict permanent delete if a contact has financial trxn associated with it
    $error = NULL;
    if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($contactID), $error)) {
        return civicrm_api3_create_error($error['_qf_default']);
    }
    if (CRM_Contact_BAO_Contact::deleteContact($contactID, $restore, $skipUndelete)) {
        return civicrm_api3_create_success();
    } else {
        return civicrm_api3_create_error('Could not delete contact');
    }
}
开发者ID:hguru,项目名称:224Civi,代码行数:32,代码来源:Contact.php

示例12: testFindById

 public function testFindById()
 {
     $params = $this->sampleContact('Individual', 4);
     $existing_contact = CRM_Contact_BAO_Contact::add($params);
     $contact = CRM_Contact_BAO_Contact::findById($existing_contact->id);
     $this->assertEquals($existing_contact->id, $contact->id);
     $deleted_contact_id = $existing_contact->id;
     CRM_Contact_BAO_Contact::deleteContact($contact->id, FALSE, TRUE);
     $exception_thrown = FALSE;
     try {
         $deleted_contact = CRM_Contact_BAO_Contact::findById($deleted_contact_id);
     } catch (Exception $e) {
         $exception_thrown = TRUE;
     }
     $this->assertTrue($exception_thrown);
 }
开发者ID:saurabhbatra96,项目名称:civicrm-core,代码行数:16,代码来源:DAOTest.php

示例13: crm_delete_contact

/**
 * Delete a specified contact.
 *
 * <b>Versioning and Un-delete</b>
 *
 * <ul>
 * <li>CRM will implement a 'Versioning' utility which will include
 * structural support for 'un-delete' operations. The API and UI
 * interfaces for 'un-delete' will probably be available in v1.x.</li>
 * </ul>
 *
 * @param CRM_Contact $contact Contact object to be deleted
 *
 * @return void|CRM_Core_Error  An error if 'contact' is invalid,
 *                         permissions are insufficient, etc.
 *
 * @access public
 *
 */
function crm_delete_contact(&$contact)
{
    _crm_initialize();
    if (!isset($contact->id) || !isset($contact->contact_type)) {
        return _crm_error('Invalid contact object passed in');
    }
    CRM_Contact_BAO_Contact::deleteContact($contact->id);
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:27,代码来源:Contact.php

示例14: testDeleteContact

 /**
  * test case for deleteContact( )
  */
 function testDeleteContact()
 {
     $contactParams = $this->contactParams();
     //create contact
     require_once 'CRM/Contact/BAO/Contact.php';
     $contact = CRM_Contact_BAO_Contact::create($contactParams);
     $contactId = $contact->id;
     //delete contact.
     CRM_Contact_BAO_Contact::deleteContact($contactId);
     //Now check DB for location elements.
     //Now check DB for Address
     $this->assertDBNull('CRM_Core_DAO_Address', CRM_Utils_Array::value('street_address', $contactParams['address'][1]), 'id', 'street_address', 'Database check, Address deleted successfully.');
     //Now check DB for Email
     $this->assertDBNull('CRM_Core_DAO_Email', CRM_Utils_Array::value('email', $contactParams['email'][1]), 'id', 'email', 'Database check, Email deleted successfully.');
     //Now check DB for Phone
     $this->assertDBNull('CRM_Core_DAO_Phone', CRM_Utils_Array::value('phone', $contactParams['phone'][1]), 'id', 'phone', 'Database check, Phone deleted successfully.');
     //Now check DB for Mobile
     $this->assertDBNull('CRM_Core_DAO_Phone', CRM_Utils_Array::value('phone', $contactParams['phone'][2]), 'id', 'phone', 'Database check, Mobile deleted successfully.');
     //Now check DB for IM
     $this->assertDBNull('CRM_Core_DAO_IM', CRM_Utils_Array::value('name', $contactParams['im'][1]), 'id', 'name', 'Database check, IM deleted successfully.');
     //Now check DB for openId
     $this->assertDBNull('CRM_Core_DAO_OpenID', CRM_Utils_Array::value('openid', $contactParams['openid'][1]), 'id', 'name', 'Database check, openId deleted successfully.');
     require_once 'CRM/Core/BAO/CustomValueTable.php';
     // Check that the custom field value is no longer present
     $params = array('entityID' => $contactId, 'custom_' . $fieldID => 1);
     $values = CRM_Core_BAO_CustomValueTable::getValues($params);
     $this->assertEquals(CRM_Utils_Array::value("custom_{$fieldID}", $values), '', 'Verify that the data value is empty for contact ' . $contactId);
     $this->assertEquals($values['is_error'], 1, 'Verify that is_error = 0 (success).');
     //Now check DB for contact.
     $this->assertDBNull('CRM_Contact_DAO_Contact', $contactParams['last_name'] . ', ' . $contactParams['first_name'], 'id', 'sort_name', 'Database check, contact deleted successfully.');
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:34,代码来源:ContactTest.php

示例15: postProcess

 /**
  * process the form after the input has been submitted and validated
  *
  * @access public
  * @return None
  */
 public function postProcess()
 {
     $session =& CRM_Core_Session::singleton();
     $currentUserId = $session->get('userID');
     $selfDelete = false;
     $deletedContacts = 0;
     foreach ($this->_contactIds as $contactId) {
         if ($currentUserId == $contactId) {
             $selfDelete = true;
             continue;
         }
         if (CRM_Contact_BAO_Contact::deleteContact($contactId)) {
             $deletedContacts++;
         }
     }
     if (!$this->_single) {
         $status = array();
         $status = array(ts('Deleted Contact(s): %1', array(1 => $deletedContacts)), ts('Total Selected Contact(s): %1', array(1 => count($this->_contactIds))));
         if ($selfDelete) {
             $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $currentUserId, 'display_name');
             $status[] = ts('The contact record which is linked to the currently logged in user account - \'%1\' - cannot be deleted.', array(1 => $display_name));
         }
     } else {
         if ($deletedContacts) {
             $isAdvanced = $session->get('isAdvanced');
             $isSearchBuilder = $session->get('isSearchBuilder');
             if ($isAdvanced == 1) {
                 $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/search/advanced', 'force=1'));
             } else {
                 if ($isAdvanced == 2 && $isSearchBuilder == 1) {
                     $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/search/builder', 'force=1'));
                 } else {
                     $session->replaceUserContext(CRM_Utils_System::url('civicrm/contact/search/basic', 'force=1'));
                 }
             }
             $status = ts('Selected contact was deleted sucessfully.');
         } else {
             $status = array(ts('Selected contact cannot be deleted.'));
             if ($selfDelete) {
                 $display_name = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $currentUserId, 'display_name');
                 $status[] = ts('This contact record is linked to the currently logged in user account - \'%1\' - and cannot be deleted.', array(1 => $display_name));
             } else {
                 $status[] = ts('The contact might be the Membership Organization of a Membership Type. You will need to edit the Membership Type and change the Membership Organization before you can delete this contact.');
             }
         }
     }
     CRM_Core_Session::setStatus($status);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:54,代码来源:Delete.php


注:本文中的CRM_Contact_BAO_Contact::deleteContact方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。