X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCase%2FBAO%2FCase.php;h=0fa87b459e92f0910c38cfc3f885a539934ffea0;hb=3a6d22e70a2bcb315e5c3fb562a15b0ff901bd5c;hp=8048c8ff75b0780abecf333d40c99bd16740b29f;hpb=c9baa85a27f776bc2b49bc5d38611f537cf19f30;p=civicrm-core.git diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 8048c8ff75..0fa87b459e 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -274,16 +274,16 @@ WHERE civicrm_case.id = %1"; * ID of the case. * * @param int $contactID + * @param int $startArrayAt This is to support legacy calls to Case.Get API which may rely on the first array index being set to 1 * * @return array */ - public static function retrieveContactIdsByCaseId($caseId, $contactID = NULL) { + public static function retrieveContactIdsByCaseId($caseId, $contactID = NULL, $startArrayAt = 0) { $caseContact = new CRM_Case_DAO_CaseContact(); $caseContact->case_id = $caseId; $caseContact->find(); $contactArray = array(); - // FIXME: Why does this return a 1-based array? - $count = 1; + $count = $startArrayAt; while ($caseContact->fetch()) { if ($contactID != $caseContact->contact_id) { $contactArray[$count] = $caseContact->contact_id; @@ -840,12 +840,13 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c * @param int $caseID * Case id. * @param int $relationshipID + * @param bool $activeOnly * * @return array * case role / relationships * */ - public static function getCaseRoles($contactID, $caseID, $relationshipID = NULL) { + public static function getCaseRoles($contactID, $caseID, $relationshipID = NULL, $activeOnly = TRUE) { $query = ' SELECT rel.id as civicrm_relationship_id, con.sort_name as sort_name, @@ -861,7 +862,11 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c LEFT JOIN civicrm_phone ON (civicrm_phone.contact_id = con.id AND civicrm_phone.is_primary = 1) LEFT JOIN civicrm_email ON (civicrm_email.contact_id = con.id AND civicrm_email.is_primary = 1) WHERE (rel.contact_id_a = %1 OR rel.contact_id_b = %1) AND rel.case_id = %2 - AND rel.is_active = 1 AND con.is_deleted = 0 AND (rel.end_date IS NULL OR rel.end_date > NOW())'; + AND con.is_deleted = 0'; + + if ($activeOnly) { + $query .= ' AND rel.is_active = 1 AND (rel.end_date IS NULL OR rel.end_date > NOW())'; + } $params = array( 1 => array($contactID, 'Positive'), @@ -1085,7 +1090,6 @@ SELECT case_status.label AS case_status, status_id, civicrm_case_type.title AS c $contactViewUrl = CRM_Utils_System::url("civicrm/contact/view", "reset=1&cid=", FALSE, NULL, FALSE); $hasViewContact = CRM_Core_Permission::giveMeAllACLs(); - $clientIds = self::retrieveContactIdsByCaseId($caseID); if (!$userID) { $session = CRM_Core_Session::singleton();