當前位置: 首頁>>代碼示例>>PHP>>正文


PHP API::setSuperUserAccess方法代碼示例

本文整理匯總了PHP中Piwik\Plugins\UsersManager\API::setSuperUserAccess方法的典型用法代碼示例。如果您正苦於以下問題:PHP API::setSuperUserAccess方法的具體用法?PHP API::setSuperUserAccess怎麽用?PHP API::setSuperUserAccess使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\Plugins\UsersManager\API的用法示例。


在下文中一共展示了API::setSuperUserAccess方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testSetSuperUserAccess_ShouldAddAndRemoveSuperUserAccessOnlyForGivenLogin

 public function testSetSuperUserAccess_ShouldAddAndRemoveSuperUserAccessOnlyForGivenLogin()
 {
     $this->api->addUser('login1', 'password1', 'test1@example.com', false);
     $this->api->addUser('login2', 'password2', 'test2@example.com', false);
     $this->api->addUser('login3', 'password3', 'test3@example.com', false);
     $this->api->setSuperUserAccess('login2', true);
     // test add Super User access
     $users = $this->api->getUsers();
     $this->assertEquals(0, $users[0]['superuser_access']);
     $this->assertEquals(1, $users[1]['superuser_access']);
     $this->assertEquals('login2', $users[1]['login']);
     $this->assertEquals(0, $users[2]['superuser_access']);
     // should also accept string '1' to add Super User access
     $this->api->setSuperUserAccess('login1', '1');
     // test remove Super User access
     $this->api->setSuperUserAccess('login2', false);
     $users = $this->api->getUsers();
     $this->assertEquals(1, $users[0]['superuser_access']);
     $this->assertEquals('login1', $users[0]['login']);
     $this->assertEquals(0, $users[1]['superuser_access']);
     $this->assertEquals(0, $users[2]['superuser_access']);
     $this->api->setSuperUserAccess('login3', true);
     // should also accept string '0' to remove Super User access
     $this->api->setSuperUserAccess('login1', '0');
     $users = $this->api->getUsers();
     $this->assertEquals(0, $users[0]['superuser_access']);
     $this->assertEquals(0, $users[1]['superuser_access']);
     $this->assertEquals('login3', $users[2]['login']);
     $this->assertEquals(1, $users[2]['superuser_access']);
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:30,代碼來源:UsersManagerTest.php

示例2: test_getSitesAccessFromUser_forSuperUser

 public function test_getSitesAccessFromUser_forSuperUser()
 {
     $user2 = 'userLogin2';
     $this->api->addUser($user2, 'password', 'userlogin2@password.de');
     // new user doesn't have access to anything
     $access = $this->api->getSitesAccessFromUser($user2);
     $this->assertEmpty($access);
     $this->api->setSuperUserAccess($user2, true);
     // super user has admin access for every site
     $access = $this->api->getSitesAccessFromUser($user2);
     $expected = array(array('site' => 1, 'access' => 'admin'), array('site' => 2, 'access' => 'admin'), array('site' => 3, 'access' => 'admin'));
     $this->assertEquals($expected, $access);
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:13,代碼來源:APITest.php


注:本文中的Piwik\Plugins\UsersManager\API::setSuperUserAccess方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。