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


PHP API::getUsersWithSiteAccess方法代码示例

本文整理汇总了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));
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:46,代码来源:UsersManagerTest.php


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