本文整理汇总了PHP中CRM_Case_BAO_Case::getRelatedContacts方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::getRelatedContacts方法的具体用法?PHP CRM_Case_BAO_Case::getRelatedContacts怎么用?PHP CRM_Case_BAO_Case::getRelatedContacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_BAO_Case
的用法示例。
在下文中一共展示了CRM_Case_BAO_Case::getRelatedContacts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: triggerTrigger
/**
* Trigger a rule for this trigger
*
* @param $op
* @param $objectName
* @param $objectId
* @param $objectRef
*/
public function triggerTrigger($op, $objectName, $objectId, $objectRef)
{
$t = $this->getTriggerDataFromPost($op, $objectName, $objectId, $objectRef);
//trigger for each client
$clients = CRM_Case_BAO_Case::getCaseClients($objectId);
foreach ($clients as $client) {
$triggerData = clone $t;
$triggerData->setEntityData('Relationship', null);
$triggerData->setContactId($client);
CRM_Civirules_Engine::triggerRule($this, $triggerData);
}
//trigger for each case role
$relatedContacts = CRM_Case_BAO_Case::getRelatedContacts($objectId);
foreach ($relatedContacts as $contact) {
$triggerData = clone $t;
$relationshipData = null;
$relationship = new CRM_Contact_BAO_Relationship();
$relationship->contact_id_b = $contact['contact_id'];
$relationship->case_id = $objectId;
if ($relationship->find(true)) {
CRM_Core_DAO::storeValues($relationship, $relationshipData);
}
$triggerData->setEntityData('Relationship', $relationshipData);
$triggerData->setContactId($contact['contact_id']);
CRM_Civirules_Engine::triggerRule($this, $triggerData);
}
}
示例2: _civicrm_api3_case_read
/**
* Internal function to retrieve a case.
*
* @param int $caseId
*
* @return array (reference) case object
*
*/
function _civicrm_api3_case_read($caseId, $options)
{
$return = CRM_Utils_Array::value('return', $options, array());
$dao = new CRM_Case_BAO_Case();
$dao->id = $caseId;
if ($dao->find(TRUE)) {
$case = array();
_civicrm_api3_object_to_array($dao, $case);
// Legacy support for client_id - TODO: in apiv4 remove 'client_id'
$case['client_id'] = $case['contact_id'] = $dao->retrieveContactIdsByCaseId($caseId);
//handle multi-value case type
$sep = CRM_Core_DAO::VALUE_SEPARATOR;
$case['case_type_id'] = trim(str_replace($sep, ',', $case['case_type_id']), ',');
if (!empty($return['contacts'])) {
//get case contacts
$contacts = CRM_Case_BAO_Case::getcontactNames($caseId);
$relations = CRM_Case_BAO_Case::getRelatedContacts($caseId);
$case['contacts'] = array_merge($contacts, $relations);
}
if (!empty($return['activities'])) {
//get case activities
$case['activities'] = array();
$query = "SELECT activity_id FROM civicrm_case_activity WHERE case_id = {$caseId}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$case['activities'][] = $dao->activity_id;
}
}
return $case;
}
}
示例3: _civicrm_api3_case_read
/**
* Augment a case with extra data.
*
* @param array $case
* @param array $options
*/
function _civicrm_api3_case_read(&$case, $options)
{
if (empty($options['return']) || !empty($options['return']['contact_id'])) {
// Legacy support for client_id - TODO: in apiv4 remove 'client_id'
$case['client_id'] = $case['contact_id'] = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($case['id']);
}
if (!empty($options['return']['contacts'])) {
//get case contacts
$contacts = CRM_Case_BAO_Case::getcontactNames($case['id']);
$relations = CRM_Case_BAO_Case::getRelatedContacts($case['id']);
$case['contacts'] = array_merge($contacts, $relations);
}
if (!empty($options['return']['activities'])) {
//get case activities
$case['activities'] = array();
$query = "SELECT activity_id FROM civicrm_case_activity WHERE case_id = %1";
$dao = CRM_Core_DAO::executeQuery($query, array(1 => array($case['id'], 'Integer')));
while ($dao->fetch()) {
$case['activities'][] = $dao->activity_id;
}
}
}
示例4: _civicrm_api3_case_read
/**
* Internal function to retrieve a case.
*
* @param int $caseId
*
* @param array $options
*
* @param bool $checkPermission
*
* @return array
* case object
*/
function _civicrm_api3_case_read($caseId, $options, $checkPermission)
{
$return = CRM_Utils_Array::value('return', $options, array());
$dao = new CRM_Case_BAO_Case();
$dao->id = $caseId;
if ($dao->find(TRUE)) {
$case = array();
_civicrm_api3_object_to_array($dao, $case);
_civicrm_api3_custom_data_get($case, $checkPermission, 'Case', $caseId);
// Legacy support for client_id - TODO: in apiv4 remove 'client_id'
$case['client_id'] = $case['contact_id'] = $dao->retrieveContactIdsByCaseId($caseId);
if (!empty($return['contacts'])) {
//get case contacts
$contacts = CRM_Case_BAO_Case::getcontactNames($caseId);
$relations = CRM_Case_BAO_Case::getRelatedContacts($caseId);
$case['contacts'] = array_merge($contacts, $relations);
}
if (!empty($return['activities'])) {
//get case activities
$case['activities'] = array();
$query = "SELECT activity_id FROM civicrm_case_activity WHERE case_id = {$caseId}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$case['activities'][] = $dao->activity_id;
}
}
return $case;
}
}
示例5: civicrm_api3_case_get
/**
* Get details of a particular case, or search for cases, depending on params
*
* Please provide one (and only one) of the four get/search parameters:
*
* @param array(
'case_id' => if set, will get all available info about a case, including contacts and activities
*
* // if no case_id provided, this function will use one of the following search parameters:
* 'client_id' => finds all cases with a specific client
* 'activity_id' => returns the case containing a specific activity
* 'contact_id' => finds all cases associated with a contact (in any role, not just client)
*
* {@getfields case_get}
*
* @return (get mode, case_id provided): Array with case details, case roles, case activity ids, (search mode, case_id not provided): Array of cases found
* @access public
* @todo Eileen McNaughton 13 Oct 2011 No unit test
* @todo Erik Hommel 16 dec 2010 check if all DB fields are returned
*/
function civicrm_api3_case_get($params)
{
// Get mode
if (!($caseId = CRM_Utils_Array::value('id', $params))) {
$caseId = CRM_Utils_Array::value('case_id', $params);
}
if ($caseId) {
// Validate param
if (!is_numeric($caseId)) {
return civicrm_api3_create_error('Invalid parameter: case_id. Must provide a numeric value.');
}
$case = _civicrm_api3_case_read($caseId);
if ($case) {
//get case contacts
$contacts = CRM_Case_BAO_Case::getcontactNames($caseId);
$relations = CRM_Case_BAO_Case::getRelatedContacts($caseId);
$case['contacts'] = array_merge($contacts, $relations);
//get case activities
$query = "SELECT activity_id FROM civicrm_case_activity WHERE case_id = {$caseId}";
$dao = CRM_Core_DAO::executeQuery($query);
$case['activities'] = array();
while ($dao->fetch()) {
$case['activities'][] = $dao->activity_id;
}
$cases = array($caseId => $case);
return civicrm_api3_create_success($cases);
} else {
return civicrm_api3_create_success(array());
}
}
//search by client
if ($client = CRM_Utils_Array::value('client_id', $params)) {
$ids = array();
foreach ((array) $client as $cid) {
if (is_numeric($cid)) {
$ids = array_merge($ids, CRM_Case_BAO_Case::retrieveCaseIdsByContactId($cid, TRUE));
}
}
if (empty($ids)) {
return civicrm_api3_create_success(array());
}
$cases = array();
foreach ($ids as $id) {
$cases[$id] = _civicrm_api3_case_read($id);
}
return civicrm_api3_create_success($cases);
}
//search by activity
if ($act = CRM_Utils_Array::value('activity_id', $params)) {
if (!is_numeric($act)) {
return civicrm_api3_create_error('Invalid parameter: activity_id. Must provide a numeric value.');
}
$caseId = CRM_Case_BAO_Case::getCaseIdByActivityId($act);
if (!$caseId) {
return civicrm_api3_create_success(array());
}
$case = array($caseId => _civicrm_api3_case_read($caseId));
return civicrm_api3_create_success($case);
}
//search by contacts
if ($contact = CRM_Utils_Array::value('contact_id', $params)) {
if (!is_numeric($contact)) {
return civicrm_api3_create_error('Invalid parameter: contact_id. Must provide a numeric value.');
}
$sql = "\nSELECT DISTINCT case_id\n FROM civicrm_relationship\n WHERE (contact_id_a = {$contact}\n OR contact_id_b = {$contact})\n AND case_id IS NOT NULL";
$dao =& CRM_Core_DAO::executeQuery($sql);
$cases = array();
while ($dao->fetch()) {
$cases[$dao->case_id] = _civicrm_api3_case_read($dao->case_id);
}
return civicrm_api3_create_success($cases);
}
return civicrm_api3_create_error('Missing required parameter. Must provide case_id, client_id, activity_id, or contact_id.');
}