/**
* Installation Step 4: Table Creation
*/
function tablesCreation()
{
$this->checkPiwikIsNotInstalled();
$view = new View('@Installation/tablesCreation', $this->getInstallationSteps(), __FUNCTION__);
if ($this->getParam('deleteTables')) {
Manager::getInstance()->clearPluginsInstalledConfig();
Db::dropAllTables();
$view->existingTablesDeleted = true;
}
$tablesInstalled = DbHelper::getTablesInstalled();
$view->tablesInstalled = '';
if (count($tablesInstalled) > 0) {
// we have existing tables
$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;
}
} else {
DbHelper::createTables();
DbHelper::createAnonymousUser();
$this->updateComponents();
Updater::recordComponentSuccessfullyUpdated('core', Version::VERSION);
$view->tablesCreated = true;
$view->showNextStep = true;
}
return $view->render();
}