本文整理汇总了PHP中CRM_Case_BAO_Case::retrieveContactIdsByCaseId方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::retrieveContactIdsByCaseId方法的具体用法?PHP CRM_Case_BAO_Case::retrieveContactIdsByCaseId怎么用?PHP CRM_Case_BAO_Case::retrieveContactIdsByCaseId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_BAO_Case
的用法示例。
在下文中一共展示了CRM_Case_BAO_Case::retrieveContactIdsByCaseId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportComponents
//.........这里部分代码省略.........
}
unset($returnProperties[$relationKeyMOH]['location_type']);
unset($returnProperties[$relationKeyMOH]['im_provider']);
unset($returnProperties[$relationKeyHOH]['location_type']);
unset($returnProperties[$relationKeyHOH]['im_provider']);
}
$allRelContactArray = $relationQuery = array();
foreach ($contactRelationshipTypes as $rel => $dnt) {
if ($relationReturnProperties = CRM_Utils_Array::value($rel, $returnProperties)) {
$allRelContactArray[$rel] = array();
// build Query for each relationship
$relationQuery[$rel] = new CRM_Contact_BAO_Query(NULL, $relationReturnProperties, NULL, FALSE, FALSE, $queryMode);
list($relationSelect, $relationFrom, $relationWhere, $relationHaving) = $relationQuery[$rel]->query();
list($id, $direction) = explode('_', $rel, 2);
// identify the relationship direction
$contactA = 'contact_id_a';
$contactB = 'contact_id_b';
if ($direction == 'b_a') {
$contactA = 'contact_id_b';
$contactB = 'contact_id_a';
}
if ($exportMode == CRM_Export_Form_Select::CONTACT_EXPORT) {
$relIDs = $ids;
} elseif ($exportMode == CRM_Export_Form_Select::ACTIVITY_EXPORT) {
$sourceID = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_ActivityContact', 'record_type_id', 'Activity Source');
$query = "SELECT contact_id FROM civicrm_activity_contact\n WHERE activity_id IN ( " . implode(',', $ids) . ") AND\n record_type_id = {$sourceID}";
$dao = CRM_Core_DAO::executeQuery($query);
while ($dao->fetch()) {
$relIDs[] = $dao->contact_id;
}
} else {
$component = self::exportComponent($exportMode);
if ($exportMode == CRM_Export_Form_Select::CASE_EXPORT) {
$relIDs = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($ids);
} else {
$relIDs = CRM_Core_DAO::getContactIDsFromComponent($ids, $component);
}
}
$relationshipJoin = $relationshipClause = '';
if (!$selectAll && $componentTable) {
$relationshipJoin = " INNER JOIN {$componentTable} ctTable ON ctTable.contact_id = {$contactA}";
} elseif (!empty($relIDs)) {
$relID = implode(',', $relIDs);
$relationshipClause = " AND crel.{$contactA} IN ( {$relID} )";
}
$relationFrom = " {$relationFrom}\n INNER JOIN civicrm_relationship crel ON crel.{$contactB} = contact_a.id AND crel.relationship_type_id = {$id}\n {$relationshipJoin} ";
//check for active relationship status only
$today = date('Ymd');
$relationActive = " AND (crel.is_active = 1 AND ( crel.end_date is NULL OR crel.end_date >= {$today} ) )";
$relationWhere = " WHERE contact_a.is_deleted = 0 {$relationshipClause} {$relationActive}";
$relationGroupBy = " GROUP BY crel.{$contactA}";
$relationSelect = "{$relationSelect}, {$contactA} as refContact ";
$relationQueryString = "{$relationSelect} {$relationFrom} {$relationWhere} {$relationHaving} {$relationGroupBy}";
$allRelContactDAO = CRM_Core_DAO::executeQuery($relationQueryString);
while ($allRelContactDAO->fetch()) {
//FIX Me: Migrate this to table rather than array
// build the array of all related contacts
$allRelContactArray[$rel][$allRelContactDAO->refContact] = clone $allRelContactDAO;
}
$allRelContactDAO->free();
}
}
// make sure the groups stuff is included only if specifically specified
// by the fields param (CRM-1969), else we limit the contacts outputted to only
// ones that are part of a group
if (!empty($returnProperties['groups'])) {
示例2: civicrm_api3_case_update
/**
* Update a specified case.
*
* @param array(
//REQUIRED:
* 'case_id' => int
*
* //OPTIONAL
* 'status_id' => int
* 'start_date' => str datestamp
* 'contact_id' => int // case client
*
* @return Updated case
*
* @access public
*
*/
function civicrm_api3_case_update($params)
{
//check parameters
civicrm_api3_verify_mandatory($params, NULL, array('id'));
// return error if modifing creator id
if (array_key_exists('creator_id', $params)) {
return civicrm_api3_create_error(ts('You cannot update creator id'));
}
$mCaseId = array();
$origContactIds = array();
// get original contact id and creator id of case
if (!empty($params['contact_id'])) {
$origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['id']);
$origContactId = $origContactIds[1];
}
if (count($origContactIds) > 1) {
// check valid orig contact id
if (!empty($params['orig_contact_id']) && !in_array($params['orig_contact_id'], $origContactIds)) {
return civicrm_api3_create_error('Invalid case contact id (orig_contact_id)');
} elseif (empty($params['orig_contact_id'])) {
return civicrm_api3_create_error('Case is linked with more than one contact id. Provide the required params orig_contact_id to be replaced');
}
$origContactId = $params['orig_contact_id'];
}
// check for same contact id for edit Client
if (!empty($params['contact_id']) && !in_array($params['contact_id'], $origContactIds)) {
$mCaseId = CRM_Case_BAO_Case::mergeCases($params['contact_id'], $params['case_id'], $origContactId, NULL, TRUE);
}
if (!empty($mCaseId[0])) {
$params['id'] = $mCaseId[0];
}
$dao = new CRM_Case_BAO_Case();
$dao->id = $params['id'];
$dao->copyValues($params);
$dao->save();
$case = array();
_civicrm_api3_object_to_array($dao, $case);
return civicrm_api3_create_success($case, $params, 'case', 'update', $dao);
}
示例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: setDefaultValues
function setDefaultValues()
{
$defaults = array();
$contactNames = array();
require_once 'CRM/Case/BAO/Case.php';
if (isset($this->_id)) {
$params = array('id' => $this->_id);
CRM_Case_BAO_Case::retrieve($params, $defaults, $ids);
$defaults['case_contact'] = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($this->_id, $this->_contactID);
$contactNames = CRM_Case_BAO_Case::getcontactNames($this->_id);
foreach ($contactNames as $key => $name) {
$defaults['contact_names'] .= $defaults['contact_names'] ? ",\"{$name}\"" : "\"{$name}\"";
}
}
$this->assign('contactNames', CRM_Utils_Array::value('contact_names', $defaults));
$defaults['case_type_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('case_type_id', $defaults));
$config =& CRM_Core_Config::singleton();
if ($config->civiHRD) {
$defaults['casetag2_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('casetag2_id', $defaults));
$defaults['casetag3_id'] = explode(CRM_Case_BAO_Case::VALUE_SEPERATOR, CRM_Utils_Array::value('casetag3_id', $defaults));
}
if ($this->_action & CRM_Core_Action::ADD || $this->_context == 'search') {
$defaults['start_date'] = array();
CRM_Utils_Date::getAllDefaultValues($defaults['start_date']);
}
//set the assigneed contact count to template
if (!empty($defaults['case_contact'])) {
$this->assign('caseContactCount', count($defaults['case_contact']));
}
return $defaults;
}
示例5: hrcase_civicrm_post
function hrcase_civicrm_post($op, $objectName, $objectId, &$objectRef)
{
if ($objectName == 'Activity' && isset($objectRef->case_id)) {
$contact_id = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($objectRef->case_id);
$hrjob = civicrm_api3('HRJobContract', 'get', array('sequential' => 1, 'contact_id' => $contact_id[1], 'is_primary' => 1, 'return' => "notice_amount,notice_unit"));
foreach ($hrjob['values'] as $key => $val) {
$notice_amt = $val['notice_amount'];
$notice_unit = $val['notice_unit'];
}
if (isset($notice_amt)) {
$revoke = civicrm_api3('OptionValue', 'getsingle', array('return' => "value", 'name' => "Revoke access to databases"));
$block = civicrm_api3('OptionValue', 'getsingle', array('return' => "value", 'name' => "Block work email ID"));
$date = strtotime($objectRef->activity_date_time);
if ($objectRef->activity_type_id == $revoke['value']) {
$date = date('Y-m-d h:i:s', strtotime("+{$notice_amt} {$notice_unit}", $date));
civicrm_api3('Activity', 'create', array('id' => $objectRef->id, 'activity_date_time' => $date));
}
if ($objectRef->activity_type_id == $block['value']) {
$date = date('Y-m-d h:i:s', strtotime("+{$notice_amt} {$notice_unit} +1 day", $date));
civicrm_api3('Activity', 'create', array('id' => $objectRef->id, 'activity_date_time' => $date));
}
}
}
}
示例6: civicrm_case_update
/**
* Update a specified case.
*
* @param array( //REQUIRED:
* 'case_id' => int
*
* //OPTIONAL
* 'status_id' => int
* 'start_date' => str datestamp
* 'contact_id' => int // case client
* 'creator_id' => int // case manager
*
* @return Updated case
*
* @access public
*
*/
function civicrm_case_update(&$params)
{
_civicrm_initialize();
$errors = array();
//check for various error and required conditions
$errors = _civicrm_case_check_params($params, 'update');
if (!empty($errors)) {
return $errors;
}
// return error if modifing creator id
if (array_key_exists('creator_id', $params)) {
return civicrm_create_error(ts('You have no provision to update creator id'));
}
$mCaseId = array();
$origContactIds = array();
// get original contact id and creator id of case
if ($params['contact_id']) {
$origContactIds = CRM_Case_BAO_Case::retrieveContactIdsByCaseId($params['case_id']);
$origContactId = $origContactIds[1];
}
if (count($origContactIds) > 1) {
// check valid orig contact id
if ($params['orig_contact_id'] && !in_array($params['orig_contact_id'], $origContactIds)) {
return civicrm_create_error(ts('Invalid case contact id (orig_contact_id)'));
} else {
if (!$params['orig_contact_id']) {
return civicrm_create_error(ts('Case is linked with more than one contact id. Provide the required params orig_contact_id to be replaced'));
}
}
$origContactId = $params['orig_contact_id'];
}
// check for same contact id for edit Client
if ($params['contact_id'] && !in_array($params['contact_id'], $origContactIds)) {
$mCaseId = CRM_Case_BAO_Case::mergeCases($params['contact_id'], $params['case_id'], $origContactId, null, true);
}
if (CRM_Utils_Array::value('0', $mCaseId)) {
$params['case_id'] = $mCaseId[0];
}
$dao = new CRM_Case_BAO_Case();
$dao->id = $params['case_id'];
$dao->copyValues($params);
$dao->save();
$case = array();
_civicrm_object_to_array($dao, $case);
return civicrm_create_success($case);
}