当前位置: 首页>>代码示例>>PHP>>正文


PHP Access::getInstance方法代码示例

本文整理汇总了PHP中Piwik\Access::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Access::getInstance方法的具体用法?PHP Access::getInstance怎么用?PHP Access::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Access的用法示例。


在下文中一共展示了Access::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $this->recreateContainerWithWebEnvironment();
     $this->initHostAndQueryString($input);
     if ($this->isTestModeEnabled()) {
         $indexFile = '/tests/PHPUnit/proxy/';
         $this->resetDatabase();
     } else {
         $indexFile = '/';
     }
     $indexFile .= 'index.php';
     if (!empty($_GET['pid'])) {
         $process = new Process($_GET['pid']);
         if ($process->hasFinished()) {
             return;
         }
         $process->startProcess();
     }
     if ($input->getOption('superuser')) {
         StaticContainer::addDefinitions(array('observers.global' => \DI\add(array(array('Environment.bootstrapped', function () {
             Access::getInstance()->setSuperUserAccess(true);
         })))));
     }
     require_once PIWIK_INCLUDE_PATH . $indexFile;
     if (!empty($process)) {
         $process->finishProcess();
     }
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:28,代码来源:RequestCommand.php

示例2: makeSureTestRunsInContextOfAnonymousUser

 private function makeSureTestRunsInContextOfAnonymousUser()
 {
     Piwik::postEvent('Request.initAuthenticationObject');
     $access = Access::getInstance();
     $this->hasSuperUserAccess = $access->hasSuperUserAccess();
     $access->setSuperUserAccess(false);
     $access->reloadAccess(StaticContainer::get('Piwik\\Auth'));
     Request::reloadAuthUsingTokenAuth(array('token_auth' => 'anonymous'));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:9,代码来源:APITest.php

示例3: setUp

 public function setUp()
 {
     parent::setUp();
     $access = Access::getInstance();
     $access->setSuperUserAccess(true);
     $this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
     \Piwik\Plugin\Manager::getInstance()->loadPlugins(array('MultiSites', 'VisitsSummary', 'Actions'));
     \Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:9,代码来源:MultiSitesTest.php

示例4: test_PiwikUserIsNotCreated_IfPiwikUserAlreadyExists

 public function test_PiwikUserIsNotCreated_IfPiwikUserAlreadyExists()
 {
     Access::getInstance()->setSuperUserAccess(true);
     UsersManagerAPI::getInstance()->addUser(self::TEST_LOGIN, self::TEST_PASS, 'billionairephilanthropistplayboy@starkindustries.com', $alias = false);
     Access::getInstance()->setSuperUserAccess(false);
     $this->authenticateViaLdap();
     $user = Db::fetchRow("SELECT login, password, alias, email, token_auth FROM " . Common::prefixTable('user') . " WHERE login = ?", array(self::TEST_LOGIN));
     $this->assertNotEmpty($user);
     $this->assertEquals(array('login' => self::TEST_LOGIN, 'password' => md5(self::TEST_PASS), 'alias' => self::TEST_LOGIN, 'email' => 'billionairephilanthropistplayboy@starkindustries.com', 'token_auth' => UsersManagerAPI::getInstance()->getTokenAuth(self::TEST_LOGIN, md5(self::TEST_PASS))), $user);
     $this->assertNoAccessInDb();
 }
开发者ID:heiglandreas,项目名称:plugin-LoginLdap,代码行数:11,代码来源:LdapUserSynchronizationTest.php

示例5: testDynamicResolverSitesCreated

 /**
  * NOTE: This test must be last since the new sites that get added are added in
  *       random order.
  */
 public function testDynamicResolverSitesCreated()
 {
     self::$fixture->logVisitsWithDynamicResolver();
     // reload access so new sites are viewable
     Access::getInstance()->setSuperUserAccess(true);
     // make sure sites aren't created twice
     $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
     $this->assertEquals(1, count($piwikDotNet));
     $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
     $this->assertEquals(1, count($anothersiteDotCom));
     $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
     $this->assertEquals(1, count($whateverDotCom));
 }
开发者ID:ahdinosaur,项目名称:analytics.dinosaur.is,代码行数:17,代码来源:ImportLogsTest.php

示例6: setUp

 public function setUp()
 {
     // drop all tables
     Db::dropAllTables();
     // download data dump if url supplied
     if (is_file($this->dumpUrl)) {
         $dumpPath = $this->dumpUrl;
     } else {
         $dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
         $bufferSize = 1024 * 1024;
         $dump = fopen($this->dumpUrl, 'rb');
         $outfile = fopen($dumpPath, 'wb');
         $bytesRead = 0;
         while (!feof($dump)) {
             fwrite($outfile, fread($dump, $bufferSize), $bufferSize);
             $bytesRead += $bufferSize;
         }
         fclose($dump);
         fclose($outfile);
         if ($bytesRead <= 40 * 1024 * 1024) {
             // sanity check
             throw new Exception("Could not download sql dump!");
         }
     }
     // unzip the dump
     if (substr($dumpPath, -3) === ".gz") {
         $deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
         // TODO: should depend on name of URL
         exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
         if ($return !== 0) {
             throw new Exception("gunzip failed: " . implode("\n", $output));
         }
     } else {
         $deflatedDumpPath = $dumpPath;
     }
     // load the data into the correct database
     $user = Config::getInstance()->database['username'];
     $password = Config::getInstance()->database['password'];
     Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
     $cmd = "mysql -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
     exec($cmd, $output, $return);
     if ($return !== 0) {
         throw new Exception("Failed to load sql dump: " . implode("\n", $output));
     }
     // make sure archiving will be called
     Rules::setBrowserTriggerArchiving(true);
     // reload access
     Access::getInstance()->reloadAccess();
     $this->getTestEnvironment()->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
     $this->getTestEnvironment()->save();
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:51,代码来源:SqlDump.php

示例7: setUserDefaultReportPreference

 public function setUserDefaultReportPreference()
 {
     // We initialize the default report user preference for each user (if it hasn't been inited before) for performance,
     // doing this lets us avoid loading all siteIds (which can be 50k or more) when this preference is requested.
     // getting the user preference can be called quite often when generating links etc (to get defaultWebsiteId).
     $usersModel = $this->usersModel;
     $usersManagerApi = $this->usersManagerApi;
     Access::getInstance()->doAsSuperUser(function () use($usersModel, $usersManagerApi) {
         $allUsers = $usersModel->getUsers(array());
         foreach ($allUsers as $user) {
             $usersManagerApi->initUserPreferenceWithDefault($user['login'], API::PREFERENCE_DEFAULT_REPORT);
         }
     });
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:14,代码来源:Tasks.php

示例8: setUp

 /**
  * Setup the database and create the base tables for all tests
  */
 public function setUp()
 {
     parent::setUp();
     static::$fixture->extraDefinitions = array_merge(static::provideContainerConfigBeforeClass(), $this->provideContainerConfig());
     static::$fixture->createEnvironmentInstance();
     Db::createDatabaseObject();
     Fixture::loadAllPlugins(new TestingEnvironmentVariables(), get_class($this), self::$fixture->extraPluginsToLoad);
     Access::getInstance()->setSuperUserAccess(true);
     if (!empty(self::$tableData)) {
         self::restoreDbTables(self::$tableData);
     }
     PiwikCache::getEagerCache()->flushAll();
     PiwikCache::getTransientCache()->flushAll();
     MenuAbstract::clearMenus();
 }
开发者ID:hichnik,项目名称:piwik,代码行数:18,代码来源:IntegrationTestCase.php

示例9: test_LogImporter_CreatesSitesWhenDynamicResolverUsed_AndReportsOnInvalidRequests

 /**
  * NOTE: This test must be last since the new sites that get added are added in
  *       random order.
  * NOTE: This test combines two tests in order to avoid executing the log importer another time.
  *       If the log importer were refactored, the invalid requests test could be a unit test in
  *       python.
  */
 public function test_LogImporter_CreatesSitesWhenDynamicResolverUsed_AndReportsOnInvalidRequests()
 {
     $this->simulateInvalidTrackerRequest();
     $output = self::$fixture->logVisitsWithDynamicResolver($maxPayloadSize = 3);
     // reload access so new sites are viewable
     Access::getInstance()->setSuperUserAccess(true);
     // make sure sites aren't created twice
     $piwikDotNet = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
     $this->assertEquals(1, count($piwikDotNet));
     $anothersiteDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://anothersite.com');
     $this->assertEquals(1, count($anothersiteDotCom));
     $whateverDotCom = API::getInstance()->getSitesIdFromSiteUrl('http://whatever.com');
     $this->assertEquals(1, count($whateverDotCom));
     // make sure invalid requests are reported correctly
     $this->assertContains('The Piwik tracker identified 2 invalid requests on lines: 10, 11', $output);
     $this->assertContains("The following lines were not tracked by Piwik, either due to a malformed tracker request or error in the tracker:\n\n10, 11", $output);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:24,代码来源:ImportLogsTest.php

示例10: setUp

 public function setUp()
 {
     // drop all tables
     Db::dropAllTables();
     // download data dump if url supplied
     if (is_file($this->dumpUrl)) {
         $dumpPath = $this->dumpUrl;
     } else {
         $dumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql.gz';
         $bytesRead = $this->downloadDumpInPath($dumpPath);
         // sanity check
         if ($bytesRead <= 40 * 1024 * 1024) {
             $str = "Could not download sql dump! You can manually download %s into %s";
             throw new Exception(sprintf($str, $this->dumpUrl, $dumpPath));
         }
     }
     // unzip the dump
     if (substr($dumpPath, -3) === ".gz") {
         $deflatedDumpPath = PIWIK_INCLUDE_PATH . '/tmp/logdump.sql';
         // TODO: should depend on name of URL
         exec("gunzip -c \"" . $dumpPath . "\" > \"{$deflatedDumpPath}\"", $output, $return);
         if ($return !== 0) {
             throw new Exception("gunzip failed: " . implode("\n", $output));
         }
     } else {
         $deflatedDumpPath = $dumpPath;
     }
     // load the data into the correct database
     $user = Config::getInstance()->database['username'];
     $password = Config::getInstance()->database['password'];
     $host = Config::getInstance()->database['host'];
     Config::getInstance()->database['tables_prefix'] = $this->tablesPrefix;
     $cmd = "mysql -h \"{$host}\" -u \"{$user}\" \"--password={$password}\" {$this->dbName} < \"" . $deflatedDumpPath . "\" 2>&1";
     exec($cmd, $output, $return);
     if ($return !== 0) {
         throw new Exception("Failed to load sql dump: " . implode("\n", $output));
     }
     // make sure archiving will be called
     Rules::setBrowserTriggerArchiving(true);
     // reload access
     Access::getInstance()->reloadAccess();
     $testVars = new TestingEnvironmentVariables();
     $testVars->configOverride = array('database' => array('tables_prefix' => $this->tablesPrefix));
     $testVars->save();
 }
开发者ID:diosmosis,项目名称:piwik,代码行数:45,代码来源:SqlDump.php

示例11: updateComponents

 public static function updateComponents(Updater $updater, $componentsWithUpdateFile)
 {
     $warnings = array();
     $errors = array();
     $deactivatedPlugins = array();
     $coreError = false;
     if (!empty($componentsWithUpdateFile)) {
         $currentAccess = Access::getInstance();
         $hasSuperUserAccess = $currentAccess->hasSuperUserAccess();
         if (!$hasSuperUserAccess) {
             $currentAccess->setSuperUserAccess(true);
         }
         // if error in any core update, show message + help message + EXIT
         // if errors in any plugins updates, show them on screen, disable plugins that errored + CONTINUE
         // if warning in any core update or in any plugins update, show message + CONTINUE
         // if no error or warning, success message + CONTINUE
         foreach ($componentsWithUpdateFile as $name => $filenames) {
             try {
                 $warnings = array_merge($warnings, $updater->update($name));
             } catch (UpdaterErrorException $e) {
                 $errors[] = $e->getMessage();
                 if ($name == 'core') {
                     $coreError = true;
                     break;
                 } elseif (\Piwik\Plugin\Manager::getInstance()->isPluginActivated($name)) {
                     \Piwik\Plugin\Manager::getInstance()->deactivatePlugin($name);
                     $deactivatedPlugins[] = $name;
                 }
             }
         }
         if (!$hasSuperUserAccess) {
             $currentAccess->setSuperUserAccess(false);
         }
     }
     Filesystem::deleteAllCacheOnUpdate();
     $result = array('warnings' => $warnings, 'errors' => $errors, 'coreError' => $coreError, 'deactivatedPlugins' => $deactivatedPlugins);
     /**
      * Triggered after Piwik has been updated.
      */
     Piwik::postEvent('CoreUpdater.update.end');
     return $result;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:42,代码来源:CoreUpdater.php

示例12: performSetUp

 public function performSetUp($setupEnvironmentOnly = false)
 {
     // TODO: don't use static var, use test env var for this
     TestingEnvironmentManipulator::$extraPluginsToLoad = $this->extraPluginsToLoad;
     $this->dbName = $this->getDbName();
     if ($this->persistFixtureData) {
         $this->dropDatabaseInSetUp = false;
         $this->dropDatabaseInTearDown = false;
         $this->overwriteExisting = false;
         $this->removeExistingSuperUser = false;
     }
     $testEnv = $this->getTestEnvironment();
     $testEnv->testCaseClass = $this->testCaseClass;
     $testEnv->fixtureClass = get_class($this);
     $testEnv->dbName = $this->dbName;
     $testEnv->extraDiEnvironments = $this->extraDiEnvironments;
     foreach ($this->extraTestEnvVars as $name => $value) {
         $testEnv->{$name} = $value;
     }
     $testEnv->save();
     $this->createEnvironmentInstance();
     if ($this->dbName === false) {
         // must be after test config is created
         $this->dbName = self::getConfig()->database['dbname'];
     }
     try {
         static::connectWithoutDatabase();
         if ($this->dropDatabaseInSetUp || $this->resetPersistedFixture) {
             $this->dropDatabase();
         }
         DbHelper::createDatabase($this->dbName);
         DbHelper::disconnectDatabase();
         Tracker::disconnectCachedDbConnection();
         // reconnect once we're sure the database exists
         self::getConfig()->database['dbname'] = $this->dbName;
         Db::createDatabaseObject();
         Db::get()->query("SET wait_timeout=28800;");
         DbHelper::createTables();
         self::getPluginManager()->unloadPlugins();
     } catch (Exception $e) {
         static::fail("TEST INITIALIZATION FAILED: " . $e->getMessage() . "\n" . $e->getTraceAsString());
     }
     include "DataFiles/Providers.php";
     if (!$this->isFixtureSetUp()) {
         DbHelper::truncateAllTables();
     }
     // We need to be SU to create websites for tests
     Access::getInstance()->setSuperUserAccess();
     Cache::deleteTrackerCache();
     self::resetPluginsInstalledConfig();
     $testEnvironment = $this->getTestEnvironment();
     static::loadAllPlugins($testEnvironment, $this->testCaseClass, $this->extraPluginsToLoad);
     self::updateDatabase();
     self::installAndActivatePlugins($testEnvironment);
     $_GET = $_REQUEST = array();
     $_SERVER['HTTP_REFERER'] = '';
     FakeAccess::$superUserLogin = 'superUserLogin';
     File::$invalidateOpCacheBeforeRead = true;
     if ($this->configureComponents) {
         IPAnonymizer::deactivate();
         $dntChecker = new DoNotTrackHeaderChecker();
         $dntChecker->deactivate();
     }
     if ($this->createSuperUser) {
         self::createSuperUser($this->removeExistingSuperUser);
         if (!Access::getInstance() instanceof FakeAccess) {
             $this->loginAsSuperUser();
         }
         APILanguageManager::getInstance()->setLanguageForUser('superUserLogin', 'en');
     }
     SettingsPiwik::overwritePiwikUrl(self::getTestRootUrl());
     if ($setupEnvironmentOnly) {
         return;
     }
     PiwikCache::getTransientCache()->flushAll();
     if ($this->overwriteExisting || !$this->isFixtureSetUp()) {
         $this->setUp();
         $this->markFixtureSetUp();
         $this->log("Database {$this->dbName} marked as successfully set up.");
     } else {
         $this->log("Using existing database {$this->dbName}.");
     }
 }
开发者ID:dorelljames,项目名称:piwik,代码行数:83,代码来源:Fixture.php

示例13: test_reloadAccess_DoesNotRemoveSuperUserAccess_IfUsedInDoAsSuperUser

 public function test_reloadAccess_DoesNotRemoveSuperUserAccess_IfUsedInDoAsSuperUser()
 {
     Access::getInstance()->setSuperUserAccess(false);
     Access::doAsSuperUser(function () {
         $access = Access::getInstance();
         Core_AccessTest::assertTrue($access->hasSuperUserAccess());
         $access->reloadAccess();
         Core_AccessTest::assertTrue($access->hasSuperUserAccess());
     });
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:10,代码来源:AccessTest.php

示例14: updateComponents

 /**
  * @return array|bool
  */
 protected function updateComponents()
 {
     Access::getInstance();
     return Access::doAsSuperUser(function () {
         $updater = new Updater();
         $componentsWithUpdateFile = $updater->getComponentUpdates();
         if (empty($componentsWithUpdateFile)) {
             return false;
         }
         $result = $updater->updateComponents($componentsWithUpdateFile);
         return $result;
     });
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:16,代码来源:Controller.php

示例15: testGetSitesIdFromSiteUrlUser

 /**
  * @group Plugins
  */
 public function testGetSitesIdFromSiteUrlUser()
 {
     $idsite = API::getInstance()->addSite("site1", array("http://www.piwik.net", "http://piwik.com"));
     $idsite = API::getInstance()->addSite("site2", array("http://piwik.com", "http://piwik.net"));
     $idsite = API::getInstance()->addSite("site3", array("http://piwik.com", "http://piwik.org"));
     $saveAccess = Access::getInstance();
     APIUsersManager::getInstance()->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
     APIUsersManager::getInstance()->setUserAccess("user1", "view", array(1));
     APIUsersManager::getInstance()->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
     APIUsersManager::getInstance()->setUserAccess("user2", "view", array(1));
     APIUsersManager::getInstance()->setUserAccess("user2", "admin", array(3));
     APIUsersManager::getInstance()->addUser("user3", "geqgegagae", "tegst3@tesgt.com", "alias");
     APIUsersManager::getInstance()->setUserAccess("user3", "view", array(1, 2));
     APIUsersManager::getInstance()->setUserAccess("user3", "admin", array(3));
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = false;
     FakeAccess::$identity = 'user1';
     FakeAccess::setIdSitesView(array(1));
     FakeAccess::setIdSitesAdmin(array());
     Access::setSingletonInstance($pseudoMockAccess);
     $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
     $this->assertEquals(1, count($idsites));
     // testing URL normalization
     $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://www.piwik.com');
     $this->assertEquals(1, count($idsites));
     $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.net');
     $this->assertEquals(1, count($idsites));
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = false;
     FakeAccess::$identity = 'user2';
     FakeAccess::setIdSitesView(array(1));
     FakeAccess::setIdSitesAdmin(array(3));
     Access::setSingletonInstance($pseudoMockAccess);
     $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
     $this->assertEquals(2, count($idsites));
     $pseudoMockAccess = new FakeAccess();
     FakeAccess::$superUser = false;
     FakeAccess::$identity = 'user3';
     FakeAccess::setIdSitesView(array(1, 2));
     FakeAccess::setIdSitesAdmin(array(3));
     Access::setSingletonInstance($pseudoMockAccess);
     $idsites = API::getInstance()->getSitesIdFromSiteUrl('http://piwik.com');
     $this->assertEquals(3, count($idsites));
     Access::setSingletonInstance($saveAccess);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:48,代码来源:SitesManagerTest.php


注:本文中的Piwik\Access::getInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。