Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
7d6d923d
Unverified
Commit
7d6d923d
authored
6 years ago
by
eileen
Committed by
GitHub
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #13327 from pradpnayak/SerarchView
Used buildoptions function to get all groups
parents
90b7caa5
f639bf2f
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/v3/Contact.php
+11
-9
11 additions, 9 deletions
api/v3/Contact.php
tests/phpunit/api/v3/ContactTest.php
+25
-0
25 additions, 0 deletions
tests/phpunit/api/v3/ContactTest.php
with
36 additions
and
9 deletions
api/v3/Contact.php
+
11
−
9
View file @
7d6d923d
...
...
@@ -430,13 +430,15 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
}
if
(
isset
(
$params
[
'group'
]))
{
$groups
=
$params
[
'group'
];
$allGroups
=
CRM_Core_PseudoConstant
::
group
();
$groupsByTitle
=
CRM_Core_PseudoConstant
::
group
();
$groupsByName
=
CRM_Contact_BAO_GroupContact
::
buildOptions
(
'group_id'
,
'validate'
);
$allGroups
=
array_merge
(
array_flip
(
$groupsByTitle
),
array_flip
(
$groupsByName
));
if
(
is_array
(
$groups
)
&&
in_array
(
key
(
$groups
),
CRM_Core_DAO
::
acceptedSQLOperators
(),
TRUE
))
{
// Get the groups array.
$groupsArray
=
$groups
[
key
(
$groups
)];
foreach
(
$groupsArray
as
&
$group
)
{
if
(
!
is_numeric
(
$group
)
&&
array_search
(
$group
,
$allGroups
))
{
$group
=
array_search
(
$group
,
$allGroups
)
;
if
(
!
is_numeric
(
$group
)
&&
!
empty
(
$allGroups
[
$group
]
))
{
$group
=
$allGroups
[
$group
]
;
}
}
// Now reset the $groups array with the ids not the titles.
...
...
@@ -445,17 +447,17 @@ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) {
// handle format like 'group' => array('title1', 'title2').
elseif
(
is_array
(
$groups
))
{
foreach
(
$groups
as
$k
=>
&
$group
)
{
if
(
!
is_numeric
(
$group
)
&&
array_search
(
$group
,
$allGroups
))
{
$group
=
array_search
(
$group
,
$allGroups
)
;
if
(
!
is_numeric
(
$group
)
&&
!
empty
(
$allGroups
[
$group
]
))
{
$group
=
$allGroups
[
$group
]
;
}
if
(
!
is_numeric
(
$k
)
&&
array_search
(
$k
,
$allGroups
))
{
if
(
!
is_numeric
(
$k
)
&&
!
empty
(
$allGroups
[
$k
]
))
{
unset
(
$groups
[
$k
]);
$groups
[
array_search
(
$k
,
$allGroups
)
]
=
$group
;
$groups
[
$allGroups
[
$k
]
]
=
$group
;
}
}
}
elseif
(
!
is_numeric
(
$groups
)
&&
array_search
(
$groups
,
$allG
roups
))
{
$groups
=
array_search
(
$groups
,
$allGroups
)
;
elseif
(
!
is_numeric
(
$groups
)
&&
!
empty
(
$allGroups
[
$g
roups
]
))
{
$groups
=
$allGroups
[
$groups
]
;
}
$params
[
'group'
]
=
$groups
;
}
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/api/v3/ContactTest.php
+
25
−
0
View file @
7d6d923d
...
...
@@ -3842,6 +3842,31 @@ class api_v3_ContactTest extends CiviUnitTestCase {
$this
->
assertEquals
(
array
(
'external_identifier'
),
$result
[
'values'
][
'UI_external_identifier'
]);
}
/**
* API test to retrieve contact from group having different group title and name.
*/
public
function
testContactGetFromGroup
()
{
$groupId
=
$this
->
groupCreate
([
'name'
=>
'Test_Group'
,
'domain_id'
=>
1
,
'title'
=>
'New Test Group Created'
,
'description'
=>
'New Test Group Created'
,
'is_active'
=>
1
,
'visibility'
=>
'User and User Admin Only'
,
]);
$contact
=
$this
->
callAPISuccess
(
'contact'
,
'create'
,
$this
->
_params
);
$groupContactCreateParams
=
array
(
'contact_id'
=>
$contact
[
'id'
],
'group_id'
=>
$groupId
,
'status'
=>
'Pending'
,
);
$groupContact
=
$this
->
callAPISuccess
(
'groupContact'
,
'create'
,
$groupContactCreateParams
);
$groupGetContact
=
$this
->
CallAPISuccess
(
'groupContact'
,
'get'
,
$groupContactCreateParams
);
$this
->
CallAPISuccess
(
'Contact'
,
'getcount'
,
[
'group'
=>
"Test_Group"
,
]);
}
public
function
testSmartGroupsForRelatedContacts
()
{
$rtype1
=
$this
->
callAPISuccess
(
'relationship_type'
,
'create'
,
array
(
"name_a_b"
=>
uniqid
()
.
" Child of"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment