本文整理汇总了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);
}
示例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();
}
}
示例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;
}
示例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'));
}
示例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;
}
示例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']);
}
示例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;
}