$ids = ['contact' => $contactID];
$relationshipIds = [];
- foreach ($params['contact_check'] as $key => $value) {
+ foreach (array_keys($params['contact_check']) as $organizationID) {
// check if the relationship is valid between contacts.
// step 1: check if the relationship is valid if not valid skip and keep the count
// step 2: check the if two contacts already have a relationship if yes skip and keep the count
// step 3: if valid relationship then add the relation and keep the count
// step 1
- $contactFields = CRM_Contact_BAO_Relationship::setContactABFromIDs($params, $ids, $key);
- $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($contactFields, $ids, $key);
+ $contactFields = CRM_Contact_BAO_Relationship::setContactABFromIDs($params, $ids, $organizationID);
+ $errors = CRM_Contact_BAO_Relationship::checkValidRelationship($contactFields, $ids, $organizationID);
if ($errors) {
$invalid++;
continue;
$contactFields,
CRM_Utils_Array::value('contact', $ids),
// step 2
- $key
+ $organizationID
)
) {
$duplicate++;
if (!$relationshipId) {
// creating a new relationship
$relationshipIds = [];
- foreach ($params['contact_check'] as $key => $value) {
+ foreach (array_keys($params['contact_check']) as $relatedContactID) {
// check if the relationship is valid between contacts.
// step 1: check if the relationship is valid if not valid skip and keep the count
// step 2: check the if two contacts already have a relationship if yes skip and keep the count
// step 3: if valid relationship then add the relation and keep the count
// step 1
- $contactFields = self::setContactABFromIDs($params, $ids, $key);
- $errors = self::checkValidRelationship($contactFields, $ids, $key);
+ $contactFields = self::setContactABFromIDs($params, $ids, $relatedContactID);
+ $errors = self::checkValidRelationship($contactFields, $ids, $relatedContactID);
if ($errors) {
$invalid++;
continue;
$contactFields,
CRM_Utils_Array::value('contact', $ids),
// step 2
- $key
+ $relatedContactID
)
) {
$duplicate++;