コード例 #1
0
ファイル: Database.test.php プロジェクト: nnnnathann/piwik
 public function tearDown()
 {
     parent::tearDown();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Site::clearCache();
     Piwik::truncateAllTables();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
 }
コード例 #2
0
ファイル: DatabaseTestCase.php プロジェクト: nnnnathann/piwik
 /**
  * Resets all caches and drops the database
  */
 public function tearDown()
 {
     parent::tearDown();
     try {
         $plugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
         foreach ($plugins as $plugin) {
             $plugin->uninstall();
         }
         Piwik_PluginsManager::getInstance()->unloadPlugins();
     } catch (Exception $e) {
     }
     Piwik::dropDatabase();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Config::getInstance()->clear();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     Zend_Registry::_unsetInstance();
 }
コード例 #3
0
 public static function tearDownAfterClass()
 {
     try {
         $plugins = Piwik_PluginsManager::getInstance()->getLoadedPlugins();
         foreach ($plugins as $plugin) {
             $plugin->uninstall();
         }
         Piwik_PluginsManager::getInstance()->unloadPlugins();
     } catch (Exception $e) {
     }
     Piwik::dropDatabase();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_Config::getInstance()->clear();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     Zend_Registry::_unsetInstance();
     $_GET = $_REQUEST = array();
     Piwik_Translate::getInstance()->unloadEnglishTranslation();
     // re-enable tag cloud shuffling
     Piwik_Visualization_Cloud::$debugDisableShuffle = true;
 }
コード例 #4
0
ファイル: API.php プロジェクト: nnnnathann/piwik
 /**
  * Set an access level to a given user for a list of websites ID.
  * 
  * If access = 'noaccess' the current access (if any) will be deleted.
  * If access = 'view' or 'admin' the current access level is deleted and updated with the new value.
  *
  * @param string $userLogin The user login
  * @param string $access Access to grant. Must have one of the following value : noaccess, view, admin
  * @param int|array $idSites The array of idSites on which to apply the access level for the user.
  *       If the value is "all" then we apply the access level to all the websites ID for which the current authentificated user has an 'admin' access.
  * 
  * @throws Exception if the user doesn't exist
  * @throws Exception if the access parameter doesn't have a correct value
  * @throws Exception if any of the given website ID doesn't exist
  * 
  * @return bool true on success
  */
 public function setUserAccess($userLogin, $access, $idSites)
 {
     $this->checkAccessType($access);
     $this->checkUserExists($userLogin);
     $this->checkUserIsNotSuperUser($userLogin);
     if ($userLogin == 'anonymous' && $access == 'admin') {
         throw new Exception(Piwik_TranslateException("UsersManager_ExceptionAdminAnonymous"));
     }
     // in case idSites is null we grant access to all the websites on which the current connected user
     // has an 'admin' access
     if ($idSites === 'all') {
         $idSites = Piwik_SitesManager_API::getInstance()->getSitesIdWithAdminAccess();
     } elseif (!is_array($idSites)) {
         $idSites = Piwik_Site::getIdSitesFromIdSitesString($idSites);
     }
     // it is possible to set user access on websites only for the websites admin
     // basically an admin can give the view or the admin access to any user for the websites he manages
     Piwik::checkUserHasAdminAccess($idSites);
     $this->deleteUserAccess($userLogin, $idSites);
     // delete UserAccess
     $db = Zend_Registry::get('db');
     // if the access is noaccess then we don't save it as this is the default value
     // when no access are specified
     if ($access != 'noaccess') {
         foreach ($idSites as $idsite) {
             $db->insert(Piwik_Common::prefixTable("access"), array("idsite" => $idsite, "login" => $userLogin, "access" => $access));
         }
     }
     // we reload the access list which doesn't yet take in consideration this new user access
     Zend_Registry::get('access')->reloadAccess();
     Piwik_Common::deleteTrackerCache();
 }
コード例 #5
0
ファイル: Piwik.php プロジェクト: neolf/PIWIK4MOBILE
 /**
  * Called on Core install, update, plugin enable/disable
  * Will clear all cache that could be affected by the change in configuration being made
  */
 public static function deleteAllCacheOnUpdate()
 {
     Piwik_AssetManager::removeMergedAssets();
     Piwik_View::clearCompiledTemplates();
     Piwik_Common::deleteTrackerCache();
 }
コード例 #6
0
ファイル: API.php プロジェクト: BackupTheBerlios/oos-svn
	/**
	 * Sets list of URL query parameters to be excluded on all websites.
	 * Will also apply to websites created in the future.
	 * 
	 * @param string Comma separated list of URL query parameters to exclude from URLs
	 * @return bool
	 */
	public function setGlobalExcludedQueryParameters($excludedQueryParameters)
	{
		Piwik::checkUserIsSuperUser();
		$excludedQueryParameters = $this->checkAndReturnExcludedQueryParameters($excludedQueryParameters);
		Piwik_SetOption(self::OPTION_EXCLUDED_QUERY_PARAMETERS_GLOBAL, $excludedQueryParameters);
		Piwik_Common::deleteTrackerCache();
		return true;
	}
コード例 #7
0
 public function tearDown()
 {
     parent::tearDown();
     Piwik_DataTable_Manager::getInstance()->deleteAll();
     Piwik_Option::getInstance()->clearCache();
     Piwik_Site::clearCache();
     Piwik_Common::deleteTrackerCache();
     Piwik_TablePartitioning::$tablesAlreadyInstalled = null;
     $tempTableName = Piwik_Common::prefixTable(Piwik_PrivacyManager_LogDataPurger::TEMP_TABLE_NAME);
     Piwik_Query("DROP TABLE IF EXISTS " . $tempTableName);
 }
コード例 #8
0
ファイル: piwik.php プロジェクト: nomoto-ubicast/piwik
/**
 *  Proxy to normal piwik.php, but in testing mode
 *  
 *  - Use the tests database to record Tracking data
 *  - Allows to overwrite the Visitor IP, and Server datetime 
 *  
 * @see Main.test.php
 * 
 */
// Wrapping the request inside ob_start() calls to ensure that the Test
// calling us waits for the full request to process before unblocking
ob_start();
define('PIWIK_INCLUDE_PATH', '../../..');
define('PIWIK_USER_PATH', PIWIK_INCLUDE_PATH);
require_once PIWIK_INCLUDE_PATH . '/libs/upgradephp/upgrade.php';
require_once PIWIK_INCLUDE_PATH . '/core/Loader.php';
// Config files forced to use the test database
// Note that this also provides security for Piwik installs containing tests files:
// this proxy will not record any data in the production database.
Piwik::createConfigObject();
Piwik_Config::getInstance()->setTestEnvironment();
Piwik_Config::getInstance()->PluginsInstalled['PluginsInstalled'] = array();
Piwik_UserCountry_LocationProvider_GeoIp::$geoIPDatabaseDir = 'tests/lib/geoip-files';
Piwik_Tracker::setTestEnvironment();
Piwik_DataTable_Manager::getInstance()->deleteAll();
Piwik_Option::getInstance()->clearCache();
Piwik_Site::clearCache();
Piwik_Common::deleteTrackerCache();
include PIWIK_INCLUDE_PATH . '/piwik.php';
ob_end_flush();