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
path: root/core
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2014-10-22 07:54:14 +0400
committermattab <matthieu.aubry@gmail.com>2014-10-22 07:54:14 +0400
commit9425c0f6d0134a65b0e22d9971923d03f83dcfa8 (patch)
treef1adb401876c81de41eb99e3afe6f3e2156d3ecc /core
parenta10375e68a971accfc3921e22f64986c5fe52b58 (diff)
Refactor isUserIsAnonymous
Diffstat (limited to 'core')
-rw-r--r--core/Piwik.php10
-rw-r--r--core/Plugin/Controller.php5
2 files changed, 9 insertions, 6 deletions
diff --git a/core/Piwik.php b/core/Piwik.php
index f8d6df175e..625a7cf9f8 100644
--- a/core/Piwik.php
+++ b/core/Piwik.php
@@ -189,7 +189,12 @@ class Piwik
*/
public static function getCurrentUserLogin()
{
- return Access::getInstance()->getLogin();
+ $login = Access::getInstance()->getLogin();
+
+ if(empty($login)) {
+ return 'anonymous';
+ }
+ return $login;
}
/**
@@ -296,7 +301,8 @@ class Piwik
*/
public static function isUserIsAnonymous()
{
- return Piwik::getCurrentUserLogin() == 'anonymous';
+ $currentUserLogin = Piwik::getCurrentUserLogin();
+ return $currentUserLogin == 'anonymous';
}
/**
diff --git a/core/Plugin/Controller.php b/core/Plugin/Controller.php
index 0342e34724..d4b6539639 100644
--- a/core/Plugin/Controller.php
+++ b/core/Plugin/Controller.php
@@ -845,10 +845,7 @@ abstract class Controller
<br />Check the table '" . Common::prefixTable('site') . "' in your database, it should contain your Piwik websites.", false, true);
}
- $currentLogin = Piwik::getCurrentUserLogin();
- if (!empty($currentLogin)
- && $currentLogin != 'anonymous'
- ) {
+ if (!Piwik::isUserIsAnonymous()) {
$emails = implode(',', Piwik::getAllSuperUserAccessEmailAddresses());
$errorMessage = sprintf(Piwik::translate('CoreHome_NoPrivilegesAskPiwikAdmin'), $currentLogin, "<br/><a href='mailto:" . $emails . "?subject=Access to Piwik for user $currentLogin'>", "</a>");
$errorMessage .= "<br /><br />&nbsp;&nbsp;&nbsp;<b><a href='index.php?module=" . Registry::get('auth')->getName() . "&amp;action=logout'>&rsaquo; " . Piwik::translate('General_Logout') . "</a></b><br />";