Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/Access.php11
-rw-r--r--core/Piwik.php3
-rw-r--r--plugins/PDFReports/API.php2
-rw-r--r--plugins/PDFReports/PDFReports.php2
-rw-r--r--plugins/UsersManager/API.php2
-rw-r--r--tests/PHPUnit/FakeAccess.php6
-rwxr-xr-xtests/PHPUnit/IntegrationTestCase.php3
-rw-r--r--tests/PHPUnit/Plugins/UsersManagerTest.php1
8 files changed, 22 insertions, 8 deletions
diff --git a/core/Access.php b/core/Access.php
index 722595aecb..30cb7a656c 100644
--- a/core/Access.php
+++ b/core/Access.php
@@ -231,6 +231,17 @@ class Piwik_Access
{
return $this->token_auth;
}
+
+ /**
+ * Returns the super user's login.
+ *
+ * @return string
+ */
+ public function getSuperUserLogin()
+ {
+ $superuser = Piwik_Config::getInstance()->superuser;
+ return $superuser['login'];
+ }
/**
* Returns an array of ID sites for which the user has at least a VIEW access.
diff --git a/core/Piwik.php b/core/Piwik.php
index 171a8fa7e2..961f561a4e 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -1569,8 +1569,7 @@ class Piwik
*/
static public function getSuperUserLogin()
{
- $superuser = Piwik_Config::getInstance()->superuser;
- return $superuser['login'];
+ return Zend_Registry::get('access')->getSuperUserLogin();
}
/**
diff --git a/plugins/PDFReports/API.php b/plugins/PDFReports/API.php
index 373b19fe0f..b57c05d5dc 100644
--- a/plugins/PDFReports/API.php
+++ b/plugins/PDFReports/API.php
@@ -351,7 +351,7 @@ class Piwik_PDFReports_API
// is enforced in Scheduled tasks, and ensure Multisites.getAll only return the websites that this user can access
$userLogin = $report['login'];
if (!empty($userLogin)
- && $userLogin != Piwik_Config::getInstance()->superuser['login']
+ && $userLogin != Piwik::getSuperUserLogin()
) {
$_GET['_restrictSitesToLogin'] = $userLogin;
}
diff --git a/plugins/PDFReports/PDFReports.php b/plugins/PDFReports/PDFReports.php
index 5f295b8366..6a0ead9469 100644
--- a/plugins/PDFReports/PDFReports.php
+++ b/plugins/PDFReports/PDFReports.php
@@ -371,7 +371,7 @@ class Piwik_PDFReports extends Piwik_Plugin
if ($reportParameters[self::EMAIL_ME_PARAMETER] == 1) {
if (Piwik::getCurrentUserLogin() == $report['login']) {
$emails[] = Piwik::getCurrentUserEmail();
- } elseif ($report['login'] == Piwik_Config::getInstance()->superuser['login']) {
+ } elseif ($report['login'] == Piwik::getSuperUserLogin()) {
$emails[] = Piwik::getSuperUserEmail();
} else {
try {
diff --git a/plugins/UsersManager/API.php b/plugins/UsersManager/API.php
index 60d13ea6c1..7937c90ec4 100644
--- a/plugins/UsersManager/API.php
+++ b/plugins/UsersManager/API.php
@@ -601,7 +601,7 @@ class Piwik_UsersManager_API
private function checkUserIsNotSuperUser($userLogin)
{
- if ($userLogin == Piwik_Config::getInstance()->superuser['login']) {
+ if ($userLogin == Piwik::getSuperUserLogin()) {
throw new Exception(Piwik_TranslateException("UsersManager_ExceptionSuperUser"));
}
}
diff --git a/tests/PHPUnit/FakeAccess.php b/tests/PHPUnit/FakeAccess.php
index 2f2dba4043..5b14a25c41 100644
--- a/tests/PHPUnit/FakeAccess.php
+++ b/tests/PHPUnit/FakeAccess.php
@@ -14,6 +14,7 @@ class FakeAccess
public static $idSitesAdmin = array();
public static $idSitesView = array();
public static $identity = 'superUserLogin';
+ public static $superUserLogin = 'superUserLogin';
public function __construct()
{
@@ -155,4 +156,9 @@ class FakeAccess
}
return $result;
}
+
+ public function getSuperUserLogin()
+ {
+ return self::$superUserLogin;
+ }
}
diff --git a/tests/PHPUnit/IntegrationTestCase.php b/tests/PHPUnit/IntegrationTestCase.php
index 8647ea4c56..b3f25de242 100755
--- a/tests/PHPUnit/IntegrationTestCase.php
+++ b/tests/PHPUnit/IntegrationTestCase.php
@@ -146,9 +146,6 @@ abstract class IntegrationTestCase extends PHPUnit_Framework_TestCase
// Usually these modules either return random changing data, or are already tested in specific unit tests.
self::setApiNotToCall(self::$defaultApiNotToCall);
self::setApiToCall(array());
-
- // set config superuser login to test login
- Piwik_Config::getInstance()->superuser['login'] = 'superUserLogin';
}
public static function tearDownAfterClass()
diff --git a/tests/PHPUnit/Plugins/UsersManagerTest.php b/tests/PHPUnit/Plugins/UsersManagerTest.php
index 48d3f17390..ee36e68751 100644
--- a/tests/PHPUnit/Plugins/UsersManagerTest.php
+++ b/tests/PHPUnit/Plugins/UsersManagerTest.php
@@ -21,6 +21,7 @@ class UsersManagerTest extends DatabaseTestCase
//finally we set the user as a super user by default
FakeAccess::$superUser = true;
+ FakeAccess::$superUserLogin = 'superusertest';
Zend_Registry::set('access', $pseudoMockAccess);
// we make sure the tests don't depend on the config file content