From f22205d7c24a084c5703948b3d3e6f5cf6f74258 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 17 Feb 2021 00:19:11 -0800 Subject: [PATCH] Joomla - Implement getUfId(). Fix '@user:'. Overview -------- APIv3 includes shorthand support for referencing a contact by their username, e.g. ``` cv api contact.get id=@user:admin return=display_name ``` Before ------ On Joomla, this emits an error because `getUfId($username):int` is not implemented. After ----- On Joomla, this works. Comments -------- There is implicit E2E test-coverage in the pending work for authx. --- CRM/Utils/System/Joomla.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index 7883e484e0..823fef3360 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -456,6 +456,12 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { return TRUE; } + public function getUfId($username) { + jimport('joomla.user.helper'); + $uid = JUserHelper::getUserId($username); + return empty($uid) ? NULL : $uid; + } + /** * FIXME: Use CMS-native approach * @throws \CRM_Core_Exception. -- 2.25.1