diff options
author | Thomas Steur <thomas.steur@gmail.com> | 2014-01-23 06:03:00 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@gmail.com> | 2014-01-23 06:03:00 +0400 |
commit | df54712a053b8ea326b2389a245de2a4b35fa4f7 (patch) | |
tree | c742dee2c363872c1e2411b3ae0e89dcb335df29 /core/Access.php | |
parent | 81e7f870124d2356c1784355e54fb4716901dfec (diff) |
refs #4564 introducing some more new methods for has superuser access. Old methods will still work but are marked as deprecated and they will be removed in a future release
Diffstat (limited to 'core/Access.php')
-rw-r--r-- | core/Access.php | 44 |
1 files changed, 32 insertions, 12 deletions
diff --git a/core/Access.php b/core/Access.php index 418cfd2b75..e404e69d94 100644 --- a/core/Access.php +++ b/core/Access.php @@ -84,11 +84,11 @@ class Access /** * Defines if the current user is the super user - * @see isSuperUser() + * @see hasSuperUserAccess() * * @var bool */ - protected $isSuperUser = false; + protected $hasSuperUserAccess = false; /** * List of available permissions in Piwik @@ -147,7 +147,7 @@ class Access // if the Auth wasn't set, we may be in the special case of setSuperUser(), otherwise we fail if (is_null($this->auth)) { - if ($this->isSuperUser()) { + if ($this->hasSuperUserAccess()) { return $this->reloadAccessSuperUser(); } return false; @@ -204,7 +204,7 @@ class Access */ protected function reloadAccessSuperUser() { - $this->isSuperUser = true; + $this->hasSuperUserAccess = true; try { $allSitesId = Plugins\SitesManager\API::getInstance()->getAllSitesId(); @@ -231,7 +231,7 @@ class Access if ($bool) { $this->reloadAccessSuperUser(); } else { - $this->isSuperUser = false; + $this->hasSuperUserAccess = false; $this->idsitesByAccess['superuser'] = array(); } } @@ -241,9 +241,19 @@ class Access * * @return bool */ + public function hasSuperUserAccess() + { + return $this->hasSuperUserAccess; + } + + /** + * @see Access::hasSuperUserAccess() + * @deprecated deprecated since version 2.0.4 + * @todo To be removed from April 1st 2014. + */ public function isSuperUser() { - return $this->isSuperUser; + return $this->hasSuperUserAccess(); } /** @@ -325,21 +335,31 @@ class Access * * @throws \Piwik\NoAccessException */ - public function checkUserIsSuperUser() + public function checkUserHasSuperUserAccess() { - if (!$this->isSuperUser()) { + if (!$this->hasSuperUserAccess()) { throw new NoAccessException(Piwik::translate('General_ExceptionPrivilege', array("'superuser'"))); } } /** + * @see Access::checkUserHasSuperUserAccess() + * @deprecated deprecated since version 2.0.4 + * @todo To be removed from April 1st 2014. + */ + public function checksUserIsSuperUser() + { + self::checkUserHasSuperUserAccess(); + } + + /** * If the user doesn't have an ADMIN access for at least one website, throws an exception * * @throws \Piwik\NoAccessException */ public function checkUserHasSomeAdminAccess() { - if ($this->isSuperUser()) { + if ($this->hasSuperUserAccess()) { return; } $idSitesAccessible = $this->getSitesIdWithAdminAccess(); @@ -355,7 +375,7 @@ class Access */ public function checkUserHasSomeViewAccess() { - if ($this->isSuperUser()) { + if ($this->hasSuperUserAccess()) { return; } $idSitesAccessible = $this->getSitesIdWithAtLeastViewAccess(); @@ -373,7 +393,7 @@ class Access */ public function checkUserHasAdminAccess($idSites) { - if ($this->isSuperUser()) { + if ($this->hasSuperUserAccess()) { return; } $idSites = $this->getIdSites($idSites); @@ -394,7 +414,7 @@ class Access */ public function checkUserHasViewAccess($idSites) { - if ($this->isSuperUser()) { + if ($this->hasSuperUserAccess()) { return; } $idSites = $this->getIdSites($idSites); |