X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FContact%2FBAO%2FRelationship.php;h=15c4dc0d4a02492ed63b1c4f829abee876b7cc22;hb=83562390030fc9e97c5df95a87476e15986974ea;hp=e2d30b4cfebf5de4999641252acf9e878c382645;hpb=c74318cd011a4372c66d588b26a38da2b87d5a4c;p=civicrm-core.git diff --git a/CRM/Contact/BAO/Relationship.php b/CRM/Contact/BAO/Relationship.php index e2d30b4cfe..15c4dc0d4a 100644 --- a/CRM/Contact/BAO/Relationship.php +++ b/CRM/Contact/BAO/Relationship.php @@ -261,7 +261,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { $relationship->free(); - CRM_Utils_Hook::post($hook, 'Relationship', $relationshipId, $relationship); + CRM_Utils_Hook::post($hook, 'Relationship', $relationship->id, $relationship); return $relationship; } @@ -305,18 +305,21 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { /** * Function to get get list of relationship type based on the contact type. * - * @param int $contactId this is the contact id of the current contact. - * @param string $strContact this value is currently ignored, keeping it there for legacy reasons - * @param string $relationshipId the id of the existing relationship if any - * @param string $contactType contact type - * @param boolean $all if true returns relationship types in both the direction - * @param string $column name/label that going to retrieve from db. + * @param int $contactId this is the contact id of the current contact. + * @param null $contactSuffix + * @param string $relationshipId the id of the existing relationship if any + * @param string $contactType contact type + * @param boolean $all if true returns relationship types in both the direction + * @param string $column name/label that going to retrieve from db. * * - * @param string $contactSubType includes relationshiptypes between this subtype + * @param bool $biDirectional + * @param string $contactSubType includes relationshiptypes between this subtype * * @param boolean $onlySubTypeRelationTypes if set only subtype which is passed by $contactSubType * related relationshiptypes get return + * + * @internal param string $strContact this value is currently ignored, keeping it there for legacy reasons * @access public * @static * @@ -372,6 +375,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { ) && (!$contactSubType || (in_array($value['contact_sub_type_a'], $contactSubType) || + in_array($value['contact_sub_type_b'], $contactSubType) || ((!$value['contact_sub_type_b'] && !$value['contact_sub_type_a'] ) && @@ -392,6 +396,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { ) && (!$contactSubType || (in_array($value['contact_sub_type_b'], $contactSubType) || + in_array($value['contact_sub_type_a'], $contactSubType) || ((!$value['contact_sub_type_a'] && !$value['contact_sub_type_b'] ) && @@ -420,6 +425,12 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { return $relationshipType; } + /** + * @param $id + * @param $action + * + * @return CRM_Contact_DAO_Relationship + */ static function clearCurrentEmployer($id, $action) { $relationship = new CRM_Contact_DAO_Relationship(); $relationship->id = $id; @@ -480,7 +491,7 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { $relationship->delete(); CRM_Core_Session::setStatus(ts('Selected relationship has been deleted successfully.'), ts('Record Deleted'), 'success'); - CRM_Utils_Hook::post('delete', 'Relationship', $relationship->id, $relationship); + CRM_Utils_Hook::post('delete', 'Relationship', $id, $relationship); // delete the recently created Relationship $relationshipRecent = array( @@ -497,9 +508,10 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { * * @param int $id relationship id * + * @param $action + * * @return null * @access public - * @static */ static function disableEnableRelationship($id, $action) { @@ -562,6 +574,8 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { * @param int $id relationship id * * $returns returns the contact ids in the realtionship + * + * @return \CRM_Contact_DAO_Relationship * @access public * @static */ @@ -620,12 +634,12 @@ class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship { /** * this function does the validtion for valid relationship * - * @param array $params this array contains the values there are subitted by the form - * @param array $ids the array that holds all the db ids - * @param integer $contactId this is contact id for adding relationship + * @param array $params this array contains the values there are subitted by the form + * @param array $ids the array that holds all the db ids + * @param integer $contactId this is contact id for adding relationship * - * @return - * @access public + * @return string + @access public * @static */ static function checkValidRelationship(&$params, &$ids, $contactId) { @@ -724,9 +738,10 @@ WHERE relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer'); /** * update the is_active flag in the db * - * @param int $id id of the database record - * @param boolean $is_active value we want to set the is_active field + * @param int $id id of the database record + * @param boolean $is_active value we want to set the is_active field * + * @throws CiviCRM_API3_Exception * @return Object DAO object on success, null otherwise * @static */ @@ -757,9 +772,9 @@ WHERE relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer'); * Given the list of params in the params array, fetch the object * and store the values in the values array * - * @param array $params input parameters to find object - * @param array $values output values of the object - * @param array $ids the array that holds all the db ids + * @param array $params input parameters to find object + * @param array $values output values of the object + * @internal param array $ids the array that holds all the db ids * * @return array (reference) the values that could be potentially assigned to smarty * @access public @@ -796,10 +811,13 @@ WHERE relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer'); * @param int $numRelationship no of relationships to display (limit) * @param int $count get the no of relationships * $param int $relationshipId relationship id - * @param string $direction the direction we are interested in a_b or b_a + * @param $relationshipId + * @param string $direction the direction we are interested in a_b or b_a * @param array $params array of extra values including relationship_type_id per api spec * * return string the query for this diretion + * + * @return array * @static * @access public */ @@ -828,9 +846,9 @@ WHERE relationship_type_id = " . CRM_Utils_Type::escape($type, 'Integer'); civicrm_state_province.abbreviation as state, civicrm_country.name as country, civicrm_email.email as email, + civicrm_contact.contact_type as contact_type, civicrm_phone.phone as phone, civicrm_contact.id as civicrm_contact_id, - civicrm_contact.contact_type as contact_type, civicrm_relationship.contact_id_b as contact_id_b, civicrm_relationship.contact_id_a as contact_id_a, civicrm_relationship_type.id as civicrm_relationship_type_id, @@ -940,6 +958,13 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) * $param boolean $permissionedContact to return only permissioned Contact * $param array $params array of variables consistent with filters supported by the api * return array $values relationship records + * @param int $relationshipId + * @param null $links + * @param null $permissionMask + * @param bool $permissionedContact + * @param array $params + * + * @return array|int * @static * @access public */ @@ -1029,6 +1054,7 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) $values[$rid]['cid'] = $cid; $values[$rid]['contact_id_a'] = $relationship->contact_id_a; $values[$rid]['contact_id_b'] = $relationship->contact_id_b; + $values[$rid]['contact_type'] = $relationship->contact_type; $values[$rid]['relationship_type_id'] = $relationship->civicrm_relationship_type_id; $values[$rid]['relation'] = $relationship->relation; $values[$rid]['name'] = $relationship->sort_name; @@ -1161,10 +1187,11 @@ LEFT JOIN civicrm_country ON (civicrm_address.country_id = civicrm_country.id) * @param $contactId Int contact id * @param $params array array of values submitted by POST * @param $ids array array of ids - * @param $action which action called this function + * @param \const|\which $action which action called this function * - * @static + * @param bool $active * + * @static */ static function relatedMemberships($contactId, &$params, $ids, $action = CRM_Core_Action::ADD, $active = TRUE) { // Check the end date and set the status of the relationship @@ -1416,10 +1443,7 @@ SELECT count(*) * * @param $contactIds Contact Ids * - * @return $currentEmployer array of the current employer - * - * @static - * + * @return array $currentEmployer array of the current employer@static */ static function getCurrentEmployer($contactIds) { $contacts = implode(',', $contactIds); @@ -1574,6 +1598,9 @@ AND cc.sort_name LIKE '%$name%'"; * (as opposed to those who inherit a particular membership * * @param array $params api input array + * @param null $direction + * + * @return array */ static function membershipTypeToRelationshipTypes(&$params, $direction = NULL) { $membershipType = civicrm_api3('membership_type', 'getsingle', array('id' => $params['membership_type_id'], 'return' => 'relationship_type_id, relationship_direction')); @@ -1679,15 +1706,20 @@ AND cc.sort_name LIKE '%$name%'"; // format params foreach ($relationships as $relationshipId => $values) { - $contactRelationships[$relationshipId]['name'] = CRM_Utils_System::href( + //Add image icon for related contacts: CRM-14919 + $icon = CRM_Contact_BAO_Contact_Utils::getImage($values['contact_type'], + FALSE, + $values['cid'] + ); + $contactRelationships[$relationshipId]['name'] = $icon.' '.CRM_Utils_System::href( $values['name'], 'civicrm/contact/view', - "reset=1&cid={$values['contact_id_b']}"); + "reset=1&cid={$values['cid']}"); $contactRelationships[$relationshipId]['relation'] = CRM_Utils_System::href( $values['relation'], 'civicrm/contact/view/rel', - "action=view&reset=1&cid={$values['contact_id_a']}&id={$values['id']}&rtype={$values['rtype']}"); + "action=view&reset=1&cid={$values['cid']}&id={$values['id']}&rtype={$values['rtype']}"); if ($params['context'] == 'current') { if (($params['contact_id'] == $values['contact_id_a'] AND $values['is_permission_a_b'] == 1) OR