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 f329c0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion CRM/Contact/BAO/Contact.php
Original file line number Diff line number Diff line change
Expand Up @@ -2021,7 +2021,7 @@ public static function createProfileContact(
}

// Process group and tag
if (!empty($fields['group'])) {
if (isset($params['group'])) {
$method = 'Admin';
// this for sure means we are coming in via profile since i added it to fix
// removing contacts from user groups -- lobo
Expand Down
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 f329c0c

Please sign in to comment.