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


PHP OC_Group::addToGroup方法代码示例

本文整理汇总了PHP中OC_Group::addToGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Group::addToGroup方法的具体用法?PHP OC_Group::addToGroup怎么用?PHP OC_Group::addToGroup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OC_Group的用法示例。


在下文中一共展示了OC_Group::addToGroup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // enable resharing
     \OC_Appconfig::setValue('core', 'shareapi_allow_resharing', 'yes');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     \OCP\Util::connectHook('OC_Filesystem', 'setup', '\\OC\\Files\\Storage\\Shared', 'setup');
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create users
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:28,代码来源:share.php

示例2: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // enable resharing
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
     // clear share hooks
     \OC_Hook::clear('OCP\\Share');
     // register share hooks
     \OC::registerShareHooks();
     \OCA\Files_Sharing\Helper::registerHooks();
     // Sharing related hooks
     \OCA\Encryption\Helper::registerShareHooks();
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Files\Share\Proxy());
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create users
     self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER1, true);
     self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER2, true);
     self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, true);
     self::loginHelper(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER3, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(\Test_Encryption_Share::TEST_ENCRYPTION_SHARE_USER4, \Test_Encryption_Share::TEST_ENCRYPTION_SHARE_GROUP1);
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:31,代码来源:share.php

示例3: testGetApps

 public function testGetApps()
 {
     $user = $this->generateUsers();
     \OC_Group::addToGroup($user, 'admin');
     self::loginAsUser($user);
     $result = \OCA\provisioning_API\Apps::getApps(array());
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals(count(\OC_App::listAllApps()), count($data['apps']));
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:10,代码来源:appstest.php

示例4: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // create test user
     self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER1, true);
     self::loginHelper(self::TEST_ENCRYPTION_UTIL_USER2, true);
     self::loginHelper(self::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
     // create groups
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
     // add user 1 to group1
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:13,代码来源:util.php

示例5: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     self::setupHooks();
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
     // create groups
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
     // add user 1 to group1
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:16,代码来源:util.php

示例6: setUp

 protected function setUp()
 {
     parent::setUp();
     \OC_User::clearBackends();
     \OC_User::useBackend('dummy');
     $this->user1 = $this->getUniqueID('user1_');
     $this->user2 = $this->getUniqueID('user2_');
     $this->user3 = $this->getUniqueID('user3_');
     $this->user4 = $this->getUniqueID('user4_');
     $this->user5 = $this->getUniqueID('user5_');
     $this->user6 = $this->getUniqueID('user6_');
     $this->groupAndUser = $this->getUniqueID('groupAndUser_');
     \OC::$server->getUserManager()->createUser($this->user1, 'pass');
     \OC::$server->getUserManager()->createUser($this->user2, 'pass');
     \OC::$server->getUserManager()->createUser($this->user3, 'pass');
     \OC::$server->getUserManager()->createUser($this->user4, 'pass');
     \OC::$server->getUserManager()->createUser($this->user5, 'pass');
     \OC::$server->getUserManager()->createUser($this->user6, 'pass');
     // no group
     \OC::$server->getUserManager()->createUser($this->groupAndUser, 'pass');
     \OC_User::setUserId($this->user1);
     \OC_Group::clearBackends();
     \OC_Group::useBackend(new \Test\Util\Group\Dummy());
     $this->group1 = $this->getUniqueID('group1_');
     $this->group2 = $this->getUniqueID('group2_');
     \OC_Group::createGroup($this->group1);
     \OC_Group::createGroup($this->group2);
     \OC_Group::createGroup($this->groupAndUser);
     \OC_Group::addToGroup($this->user1, $this->group1);
     \OC_Group::addToGroup($this->user2, $this->group1);
     \OC_Group::addToGroup($this->user3, $this->group1);
     \OC_Group::addToGroup($this->user2, $this->group2);
     \OC_Group::addToGroup($this->user4, $this->group2);
     \OC_Group::addToGroup($this->user2, $this->groupAndUser);
     \OC_Group::addToGroup($this->user3, $this->groupAndUser);
     \OCP\Share::registerBackend('test', 'Test\\Share\\Backend');
     \OC_Hook::clear('OCP\\Share');
     \OC::registerShareHooks();
     $this->resharing = \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_resharing', 'yes');
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
     // 20 Minutes in the past, 20 minutes in the future.
     $now = time();
     $dateFormat = 'Y-m-d H:i:s';
     $this->dateInPast = date($dateFormat, $now - 20 * 60);
     $this->dateInFuture = date($dateFormat, $now + 20 * 60);
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:46,代码来源:ShareTest.php

示例7: setUp

 public function setUp()
 {
     \OC_User::createUser(self::TEST_USER1, self::TEST_USER1);
     \OC_User::createUser(self::TEST_USER2, self::TEST_USER2);
     \OC_Group::createGroup(self::TEST_GROUP1);
     \OC_Group::addToGroup(self::TEST_USER1, self::TEST_GROUP1);
     \OC_Group::createGroup(self::TEST_GROUP2);
     \OC_Group::addToGroup(self::TEST_USER2, self::TEST_GROUP2);
     \OC_User::setUserId(self::TEST_USER1);
     $this->userHome = \OC_User::getHome(self::TEST_USER1);
     mkdir($this->userHome);
     $this->dataDir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT . '/data/');
     $this->oldAllowedBackends = OCP\Config::getAppValue('files_external', 'user_mounting_backends', '');
     $this->allBackends = OC_Mount_Config::getBackends();
     OCP\Config::setAppValue('files_external', 'user_mounting_backends', implode(',', array_keys($this->allBackends)));
     OC_Mount_Config::$skipTest = true;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:17,代码来源:mountconfig.php

示例8: testUnshareFromSelf

 function testUnshareFromSelf()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $fileinfo = $this->view->getFileInfo($this->filename);
     $pathinfo = pathinfo($this->filename);
     $duplicate = '/' . $pathinfo['filename'] . ' (2).' . $pathinfo['extension'];
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup', 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($this->filename);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertTrue(\OC\Files\Filesystem::file_exists($duplicate));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($duplicate);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($duplicate));
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup');
     \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2);
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::deleteGroup('testGroup');
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:44,代码来源:share.php

示例9: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     // enable resharing
     \OC::$server->getAppConfig()->setValue('core', 'shareapi_allow_resharing', 'yes');
     // register share hooks
     \OC::registerShareHooks();
     \OCA\Files_Sharing\Helper::registerHooks();
     // clear and register hooks
     \OC_FileProxy::register(new \OCA\Files\Share\Proxy());
     // create users
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER1, true);
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER2, true);
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER3, true);
     self::loginHelper(self::TEST_ENCRYPTION_SHARE_USER4, true);
     // create group and assign users
     \OC_Group::createGroup(self::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER3, self::TEST_ENCRYPTION_SHARE_GROUP1);
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_SHARE_USER4, self::TEST_ENCRYPTION_SHARE_GROUP1);
 }
