self::setCurrentEmployer(array($contactID => $organization));
$relationshipParams['relationship_ids'] = $relationshipIds;
- // handle related meberships. CRM-3792
+ // Handle related memberships. CRM-3792
self::currentEmployerRelatedMembership($contactID, $organization, $relationshipParams, $duplicate, $previousEmployerID);
}
}
$valid = $invalid = $duplicate = $saved = 0;
$relationships = $relationshipIds = array();
$relationshipId = CRM_Utils_Array::value('relationship', $ids, CRM_Utils_Array::value('id', $params));
- echo 'relationship id is ' . $relationshipId . "\n";
//CRM-9015 - the hooks are called here & in add (since add doesn't call create)
// but in future should be tidied per ticket
// step 3: if valid relationship then add the relation and keep the count
// step 1
- $errors = self::checkValidRelationship($params, $ids, $key);
+ $contactFields = self::setContactABFromIDs($params, $ids, $key);
+ $errors = self::checkValidRelationship($contactFields, $ids, $key);
if ($errors) {
$invalid++;
continue;
if (
self::checkDuplicateRelationship(
- $params,
+ $contactFields,
CRM_Utils_Array::value('contact', $ids),
// step 2
$key
$duplicate++;
continue;
}
- $contactFields = self::setContactABFromIDs($params, $ids, $key);
+
$singleInstanceParams = array_merge($params, $contactFields);
$relationship = self::add($singleInstanceParams);
$relationshipIds[] = $relationship->id;
}
throw new CRM_Core_Exception('Cannot create relationship, insufficient contact IDs provided');
}
- if (!is_numeric($params['relationship_type_id'])) {
+ if (isset($params['relationship_type_id']) && !is_numeric($params['relationship_type_id'])) {
$relationshipTypes = CRM_Utils_Array::value('relationship_type_id', $params);
list($relationshipTypeID, $first) = explode('_', $relationshipTypes);
- if (empty($params['relationship_type_id'])) {
- $returnFields['relationship_type_id'] = $relationshipTypeID;
- }
+ $returnFields['relationship_type_id'] = $relationshipTypeID;
+
foreach (array('a', 'b') as $contactLetter) {
if (empty($params['contact_' . $contactLetter])) {
if ($first == $contactLetter) {