本文整理汇总了PHP中Piwik\Access类的典型用法代码示例。如果您正苦于以下问题:PHP Access类的具体用法?PHP Access怎么用?PHP Access使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Access类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertAccessReloadedAndRestored
private function assertAccessReloadedAndRestored($expectedTokenToBeReloaded)
{
$this->access->expects($this->exactly(2))->method('reloadAccess');
// verify access reloaded
$this->auth->expects($this->at(0))->method('setLogin')->with($this->equalTo(null));
$this->auth->expects($this->at(1))->method('setTokenAuth')->with($this->equalTo($expectedTokenToBeReloaded));
$this->auth->expects($this->at(2))->method('authenticate')->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login1', $expectedTokenToBeReloaded)));
// verify access restored
$this->auth->expects($this->at(3))->method('setLogin')->with($this->equalTo(null));
$this->auth->expects($this->at(4))->method('setTokenAuth')->with($this->equalTo($tokenRestored = $this->userAuthToken));
$this->auth->expects($this->at(5))->method('authenticate')->will($this->returnValue(new AuthResult(AuthResult::SUCCESS, 'login', $this->userAuthToken)));
}
示例2: addAnnotations
private function addAnnotations()
{
// create fake access for fake username
$access = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($access);
// add two annotations per week for three months, starring every third annotation
// first month in 2011, second two in 2012
$count = 0;
$dateStart = Date::factory('2011-12-01');
$dateEnd = Date::factory('2012-03-01');
while ($dateStart->getTimestamp() < $dateEnd->getTimestamp()) {
$starred = $count % 3 == 0 ? 1 : 0;
$site1Text = "{$count}: Site 1 annotation for " . $dateStart->toString();
$site2Text = "{$count}: Site 2 annotation for " . $dateStart->toString();
API::getInstance()->add($this->idSite1, $dateStart->toString(), $site1Text, $starred);
API::getInstance()->add($this->idSite2, $dateStart->toString(), $site2Text, $starred);
$nextDay = $dateStart->addDay(1);
++$count;
$starred = $count % 3 == 0 ? 1 : 0;
$site1Text = "{$count}: Site 1 annotation for " . $nextDay->toString();
$site2Text = "{$count}: Site 2 annotation for " . $nextDay->toString();
API::getInstance()->add($this->idSite1, $nextDay->toString(), $site1Text, $starred);
API::getInstance()->add($this->idSite2, $nextDay->toString(), $site2Text, $starred);
$dateStart = $dateStart->addPeriod(1, 'WEEK');
++$count;
}
}
示例3: 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();
}
}
示例4: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
}
示例5: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
\Piwik\Plugin\Manager::getInstance()->loadPlugins(array('SitesManager'));
}
示例6: 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'));
}
示例7: migratePluginEmailUpdateSetting
private function migratePluginEmailUpdateSetting()
{
$isEnabled = Option::get('enableUpdateCommunicationPlugins');
Access::doAsSuperUser(function () use($isEnabled) {
$settings = StaticContainer::get('Piwik\\Plugins\\CoreUpdater\\SystemSettings');
$settings->sendPluginUpdateEmail->setValue(!empty($isEnabled));
$settings->save();
});
}
示例8: 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();
}
示例9: testGetUnit
/**
* @dataProvider getUnitColumns
* @group Core
*/
public function testGetUnit($column, $expected)
{
\Piwik\Site::setSites(array(1 => array('name' => 'TestSite', 'currency' => 'EUR')));
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
$actual = Metrics::getUnit($column, 1);
$this->assertEquals($expected, $actual);
}
示例10: setUp
public function setUp()
{
parent::setUp();
$pseudoMockAccess = new \FakeAccess();
\FakeAccess::setSuperUserAccess(true);
Access::setSingletonInstance($pseudoMockAccess);
$idSite = Fixture::createWebsite('2014-01-01 00:00:00');
$this->builder = $this->makeBuilder(array('method' => 'MultiSites_getAll', 'idSite' => $idSite));
}
示例11: hasAccessToSameSite
private function hasAccessToSameSite($login)
{
// users is allowed to see other users having view or admin access to these sites
if (!isset($this->idSitesWithAdmin)) {
$this->idSitesWithAdmin = $this->access->getSitesIdWithAdminAccess();
$this->usersWithAdminAccess = $this->model->getUsersSitesFromAccess('admin');
$this->usersWithViewAccess = $this->model->getUsersSitesFromAccess('view');
}
return isset($this->usersWithViewAccess[$login]) && array_intersect($this->idSitesWithAdmin, $this->usersWithViewAccess[$login]) || isset($this->usersWithAdminAccess[$login]) && array_intersect($this->idSitesWithAdmin, $this->usersWithAdminAccess[$login]);
}
示例12: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
//finally we set the user as a Super User by default
Access::setSingletonInstance($pseudoMockAccess);
$this->idSiteAccess = APISitesManager::getInstance()->addSite("test", "http://test");
\Piwik\Plugin\Manager::getInstance()->loadPlugins(array('ScheduledReports', 'MobileMessaging', 'MultiSites'));
\Piwik\Plugin\Manager::getInstance()->installLoadedPlugins();
}
示例13: setUp
public function setUp()
{
parent::setUp();
// setup the access layer
$pseudoMockAccess = new FakeAccess();
FakeAccess::setIdSitesView(array(1, 2));
FakeAccess::setIdSitesAdmin(array(3, 4));
//finally we set the user as a Super User by default
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
$this->auth = new Auth();
}
示例14: setUp
public function setUp()
{
parent::setUp();
$this->api = API::getInstance();
$pseudoMockAccess = new FakeAccess();
FakeAccess::$superUser = true;
Access::setSingletonInstance($pseudoMockAccess);
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
Fixture::createWebsite('2014-01-01 00:00:00');
$this->api->addUser('userLogin', 'password', 'userlogin@password.de');
}
示例15: 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));
}