diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-07-20 10:39:01 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-07-20 10:39:01 +0400 |
commit | e492c76009ea81c9513ae359f5fd41e84703116f (patch) | |
tree | 67b0f9006616d5f093447af6f5646c66b5e56ff8 /core | |
parent | e79675330823b957fe9f8ffa462ad5317c14dbc9 (diff) |
Adding Logic for namespaces in Loader.php + Fixing build
Converting Access & Auth to namespace
Diffstat (limited to 'core')
-rw-r--r-- | core/API/DataTableManipulator/LabelFilter.php | 2 | ||||
-rw-r--r-- | core/API/Proxy.php | 2 | ||||
-rw-r--r-- | core/API/Request.php | 3 | ||||
-rw-r--r-- | core/API/ResponseBuilder.php | 4 | ||||
-rw-r--r-- | core/Access.php | 45 | ||||
-rw-r--r-- | core/AssetManager.php | 2 | ||||
-rw-r--r-- | core/Auth.php | 14 | ||||
-rw-r--r-- | core/Controller.php | 11 | ||||
-rw-r--r-- | core/DataFiles/SearchEngines.php | 2 | ||||
-rw-r--r-- | core/FrontController.php | 8 | ||||
-rw-r--r-- | core/JqplotDataGenerator.php | 6 | ||||
-rw-r--r-- | core/JqplotDataGenerator/Evolution.php | 2 | ||||
-rw-r--r-- | core/Loader.php | 11 | ||||
-rw-r--r-- | core/Piwik.php | 46 | ||||
-rw-r--r-- | core/Tracker.php | 3 | ||||
-rw-r--r-- | core/Tracker/Visit.php | 2 | ||||
-rw-r--r-- | core/Updates/1.8.3-b1.php | 8 | ||||
-rw-r--r-- | core/ViewDataTable.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable/GenerateGraphHTML.php | 2 | ||||
-rw-r--r-- | core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php | 3 | ||||
-rw-r--r-- | core/ViewDataTable/HtmlTable.php | 4 |
21 files changed, 100 insertions, 82 deletions
diff --git a/core/API/DataTableManipulator/LabelFilter.php b/core/API/DataTableManipulator/LabelFilter.php index 20ba5b273f..550dbde69b 100644 --- a/core/API/DataTableManipulator/LabelFilter.php +++ b/core/API/DataTableManipulator/LabelFilter.php @@ -107,7 +107,7 @@ class Piwik_API_DataTableManipulator_LabelFilter extends Piwik_API_DataTableMani * Use variations of the label to make it easier to specify the desired label * * Note: The HTML Encoded version must be tried first, since in Piwik_API_ResponseBuilder the $label is unsanitized - * via Piwik_Common::unsanitizeLabelParameter. + * via Common::unsanitizeLabelParameter. * * @param string $label * @return array diff --git a/core/API/Proxy.php b/core/API/Proxy.php index 723820e1ee..08810ab396 100644 --- a/core/API/Proxy.php +++ b/core/API/Proxy.php @@ -154,7 +154,7 @@ class Piwik_API_Proxy * @param array $parametersRequest The parameters pairs (name=>value) * * @return mixed|null - * @throws Exception|Piwik_Access_NoAccessException + * @throws Exception|Access_NoAccessException */ public function call($className, $methodName, $parametersRequest) { diff --git a/core/API/Request.php b/core/API/Request.php index 503481f185..49ffc2a5df 100644 --- a/core/API/Request.php +++ b/core/API/Request.php @@ -10,6 +10,7 @@ */ use Piwik\Piwik; use Piwik\Common; +use Piwik\Access; /** * An API request is the object used to make a call to the API and get the result. @@ -167,7 +168,7 @@ class Piwik_API_Request $token_auth = Common::getRequestVar('token_auth', '', 'string', $request); if ($token_auth) { Piwik_PostEvent('API.Request.authenticate', array($token_auth)); - Piwik_Access::getInstance()->reloadAccess(); + Access::getInstance()->reloadAccess(); Piwik::raiseMemoryLimitIfNecessary(); } } diff --git a/core/API/ResponseBuilder.php b/core/API/ResponseBuilder.php index 3935f267f7..8040721329 100644 --- a/core/API/ResponseBuilder.php +++ b/core/API/ResponseBuilder.php @@ -493,8 +493,8 @@ class Piwik_API_ResponseBuilder static public function unsanitizeLabelParameter($label) { - // this is needed because Piwik_API_Proxy uses Piwik_Common::getRequestVar which in turn - // uses Piwik_Common::sanitizeInputValue. This causes the > that separates recursive labels + // this is needed because Piwik_API_Proxy uses Common::getRequestVar which in turn + // uses Common::sanitizeInputValue. This causes the > that separates recursive labels // to become > and we need to undo that here. $label = Common::unsanitizeInputValues($label); return $label; diff --git a/core/Access.php b/core/Access.php index 715b96aae0..931e958567 100644 --- a/core/Access.php +++ b/core/Access.php @@ -8,12 +8,15 @@ * @category Piwik * @package Piwik */ +namespace Piwik; + use Piwik\Config; use Piwik\Common; +use Piwik\Auth; /** * Class to handle User Access: - * - loads user access from the Piwik_Auth_Result object + * - loads user access from the AuthResult object * - provides easy to use API to check the permissions for the current (check* methods) * * In Piwik there are mainly 4 access levels @@ -34,9 +37,9 @@ use Piwik\Common; * and he only can change the main configuration settings. * * @package Piwik - * @subpackage Piwik_Access + * @subpackage Access */ -class Piwik_Access +class Access { private static $instance = null; @@ -142,7 +145,7 @@ class Piwik_Access * @param null|Piwik_Auth $auth Auth adapter * @return bool true on success, false if reloading access failed (when auth object wasn't specified and user is not enforced to be Super User) */ - public function reloadAccess(Piwik_Auth $auth = null) + public function reloadAccess(Auth $auth = null) { if (!is_null($auth)) { $this->auth = $auth; @@ -166,7 +169,7 @@ class Piwik_Access $this->token_auth = $result->getTokenAuth(); // case the superUser is logged in - if ($result->getCode() == Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE) { + if ($result->getCode() == AuthResult::SUCCESS_SUPERUSER_AUTH_CODE) { return $this->reloadAccessSuperUser(); } // in case multiple calls to API using different tokens, we ensure we reset it as not SU @@ -210,7 +213,7 @@ class Piwik_Access $this->isSuperUser = true; try { - $allSitesId = Piwik_SitesManager_API::getInstance()->getAllSitesId(); + $allSitesId = \Piwik_SitesManager_API::getInstance()->getAllSitesId(); } catch(Exception $e) { $allSitesId = array(); } @@ -328,19 +331,19 @@ class Piwik_Access /** * Throws an exception if the user is not the SuperUser * - * @throws Piwik_Access_NoAccessException + * @throws Access_NoAccessException */ public function checkUserIsSuperUser() { if (!$this->isSuperUser()) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionPrivilege', array("'superuser'"))); + throw new NoAccessException(Piwik_TranslateException('General_ExceptionPrivilege', array("'superuser'"))); } } /** * If the user doesn't have an ADMIN access for at least one website, throws an exception * - * @throws Piwik_Access_NoAccessException + * @throws Access_NoAccessException */ public function checkUserHasSomeAdminAccess() { @@ -349,14 +352,14 @@ class Piwik_Access } $idSitesAccessible = $this->getSitesIdWithAdminAccess(); if (count($idSitesAccessible) == 0) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAtLeastOneWebsite', array('admin'))); + throw new NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAtLeastOneWebsite', array('admin'))); } } /** * If the user doesn't have any view permission, throw exception * - * @throws Piwik_Access_NoAccessException + * @throws Access_NoAccessException */ public function checkUserHasSomeViewAccess() { @@ -365,7 +368,7 @@ class Piwik_Access } $idSitesAccessible = $this->getSitesIdWithAtLeastViewAccess(); if (count($idSitesAccessible) == 0) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAtLeastOneWebsite', array('view'))); + throw new NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAtLeastOneWebsite', array('view'))); } } @@ -374,7 +377,7 @@ class Piwik_Access * If the user doesn't have ADMIN access for at least one website of the list, we throw an exception. * * @param int|array $idSites List of ID sites to check - * @throws Piwik_Access_NoAccessException If for any of the websites the user doesn't have an ADMIN access + * @throws Access_NoAccessException If for any of the websites the user doesn't have an ADMIN access */ public function checkUserHasAdminAccess($idSites) { @@ -385,7 +388,7 @@ class Piwik_Access $idSitesAccessible = $this->getSitesIdWithAdminAccess(); foreach ($idSites as $idsite) { if (!in_array($idsite, $idSitesAccessible)) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'admin'", $idsite))); + throw new NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'admin'", $idsite))); } } } @@ -395,7 +398,7 @@ class Piwik_Access * If the user doesn't have VIEW or ADMIN access for at least one website of the list, we throw an exception. * * @param int|array|string $idSites List of ID sites to check (integer, array of integers, string comma separated list of integers) - * @throws Piwik_Access_NoAccessException If for any of the websites the user doesn't have an VIEW or ADMIN access + * @throws Access_NoAccessException If for any of the websites the user doesn't have an VIEW or ADMIN access */ public function checkUserHasViewAccess($idSites) { @@ -406,7 +409,7 @@ class Piwik_Access $idSitesAccessible = $this->getSitesIdWithAtLeastViewAccess(); foreach ($idSites as $idsite) { if (!in_array($idsite, $idSitesAccessible)) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idsite))); + throw new NoAccessException(Piwik_TranslateException('General_ExceptionPrivilegeAccessWebsite', array("'view'", $idsite))); } } } @@ -414,7 +417,7 @@ class Piwik_Access /** * @param int|array|string $idSites * @return array - * @throws Piwik_Access_NoAccessException + * @throws Access_NoAccessException */ protected function getIdSites($idSites) { @@ -422,9 +425,9 @@ class Piwik_Access $idSites = $this->getSitesIdWithAtLeastViewAccess(); } - $idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites); + $idSites = \Piwik_Site::getIdSitesFromIdSitesString($idSites); if (empty($idSites)) { - throw new Piwik_Access_NoAccessException("The parameter 'idSite=' is missing from the request."); + throw new NoAccessException("The parameter 'idSite=' is missing from the request."); } return $idSites; } @@ -434,8 +437,8 @@ class Piwik_Access * Exception thrown when a user doesn't have sufficient access. * * @package Piwik - * @subpackage Piwik_Access + * @subpackage Access */ -class Piwik_Access_NoAccessException extends Exception +class NoAccessException extends \Exception { } diff --git a/core/AssetManager.php b/core/AssetManager.php index 5d03dee430..c425a92c32 100644 --- a/core/AssetManager.php +++ b/core/AssetManager.php @@ -381,7 +381,7 @@ class Piwik_AssetManager */ private static function isMergedAssetsDisabled() { - return Piwik_Config::getInstance()->Debug['disable_merged_assets']; + return Config::getInstance()->Debug['disable_merged_assets']; } /** diff --git a/core/Auth.php b/core/Auth.php index 252a31afbd..67edbbabaf 100644 --- a/core/Auth.php +++ b/core/Auth.php @@ -9,13 +9,15 @@ * @package Piwik */ +namespace Piwik; + /** * Interface for authentication modules * * @package Piwik * @subpackage Piwik_Auth */ -interface Piwik_Auth +interface Auth { /** * Authentication module's name, e.g., "Login" @@ -27,7 +29,7 @@ interface Piwik_Auth /** * Authenticates user * - * @return Piwik_Auth_Result + * @return AuthResult */ public function authenticate(); } @@ -37,10 +39,10 @@ interface Piwik_Auth * * @package Piwik * @subpackage Piwik_Auth - * @see Zend_Auth_Result, libs/Zend/Auth/Result.php + * @see Zend_AuthResult, libs/Zend/Auth/Result.php * @link http://framework.zend.com/manual/en/zend.auth.html */ -class Piwik_Auth_Result extends Zend_Auth_Result +class AuthResult extends \Zend_Auth_Result { /** * token_auth parameter used to authenticate in the API @@ -52,7 +54,7 @@ class Piwik_Auth_Result extends Zend_Auth_Result const SUCCESS_SUPERUSER_AUTH_CODE = 42; /** - * Constructor for Piwik_Auth_Result + * Constructor for AuthResult * * @param int $code * @param string $login identity @@ -61,7 +63,7 @@ class Piwik_Auth_Result extends Zend_Auth_Result */ public function __construct($code, $login, $token_auth, array $messages = array()) { - // Piwik_Auth_Result::SUCCESS_SUPERUSER_AUTH_CODE, Piwik_Auth_Result::SUCCESS, Piwik_Auth_Result::FAILURE + // AuthResult::SUCCESS_SUPERUSER_AUTH_CODE, AuthResult::SUCCESS, AuthResult::FAILURE $this->_code = (int)$code; $this->_identity = $login; $this->_messages = $messages; diff --git a/core/Controller.php b/core/Controller.php index 84fe4734a9..55857f7ce8 100644 --- a/core/Controller.php +++ b/core/Controller.php @@ -11,6 +11,7 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Access; /** * Parent class of all plugins Controllers (located in /plugins/PluginName/Controller.php @@ -248,7 +249,7 @@ abstract class Piwik_Controller * - period: day, week, month, year * * @param array $paramsToSet array( 'date' => 'last50', 'viewDataTable' =>'sparkline' ) - * @throws Piwik_Access_NoAccessException + * @throws Access_NoAccessException * @return array */ protected function getGraphParamsModified($paramsToSet = array()) @@ -274,7 +275,7 @@ abstract class Piwik_Controller } if (is_null($this->site)) { - throw new Piwik_Access_NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth."); + throw new Access_NoAccessException("Website not initialized, check that you are logged in and/or using the correct token_auth."); } $paramDate = self::getDateRangeRelativeToEndDate($period, $range, $endDate, $this->site); @@ -451,7 +452,7 @@ abstract class Piwik_Controller protected function setBasicVariablesView($view) { $view->debugTrackVisitsInsidePiwikUI = Config::getInstance()->Debug['track_visits_inside_piwik_ui']; - $view->isSuperUser = Piwik_Access::getInstance()->isSuperUser(); + $view->isSuperUser = Access::getInstance()->isSuperUser(); $view->hasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess(); $view->isCustomLogo = Config::getInstance()->branding['use_custom_logo']; $view->logoHeader = Piwik_API_API::getInstance()->getHeaderLogoUrl(); @@ -745,13 +746,13 @@ abstract class Piwik_Controller * within the site. The token should never appear in the browser's * address bar. * - * @throws Piwik_Access_NoAccessException if token doesn't match + * @throws Access_NoAccessException if token doesn't match * @return void */ protected function checkTokenInUrl() { if (Common::getRequestVar('token_auth', false) != Piwik::getCurrentUserTokenAuth()) { - throw new Piwik_Access_NoAccessException(Piwik_TranslateException('General_ExceptionInvalidToken')); + throw new Access_NoAccessException(Piwik_TranslateException('General_ExceptionInvalidToken')); } } diff --git a/core/DataFiles/SearchEngines.php b/core/DataFiles/SearchEngines.php index 3dacdb1bd3..7df02fb1c0 100644 --- a/core/DataFiles/SearchEngines.php +++ b/core/DataFiles/SearchEngines.php @@ -555,7 +555,7 @@ if (!isset($GLOBALS['Piwik_SearchEngines'])) { 'search.handycafe.com' => array('InfoSpace', 'q'), /* - * Other InfoSpace powered metasearches are handled in Piwik_Common::extractSearchEngineInformationFromUrl() + * Other InfoSpace powered metasearches are handled in Common::extractSearchEngineInformationFromUrl() * * This includes sites such as: * - search.nation.com diff --git a/core/FrontController.php b/core/FrontController.php index a90f4b8554..a66a093cb8 100644 --- a/core/FrontController.php +++ b/core/FrontController.php @@ -11,6 +11,7 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Access; /** * @see core/PluginsManager.php @@ -20,7 +21,6 @@ use Piwik\Common; require_once PIWIK_INCLUDE_PATH . '/core/PluginsManager.php'; require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; require_once PIWIK_INCLUDE_PATH . '/core/Option.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Piwik.php'; /** * Front controller. @@ -127,7 +127,7 @@ class Piwik_FrontController try { return call_user_func_array(array($params[0], $params[1]), $params[2]); - } catch (Piwik_Access_NoAccessException $e) { + } catch (Access_NoAccessException $e) { Piwik_PostEvent('FrontController.NoAccessException', array($e), $pending = true); } catch (Exception $e) { $debugTrace = $e->getTraceAsString(); @@ -269,7 +269,7 @@ class Piwik_FrontController Piwik::createLogObject(); // Init the Access object, so that eg. core/Updates/* can enforce Super User and use some APIs - Piwik_Access::getInstance(); + Access::getInstance(); Piwik_PostEvent('FrontController.dispatchCoreAndPluginUpdatesScreen'); @@ -289,7 +289,7 @@ class Piwik_FrontController <code>Plugins[] = Login</code><br /> under the <code>[Plugins]</code> section in your config/config.ini.php"); } - Piwik_Access::getInstance()->reloadAccess($authAdapter); + Access::getInstance()->reloadAccess($authAdapter); // Force the auth to use the token_auth if specified, so that embed dashboard // and all other non widgetized controller methods works fine diff --git a/core/JqplotDataGenerator.php b/core/JqplotDataGenerator.php index c6e9845e8b..d99d986cc9 100644 --- a/core/JqplotDataGenerator.php +++ b/core/JqplotDataGenerator.php @@ -9,6 +9,8 @@ * @package Piwik */ +use Piwik\Common; + /** * Generates JSON data used to configure and populate JQPlot graphs. * @@ -159,7 +161,7 @@ class Piwik_JqplotDataGenerator private function deriveUnitsFromRequestedColumnNames() { - $idSite = Piwik_Common::getRequestVar('idSite', null, 'int'); + $idSite = Common::getRequestVar('idSite', null, 'int'); $units = array(); foreach ($this->properties['columns_to_display'] as $columnName) { @@ -176,7 +178,7 @@ class Piwik_JqplotDataGenerator protected function addSeriesPickerToView() { if (count($this->properties['selectable_columns']) - && Piwik_Common::getRequestVar('showSeriesPicker', 1) == 1 + && Common::getRequestVar('showSeriesPicker', 1) == 1 ) { $selectableColumns = array(); foreach ($this->properties['selectable_columns'] as $column) { diff --git a/core/JqplotDataGenerator/Evolution.php b/core/JqplotDataGenerator/Evolution.php index 559ec589b5..50fd2a61a2 100644 --- a/core/JqplotDataGenerator/Evolution.php +++ b/core/JqplotDataGenerator/Evolution.php @@ -45,7 +45,7 @@ class Piwik_JqplotDataGenerator_Evolution extends Piwik_JqplotDataGenerator $uniqueIdsDataTable[] = $idDataTable; } - $idSite = Piwik_Common::getRequestVar('idSite', null, 'int'); + $idSite = Common::getRequestVar('idSite', null, 'int'); $requestedColumnNames = $this->properties['columns_to_display']; $units = $this->getUnitsForColumnsToDisplay(); diff --git a/core/Loader.php b/core/Loader.php index d46a57b01e..c0d2d14622 100644 --- a/core/Loader.php +++ b/core/Loader.php @@ -26,14 +26,18 @@ class Piwik_Loader * @return string Class file name * @throws Exception if class name is invalid */ - protected static function getClassFileName($class) + protected static function getClassFileName($class) { - if (!preg_match("/^[A-Za-z0-9_]+$/D", $class)) { + if (!preg_match('/^[A-Za-z0-9_\\\\]+$/D', $class)) { throw new Exception("Invalid class name \"$class\"."); } + // prefixed class $class = str_replace('_', '/', $class); + // namespace \Piwik\Common + $class = str_replace('\\', '/', $class); + if ($class == 'Piwik') { return $class; } @@ -54,7 +58,8 @@ class Piwik_Loader public static function loadClass($class) { $classPath = self::getClassFileName($class); - if ($class == 'Piwik' || !strncmp($class, 'Piwik_', 6)) { + if ($class == 'Piwik' + || !strncmp($class, 'Piwik', 5) /* catches Piwik_ and Piwik\ */ ) { // Piwik classes are in core/ or plugins/ do { // auto-discover class location diff --git a/core/Piwik.php b/core/Piwik.php index f788d50f89..0e07c888ca 100644 --- a/core/Piwik.php +++ b/core/Piwik.php @@ -12,8 +12,8 @@ namespace Piwik; use Exception; use Piwik\Config; -use Piwik_Access; -use Piwik_Access_NoAccessException; +use Piwik\Access; +use Access_NoAccessException; use Piwik_AssetManager; use Piwik\Common; use Piwik_Db_Adapter; @@ -40,8 +40,6 @@ use Zend_Registry; * @see core/Translate.php */ require_once PIWIK_INCLUDE_PATH . '/core/Translate.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Common.php'; -require_once PIWIK_INCLUDE_PATH . '/core/Config.php'; /** * Main piwik helper class. @@ -387,11 +385,15 @@ class Piwik */ public static function globr($sDir, $sPattern, $nFlags = null) { - if (($aFiles = _glob("$sDir/$sPattern", $nFlags)) == false) { + if (($aFiles = \_glob("$sDir/$sPattern", $nFlags)) == false) { $aFiles = array(); } - if (($aDirs = _glob("$sDir/*", GLOB_ONLYDIR)) != false) { + if (($aDirs = \_glob("$sDir/*", GLOB_ONLYDIR)) != false) { foreach ($aDirs as $sSubDir) { + // avoid infinite recursion of symlink'ed directories + if(strpos($sSubDir, "tests/PHPUnit/proxy/tests/PHPUnit/proxy") !== false) { + continue; + } $aSubFiles = self::globr($sSubDir, $sPattern, $nFlags); $aFiles = array_merge($aFiles, $aSubFiles); } @@ -1591,7 +1593,7 @@ class Piwik */ static public function getSuperUserLogin() { - return Piwik_Access::getInstance()->getSuperUserLogin(); + return Access::getInstance()->getSuperUserLogin(); } /** @@ -1612,7 +1614,7 @@ class Piwik */ static public function getCurrentUserLogin() { - return Piwik_Access::getInstance()->getLogin(); + return Access::getInstance()->getLogin(); } /** @@ -1622,7 +1624,7 @@ class Piwik */ static public function getCurrentUserTokenAuth() { - return Piwik_Access::getInstance()->getTokenAuth(); + return Access::getInstance()->getTokenAuth(); } /** @@ -1646,7 +1648,7 @@ class Piwik * Check that current user is either the specified user or the superuser * * @param string $theUser - * @throws Piwik_Access_NoAccessException if the user is neither the super user nor the user $theUser + * @throws Access_NoAccessException if the user is neither the super user nor the user $theUser */ static public function checkUserIsSuperUserOrTheUser($theUser) { @@ -1655,8 +1657,8 @@ class Piwik // or to the super user Piwik::checkUserIsSuperUser(); } - } catch (Piwik_Access_NoAccessException $e) { - throw new Piwik_Access_NoAccessException(Piwik_Translate('General_ExceptionCheckUserIsSuperUserOrTheUser', array($theUser))); + } catch (Access_NoAccessException $e) { + throw new Access_NoAccessException(Piwik_Translate('General_ExceptionCheckUserIsSuperUserOrTheUser', array($theUser))); } } @@ -1688,12 +1690,12 @@ class Piwik /** * Checks if user is not the anonymous user. * - * @throws Piwik_Access_NoAccessException if user is anonymous. + * @throws Access_NoAccessException if user is anonymous. */ static public function checkUserIsNotAnonymous() { if (self::isUserIsAnonymous()) { - throw new Piwik_Access_NoAccessException(Piwik_Translate('General_YouMustBeLoggedIn')); + throw new \Piwik\NoAccessException(Piwik_Translate('General_YouMustBeLoggedIn')); } } @@ -1705,7 +1707,7 @@ class Piwik */ static public function setUserIsSuperUser($bool = true) { - Piwik_Access::getInstance()->setSuperUser($bool); + Access::getInstance()->setSuperUser($bool); } /** @@ -1715,7 +1717,7 @@ class Piwik */ static public function checkUserIsSuperUser() { - Piwik_Access::getInstance()->checkUserIsSuperUser(); + Access::getInstance()->checkUserIsSuperUser(); } /** @@ -1742,7 +1744,7 @@ class Piwik */ static public function checkUserHasAdminAccess($idSites) { - Piwik_Access::getInstance()->checkUserHasAdminAccess($idSites); + Access::getInstance()->checkUserHasAdminAccess($idSites); } /** @@ -1767,7 +1769,7 @@ class Piwik */ static public function checkUserHasSomeAdminAccess() { - Piwik_Access::getInstance()->checkUserHasSomeAdminAccess(); + Access::getInstance()->checkUserHasSomeAdminAccess(); } /** @@ -1794,7 +1796,7 @@ class Piwik */ static public function checkUserHasViewAccess($idSites) { - Piwik_Access::getInstance()->checkUserHasViewAccess($idSites); + Access::getInstance()->checkUserHasViewAccess($idSites); } /** @@ -1819,7 +1821,7 @@ class Piwik */ static public function checkUserHasSomeViewAccess() { - Piwik_Access::getInstance()->checkUserHasSomeViewAccess(); + Access::getInstance()->checkUserHasSomeViewAccess(); } /* @@ -2311,7 +2313,7 @@ class Piwik * Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs, * as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs. * - * @param string $tableName PREFIXED table name! you must call Piwik_Common::prefixTable() before passing the table name + * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name * @param array $fields array of unquoted field names * @param array $values array of data to be inserted * @param bool $throwException Whether to throw an exception that was caught while trying @@ -2372,7 +2374,7 @@ class Piwik * * NOTE: you should use tableInsertBatch() which will fallback to this function if LOAD DATA INFILE not available * - * @param string $tableName PREFIXED table name! you must call Piwik_Common::prefixTable() before passing the table name + * @param string $tableName PREFIXED table name! you must call Common::prefixTable() before passing the table name * @param array $fields array of unquoted field names * @param array $values array of data to be inserted * @param bool $ignoreWhenDuplicate Ignore new rows that contain unique key values that duplicate old rows diff --git a/core/Tracker.php b/core/Tracker.php index d3d9a765b6..8e0fac450b 100644 --- a/core/Tracker.php +++ b/core/Tracker.php @@ -11,6 +11,7 @@ use Piwik\Config; use Piwik\Piwik; use Piwik\Common; +use Piwik\Access; /** * Class used by the logging script piwik.php called by the javascript tag. @@ -342,7 +343,7 @@ class Piwik_Tracker require_once PIWIK_INCLUDE_PATH . '/core/Loader.php'; require_once PIWIK_INCLUDE_PATH . '/core/Option.php'; - $access = Piwik_Access::getInstance(); + $access = Access::getInstance(); $config = Config::getInstance(); try { diff --git a/core/Tracker/Visit.php b/core/Tracker/Visit.php index d2d87d121e..da14bb6de0 100644 --- a/core/Tracker/Visit.php +++ b/core/Tracker/Visit.php @@ -1024,7 +1024,7 @@ class Piwik_Tracker_Visit implements Piwik_Tracker_Visit_Interface /** * Returns either * - "-1" for a known visitor - * - at least 16 char identifier in hex @see Piwik_Common::generateUniqId() + * - at least 16 char identifier in hex @see Common::generateUniqId() * @return int|string */ protected function getVisitorUniqueId() diff --git a/core/Updates/1.8.3-b1.php b/core/Updates/1.8.3-b1.php index 3f3d579e58..77b9ffdf14 100644 --- a/core/Updates/1.8.3-b1.php +++ b/core/Updates/1.8.3-b1.php @@ -49,11 +49,11 @@ class Piwik_Updates_1_8_3_b1 extends Piwik_Updates try { - // Piwik_Common::prefixTable('pdf') has been heavily refactored to be more generic + // Common::prefixTable('pdf') has been heavily refactored to be more generic // The following actions are taken in this update script : - // - create the new generic report table Piwik_Common::prefixTable('report') - // - migrate previous reports, if any, from Piwik_Common::prefixTable('pdf') to Piwik_Common::prefixTable('report') - // - delete Piwik_Common::prefixTable('pdf') + // - create the new generic report table Common::prefixTable('report') + // - migrate previous reports, if any, from Common::prefixTable('pdf') to Common::prefixTable('report') + // - delete Common::prefixTable('pdf') $reports = Piwik_FetchAll('SELECT * FROM `' . Common::prefixTable('pdf') . '`'); foreach ($reports AS $report) { diff --git a/core/ViewDataTable.php b/core/ViewDataTable.php index f4d0cbd3d8..be9770ce6d 100644 --- a/core/ViewDataTable.php +++ b/core/ViewDataTable.php @@ -858,7 +858,7 @@ abstract class Piwik_ViewDataTable // we escape the values that will be displayed in the javascript footer of each datatable // to make sure there is no malicious code injected (the value are already htmlspecialchar'ed as they - // are loaded with Piwik_Common::getRequestVar() + // are loaded with Common::getRequestVar() foreach ($javascriptVariablesToSet as &$value) { if (is_array($value)) { $value = array_map('addslashes', $value); diff --git a/core/ViewDataTable/GenerateGraphHTML.php b/core/ViewDataTable/GenerateGraphHTML.php index 71a7787cb6..2543d2a64c 100644 --- a/core/ViewDataTable/GenerateGraphHTML.php +++ b/core/ViewDataTable/GenerateGraphHTML.php @@ -134,7 +134,7 @@ abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable // selectable columns if ($this->graphType != 'evolution') { $selectableColumns = array('nb_visits', 'nb_actions'); - if (Piwik_Common::getRequestVar('period', false) == 'day') { + if (Common::getRequestVar('period', false) == 'day') { $selectableColumns[] = 'nb_uniq_visitors'; } $this->viewProperties['selectable_columns'] = $selectableColumns; diff --git a/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php b/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php index 0c316f84ad..125c1c92ed 100644 --- a/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php +++ b/core/ViewDataTable/GenerateGraphHTML/ChartEvolution.php @@ -8,6 +8,7 @@ * @category Piwik * @package Piwik */ + use Piwik\Common; /** @@ -176,7 +177,7 @@ class Piwik_ViewDataTable_GenerateGraphHTML_ChartEvolution extends Piwik_ViewDat // period will be overridden when 'range' is requested in the UI // TODO: this code probably shouldn't be here... // but the graph will display for each day of the range. // Default 'range' behavior is to return the 'sum' for the range - if (Piwik_Common::getRequestVar('period', false) == 'range') { + if (Common::getRequestVar('period', false) == 'range') { $this->viewProperties['request_parameters_to_modify']['period'] = 'day'; } diff --git a/core/ViewDataTable/HtmlTable.php b/core/ViewDataTable/HtmlTable.php index e7d409b853..dc23e95d2b 100644 --- a/core/ViewDataTable/HtmlTable.php +++ b/core/ViewDataTable/HtmlTable.php @@ -60,7 +60,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable /** * @see Piwik_ViewDataTable::main() - * @throws Exception|Piwik_Access_NoAccessException + * @throws Exception|Access_NoAccessException * @return null */ public function main() @@ -73,7 +73,7 @@ class Piwik_ViewDataTable_HtmlTable extends Piwik_ViewDataTable $this->isDataAvailable = true; try { $this->loadDataTableFromAPI(); - } catch (Piwik_Access_NoAccessException $e) { + } catch (Access_NoAccessException $e) { throw $e; } catch (Exception $e) { Piwik::log("Failed to get data from API: " . $e->getMessage()); |