From 839834b42c721283f0589df45bcb53b6d3e62077 Mon Sep 17 00:00:00 2001 From: demeritcowboy Date: Tue, 17 Nov 2020 09:55:52 -0500 Subject: [PATCH] oo-ify permissions page links --- CRM/Admin/Page/Access.php | 42 +++++---------------------------- CRM/Utils/System/Backdrop.php | 8 +++++++ CRM/Utils/System/Base.php | 8 +++++++ CRM/Utils/System/Drupal6.php | 8 +++++++ CRM/Utils/System/Drupal8.php | 8 +++++++ CRM/Utils/System/DrupalBase.php | 8 +++++++ CRM/Utils/System/Joomla.php | 25 ++++++++++++++++++++ CRM/Utils/System/WordPress.php | 8 +++++++ 8 files changed, 79 insertions(+), 36 deletions(-) diff --git a/CRM/Admin/Page/Access.php b/CRM/Admin/Page/Access.php index e8ca758623..b7d3f346ca 100644 --- a/CRM/Admin/Page/Access.php +++ b/CRM/Admin/Page/Access.php @@ -17,8 +17,6 @@ /** * Dashboard page for managing Access Control. - * - * For initial version, this page only contains static links - so this class is empty for now. */ class CRM_Admin_Page_Access extends CRM_Core_Page { @@ -26,40 +24,12 @@ class CRM_Admin_Page_Access extends CRM_Core_Page { * @return string */ public function run() { - $config = CRM_Core_Config::singleton(); - - switch ($config->userFramework) { - case 'Drupal': - $this->assign('ufAccessURL', url('admin/people/permissions')); - break; - - case 'Drupal6': - $this->assign('ufAccessURL', url('admin/user/permissions')); - break; - - case 'Joomla': - //condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value - if (version_compare(JVERSION, '3.0', 'lt')) { - JHTML::_('behavior.modal'); - $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component'; - $jparams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"'; - - $this->assign('ufAccessURL', $url); - $this->assign('jAccessParams', $jparams); - } - else { - $uri = (string) JUri::getInstance(); - $return = urlencode(base64_encode($uri)); - $url = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return; - - $this->assign('ufAccessURL', $url); - $this->assign('jAccessParams', ''); - } - break; - - case 'WordPress': - $this->assign('ufAccessURL', CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1')); - break; + $urlParams = CRM_Utils_System::getCMSPermissionsUrlParams(); + if (isset($urlParams['ufAccessURL'])) { + $this->assign('ufAccessURL', $urlParams['ufAccessURL']); + } + if (isset($urlParams['jAccessParams'])) { + $this->assign('jAccessParams', $urlParams['jAccessParams']); } return parent::run(); } diff --git a/CRM/Utils/System/Backdrop.php b/CRM/Utils/System/Backdrop.php index 9e7f564013..ded63e2164 100644 --- a/CRM/Utils/System/Backdrop.php +++ b/CRM/Utils/System/Backdrop.php @@ -1049,4 +1049,12 @@ AND u.status = 1 } } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return ['ufAccessURL' => url('admin/config/people/permissions')]; + } + } diff --git a/CRM/Utils/System/Base.php b/CRM/Utils/System/Base.php index aabb9aa48b..e126a6d5f3 100644 --- a/CRM/Utils/System/Base.php +++ b/CRM/Utils/System/Base.php @@ -1004,4 +1004,12 @@ abstract class CRM_Utils_System_Base { public function prePostRedirect() { } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return []; + } + } diff --git a/CRM/Utils/System/Drupal6.php b/CRM/Utils/System/Drupal6.php index 343ec7fe74..97249fd9bd 100644 --- a/CRM/Utils/System/Drupal6.php +++ b/CRM/Utils/System/Drupal6.php @@ -809,4 +809,12 @@ class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase { ]; } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return ['ufAccessURL' => url('admin/user/permissions')]; + } + } diff --git a/CRM/Utils/System/Drupal8.php b/CRM/Utils/System/Drupal8.php index 85d0468296..fa6d8ac926 100644 --- a/CRM/Utils/System/Drupal8.php +++ b/CRM/Utils/System/Drupal8.php @@ -827,4 +827,12 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase { return FALSE; } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return ['ufAccessURL' => \Drupal\Core\Url::fromRoute('user.admin_permissions')->toString()]; + } + } diff --git a/CRM/Utils/System/DrupalBase.php b/CRM/Utils/System/DrupalBase.php index 9234c87d75..e4cf7edf2c 100644 --- a/CRM/Utils/System/DrupalBase.php +++ b/CRM/Utils/System/DrupalBase.php @@ -701,4 +701,12 @@ abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base { return FALSE; } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return ['ufAccessURL' => url('admin/people/permissions')]; + } + } diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index f7b4b68213..7883e484e0 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -917,4 +917,29 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { ]; } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + $ufAccessURL = ''; + $jAccessParams = ''; + $config = CRM_Core_Config::singleton(); + //condition based on Joomla version; <= 2.5 uses modal window; >= 3.0 uses full page with return value + if (version_compare(JVERSION, '3.0', 'lt')) { + JHTML::_('behavior.modal'); + $ufAccessURL = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&tmpl=component'; + $jAccessParams = 'rel="{handler: \'iframe\', size: {x: 875, y: 550}, onClose: function() {}}" class="modal"'; + } + else { + $uri = (string) JUri::getInstance(); + $return = urlencode(base64_encode($uri)); + $ufAccessURL = $config->userFrameworkBaseURL . 'index.php?option=com_config&view=component&component=com_civicrm&return=' . $return; + } + return [ + 'ufAccessURL' => $ufAccessURL, + 'jAccessParams' => $jAccessParams, + ]; + } + } diff --git a/CRM/Utils/System/WordPress.php b/CRM/Utils/System/WordPress.php index f13ad38830..2877ffed2a 100644 --- a/CRM/Utils/System/WordPress.php +++ b/CRM/Utils/System/WordPress.php @@ -1244,4 +1244,12 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base { $_COOKIE[$name] = $value; } + /** + * Return the CMS-specific url for its permissions page + * @return array + */ + public function getCMSPermissionsUrlParams() { + return ['ufAccessURL' => CRM_Utils_System::url('civicrm/admin/access/wp-permissions', 'reset=1')]; + } + } -- 2.25.1