开发者ID:yheric455042,项目名称:owncloud82,代码行数:20,代码来源:share.php

示例10: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     // reset backend
     \OC_User::clearBackends();
     \OC_User::useBackend('database');
     // Filesystem related hooks
     \OCA\Encryption\Helper::registerFilesystemHooks();
     // clear and register hooks
     \OC_FileProxy::clearProxies();
     \OC_FileProxy::register(new OCA\Encryption\Proxy());
     // create test user
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER1, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_USER2, true);
     \Test_Encryption_Util::loginHelper(\Test_Encryption_Util::TEST_ENCRYPTION_UTIL_LEGACY_USER, true);
     // create groups
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP1);
     \OC_Group::createGroup(self::TEST_ENCRYPTION_UTIL_GROUP2);
     // add user 1 to group1
     \OC_Group::addToGroup(self::TEST_ENCRYPTION_UTIL_USER1, self::TEST_ENCRYPTION_UTIL_GROUP1);
 }
开发者ID:ArcherSys,项目名称:ArcherSysOSCloud7,代码行数:20,代码来源:util.php

示例11: testUnshareFromSelf

 public function testUnshareFromSelf()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $share1 = $this->share(\OCP\Share::SHARE_TYPE_USER, $this->filename, self::TEST_FILES_SHARING_API_USER1, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
     $share2 = $this->share(\OCP\Share::SHARE_TYPE_GROUP, $this->filename, self::TEST_FILES_SHARING_API_USER1, 'testGroup', \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($this->filename);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // both group share and user share should be gone
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     $this->shareManager->deleteShare($share1);
     $this->shareManager->deleteShare($share2);
 }
开发者ID:GitHubUser4234,项目名称:core,代码行数:22,代码来源:ShareTest.php

示例12: testGetSubAdminsOfGroup

 public function testGetSubAdminsOfGroup()
 {
     $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\Groups::getSubAdminsOfGroup(array('groupid' => $group1));
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertTrue($result->succeeded());
     $data = $result->getData();
     $this->assertEquals($user2, reset($data));
     \OC_Group::deleteGroup($group1);
     $user1 = $this->generateUsers();
     self::loginAsUser($user1);
     \OC_Group::addToGroup($user1, 'admin');
     $result = \OCA\provisioning_api\Groups::getSubAdminsOfGroup(array('groupid' => $this->getUniqueID()));
     $this->assertInstanceOf('OC_OCS_Result', $result);
     $this->assertFalse($result->succeeded());
     $this->assertEquals(101, $result->getStatusCode());
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:23,代码来源:groupstest.php

示例13: testUnshareFromSelf

 public function testUnshareFromSelf()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $fileinfo = $this->view->getFileInfo($this->filename);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, 'testGroup', 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     \OC\Files\Filesystem::unlink($this->filename);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // both group share and user share should be gone
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->filename));
     // for user3 nothing should change
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->filename));
 }
