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:
authordiosmosis <benaka@piwik.pro>2014-09-30 04:19:58 +0400
committerdiosmosis <benaka@piwik.pro>2014-09-30 16:37:37 +0400
commit8e82428416bd17832b5f059ae8b6933f301c4719 (patch)
treed2900459458e5107c24c86e5c6fcd5f03555fbe4 /plugins/Installation/Controller.php
parent0401d7e82714a770a4835b1ad4a90a42fbed0f15 (diff)
Deprecating Piwik::setUserHasSuperUserAccess() and switching to Access::doAsSuperUser().
Diffstat (limited to 'plugins/Installation/Controller.php')
-rw-r--r--plugins/Installation/Controller.php64
1 files changed, 30 insertions, 34 deletions
diff --git a/plugins/Installation/Controller.php b/plugins/Installation/Controller.php
index 4349b6aca9..7d66116082 100644
--- a/plugins/Installation/Controller.php
+++ b/plugins/Installation/Controller.php
@@ -196,14 +196,16 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
$view->tablesInstalled = implode(', ', $tablesInstalled);
$view->someTablesInstalled = true;
- Access::getInstance();
- Piwik::setUserHasSuperUserAccess();
- if ($this->hasEnoughTablesToReuseDb($tablesInstalled) &&
- count(APISitesManager::getInstance()->getAllSitesId()) > 0 &&
- count(APIUsersManager::getInstance()->getUsers()) > 0
- ) {
- $view->showReuseExistingTables = true;
- }
+ $self = $this;
+ Access::doAsSuperUser(function () use ($self, $tablesInstalled, $view) {
+ Access::getInstance();
+ if ($self->hasEnoughTablesToReuseDb($tablesInstalled) &&
+ count(APISitesManager::getInstance()->getAllSitesId()) > 0 &&
+ count(APIUsersManager::getInstance()->getUsers()) > 0
+ ) {
+ $view->showReuseExistingTables = true;
+ }
+ });
} else {
DbHelper::createTables();
@@ -258,8 +260,11 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
{
$this->checkPiwikIsNotInstalled();
- $this->initObjectsToCallAPI();
- if (count(APIUsersManager::getInstance()->getUsersHavingSuperUserAccess()) > 0) {
+ $superUserAlreadyExists = Access::doAsSuperUser(function () {
+ return count(APIUsersManager::getInstance()->getUsersHavingSuperUserAccess()) > 0;
+ });
+
+ if ($superUserAlreadyExists) {
$this->redirectToNextStep('setupSuperUser');
}
@@ -464,14 +469,6 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
}
/**
- * Instantiate access and log objects
- */
- private function initObjectsToCallAPI()
- {
- Piwik::setUserHasSuperUserAccess();
- }
-
- /**
* Write configuration file from session-store
*/
private function createConfigFile($dbInfos)
@@ -633,13 +630,12 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
private function createSuperUser($login, $password, $email)
{
- $this->initObjectsToCallAPI();
-
- $api = APIUsersManager::getInstance();
- $api->addUser($login, $password, $email);
-
- $this->initObjectsToCallAPI();
- $api->setSuperUserAccess($login, true);
+ $self = $this;
+ Access::doAsSuperUser(function () use ($self, $login, $password, $email) {
+ $api = APIUsersManager::getInstance();
+ $api->addUser($login, $password, $email);
+ $api->setSuperUserAccess($login, true);
+ });
}
private function hasEnoughTablesToReuseDb($tablesInstalled)
@@ -702,16 +698,16 @@ class Controller extends \Piwik\Plugin\ControllerAdmin
protected function updateComponents()
{
Access::getInstance();
- Piwik::setUserHasSuperUserAccess();
- $updater = new Updater();
- $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
+ return Access::doAsSuperUser(function () {
+ $updater = new Updater();
+ $componentsWithUpdateFile = CoreUpdater::getComponentUpdates($updater);
- if (empty($componentsWithUpdateFile)) {
- return false;
- }
- $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile);
- return $result;
+ if (empty($componentsWithUpdateFile)) {
+ return false;
+ }
+ $result = CoreUpdater::updateComponents($updater, $componentsWithUpdateFile);
+ return $result;
+ });
}
-
}