/** * Installation Step 5: Table Creation */ function tablesCreation() { $this->checkPreviousStepIsValid(__FUNCTION__); $view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__); $this->skipThisStep(__FUNCTION__); $this->createDbFromSessionInformation(); if (Common::getRequestVar('deleteTables', 0, 'int') == 1) { DbHelper::dropTables(); $view->existingTablesDeleted = true; // when the user decides to drop the tables then we dont skip the next steps anymore // workaround ZF-1743 $tmp = $this->session->skipThisStep; $tmp['firstWebsiteSetup'] = false; $tmp['trackingCode'] = false; $this->session->skipThisStep = $tmp; } $tablesInstalled = DbHelper::getTablesInstalled(); $view->tablesInstalled = ''; if (count($tablesInstalled) > 0) { // we have existing tables $view->tablesInstalled = implode(', ', $tablesInstalled); $view->someTablesInstalled = true; // remove monthly archive tables $archiveTables = ArchiveTableCreator::getTablesArchivesInstalled(); $baseTablesInstalled = count($tablesInstalled) - count($archiveTables); $minimumCountPiwikTables = 17; Access::getInstance(); Piwik::setUserIsSuperUser(); if ($baseTablesInstalled >= $minimumCountPiwikTables && count(APISitesManager::getInstance()->getAllSitesId()) > 0 && count(APIUsersManager::getInstance()->getUsers()) > 0) { $view->showReuseExistingTables = true; // when the user reuses the same tables we skip the website creation step // workaround ZF-1743 $tmp = $this->session->skipThisStep; $tmp['firstWebsiteSetup'] = true; $tmp['trackingCode'] = true; $this->session->skipThisStep = $tmp; } } else { DbHelper::createTables(); DbHelper::createAnonymousUser(); Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION); $view->tablesCreated = true; $view->showNextStep = true; } $this->session->currentStepDone = __FUNCTION__; return $view->render(); }