本文整理汇总了PHP中Piwik\Plugins\UsersManager\API::getUsersWithSiteAccess方法的典型用法代码示例。如果您正苦于以下问题:PHP API::getUsersWithSiteAccess方法的具体用法?PHP API::getUsersWithSiteAccess怎么用?PHP API::getUsersWithSiteAccess使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\Plugins\UsersManager\API
的用法示例。
在下文中一共展示了API::getUsersWithSiteAccess方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSetUserAccessMultipleCallDistinctAccessMultipleUser
/**
* normal case, set different access to different websites for multiple users
*/
public function testSetUserAccessMultipleCallDistinctAccessMultipleUser()
{
$this->api->addUser("user1", "geqgegagae", "tegst@tesgt.com", "alias");
$this->api->addUser("user2", "geqgegagae", "tegst2@tesgt.com", "alias");
list($id1, $id2, $id3) = $this->addSites(3);
$this->api->setUserAccess("user1", "view", array($id1, $id2));
$this->api->setUserAccess("user2", "admin", array($id1));
$this->api->setUserAccess("user2", "view", array($id3, $id2));
$access1 = $this->api->getSitesAccessFromUser("user1");
$access1 = $this->_flatten($access1);
$access2 = $this->api->getSitesAccessFromUser("user2");
$access2 = $this->_flatten($access2);
$wanted1 = array($id1 => 'view', $id2 => 'view');
$wanted2 = array($id1 => 'admin', $id2 => 'view', $id3 => 'view');
$this->assertEquals($wanted1, $access1);
$this->assertEquals($wanted2, $access2);
$access1 = $this->api->getUsersAccessFromSite($id1);
$access2 = $this->api->getUsersAccessFromSite($id2);
$access3 = $this->api->getUsersAccessFromSite($id3);
$wanted1 = array('user1' => 'view', 'user2' => 'admin');
$wanted2 = array('user1' => 'view', 'user2' => 'view');
$wanted3 = array('user2' => 'view');
$this->assertEquals($wanted1, $access1);
$this->assertEquals($wanted2, $access2);
$this->assertEquals($wanted3, $access3);
$access1 = $this->api->getUsersSitesFromAccess('view');
$access2 = $this->api->getUsersSitesFromAccess('admin');
$wanted1 = array('user1' => array($id1, $id2), 'user2' => array($id2, $id3));
$wanted2 = array('user2' => array($id1));
$this->assertEquals($wanted1, $access1);
$this->assertEquals($wanted2, $access2);
// Test getUsersWithSiteAccess
$users = $this->api->getUsersWithSiteAccess($id1, $access = 'view');
$this->assertEquals(1, count($users));
$this->assertEquals('user1', $users[0]['login']);
$users = $this->api->getUsersWithSiteAccess($id2, $access = 'view');
$this->assertEquals(2, count($users));
$users = $this->api->getUsersWithSiteAccess($id1, $access = 'admin');
$this->assertEquals(1, count($users));
$this->assertEquals('user2', $users[0]['login']);
$users = $this->api->getUsersWithSiteAccess($id3, $access = 'admin');
$this->assertEquals(0, count($users));
}