From 08d5b4df141437b2e9a588f5743558fd5c5434fa Mon Sep 17 00:00:00 2001 From: Jitendra Purohit Date: Wed, 18 Sep 2019 12:42:51 +0530 Subject: [PATCH] dev/core#1263 - Drupal 8 - Contact Report does not load any values in the ACL Group/Role field --- CRM/Report/Form/Instance.php | 6 +----- CRM/Utils/System/Base.php | 9 +++++++++ CRM/Utils/System/Drupal8.php | 9 +++++++++ CRM/Utils/System/DrupalBase.php | 9 +++++++++ 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/CRM/Report/Form/Instance.php b/CRM/Report/Form/Instance.php index 8f00408a17..4ca1b81ad2 100644 --- a/CRM/Report/Form/Instance.php +++ b/CRM/Report/Form/Instance.php @@ -109,11 +109,7 @@ class CRM_Report_Form_Instance { ); // prepare user_roles to save as names not as ids - if (function_exists('user_roles')) { - $user_roles_array = user_roles(); - foreach ($user_roles_array as $key => $value) { - $user_roles[$value] = $value; - } + if ($user_roles = CRM_Core_Config::singleton()->userSystem->getRoleNames()) { $grouprole = $form->addElement('advmultiselect', 'grouprole', ts('ACL Group/Role'), diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index 20bf040b94..c49b8afba2 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -981,4 +981,13 @@ abstract class CRM_Utils_System_Base { session_start(); } + /** + * Get role names + * + * @return array|null + */ + public function getRoleNames() { + return NULL; + } + } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 68a91361e3..48e3808cac 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -794,4 +794,13 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return $url; } + /** + * Get role names + * + * @return array|null + */ + public function getRoleNames() { + return user_role_names(); + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 27e11078ef..380a9f07d9 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -681,4 +681,13 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { } } + /** + * Get role names + * + * @return array|null + */ + public function getRoleNames() { + return array_combine(user_roles(), user_roles()); + } + } -- 2.25.1