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


PHP Share::getItemsShared方法代码示例

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


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

示例1: testShareAndUnshareFromSelf

 /**
  * user1 share file to a group and to a user2 in the same group. Then user2
  * unshares the file from self. Afterwards user1 should no longer see the
  * single user share to user2. If he re-shares the file to user2 the same target
  * then the group share should be used to group the item
  */
 public function testShareAndUnshareFromSelf()
 {
     $fileinfo = $this->view->getFileInfo($this->filename);
     // share the file to group1 (user2 is a member of this group) and explicitely to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, self::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_ALL);
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user1 should have to shared files
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(2, count($shares));
     // user2 should have two files "welcome.txt" and the shared file,
     // both the group share and the single share of the same file should be
     // grouped to one file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
     // now user2 deletes the share (= unshare from self)
     \OC\Files\Filesystem::unlink($this->filename);
     // only welcome.txt should exists
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(1, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt'));
     // login as user1...
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // ... now user1 should have only one shared file, the group share
     $shares = \OCP\Share::getItemsShared('file');
     $this->assertSame(1, count($shares));
     // user1 shares a gain the file directly to user2
     \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_ALL);
     // user2 should see again welcome.txt and the shared file
     \Test_Files_Sharing::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $dirContent = \OC\Files\Filesystem::getDirectoryContent('/');
     $this->assertSame(2, count($dirContent));
     $this->verifyDirContent($dirContent, array('welcome.txt', ltrim($this->filename, '/')));
 }
开发者ID:evanjt,项目名称:core,代码行数:41,代码来源:share.php

示例2: testUnshareAll

 public function testUnshareAll()
 {
     $this->shareUserTestFileWithUser($this->user1, $this->user2);
     $this->shareUserTestFileWithUser($this->user2, $this->user3);
     $this->shareUserTestFileWithUser($this->user3, $this->user4);
     $this->shareUserOneTestFileWithGroupOne();
     \OC_User::setUserId($this->user1);
     $this->assertEquals(array('test.txt', 'test.txt'), \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly two times by user1.');
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly once by user2.');
     \OC_User::setUserId($this->user3);
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemsShared('test', Backend::FORMAT_SOURCE), 'Failed asserting that the test.txt file is shared exactly once by user3.');
     $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'), 'Failed asserting that user 3 successfully unshared all shares of the test.txt share.');
     $this->assertEquals(array(), \OCP\Share::getItemsShared('test'), 'Failed asserting that the share of the test.txt file by user 3 has been removed.');
     \OC_User::setUserId($this->user1);
     $this->assertEquals(array(), \OCP\Share::getItemsShared('test'), 'Failed asserting that both shares of the test.txt file by user 1 have been removed.');
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array(), \OCP\Share::getItemsShared('test'), 'Failed asserting that the share of the test.txt file by user 2 has been removed.');
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:19,代码来源:ShareTest.php

示例3: delete

 /**
  * {@inheritDoc}
  */
 public function delete($privateUri, $userId)
 {
     list($itemType, $itemTarget) = explode('::', $privateUri, 1);
     if ($itemType === 'calendar') {
         return Share::unshareFromSelf('calendar', $itemTarget);
     } elseif ($itemType === 'object') {
         $calendars = Share::getItemsShared($itemType, ShareTypes::GROUPED);
         /** @var ICalendar $calendar */
         foreach ($calendars as $calendar) {
             if ($calendar->getPrivateUri() !== $privateUri) {
                 continue;
             }
             $objects = $calendar['objects'];
             foreach ($objects as $object) {
                 Share::unshareFromSelf('object', $object['shareItem']['item_source']);
             }
         }
         return true;
     } else {
         throw new BackendUtils\DoesNotExistException();
     }
 }
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:25,代码来源:calendar.php


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