Skip to content
Snippets Groups Projects
Commit 14ff0c2b authored by mattwire's avatar mattwire
Browse files

Merge branch 'get_sequential' into 'master'

Make get() more get-like

See merge request !2
parents d1506902 426f3a04
No related branches found
No related tags found
1 merge request!2Make get() more get-like
......@@ -39,7 +39,7 @@ class CRM_CivirulesConditions_Cmsuser_HasAccount extends CRM_Civirules_Condition
return FALSE;
}
// Cmsuser.get returns exception if no ufmatch record found
// Cmsuser.get returns no values if no ufmatch record found
try {
$cmsuser = civicrm_api3('Cmsuser', 'get', ['contact_id' => $entityID]);
}
......
......@@ -24,14 +24,22 @@ function _civicrm_api3_cmsuser_get_spec(&$params) {
* @return array
*/
function civicrm_api3_cmsuser_get($params) {
$user = CRM_Core_Config::singleton()->userSystem->getUser($params['contact_id']);
$result = [];
if ($user) {
$result[$params['contact_id']] = [
'uf_id' => $user['id'],
'uf_name' => $user['name'],
'contact_id' => $params['contact_id'],
];
try {
$user = CRM_Core_Config::singleton()->userSystem->getUser($params['contact_id']);
if ($user) {
$result[$params['sequential'] ? 0 : $params['contact_id']] = [
'uf_id' => $user['id'],
'uf_name' => $user['name'],
'contact_id' => $params['contact_id'],
];
}
}
catch (Exception $e) {
// no need for Exception if it just means no user found
if ($e->getMessage() != "Expected one UFMatch but found 0") {
throw $e;
}
}
return civicrm_api3_create_success($result);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment