本文整理匯總了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'));
}