diff options
author | mattab <matthieu.aubry@gmail.com> | 2014-03-29 09:10:52 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2014-03-29 09:10:52 +0400 |
commit | f30cf2077e026fb5536b110ace8be95eae209b0e (patch) | |
tree | 86adaa365da32a103cd1122aff38cf1622745bef /core | |
parent | 103f5daad5500e91afd7c78513f448604de2012a (diff) |
Fixes #4924: in Tracker mode, do not check for permission when getting/setting plugin settings.
Diffstat (limited to 'core')
-rw-r--r-- | core/Config.php | 2 | ||||
-rw-r--r-- | core/Db.php | 2 | ||||
-rw-r--r-- | core/FrontController.php | 2 | ||||
-rw-r--r-- | core/Plugin/Settings.php | 6 | ||||
-rw-r--r-- | core/Profiler.php | 2 | ||||
-rw-r--r-- | core/SettingsServer.php | 12 | ||||
-rw-r--r-- | core/Tracker.php | 2 |
7 files changed, 23 insertions, 5 deletions
diff --git a/core/Config.php b/core/Config.php index 3dc081d80e..726a13d56f 100644 --- a/core/Config.php +++ b/core/Config.php @@ -296,7 +296,7 @@ class Config extends Singleton public function init() { $this->initialized = true; - $reportError = !empty($GLOBALS['PIWIK_TRACKER_MODE']); + $reportError = SettingsServer::isTrackerApiRequest(); // read defaults from global.ini.php if (!is_readable($this->pathGlobal) && $reportError) { diff --git a/core/Db.php b/core/Db.php index 4b4ec86cd6..f099d01409 100644 --- a/core/Db.php +++ b/core/Db.php @@ -42,7 +42,7 @@ class Db */ public static function get() { - if (!empty($GLOBALS['PIWIK_TRACKER_MODE'])) { + if (SettingsServer::isTrackerApiRequest()) { return Tracker::getDatabase(); } diff --git a/core/FrontController.php b/core/FrontController.php index 53227f886a..0efcfa1a99 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -168,7 +168,7 @@ class FrontController extends Singleton { try { if (class_exists('Piwik\\Profiler') - && empty($GLOBALS['PIWIK_TRACKER_MODE'])) { + && !SettingsServer::isTrackerApiRequest()) { // in tracker mode Piwik\Tracker\Db\Pdo\Mysql does currently not implement profiling Profiler::displayDbProfileReport(); Profiler::printQueryCount(); diff --git a/core/Plugin/Settings.php b/core/Plugin/Settings.php index 1200d9eb6a..20a5a30599 100644 --- a/core/Plugin/Settings.php +++ b/core/Plugin/Settings.php @@ -12,6 +12,7 @@ use Piwik\Option; use Piwik\Piwik; use Piwik\Settings\Setting; use Piwik\Settings\StorageInterface; +use Piwik\SettingsServer; /** * Base class of all plugin settings providers. Plugins that define their own configuration settings @@ -325,6 +326,11 @@ abstract class Settings implements StorageInterface */ private function checkHasEnoughPermission(Setting $setting) { + // When the request is a Tracker request, allow plugins to read/write settings + if(SettingsServer::isTrackerApiRequest()) { + return; + } + if (!$setting->canBeDisplayedForCurrentUser()) { $errorMsg = Piwik::translate('CoreAdminHome_PluginSettingChangeNotAllowed', array($setting->getName(), $this->pluginName)); throw new \Exception($errorMsg); diff --git a/core/Profiler.php b/core/Profiler.php index 122e61f4b4..ae9c5e8b76 100644 --- a/core/Profiler.php +++ b/core/Profiler.php @@ -186,7 +186,7 @@ class Profiler */ public static function setupProfilerXHProf($mainRun = false) { - if(!empty($GLOBALS['PIWIK_TRACKER_MODE'])) { + if(SettingsServer::isTrackerApiRequest()) { // do not profile Tracker return; } diff --git a/core/SettingsServer.php b/core/SettingsServer.php index d1d5142ec7..7223d3e304 100644 --- a/core/SettingsServer.php +++ b/core/SettingsServer.php @@ -31,6 +31,18 @@ class SettingsServer && Piwik::hasUserSuperUserAccess(); } + + /** + * Returns true if the current request is a Tracker request. + * + * @return bool true if the current request is a Tracking API Request (ie. piwik.php) + */ + public static function isTrackerApiRequest() + { + return !empty($GLOBALS['PIWIK_TRACKER_MODE']); + } + + /** * Returns `true` if running on Microsoft IIS 7 (or above), `false` if otherwise. * diff --git a/core/Tracker.php b/core/Tracker.php index c67d2e91f1..05deb9a2aa 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -369,7 +369,7 @@ class Tracker */ static public function initCorePiwikInTrackerMode() { - if (!empty($GLOBALS['PIWIK_TRACKER_MODE']) + if (SettingsServer::isTrackerApiRequest() && self::$initTrackerMode === false ) { self::$initTrackerMode = true; |