Exemple #1
0
 public function onSiteDeleted($idSite)
 {
     // we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
     Cache::deleteCacheWebsiteAttributes($idSite);
     $archiveInvalidator = new ArchiveInvalidator();
     $archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
 }
Exemple #2
0
 public function onSiteDeleted($idSite)
 {
     // we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
     Cache::deleteCacheWebsiteAttributes($idSite);
     $archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
     $archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
     MeasurableSettingsTable::removeAllSettingsForSite($idSite);
 }
Exemple #3
0
 public function onSiteDeleted($idSite)
 {
     // we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
     Cache::deleteCacheWebsiteAttributes($idSite);
     $archiveInvalidator = StaticContainer::get('Piwik\\Archive\\ArchiveInvalidator');
     $archiveInvalidator->forgetRememberedArchivedReportsToInvalidateForSite($idSite);
     $measurableStorage = new Storage(Db::get(), $idSite);
     $measurableStorage->deleteAllValues();
 }
 public function setUp()
 {
     parent::setUp();
     if (!Fixture::siteCreated(1)) {
         Fixture::createWebsite('2012-01-01 00:00:00');
     }
     if (!Fixture::siteCreated(2)) {
         Fixture::createWebsite('2012-01-01 00:00:00');
     }
     Cache::clearCacheGeneral();
     Cache::deleteCacheWebsiteAttributes($idSite = 1);
     Cache::deleteCacheWebsiteAttributes($idSite = 2);
     $this->processor = new Processor();
 }
 private function configureSomeDimensions()
 {
     $configuration = new Configuration();
     $configuration->configureNewDimension($this->idSite, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, $active = true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($this->idSite, 'MyName2', CustomDimensions::SCOPE_VISIT, 2, $active = true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($this->idSite2, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, $active = true, $extractions = array(), $caseSensitive = true);
     $extraction1 = new Extraction('urlparam', 'test');
     $extraction2 = new Extraction('urlparam', 'param');
     $extraction3 = new Extraction('url', '/sub_(.{2})/page');
     $configuration->configureNewDimension($this->idSite, 'MyName3', CustomDimensions::SCOPE_ACTION, 1, $active = true, $extractions = array($extraction3->toArray()), $caseSensitive = true);
     $configuration->configureNewDimension($this->idSite, 'MyName4', CustomDimensions::SCOPE_ACTION, 2, $active = false, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($this->idSite, 'MyName5', CustomDimensions::SCOPE_ACTION, 3, $active = true, $extractions = array($extraction1->toArray(), $extraction2->toArray()), $caseSensitive = true);
     $configuration->configureNewDimension($this->idSite, 'MyName6', CustomDimensions::SCOPE_VISIT, 4, $active = true, $extractions = array(), $caseSensitive = true);
     Cache::deleteCacheWebsiteAttributes(1);
     Cache::deleteCacheWebsiteAttributes(2);
     Cache::clearCacheGeneral();
 }
Exemple #6
0
 /**
  * Delete a website from the database, given its Id.
  *
  * Requires Super User access.
  *
  * @param int $idSite
  * @throws Exception
  */
 public function deleteSite($idSite)
 {
     Piwik::checkUserHasSuperUserAccess();
     $idSites = API::getInstance()->getSitesId();
     if (!in_array($idSite, $idSites)) {
         throw new Exception("website id = {$idSite} not found");
     }
     $nbSites = count($idSites);
     if ($nbSites == 1) {
         throw new Exception(Piwik::translate("SitesManager_ExceptionDeleteSite"));
     }
     $db = Db::get();
     $db->query("DELETE FROM " . Common::prefixTable("site") . "\n\t\t\t\t\tWHERE idsite = ?", $idSite);
     $db->query("DELETE FROM " . Common::prefixTable("site_url") . "\n\t\t\t\t\tWHERE idsite = ?", $idSite);
     $db->query("DELETE FROM " . Common::prefixTable("access") . "\n\t\t\t\t\tWHERE idsite = ?", $idSite);
     // we do not delete logs here on purpose (you can run these queries on the log_ tables to delete all data)
     Cache::deleteCacheWebsiteAttributes($idSite);
     /**
      * Triggered after a site has been deleted.
      *
      * Plugins can use this event to remove site specific values or settings, such as removing all
      * goals that belong to a specific website. If you store any data related to a website you
      * should clean up that information here.
      *
      * @param int $idSite The ID of the site being deleted.
      */
     Piwik::postEvent('SitesManager.deleteSite.end', array($idSite));
 }
Exemple #7
0
 /**
  * Creates a website, then sets its creation date to a day earlier than specified dateTime
  * Useful to create a website now, but force data to be archived back in the past.
  *
  * @param string $dateTime eg '2010-01-01 12:34:56'
  * @param int $ecommerce
  * @param string $siteName
  *
  * @param bool|string $siteUrl
  * @param int $siteSearch
  * @param null|string $searchKeywordParameters
  * @param null|string $searchCategoryParameters
  * @param null|string $timezone
  * @param null|string $type eg 'website' or 'mobileapp'
  * @return int    idSite of website created
  */
 public static function createWebsite($dateTime, $ecommerce = 0, $siteName = false, $siteUrl = false, $siteSearch = 1, $searchKeywordParameters = null, $searchCategoryParameters = null, $timezone = null, $type = null)
 {
     if ($siteName === false) {
         $siteName = self::DEFAULT_SITE_NAME;
     }
     $idSite = APISitesManager::getInstance()->addSite($siteName, $siteUrl === false ? "http://piwik.net/" : $siteUrl, $ecommerce, $siteSearch, $searchKeywordParameters, $searchCategoryParameters, $ips = null, $excludedQueryParameters = null, $timezone, $currency = null, $group = null, $startDate = null, $excludedUserAgents = null, $keepURLFragments = null, $type);
     // Manually set the website creation date to a day earlier than the earliest day we record stats for
     Db::get()->update(Common::prefixTable("site"), array('ts_created' => Date::factory($dateTime)->subDay(1)->getDatetime()), "idsite = {$idSite}");
     // Clear the memory Website cache
     Site::clearCache();
     Cache::deleteCacheWebsiteAttributes($idSite);
     return $idSite;
 }
 private function configureSomeDimensions()
 {
     $configuration = new Configuration();
     $configuration->configureNewDimension($idSite = 1, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 1, 'MyName2', CustomDimensions::SCOPE_VISIT, 2, false, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 2, 'MyName1', CustomDimensions::SCOPE_VISIT, 1, true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 1, 'MyName3', CustomDimensions::SCOPE_ACTION, 1, true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 1, 'MyName4', CustomDimensions::SCOPE_ACTION, 2, $active = false, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 1, 'MyName5', CustomDimensions::SCOPE_ACTION, 3, $active = true, $extractions = array(), $caseSensitive = true);
     $configuration->configureNewDimension($idSite = 1, 'MyName6', CustomDimensions::SCOPE_VISIT, 4, $active = true, $extractions = array(), $caseSensitive = true);
     Cache::deleteCacheWebsiteAttributes(1);
     Cache::deleteCacheWebsiteAttributes(2);
 }
 /**
  * Updates an existing Custom Dimension. This method updates all values, you need to pass existing values of the
  * dimension if you do not want to reset any value. Requires at least Admin access for the specified website.
  *
  * @param int $idDimension  The id of a Custom Dimension.
  * @param int $idSite       The idSite the dimension belongs to
  * @param string $name      The name of the dimension
  * @param int $active       '0' if dimension should be inactive, '1' if dimension should be active
  * @param array $extractions    Either an empty array or if extractions shall be used one or multiple extractions
  *                              the format array(array('dimension' => 'url', 'pattern' => 'index_(.+).html'), array('dimension' => 'urlparam', 'pattern' => '...'))
  *                              Supported dimensions are  eg 'url', 'urlparam' and 'action_name'. To get an up to date list of
  *                              supported dimensions request the API method `CustomDimensions.getAvailableExtractionDimensions`.
  *                              Note: Extractions can be only set for dimensions in scope 'action'.
  * @param int|bool|null $caseSensitive  '0' if extractions should be applied case insensitive, '1' if extractions should be applied case sensitive, null to keep case sensitive unchanged
  * @return int Returns the ID of the configured dimension. Note that the same idDimension will be used for different websites.
  * @throws \Exception
  */
 public function configureExistingCustomDimension($idDimension, $idSite, $name, $active, $extractions = array(), $caseSensitive = null)
 {
     Piwik::checkUserHasAdminAccess($idSite);
     $dimension = new Dimension($idDimension, $idSite);
     $dimension->checkExists();
     if (!isset($caseSensitive)) {
         $caseSensitive = $dimension->getCaseSensitive();
     }
     $this->checkCustomDimensionConfig($name, $active, $extractions, $caseSensitive);
     $this->checkExtractionsAreSupportedForScope($dimension->getScope(), $extractions);
     $this->getConfiguration()->configureExistingDimension($idDimension, $idSite, $name, $active, $extractions, $caseSensitive);
     Cache::deleteCacheWebsiteAttributes($idSite);
     Cache::clearCacheGeneral();
 }
 private function updateSiteCreatedTime($idSite, Date $timestamp)
 {
     $this->sitesManagerModel->updateSiteCreatedTime(array($idSite), $timestamp->getDatetime());
     Cache::deleteCacheWebsiteAttributes($idSite);
 }