Skip to content

Commit

Permalink
[REF] Minor function signuturre cleanup
Browse files Browse the repository at this point in the history
 is never altered so it is unnecessary to pass by reference. visibility is just
used to set ignorePermissions
  • Loading branch information
eileenmcnaughton committed Jul 23, 2020
1 parent 7526f12 commit ae09f2e
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions CRM/Contact/BAO/GroupContact.php
Original file line number Diff line number Diff line change
Expand Up @@ -487,28 +487,22 @@ public static function getGroupId($groupContactID) {
}

/**
* Takes an associative array and creates / removes
* contacts from the groups
*
* Creates / removes contacts from the groups
*
* @param array $params
* (reference ) an assoc array of name/value pairs.
* @param array $contactId
* Name/value pairs.
* @param int $contactId
* Contact id.
*
* @param bool $visibility
* @param bool $ignorePermission
* if ignorePermission is true we are coming in via profile mean $method = 'Web'
*
* @param string $method
*/
public static function create(&$params, $contactId, $visibility = FALSE, $method = 'Admin') {
public static function create($params, $contactId, $ignorePermission = FALSE, $method = 'Admin') {
$contactIds = [];
$contactIds[] = $contactId;

//if $visibility is true we are coming in via profile mean $method = 'Web'
$ignorePermission = FALSE;
if ($visibility) {
$ignorePermission = TRUE;
}

if ($contactId) {
$contactGroupList = CRM_Contact_BAO_GroupContact::getContactGroup($contactId, 'Added',
NULL, FALSE, $ignorePermission
Expand All @@ -522,7 +516,7 @@ public static function create(&$params, $contactId, $visibility = FALSE, $method
}

// get the list of all the groups
$allGroup = CRM_Contact_BAO_GroupContact::getGroupList(0, $visibility);
$allGroup = CRM_Contact_BAO_GroupContact::getGroupList(0, $ignorePermission);

// this fix is done to prevent warning generated by array_key_exits incase of empty array is given as input
if (!is_array($params)) {
Expand Down

0 comments on commit ae09f2e

Please sign in to comment.