From 420ceacd8436b5ef336765a2c88e38946da9c1f1 Mon Sep 17 00:00:00 2001 From: chiachin Date: Wed, 11 Sep 2024 17:56:25 +0800 Subject: [PATCH] Refs #41489, Update reserved profile access check for User Account. --- CRM/Profile/Form.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CRM/Profile/Form.php b/CRM/Profile/Form.php index 865e9bb4e..95c3e96ae 100644 --- a/CRM/Profile/Form.php +++ b/CRM/Profile/Form.php @@ -198,9 +198,17 @@ function preProcess() { // restrict permission when profile is reserved if ($dao->is_reserved && !CRM_Core_Permission::check('access CiviCRM')) { - return CRM_Core_Error::statusBounce(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.', array( - 1 => $this->_gid - ))); + $sql = "SELECT id FROM civicrm_uf_join WHERE uf_group_id = %1 and module = %2"; + $params = array( + 1 => array($dao->id, 'Integer'), + 2 => array("User Account", 'String'), + ); + $useForIsUserAccount = CRM_Core_DAO::singleValueQuery($sql, $params); + if (empty($useForIsUserAccount)) { + return CRM_Core_Error::statusBounce(ts('The requested Profile (gid=%1) is disabled OR it is not configured to be used for \'Profile\' listings in its Settings OR there is no Profile with that ID OR you do not have permission to access this profile. Please contact the site administrator if you need assistance.', array( + 1 => $this->_gid + ))); + } } } $dao->free();