當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。