本文整理汇总了PHP中CRM_Contact_DAO_Relationship::delete方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_DAO_Relationship::delete方法的具体用法?PHP CRM_Contact_DAO_Relationship::delete怎么用?PHP CRM_Contact_DAO_Relationship::delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_DAO_Relationship
的用法示例。
在下文中一共展示了CRM_Contact_DAO_Relationship::delete方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deleteContact
/**
* Delete the object records that are associated with this contact.
*
* @param int $contactId
* Id of the contact to delete.
*/
public static function deleteContact($contactId)
{
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->contact_id_a = $contactId;
$relationship->delete();
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->contact_id_b = $contactId;
$relationship->delete();
CRM_Contact_BAO_Household::updatePrimaryContact(NULL, $contactId);
}
示例2: del
/**
* Delete Relationship Types.
*
* @param int $relationshipTypeId
*
* @throws CRM_Core_Exception
* @return mixed
*/
public static function del($relationshipTypeId)
{
// make sure relationshipTypeId is an integer
// @todo review this as most delete functions rely on the api & form layer for this
// or do a find first & throw error if no find
if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
throw new CRM_Core_Exception(ts('Invalid relationship type'));
}
//check dependencies
// delete all relationships
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->relationship_type_id = $relationshipTypeId;
$relationship->delete();
// remove this relationship type from membership types
$mems = civicrm_api3('MembershipType', 'get', array('relationship_type_id' => array('LIKE' => "%{$relationshipTypeId}%"), 'return' => array('id', 'relationship_type_id', 'relationship_direction')));
foreach ($mems['values'] as $membershipTypeId => $membershipType) {
$pos = array_search($relationshipTypeId, $membershipType['relationship_type_id']);
// Api call may have returned false positives but currently the relationship_type_id uses
// nonstandard serialization which makes anything more accurate impossible.
if ($pos !== FALSE) {
unset($membershipType['relationship_type_id'][$pos], $membershipType['relationship_direction'][$pos]);
civicrm_api3('MembershipType', 'create', $membershipType);
}
}
//fixed for CRM-3323
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->relationship_type_id = $relationshipTypeId;
$mappingField->find();
while ($mappingField->fetch()) {
$mappingField->delete();
}
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
return $relationshipType->delete();
}
示例3: del
/**
* Function to delete Relationship Types
*
* @param int $relationshipTypeId
* @static
*/
static function del($relationshipTypeId)
{
// make sure relationshipTypeId is an integer
if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
CRM_Core_Error::fatal(ts('Invalid relationship type'));
}
//check dependencies
// delete all relationships
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->relationship_type_id = $relationshipTypeId;
$relationship->delete();
// set all membership_type to null
$query = "\nUPDATE civicrm_membership_type\n SET relationship_type_id = NULL\n WHERE relationship_type_id = %1\n";
$params = array(1 => array($relationshipTypeId, 'Integer'));
CRM_Core_DAO::executeQuery($query, $params);
//fixed for CRM-3323
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->relationship_type_id = $relationshipTypeId;
$mappingField->find();
while ($mappingField->fetch()) {
$mappingField->delete();
}
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
return $relationshipType->delete();
}
示例4: del
/**
* Function to delete Relationship Types
*
* @param int $relationshipTypeId
* @static
*/
static function del($relationshipTypeId)
{
// make sure relationshipTypeId is an integer
// @todo review this as most delete functions rely on the api & form layer for this
// or do a find first & throw error if no find
if (!CRM_Utils_Rule::positiveInteger($relationshipTypeId)) {
throw new CRM_Core_Exception(ts('Invalid relationship type'));
}
//check dependencies
// delete all relationships
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->relationship_type_id = $relationshipTypeId;
$relationship->delete();
// set all membership_type to null
$query = "\nUPDATE civicrm_membership_type\n SET relationship_type_id = NULL\n WHERE relationship_type_id = %1\n";
$params = array(1 => array(CRM_Core_DAO::VALUE_SEPARATOR . $relationshipTypeId . CRM_Core_DAO::VALUE_SEPARATOR, 'String'));
CRM_Core_DAO::executeQuery($query, $params);
//fixed for CRM-3323
$mappingField = new CRM_Core_DAO_MappingField();
$mappingField->relationship_type_id = $relationshipTypeId;
$mappingField->find();
while ($mappingField->fetch()) {
$mappingField->delete();
}
$relationshipType = new CRM_Contact_DAO_RelationshipType();
$relationshipType->id = $relationshipTypeId;
return $relationshipType->delete();
}
示例5: deleteContact
/**
* Delete the object records that are associated with this contact
*
* @param int $contactId id of the contact to delete
*
* @return void
* @access public
* @static
*/
static function deleteContact($contactId)
{
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->contact_id_a = $contactId;
$relationship->delete();
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->contact_id_b = $contactId;
$relationship->delete();
require_once 'CRM/Contact/BAO/Household.php';
CRM_Contact_BAO_Household::updatePrimaryContact(null, $contactId);
}