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


PHP Share::getItemSharedWith方法代码示例

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


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

示例1: getUidAndFilename

 private static function getUidAndFilename($filename)
 {
     if (\OCP\App::isEnabled('files_sharing') && substr($filename, 0, 7) == '/Shared' && ($source = \OCP\Share::getItemSharedWith('file', substr($filename, 7), \OC_Share_Backend_File::FORMAT_SHARED_STORAGE))) {
         $filename = $source['path'];
         $pos = strpos($filename, '/files', 1);
         $uid = substr($filename, 1, $pos - 1);
         $filename = substr($filename, $pos + 6);
     } else {
         $uid = \OCP\User::getUser();
     }
     return array($uid, $filename);
 }
开发者ID:ryanshoover,项目名称:core,代码行数:12,代码来源:versions.php

示例2: find

 /**
  * {@inheritDoc}
  */
 public function find($privateUri, $userId)
 {
     // different formats for privateUri
     // calendar::$privateUri
     // object::$userId
     list($itemType, $itemTarget) = explode('::', $privateUri, 1);
     if ($itemType === 'calendar') {
         return Share::getItemSharedWith($itemType, $itemTarget, ShareTypes::ENTITY);
     } elseif ($itemType === 'object') {
         $calendars = Share::getItemsShared($itemType, ShareTypes::GROUPED);
         if (!isset($calendars[$itemTarget])) {
             throw new BackendUtils\DoesNotExistException();
         }
         return $calendars[$itemTarget]['calendar'];
     } else {
         throw new BackendUtils\DoesNotExistException();
     }
 }
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:21,代码来源:calendar.php

示例3: getSource

 /**
  * @param string $target
  * @param string $mountPoint
  * @param string $itemType
  * @return array|false source item
  */
 public static function getSource($target, $mountPoint, $itemType)
 {
     if ($itemType === 'folder') {
         $source = \OCP\Share::getItemSharedWith('folder', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
         if ($source && $target !== '') {
             $source['path'] = $source['path'] . '/' . $target;
         }
     } else {
         $source = \OCP\Share::getItemSharedWith('file', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
     }
     if ($source) {
         return self::resolveReshares($source);
     }
     \OCP\Util::writeLog('files_sharing', 'File source not found for: ' . $target, \OCP\Util::DEBUG);
     return false;
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:22,代码来源:file.php

示例4: testShareWithGroupAndUserBothHaveTheSameId

 public function testShareWithGroupAndUserBothHaveTheSameId()
 {
     $this->shareUserTestFileWithUser($this->user1, $this->groupAndUser);
     \OC_User::setUserId($this->groupAndUser);
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE), '"groupAndUser"-User does not see the file but it was shared with him');
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array(), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE), 'User2 sees test.txt but it was only shared with the user "groupAndUser" and not with group');
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->groupAndUser, \OCP\Constants::PERMISSION_READ), 'Failed asserting that user 1 successfully shared text.txt with group 1.');
     \OC_User::setUserId($this->groupAndUser);
     $this->assertEquals(array(), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE), '"groupAndUser"-User sees test.txt but it was only shared with the group "groupAndUser" and not with the user');
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE), 'User2 does not see test.txt but it was shared with the group "groupAndUser"');
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::unshareAll('test', 'test.txt'));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:17,代码来源:ShareTest.php

示例5: getSource

 /**
  * @param string $target
  * @param string $mountPoint
  * @param string $itemType
  * @return array|false source item
  */
 public static function getSource($target, $mountPoint, $itemType)
 {
     if ($itemType === 'folder') {
         $source = \OCP\Share::getItemSharedWith('folder', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
         if ($source && $target !== '') {
             // note: in case of ext storage mount points the path might be empty
             // which would cause a leading slash to appear
             $source['path'] = ltrim($source['path'] . '/' . $target, '/');
         }
     } else {
         $source = \OCP\Share::getItemSharedWith('file', $mountPoint, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
     }
     if ($source) {
         return self::resolveReshares($source);
     }
     \OCP\Util::writeLog('files_sharing', 'File source not found for: ' . $target, \OCP\Util::DEBUG);
     return false;
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:24,代码来源:file.php

示例6: testGroupingOfShares

 /**
  * if a file was shared as group share and as individual share they should be grouped
  */
 public function testGroupingOfShares()
 {
     $fileinfo = $this->view->getFileInfo($this->filename);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_GROUP, \Test_Files_Sharing::TEST_FILES_SHARING_API_GROUP1, \OCP\Constants::PERMISSION_READ);
     $this->assertTrue($result);
     $result = \OCP\Share::shareItem('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2, \OCP\Constants::PERMISSION_UPDATE);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return exactly one shares created from testCreateShare()
     $this->assertSame(1, count($result));
     $share = reset($result);
     $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']);
     \OC\Files\Filesystem::rename($this->filename, $this->filename . '-renamed');
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return exactly one shares created from testCreateShare()
     $this->assertSame(1, count($result));
     $share = reset($result);
     $this->assertSame(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE, $share['permissions']);
     $this->assertSame($this->filename . '-renamed', $share['file_target']);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // unshare user share
     $result = \OCP\Share::unshare('file', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, \Test_Files_Sharing::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $result = \OCP\Share::getItemSharedWith('file', null);
     $this->assertTrue(is_array($result));
     // test should return the remaining group share
     $this->assertSame(1, count($result));
     $share = reset($result);
     // only the group share permissions should be available now
     $this->assertSame(\OCP\Constants::PERMISSION_READ, $share['permissions']);
     $this->assertSame($this->filename . '-renamed', $share['file_target']);
 }
开发者ID:evanjt,项目名称:core,代码行数:39,代码来源:share.php

示例7: getSource

 public static function getSource($target)
 {
     if ($target == '') {
         return false;
     }
     $target = '/' . $target;
     $target = rtrim($target, '/');
     $pos = strpos($target, '/', 1);
     // Get shared folder name
     if ($pos !== false) {
         $folder = substr($target, 0, $pos);
         $source = \OCP\Share::getItemSharedWith('folder', $folder, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
         if ($source) {
             // note: in case of ext storage mount points the path might be empty
             // which would cause a leading slash to appear
             $source['path'] = ltrim($source['path'] . substr($target, strlen($folder)), '/');
         }
     } else {
         $source = \OCP\Share::getItemSharedWith('file', $target, \OC_Share_Backend_File::FORMAT_SHARED_STORAGE);
     }
     if ($source) {
         if (isset($source['parent'])) {
             $parent = $source['parent'];
             while (isset($parent)) {
                 $query = \OC_DB::prepare('SELECT `parent`, `uid_owner` FROM `*PREFIX*share` WHERE `id` = ?', 1);
                 $item = $query->execute(array($parent))->fetchRow();
                 if (isset($item['parent'])) {
                     $parent = $item['parent'];
                 } else {
                     $fileOwner = $item['uid_owner'];
                     break;
                 }
             }
         } else {
             $fileOwner = $source['uid_owner'];
         }
         $source['fileOwner'] = $fileOwner;
         return $source;
     }
     \OCP\Util::writeLog('files_sharing', 'File source not found for: ' . $target, \OCP\Util::DEBUG);
     return false;
 }
开发者ID:hjimmy,项目名称:owncloud,代码行数:42,代码来源:file.php


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