*/
/**
- *
- * @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
- * $Id$
- *
+ * Class CRM_Contact_BAO_Relationship.
*/
class CRM_Contact_BAO_Relationship extends CRM_Contact_DAO_Relationship {
const ALL = 0, PAST = 1, DISABLED = 2, CURRENT = 4, INACTIVE = 8;
/**
- * Create function. (Use the API instead)
+ * Create function.
+ *
+ * (Use the API instead)
* Note that the previous create function has been renamed 'legacyCreateMultiple'
* and this is new in 4.6
* All existing calls have been changed to legacyCreateMultiple except the api call - however, it is recommended
- * that you call that as the end to end testing here is based on the api & refactoring may still be done
+ * that you call that as the end to end testing here is based on the api & refactoring may still be done.
+ *
* @param array $params
+ *
* @return \CRM_Contact_BAO_Relationship
* @throws \CRM_Core_Exception
*/
}
/**
- * Create multiple relationships
+ * Create multiple relationships.
*
* @param $params
* @param $primaryContactLetter
$params['contact_id_' . $secondaryContactLetter] = $secondaryContactID;
$relationship = civicrm_api3('relationship', 'create', $params);
$relationshipIds[] = $relationship['id'];
- $valid ++;
+ $valid++;
}
catch (CiviCRM_API3_Exception $e) {
switch ($e->getMessage()) {
- case 'Duplicate Relationship' :
- $duplicate ++;
+ case 'Duplicate Relationship':
+ $duplicate++;
break;
- case 'Invalid Relationship' :
- $invalid ++;
+ case 'Invalid Relationship':
+ $invalid++;
break;
default:
continue;
}
$contactFields = self::setContactABFromIDs($params, $ids, $key);
- $singleInstanceParams = array_merge($params,$contactFields);
+ $singleInstanceParams = array_merge($params, $contactFields);
$relationship = self::add($singleInstanceParams);
$relationshipIds[] = $relationship->id;
$relationships[$relationship->id] = $relationship;
}
/**
- * This is the function that check/add if the relationship created is valid
+ * This is the function that check/add if the relationship created is valid.
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
/**
* Add relationship to recent links.
+ *
* @param array $params
* @param CRM_Contact_DAO_Relationship $relationship
*/
}
/**
- * Resolve passed in contact IDs to contact_id_a & contact_id_b
+ * Resolve passed in contact IDs to contact_id_a & contact_id_b.
*
* @param array $params
* @param array $ids
*/
public static function setContactABFromIDs($params, $ids = array(), $contactID = NULL) {
$returnFields = array();
- if (!empty($params['contact_id_a']) && !empty($params['contact_id_b']) && is_numeric
- ($params['relationship_type_id'])) {
+ if (!empty($params['contact_id_a'])
+ && !empty($params['contact_id_b'])
+ && is_numeric($params['relationship_type_id'])) {
return $returnFields;
}
if (empty($ids['contact'])) {
* Name/label that going to retrieve from db.
* @param bool $biDirectional
* @param string $contactSubType
- * Includes relationshiptypes between this subtype.
+ * Includes relationship types between this subtype.
* @param bool $onlySubTypeRelationTypes
- * If set only subtype which is passed by $contactSubType.
- * related relationshiptypes get return
- *
+ * If set only subtype which is passed by $contactSubType
+ * related relationship types get return
*
* @return array
* array reference of all relationship types with context to current contact.
* array of values submitted by POST.
* @param array $ids
* array of ids.
- * @param \const|\which $action which action called this function
+ * @param \const|int $action which action called this function
*
* @param bool $active
*
+ * @throws \CRM_Core_Exception
*/
public static function relatedMemberships($contactId, &$params, $ids, $action = CRM_Core_Action::ADD, $active = TRUE) {
// Check the end date and set the status of the relationship
/**
* Merge relationships from otherContact to mainContact.
+ *
* Called during contact merge operation
*
* @param int $mainId