Ejemplo n.º 1
0
 static function update()
 {
     // force regeneration of cache files following #648
     Piwik::setUserIsSuperUser();
     $allSiteIds = Piwik_SitesManager_API::getAllSitesId();
     Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
 }
Ejemplo n.º 2
0
<?php

// force regeneration of cache files following #648
Piwik::setUserIsSuperUser();
$allSiteIds = Piwik_SitesManager_API::getAllSitesId();
Piwik_Common::regenerateCacheWebsiteAttributes($allSiteIds);
Ejemplo n.º 3
0
	/**
	 * Reload super user access
	 *
	 * @return bool
	 */	
	protected function reloadAccessSuperUser()
	{
		$this->isSuperUser = true;
		$this->idsitesByAccess['superuser'] = Piwik_SitesManager_API::getAllSitesId();
		return true;
	}
Ejemplo n.º 4
0
	function tablesCreation()
	{
		$this->checkPreviousStepIsValid( __FUNCTION__ );

		$view = new Piwik_Installation_View(
						$this->pathView . 'tablesCreation.tpl',
						$this->getInstallationSteps(),
						__FUNCTION__
					);
		$this->skipThisStep( __FUNCTION__ );
		$this->createDbFromSessionInformation();

		if(Piwik_Common::getRequestVar('deleteTables', 0, 'int') == 1)
		{
			Piwik::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['displayJavascriptCode'] = false;
			$this->session->skipThisStep = $tmp;
		}

		$tablesInstalled = Piwik::getTablesInstalled();
		$tablesToInstall = Piwik::getTablesNames();
		$view->tablesInstalled = '';
		if(count($tablesInstalled) > 0)
		{
			$view->tablesInstalled = implode(', ', $tablesInstalled);
			$view->someTablesInstalled = true;

			$minimumCountPiwikTables = 12;
			$baseTablesInstalled = preg_grep('/archive_numeric|archive_blob/', $tablesInstalled, PREG_GREP_INVERT);

			Piwik::createAccessObject();
			Piwik::setUserIsSuperUser();

			if(count($baseTablesInstalled) >= $minimumCountPiwikTables &&
				count(Piwik_SitesManager_API::getAllSitesId()) > 0 &&
				count(Piwik_UsersManager_API::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['displayJavascriptCode'] = true;
				$this->session->skipThisStep = $tmp;
			}
		}
		else
		{
			Piwik::createTables();
			Piwik::createAnonymousUser();

			$updater = new Piwik_Updater();
			$updater->recordComponentSuccessfullyUpdated('core', Piwik_Version::VERSION);
			$view->tablesCreated = true;
			$view->showNextStep = true;
		}

		$this->session->currentStepDone = __FUNCTION__;
		echo $view->render();
	}
Ejemplo n.º 5
0
 /**
  * Delete a website from the database, given its Id.
  * 
  * Requires Super User access. 
  *
  * @param int $idSite
  */
 public static function deleteSite($idSite)
 {
     Piwik::checkUserIsSuperUser();
     $idSites = Piwik_SitesManager_API::getAllSitesId();
     if (!in_array($idSite, $idSites)) {
         throw new Exception("website id = {$idSite} not found");
     }
     $nbSites = count($idSites);
     if ($nbSites == 1) {
         throw new Exception(Piwik_TranslateException("SitesManager_ExceptionDeleteSite"));
     }
     $db = Zend_Registry::get('db');
     $db->query("DELETE FROM " . Piwik::prefixTable("site") . " \n\t\t\t\t\tWHERE idsite = ?", $idSite);
     $db->query("DELETE FROM " . Piwik::prefixTable("site_url") . " \n\t\t\t\t\tWHERE idsite = ?", $idSite);
     $db->query("DELETE FROM " . Piwik::prefixTable("access") . " \n\t\t\t\t\tWHERE idsite = ?", $idSite);
     Piwik_Common::deleteCacheWebsiteAttributes($idSite);
 }
Ejemplo n.º 6
0
 public static function getSitesIdWithAtLeastViewAccess()
 {
     if (self::$superUser) {
         return Piwik_SitesManager_API::getAllSitesId();
     }
     return array_merge(self::$idSitesView, self::$idSitesAdmin);
 }
Ejemplo n.º 7
0
 /**
  * several Id -> normal array
  */
 function test_getAllSitesId_severalId()
 {
     $name = "tetq";
     $idsites = array(Piwik_SitesManager_API::addSite($name, array("http://piwik.net", "http://piwik.com/test/")), Piwik_SitesManager_API::addSite($name, array("http://piwik.net", "http://piwik.com/test/")), Piwik_SitesManager_API::addSite($name, array("http://piwik.net", "http://piwik.com/test/")), Piwik_SitesManager_API::addSite($name, array("http://piwik.net", "http://piwik.com/test/")), Piwik_SitesManager_API::addSite($name, array("http://piwik.net", "http://piwik.com/test/")));
     $ids = Piwik_SitesManager_API::getAllSitesId();
     $this->assertEqual($idsites, $ids);
 }
Ejemplo n.º 8
0
 /**
  * We bypass the normal auth method and give the current user Super User rights.
  * This should be very carefully used.
  * 
  * @return void
  */
 public function setSuperUser()
 {
     $this->isSuperUser = true;
     $this->idsitesByAccess['superuser'] = Piwik_SitesManager_API::getAllSitesId();
 }