本文整理汇总了PHP中Piwik\Plugins\UsersManager\API::setUserAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP API::setUserAccess方法的具体用法?PHP API::setUserAccess怎么用?PHP API::setUserAccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Plugins\UsersManager\API
的用法示例。
在下文中一共展示了API::setUserAccess方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_setUserAccess_ShouldNotTriggerRemoveSiteAccessEvent_IfAccessIsAdded
public function test_setUserAccess_ShouldNotTriggerRemoveSiteAccessEvent_IfAccessIsAdded()
{
$eventTriggered = false;
Piwik::addAction('UsersManager.removeSiteAccess', function () use(&$eventTriggered) {
$eventTriggered = true;
});
$this->api->setUserAccess($this->login, 'admin', array(1, 2));
$this->assertFalse($eventTriggered, 'UsersManager.removeSiteAccess event was triggered but should not');
}
示例2: testSetSuperUserAccess_ShouldDeleteAllExistingAccessEntries
public function testSetSuperUserAccess_ShouldDeleteAllExistingAccessEntries()
{
list($id1, $id2) = $this->addSites(2);
$this->api->addUser('login1', 'password1', 'test@example.com', false);
$this->api->setUserAccess('login1', 'view', array($id1));
$this->api->setUserAccess('login1', 'admin', array($id2));
// verify user has access before setting Super User access
$access = $this->_flatten($this->api->getSitesAccessFromUser('login1'));
$this->assertEquals(array($id1 => 'view', $id2 => 'admin'), $access);
$this->api->setSuperUserAccess('login1', true);
// verify no longer any access
$this->assertEquals(array(), $this->model->getSitesAccessFromUser('login1'));
}