createTables() public static method

Create all tables
public static createTables ( )
Ejemplo n.º 1
0
 /**
  * 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();
 }
Ejemplo n.º 2
0
 public static function loadAllPlugins($testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array())
 {
     if (empty($testEnvironment)) {
         $testEnvironment = new Piwik_TestingEnvironment();
     }
     DbHelper::createTables();
     $pluginsManager = \Piwik\Plugin\Manager::getInstance();
     $plugins = $testEnvironment->getCoreAndSupportedPlugins();
     // make sure the plugin that executed this method is included in the plugins to load
     $extraPlugins = array_merge($extraPluginsToLoad, array(\Piwik\Plugin::getPluginNameFromBacktrace(debug_backtrace()), \Piwik\Plugin::getPluginNameFromNamespace($testCaseClass), \Piwik\Plugin::getPluginNameFromNamespace(get_called_class())));
     foreach ($extraPlugins as $pluginName) {
         if (empty($pluginName)) {
             continue;
         }
         if (in_array($pluginName, $plugins)) {
             continue;
         }
         $plugins[] = $pluginName;
         if ($testEnvironment) {
             $testEnvironment->pluginsToLoad = array_merge($testEnvironment->pluginsToLoad ?: array(), array($pluginName));
         }
     }
     Log::debug("Plugins to load during tests: " . implode(', ', $plugins));
     $pluginsManager->loadPlugins($plugins);
 }
Ejemplo n.º 3
0
 /**
  * @param \Piwik\Tests\Framework\TestingEnvironmentVariables|null $testEnvironment Ignored.
  * @param bool|false $testCaseClass Ignored.
  * @param array $extraPluginsToLoad Ignoerd.
  */
 public static function loadAllPlugins(TestingEnvironmentVariables $testEnvironment = null, $testCaseClass = false, $extraPluginsToLoad = array())
 {
     DbHelper::createTables();
     self::getPluginManager()->loadActivatedPlugins();
 }
Ejemplo n.º 4
0
 public static function loadAllPlugins()
 {
     DbHelper::createTables();
     $pluginsManager = \Piwik\Plugin\Manager::getInstance();
     $plugins = $pluginsManager->getPluginsToLoadDuringTests();
     $pluginsManager->loadPlugins($plugins);
     // Install plugins
     $messages = $pluginsManager->installLoadedPlugins();
     if (!empty($messages)) {
         Log::info("Plugin loading messages: %s", implode(" --- ", $messages));
     }
     // Activate them
     foreach ($plugins as $name) {
         if (!$pluginsManager->isPluginActivated($name)) {
             $pluginsManager->activatePlugin($name);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * 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();
 }
Ejemplo n.º 6
0
 /**
  * inits the Piwik DB
  * @return void
  */
 public function installDatabase()
 {
     $this->initPiwikDatabase(TRUE);
     $tablesInstalled = \Piwik\DbHelper::getTablesInstalled();
     if (count($tablesInstalled) == 0) {
         \Piwik\DbHelper::createTables();
         \Piwik\DbHelper::createAnonymousUser();
         $updater = new \Piwik\Updater();
         //set Piwikversion
         $updater->recordComponentSuccessfullyUpdated('core', \Piwik\Version::VERSION);
     }
 }