本文整理汇总了PHP中CRM_Case_BAO_Case::retrieveCaseIdsByContactId方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Case_BAO_Case::retrieveCaseIdsByContactId方法的具体用法?PHP CRM_Case_BAO_Case::retrieveCaseIdsByContactId怎么用?PHP CRM_Case_BAO_Case::retrieveCaseIdsByContactId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Case_BAO_Case
的用法示例。
在下文中一共展示了CRM_Case_BAO_Case::retrieveCaseIdsByContactId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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(
'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 Erik Hommel 16 dec 2010 check if all DB fields are returned
*/
function civicrm_api3_case_get($params)
{
$options = _civicrm_api3_get_options_from_params($params);
//search by client
if (!empty($params['contact_id'])) {
$ids = array();
foreach ((array) $params['contact_id'] as $cid) {
if (is_numeric($cid)) {
$ids = array_merge($ids, CRM_Case_BAO_Case::retrieveCaseIdsByContactId($cid, TRUE));
}
}
$cases = array();
foreach ($ids as $id) {
if ($case = _civicrm_api3_case_read($id, $options)) {
$cases[$id] = $case;
}
}
return civicrm_api3_create_success($cases, $params, 'case', 'get');
}
//search by activity
if (!empty($params['activity_id'])) {
if (!is_numeric($params['activity_id'])) {
return civicrm_api3_create_error('Invalid parameter: activity_id. Must provide a numeric value.');
}
$caseId = CRM_Case_BAO_Case::getCaseIdByActivityId($params['activity_id']);
if (!$caseId) {
return civicrm_api3_create_success(array(), $params, 'case', 'get');
}
$case = array($caseId => _civicrm_api3_case_read($caseId, $options));
return civicrm_api3_create_success($case, $params, 'case', 'get');
}
//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, $options);
}
return civicrm_api3_create_success($cases, $params, 'case', 'get');
}
// For historic reasons we always return these when an id is provided
$caseId = CRM_Utils_Array::value('id', $params);
if ($caseId) {
$options['return'] = array('contacts' => 1, 'activities' => 1);
}
$foundcases = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params, TRUE, 'Case');
$cases = array();
foreach ($foundcases['values'] as $foundcase) {
if ($case = _civicrm_api3_case_read($foundcase['id'], $options)) {
$cases[$foundcase['id']] = $case;
}
}
return civicrm_api3_create_success($cases, $params, 'case', 'get');
}
示例2: deleteContact
/**
* Delete a contact and all its associated records.
*
* @param int $id
* Id of the contact to delete.
* @param bool $restore
* Whether to actually restore, not delete.
* @param bool $skipUndelete
* Whether to force contact delete or not.
*
* @return bool
* Was contact deleted?
*/
public static function deleteContact($id, $restore = FALSE, $skipUndelete = FALSE)
{
if (!$id) {
return FALSE;
}
// If trash is disabled in system settings then we always skip
if (!CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'contact_undelete', NULL, 1)) {
$skipUndelete = TRUE;
}
// make sure we have edit permission for this contact
// before we delete
if ($skipUndelete && !CRM_Core_Permission::check('delete contacts') || $restore && !CRM_Core_Permission::check('access deleted contacts')) {
return FALSE;
}
// CRM-12929
// Restrict contact to be delete if contact has financial trxns
$error = NULL;
if ($skipUndelete && CRM_Financial_BAO_FinancialItem::checkContactPresent(array($id), $error)) {
return FALSE;
}
// make sure this contact_id does not have any membership types
$membershipTypeID = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_MembershipType', $id, 'id', 'member_of_contact_id');
if ($membershipTypeID) {
return FALSE;
}
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $id;
if (!$contact->find(TRUE)) {
return FALSE;
}
$contactType = $contact->contact_type;
// currently we only clear employer cache.
// we are now deleting inherited membership if any.
if ($contact->contact_type == 'Organization') {
$action = $restore ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
$relationshipDtls = CRM_Contact_BAO_Relationship::getRelationship($id);
if (!empty($relationshipDtls)) {
foreach ($relationshipDtls as $rId => $details) {
CRM_Contact_BAO_Relationship::disableEnableRelationship($rId, $action);
}
}
CRM_Contact_BAO_Contact_Utils::clearAllEmployee($id);
}
if ($restore) {
return self::contactTrashRestore($contact, TRUE);
}
// start a new transaction
$transaction = new CRM_Core_Transaction();
if ($skipUndelete) {
CRM_Utils_Hook::pre('delete', $contactType, $id, CRM_Core_DAO::$_nullArray);
//delete billing address if exists.
CRM_Contribute_BAO_Contribution::deleteAddress(NULL, $id);
// delete the log entries since we dont have triggers enabled as yet
$logDAO = new CRM_Core_DAO_Log();
$logDAO->entity_table = 'civicrm_contact';
$logDAO->entity_id = $id;
$logDAO->delete();
// delete contact participants CRM-12155
CRM_Event_BAO_Participant::deleteContactParticipant($id);
// delete contact contributions CRM-12155
CRM_Contribute_BAO_Contribution::deleteContactContribution($id);
// do activity cleanup, CRM-5604
CRM_Activity_BAO_Activity::cleanupActivity($id);
// delete all notes related to contact
CRM_Core_BAO_Note::cleanContactNotes($id);
// delete cases related to contact
$contactCases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($id);
if (!empty($contactCases)) {
foreach ($contactCases as $caseId) {
//check if case is associate with other contact or not.
$caseContactId = CRM_Case_BAO_Case::getCaseClients($caseId);
if (count($caseContactId) <= 1) {
CRM_Case_BAO_Case::deleteCase($caseId);
}
}
}
$contact->delete();
} else {
self::contactTrashRestore($contact);
}
//delete the contact id from recently view
CRM_Utils_Recent::delContact($id);
// Update the group contact cache
if ($restore) {
CRM_Contact_BAO_GroupContactCache::remove();
} else {
CRM_Contact_BAO_GroupContactCache::removeContact($id);
//.........这里部分代码省略.........
示例3: testRetrieveCaseIdsByContactId
public function testRetrieveCaseIdsByContactId()
{
$caseIds = CRM_Case_BAO_Case::retrieveCaseIdsByContactId(3, FALSE, 'housing_support');
$this->assertEquals(array(1), $caseIds);
}
示例4: 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.');
}
示例5: postProcess
/**
* Function to process the form
*
* @access public
* @return void
*/
public function postProcess()
{
$params = $this->controller->exportValues($this->_name);
//Check the contact provided in Application form is existing or new
$profileContactType = CRM_Core_BAO_UFGroup::getContactType($this->_profileID);
$dedupeParams = CRM_Dedupe_Finder::formatParams($params, $profileContactType);
$dedupeParams['check_permission'] = FALSE;
$ids = CRM_Dedupe_Finder::dupesByParams($dedupeParams, $profileContactType);
$applicantID = $this->_contactID;
if (count($ids) && !$applicantID) {
$applicantID = CRM_Utils_Array::value(0, $ids);
}
$applicantID = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray, $applicantID, NULL, $this->_profileID);
if ($applicantID) {
$params['start_date'] = date("YmdHis");
$dao = new CRM_HRRecruitment_DAO_HRVacancyStage();
$dao->vacancy_id = $this->_id;
$dao->find();
while ($dao->fetch()) {
$params['case_status_id'] = $dao->case_status_id;
break;
}
//Create case of type Application against creator applicant and assignee as Vacancy creator
$caseTypes = array_flip(CRM_Case_PseudoConstant::caseType('name', TRUE, 'AND filter = 1'));
$cases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($applicantID, FALSE, 'Application');
foreach ($cases as $case) {
$oldAppl = CRM_HRRecruitment_BAO_HRVacancy::getVacancyIDByCase($case);
if ($oldAppl == $this->_id) {
$params['id'] = $case;
break;
}
}
$params['case_type_id'] = $caseTypes['Application'];
$caseObj = CRM_Case_BAO_Case::create($params);
if (empty($params['id'])) {
$contactParams = array('case_id' => $caseObj->id, 'contact_id' => $applicantID);
CRM_Case_BAO_Case::addCaseToContact($contactParams);
$xmlProcessor = new CRM_Case_XMLProcessor_Process();
$xmlProcessorParams = array('clientID' => $applicantID, 'creatorID' => $this->_creatorID, 'standardTimeline' => 1, 'activityTypeName' => 'Open Case', 'caseID' => $caseObj->id, 'activity_date_time' => $params['start_date']);
$xmlProcessor->run('Application', $xmlProcessorParams);
}
//process Custom data
CRM_Core_BAO_CustomValueTable::postprocess($params, CRM_Core_DAO::$_nullArray, 'civicrm_case', $caseObj->id, 'Case');
//Process case to vacancy one-to-one mapping in custom table 'application_case'
$cgID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', 'application_case', 'id', 'name');
$result = civicrm_api3('CustomField', 'get', array('custom_group_id' => $cgID, 'name' => 'vacancy_id'));
civicrm_api3('custom_value', 'create', array("custom_{$result['id']}" => $this->_id, 'entity_id' => $caseObj->id));
}
if ($this->controller->getButtonName('submit') == "_qf_Application_upload") {
CRM_Core_Session::setStatus(ts("Application has been successfully submitted."));
CRM_Core_Session::singleton()->pushUserContext(CRM_Utils_System::url('civicrm/vacancy/publiclisting', 'reset=1'));
}
}
示例6: hrrecruitment_civicrm_tabs
/**
* Implementation of hook_civicrm_tabs
*
* @return void
*/
function hrrecruitment_civicrm_tabs(&$tabs, $contactID)
{
$cases = CRM_Case_BAO_Case::retrieveCaseIdsByContactId($contactID, FALSE, 'Application');
foreach ($tabs as $key => $val) {
if ($val['title'] == 'Assignments') {
$tabs[$key]['count'] = $tabs[$key]['count'] - count($cases);
}
}
}