本文整理汇总了PHP中OC_SubAdmin::isSubAdminofGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_SubAdmin::isSubAdminofGroup方法的具体用法?PHP OC_SubAdmin::isSubAdminofGroup怎么用?PHP OC_SubAdmin::isSubAdminofGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_SubAdmin
的用法示例。
在下文中一共展示了OC_SubAdmin::isSubAdminofGroup方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
<?php
// Init owncloud
require_once '../../lib/base.php';
OC_JSON::checkAdminUser();
OCP\JSON::callCheck();
$username = $_POST["username"];
$group = OC_Util::sanitizeHTML($_POST["group"]);
// Toggle group
if (OC_SubAdmin::isSubAdminofGroup($username, $group)) {
OC_SubAdmin::deleteSubAdmin($username, $group);
} else {
OC_SubAdmin::createSubAdmin($username, $group);
}
OC_JSON::success();
示例2: testRemoveSubAdmin
public function testRemoveSubAdmin()
{
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
\OC_SubAdmin::createSubAdmin($user2, $group1);
$result = \OCA\provisioning_api\Users::removeSubAdmin(array('userid' => $user2, '_delete' => array('groupid' => $group1)));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$this->assertTrue(!\OC_SubAdmin::isSubAdminofGroup($user2, $group1));
\OC_Group::deleteGroup($group1);
$user1 = $this->generateUsers();
self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$result = \OCA\provisioning_api\Users::removeSubAdmin(array('userid' => $this->getUniqueID(), '_delete' => array('groupid' => $group1)));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertEquals(101, $result->getStatusCode());
$this->assertFalse($result->succeeded());
$this->resetParams();
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
self::loginAsUser($user1);
\OC_Group::addToGroup($user1, 'admin');
$group1 = $this->getUniqueID();
\OC_Group::createGroup($group1);
$_POST['groupid'] = $group1;
$result = \OCA\provisioning_api\Users::removeSubAdmin(array('userid' => $user2, '_delete' => array('groupid' => $group1)));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded());
$this->assertEquals(102, $result->getStatusCode());
\OC_Group::deleteGroup($group1);
}
示例3: testRemoveSubAdmin
public function testRemoveSubAdmin()
{
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
$this->userSession->setUser($user1);
$this->groupManager->get('admin')->addUser($user1);
$group1 = $this->getUniqueID();
$group1 = $this->groupManager->createGroup($group1);
\OC_SubAdmin::createSubAdmin($user2->getUID(), $group1->getGID());
$result = $this->api->removeSubAdmin(array('userid' => $user2->getUID(), '_delete' => array('groupid' => $group1->getGID())));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertTrue($result->succeeded());
$this->assertTrue(!\OC_SubAdmin::isSubAdminofGroup($user2->getUID(), $group1->getGID()));
$group1->delete();
$user1 = $this->generateUsers();
$this->userSession->setUser($user1);
$this->groupManager->get('admin')->addUser($user1);
$result = $this->api->removeSubAdmin(array('userid' => $this->getUniqueID(), '_delete' => array('groupid' => $group1->getGID())));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertEquals(101, $result->getStatusCode());
$this->assertFalse($result->succeeded());
$this->resetParams();
$user1 = $this->generateUsers();
$user2 = $this->generateUsers();
$this->userSession->setUser($user1);
$this->groupManager->get('admin')->addUser($user1);
$group1 = $this->getUniqueID();
$group1 = $this->groupManager->createGroup($group1);
$_POST['groupid'] = $group1->getGID();
$result = $this->api->removeSubAdmin(array('userid' => $user2->getUID(), '_delete' => array('groupid' => $group1->getGID())));
$this->assertInstanceOf('OC_OCS_Result', $result);
$this->assertFalse($result->succeeded());
$this->assertEquals(102, $result->getStatusCode());
$group1->delete();
}