当前位置: 首页>>代码示例>>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;未经允许,请勿转载。