From a860f6f38555ab55298cddba46e74879b8aa4e60 Mon Sep 17 00:00:00 2001 From: Pascal Robinet Date: Fri, 30 Apr 2021 20:31:25 +0200 Subject: [PATCH 1/2] Allow any user with Write permission to generate shortcodes (previously it would require SuperAdmin access) --- API.php | 8 ++++++++ Widgets/GetShortcodegenerator.php | 2 +- changelog.md | 2 ++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/API.php b/API.php index 83aac28..45e6089 100644 --- a/API.php +++ b/API.php @@ -431,6 +431,14 @@ protected function checkUserHasWriteAccess($idSite = null) { if ($idSite != false) { Piwik::checkUserHasWriteAccess($idSite); + return; + } + $settings = $this->getPluginSettings(); + $externalShortcodesIdSite = $settings->getSetting(ShortcodeTracker::SHORTENER_EXTERNAL_SHORTCODES_IDSITE)->getValue(); + if ($externalShortcodesIdSite !== null) + { + Piwik::checkUserHasWriteAccess($externalShortcodesIdSite); + return; } Piwik::checkUserHasSuperUserAccess(); } diff --git a/Widgets/GetShortcodegenerator.php b/Widgets/GetShortcodegenerator.php index 19859f2..1455f9d 100644 --- a/Widgets/GetShortcodegenerator.php +++ b/Widgets/GetShortcodegenerator.php @@ -49,7 +49,7 @@ public static function configure(WidgetConfig $config) * $config->setParameters(array('myparam' => 'myvalue')); */ - if (Piwik::isUserHasSomeAdminAccess() === false) { + if (Piwik::isUserHasSomeWriteAccess() === false) { $config->disable(); } /** diff --git a/changelog.md b/changelog.md index a975d65..9568afe 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,6 @@ ## Changelog +* 1.2.1 + * Allow any user with Write permission to generate shortcodes (previously it would require SuperAdmin access) * 1.2.0 * add proper LICENSE file to codebase From fcb595757b9cbf20945f0c17009bc03614df8a96 Mon Sep 17 00:00:00 2001 From: Pascal Robinet Date: Fri, 30 Apr 2021 20:47:38 +0200 Subject: [PATCH 2/2] Bump plugin version to 1.2.1 --- plugin.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.json b/plugin.json index de0d96e..1a819e4 100644 --- a/plugin.json +++ b/plugin.json @@ -1,6 +1,6 @@ { "name": "ShortcodeTracker", - "version": "1.2.0", + "version": "1.2.1", "description": "Plugin allowing user to create shortcodes and track their usage within Piwik. Also integrates with UI to deliver user-friendly interaction.", "theme": false, "keywords": [