本文整理汇总了PHP中CRM_Contact_BAO_Relationship::setIsActive方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_Relationship::setIsActive方法的具体用法?PHP CRM_Contact_BAO_Relationship::setIsActive怎么用?PHP CRM_Contact_BAO_Relationship::setIsActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_Relationship
的用法示例。
在下文中一共展示了CRM_Contact_BAO_Relationship::setIsActive方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: disableExpiredRelationships
/**
* Set 'is_valid' field to false for all relationships whose end date is in the past, ie. are expired.
*
* @return bool
* True on success, false if error is encountered.
*/
public static function disableExpiredRelationships()
{
$query = "SELECT id FROM civicrm_relationship WHERE is_active = 1 AND end_date < CURDATE()";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$result = CRM_Contact_BAO_Relationship::setIsActive($dao->id, FALSE);
// Result will be NULL if error occurred. We abort early if error detected.
if ($result == NULL) {
return FALSE;
}
}
return TRUE;
}
示例2: run
/**
* This function is the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->preProcess();
$this->setContext();
$this->_caseId = CRM_Utils_Request::retrieve('caseID', 'Integer', $this);
if ($this->_action & CRM_Core_Action::VIEW) {
$this->view();
} else {
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD | CRM_Core_Action::DELETE)) {
$this->edit();
} else {
if ($this->_action & CRM_Core_Action::DISABLE) {
CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_id, CRM_Core_Action::DISABLE);
CRM_Contact_BAO_Relationship::setIsActive($this->_id, 0);
$session =& CRM_Core_Session::singleton();
CRM_Utils_System::redirect($session->popUserContext());
} else {
if ($this->_action & CRM_Core_Action::ENABLE) {
CRM_Contact_BAO_Relationship::disableEnableRelationship($this->_id, CRM_Core_Action::ENABLE);
CRM_Contact_BAO_Relationship::setIsActive($this->_id, 1);
$session =& CRM_Core_Session::singleton();
CRM_Utils_System::redirect($session->popUserContext());
}
}
}
}
// if this is called from case view, suppress browse relationships form
if (!$this->_caseId) {
$this->browse();
}
return parent::run();
}
示例3: clearCurrentEmployer
/**
* Clear cached current employer name.
*
* @param int $contactId
* Contact id ( mostly individual contact id).
* @param int $employerId
* Contact id ( mostly organization contact id).
*/
public static function clearCurrentEmployer($contactId, $employerId = NULL)
{
$query = "UPDATE civicrm_contact\nSET organization_name=NULL, employer_id = NULL\nWHERE id={$contactId}; ";
$dao = CRM_Core_DAO::executeQuery($query);
// need to handle related meberships. CRM-3792
if ($employerId) {
//1. disable corresponding relationship.
//2. delete related membership.
//get the relationship type id of "Employee of"
$relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
if (!$relTypeId) {
CRM_Core_Error::fatal(ts("You seem to have deleted the relationship type 'Employee of'"));
}
$relMembershipParams['relationship_type_id'] = $relTypeId . '_a_b';
$relMembershipParams['contact_check'][$employerId] = 1;
//get relationship id.
if (CRM_Contact_BAO_Relationship::checkDuplicateRelationship($relMembershipParams, $contactId, $employerId)) {
$relationship = new CRM_Contact_DAO_Relationship();
$relationship->contact_id_a = $contactId;
$relationship->contact_id_b = $employerId;
$relationship->relationship_type_id = $relTypeId;
if ($relationship->find(TRUE)) {
CRM_Contact_BAO_Relationship::setIsActive($relationship->id, FALSE);
CRM_Contact_BAO_Relationship::relatedMemberships($contactId, $relMembershipParams, $ids = array(), CRM_Core_Action::DELETE);
}
$relationship->free();
}
}
}
示例4: run
/**
* This function is the main function that is called when the page loads,
* it decides the which action has to be taken for the page.
*
* return null
* @access public
*/
function run()
{
$this->preProcess();
if ($this->_action & CRM_CORE_ACTION_VIEW) {
$this->view();
} else {
if ($this->_action & (CRM_CORE_ACTION_UPDATE | CRM_CORE_ACTION_ADD | CRM_CORE_ACTION_DELETE)) {
$this->edit();
} else {
if ($this->_action & CRM_CORE_ACTION_DISABLE) {
CRM_Contact_BAO_Relationship::setIsActive($this->_id, 0);
} else {
if ($this->_action & CRM_CORE_ACTION_ENABLE) {
CRM_Contact_BAO_Relationship::setIsActive($this->_id, 1);
}
}
}
}
$this->browse();
return parent::run();
}