Skip to content

Commit

Permalink
[REF] Rename variable to be meaningful
Browse files Browse the repository at this point in the history
It turns out key is organizationID - rename ...

I did this in both places the function is called from - as I clean up the copy some
cleanups on the original emerge too
  • Loading branch information
eileenmcnaughton committed Jan 9, 2022
1 parent 9e06191 commit 870fb6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions CRM/Contact/BAO/Contact/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,15 @@ private static function legacyCreateMultiple(&$params, int $contactID) {
$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;
Expand All @@ -347,7 +347,7 @@ private static function legacyCreateMultiple(&$params, int $contactID) {
$contactFields,
CRM_Utils_Array::value('contact', $ids),
// step 2
$key
$organizationID
)
) {
$duplicate++;
Expand Down
8 changes: 4 additions & 4 deletions CRM/Contact/BAO/Relationship.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ public static function legacyCreateMultiple(&$params, $ids = []) {
if (!$relationshipId) {
// creating a new relationship
$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 = self::setContactABFromIDs($params, $ids, $key);
$errors = self::checkValidRelationship($contactFields, $ids, $key);
$contactFields = self::setContactABFromIDs($params, $ids, $organizationID);
$errors = self::checkValidRelationship($contactFields, $ids, $organizationID);
if ($errors) {
$invalid++;
continue;
Expand All @@ -203,7 +203,7 @@ public static function legacyCreateMultiple(&$params, $ids = []) {
$contactFields,
CRM_Utils_Array::value('contact', $ids),
// step 2
$key
$organizationID
)
) {
$duplicate++;
Expand Down

0 comments on commit 870fb6d

Please sign in to comment.