From 13594d55f08a6ea40fa380b702657546bfa0bcfa Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 13 Apr 2020 13:59:24 -0400 Subject: [PATCH] REF - Cleanup [userFrameworkURLVar] to use CRM_Utils_System::currentPath() --- CRM/Contact/Controller/Search.php | 3 +-- CRM/Core/Page/QUnit.php | 3 +-- CRM/Core/Payment.php | 2 +- CRM/Report/Utils/Report.php | 24 +++++++----------------- CRM/Utils/Pager.php | 3 +-- CRM/Utils/System.php | 17 +++++++---------- Civi/Core/Themes.php | 2 +- 7 files changed, 19 insertions(+), 35 deletions(-) diff --git a/CRM/Contact/Controller/Search.php b/CRM/Contact/Controller/Search.php index e07dfa4d4c..6d2d1c4f83 100644 --- a/CRM/Contact/Controller/Search.php +++ b/CRM/Contact/Controller/Search.php @@ -60,8 +60,7 @@ class CRM_Contact_Controller_Search extends CRM_Core_Controller { // see if we can figure out the url and redirect to the right search form // note that this happens really early on, so we can't use any of the form or controller // variables - $config = CRM_Core_Config::singleton(); - $qString = $_GET[$config->userFrameworkURLVar]; + $qString = CRM_Utils_System::currentPath(); $args = "reset=1"; $path = 'civicrm/contact/search/advanced'; if (strpos($qString, 'basic') !== FALSE) { diff --git a/CRM/Core/Page/QUnit.php b/CRM/Core/Page/QUnit.php index ae1c90c344..261ba636c9 100644 --- a/CRM/Core/Page/QUnit.php +++ b/CRM/Core/Page/QUnit.php @@ -56,8 +56,7 @@ class CRM_Core_Page_QUnit extends CRM_Core_Page { * @return array */ public function getRequestExtAndSuite() { - $config = CRM_Core_Config::singleton(); - $arg = explode('/', $_GET[$config->userFrameworkURLVar]); + $arg = explode('/', CRM_Utils_System::currentPath()); if ($arg[1] == 'dev' && CRM_Utils_Array::value(2, $arg) == 'qunit' diff --git a/CRM/Core/Payment.php b/CRM/Core/Payment.php index 2361c1a36d..288359d4e5 100644 --- a/CRM/Core/Payment.php +++ b/CRM/Core/Payment.php @@ -1502,7 +1502,7 @@ abstract class CRM_Core_Payment { */ public static function handlePaymentMethod($method, $params = []) { if (!isset($params['processor_id']) && !isset($params['processor_name'])) { - $q = explode('/', CRM_Utils_Array::value(CRM_Core_Config::singleton()->userFrameworkURLVar, $_GET, '')); + $q = explode('/', CRM_Utils_System::currentPath()); $lastParam = array_pop($q); if (is_numeric($lastParam)) { $params['processor_id'] = $_GET['processor_id'] = $lastParam; diff --git a/CRM/Report/Utils/Report.php b/CRM/Report/Utils/Report.php index 1cc6cc7d18..a6f37e04f1 100644 --- a/CRM/Report/Utils/Report.php +++ b/CRM/Report/Utils/Report.php @@ -31,8 +31,7 @@ class CRM_Report_Utils_Report { ); } else { - $config = CRM_Core_Config::singleton(); - $args = explode('/', $_GET[$config->userFrameworkURLVar]); + $args = explode('/', CRM_Utils_System::currentPath()); // remove 'civicrm/report' from args array_shift($args); @@ -298,15 +297,10 @@ WHERE inst.report_id = %1"; */ public static function getInstanceID() { - $config = CRM_Core_Config::singleton(); - $arg = explode('/', $_GET[$config->userFrameworkURLVar]); + $arg = explode('/', CRM_Utils_System::currentPath()); - if ($arg[1] == 'report' && - CRM_Utils_Array::value(2, $arg) == 'instance' - ) { - if (CRM_Utils_Rule::positiveInteger($arg[3])) { - return $arg[3]; - } + if (isset($arg[3]) && $arg[1] == 'report' && $arg[2] == 'instance' && CRM_Utils_Rule::positiveInteger($arg[3])) { + return $arg[3]; } } @@ -314,15 +308,11 @@ WHERE inst.report_id = %1"; * @return string */ public static function getInstancePath() { - $config = CRM_Core_Config::singleton(); - $arg = explode('/', $_GET[$config->userFrameworkURLVar]); + $arg = explode('/', CRM_Utils_System::currentPath()); - if ($arg[1] == 'report' && - CRM_Utils_Array::value(2, $arg) == 'instance' - ) { + if (isset($arg[3]) && $arg[1] == 'report' && $arg[2] == 'instance') { unset($arg[0], $arg[1], $arg[2]); - $path = trim(CRM_Utils_Type::escape(implode('/', $arg), 'String'), '/'); - return $path; + return trim(CRM_Utils_Type::escape(implode('/', $arg), 'String'), '/'); } } diff --git a/CRM/Utils/Pager.php b/CRM/Utils/Pager.php index a5bc97b850..0774e49009 100644 --- a/CRM/Utils/Pager.php +++ b/CRM/Utils/Pager.php @@ -239,8 +239,7 @@ class CRM_Utils_Pager extends Pager_Sliding { * @return string */ public function getCurrentLocation() { - $config = CRM_Core_Config::singleton(); - $path = $_GET[$config->userFrameworkURLVar] ?? NULL; + $path = CRM_Utils_System::currentPath(); return CRM_Utils_System::url($path, CRM_Utils_System::getLinksUrl(self::PAGE_ID, FALSE, TRUE), FALSE, NULL, FALSE) . $this->getCurrentPageID(); } diff --git a/CRM/Utils/System.php b/CRM/Utils/System.php index 08b874f1d3..e9e296de29 100644 --- a/CRM/Utils/System.php +++ b/CRM/Utils/System.php @@ -81,19 +81,16 @@ class CRM_Utils_System { * The URL fragment. */ public static function makeURL($urlVar, $includeReset = FALSE, $includeForce = TRUE, $path = NULL, $absolute = FALSE) { - if (empty($path)) { - $config = CRM_Core_Config::singleton(); - $path = $_GET[$config->userFrameworkURLVar] ?? NULL; - if (empty($path)) { - return ''; - } + $path = $path ?: CRM_Utils_System::currentPath(); + if (!$path) { + return ''; } return self::url( - $path, - CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce), - $absolute - ); + $path, + CRM_Utils_System::getLinksUrl($urlVar, $includeReset, $includeForce), + $absolute + ); } /** diff --git a/Civi/Core/Themes.php b/Civi/Core/Themes.php index c3550bc63d..8e7dc5988d 100644 --- a/Civi/Core/Themes.php +++ b/Civi/Core/Themes.php @@ -78,7 +78,7 @@ class Themes { \CRM_Utils_Hook::activeTheme($themeKey, [ 'themes' => $this, - 'page' => \CRM_Utils_Array::value(\CRM_Core_Config::singleton()->userFrameworkURLVar, $_GET), + 'page' => \CRM_Utils_System::currentPath(), ]); $themes = $this->getAll(); -- 2.25.1