开发者ID:evanjt,项目名称:core,代码行数:23,代码来源:share.php

示例14: testMultiBackend

 public function testMultiBackend()
 {
     $userBackend = new \Test\Util\User\Dummy();
     \OC_User::getManager()->registerBackend($userBackend);
     $backend1 = new OC_Group_Dummy();
     $backend2 = new OC_Group_Dummy();
     OC_Group::useBackend($backend1);
     OC_Group::useBackend($backend2);
     $group1 = $this->getUniqueID();
     $group2 = $this->getUniqueID();
     OC_Group::createGroup($group1);
     //groups should be added to the first registered backend
     $this->assertEquals(array($group1), $backend1->getGroups());
     $this->assertEquals(array(), $backend2->getGroups());
     $this->assertEquals(array($group1), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertFalse(OC_Group::groupExists($group2));
     $backend1->createGroup($group2);
     $this->assertEquals(array($group1, $group2), OC_Group::getGroups());
     $this->assertTrue(OC_Group::groupExists($group1));
     $this->assertTrue(OC_Group::groupExists($group2));
     $user1 = $this->getUniqueID();
     $user2 = $this->getUniqueID();
     $userBackend->createUser($user1, '');
     $userBackend->createUser($user2, '');
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertTrue(OC_Group::addToGroup($user1, $group1));
     $this->assertTrue(OC_Group::inGroup($user1, $group1));
     $this->assertFalse(OC_Group::inGroup($user2, $group1));
     $this->assertFalse($backend2->inGroup($user1, $group1));
     OC_Group::addToGroup($user1, $group1);
     $this->assertEquals(array($user1), OC_Group::usersInGroup($group1));
     $this->assertEquals(array($group1), OC_Group::getUserGroups($user1));
     $this->assertEquals(array(), OC_Group::getUserGroups($user2));
     OC_Group::deleteGroup($group1);
     $this->assertEquals(array(), OC_Group::getUserGroups($user1));
     $this->assertEquals(array(), OC_Group::usersInGroup($group1));
     $this->assertFalse(OC_Group::inGroup($user1, $group1));
 }
开发者ID:evanjt,项目名称:core,代码行数:40,代码来源:group.php

示例15: testPermissionUpgradeOnUserDeletedGroupShare

 /**
  * If the permissions on a group share are upgraded be sure to still respect 
  * removed shares by a member of that group
  */
 function testPermissionUpgradeOnUserDeletedGroupShare()
 {
     \OC_Group::createGroup('testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::addToGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
     $connection = \OC::$server->getDatabaseConnection();
     // Share item with group
     $fileinfo = $this->view->getFileInfo($this->folder);
     $share = $this->share(\OCP\Share::SHARE_TYPE_GROUP, $this->folder, self::TEST_FILES_SHARING_API_USER1, 'testGroup', \OCP\Constants::PERMISSION_READ);
     // Login as user 2 and verify the item exists
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
     $this->assertNotEmpty($result);
     $this->assertEquals(\OCP\Constants::PERMISSION_READ, $result->getPermissions());
     // Delete the share
     $this->assertTrue(\OC\Files\Filesystem::rmdir($this->folder));
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
     // Verify we do not get a share
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
     $this->assertEquals(0, $result->getPermissions());
     // Login as user 1 again and change permissions
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $share->setPermissions(\OCP\Constants::PERMISSION_ALL);
     $share = $this->shareManager->updateShare($share);
     // Login as user 2 and verify
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertFalse(\OC\Files\Filesystem::file_exists($this->folder));
     $result = $this->shareManager->getShareById($share->getFullId(), self::TEST_FILES_SHARING_API_USER2);
     $this->assertEquals(0, $result->getPermissions());
     $this->shareManager->deleteShare($share);
     //cleanup
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER1, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER2, 'testGroup');
     \OC_Group::removeFromGroup(self::TEST_FILES_SHARING_API_USER3, 'testGroup');
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:42,代码来源:sharedmount.php


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