Details
-
Type:
New Feature
-
Status: Done/Fixed
-
Priority:
Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 2.2.5
-
Fix Version/s: 4.2.0
-
Component/s: CiviCRM API
-
Labels:None
Description
Here's my cut at an API extension to allow a profile search which will return results to an API call similar to a publicly exposed search profile
Criteria I was looking at / decisions I made:
- Information available should be equivalent to that exposed through the search profile (and to the same people). Profiles that are not set for search should not be available, likewise if not in the selector fields should not be returned.
- sort_name included in results even if not in the profile - as per search profile behaviour, sort_name is default sort order.
- JSON formatted response available.
- separate path for the call than the main REST calls to allow anonymous access.
- Change to REST adds a function which makes sure this is the only api call that can be made via that path
- I tried not to tinker with any core code but did need to make a small change to CRM\Profile\Selector\Listings.php so make it work (below). Also, inserted xml below into crM\Core\xml\Menu\misc.xml
- I filtered out the extraneous info returned from Selector\Listings.php in the api function rather than suggest changes to listings.php. They come from line 474 ( $row[] = CRM_Contact_BAO_Contact_Utils::getImage( $result->contact_type )
and line 575 ( $row[] = CRM_Core_Action::formLink( $newLinks,
$mask,
$params )
Included files
api\v2\Profile.php
CRM\Utils\REST.php
CRM\Profile\Selector\Listings.php
Addition to menu. CRM\Core\xml\Menu\misc.xml
<item>
<path>civicrm/ajax/rest/profile</path>
<page_callback>CRM_Utils_REST::ajaxProfile</page_callback>
<access_arguments>profile listings and forms</access_arguments></item>
Change to line 367-388
CRM/Utils/Sort.php
367c367
< if( $sort ) {
—
> if(is_array( $sort ))
—
>
388c388
<
—
> }