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


PHP Share::shareItem方法代码示例

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


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

示例1: testGetParents

 function testGetParents()
 {
     $fileinfo1 = $this->view->getFileInfo($this->folder);
     $fileinfo2 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder);
     $fileinfo3 = $this->view->getFileInfo($this->folder . $this->subfolder . $this->subsubfolder . $this->filename);
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo1['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31));
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31));
     $backend = new \OC_Share_Backend_Folder();
     $result = $backend->getParents($fileinfo3['fileid']);
     $this->assertSame(2, count($result));
     $count1 = 0;
     $count2 = 0;
     foreach ($result as $r) {
         if ($r['path'] === 'files' . $this->folder) {
             $this->assertSame(ltrim($this->folder, '/'), $r['collection']['path']);
             $count1++;
         } elseif ($r['path'] === 'files' . $this->folder . $this->subfolder . $this->subsubfolder) {
             $this->assertSame(ltrim($this->subsubfolder, '/'), $r['collection']['path']);
             $count2++;
         } else {
             $this->assertTrue(false, 'unexpected result');
         }
     }
     $this->assertSame(1, $count1);
     $this->assertSame(1, $count2);
     $result1 = $backend->getParents($fileinfo3['fileid'], self::TEST_FILES_SHARING_API_USER3);
     $this->assertSame(1, count($result1));
     $elemet = reset($result1);
     $this->assertSame('files' . $this->folder . $this->subfolder . $this->subsubfolder, $elemet['path']);
     $this->assertSame(ltrim($this->subsubfolder, '/'), $elemet['collection']['path']);
 }
开发者ID:Romua1d,项目名称:core,代码行数:31,代码来源:backend.php

示例2: setUp

 protected function setUp()
 {
     parent::setUp();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // prepare user1's dir structure
     $textData = "dummy file data\n";
     $this->view->mkdir('container');
     $this->view->mkdir('container/shareddir');
     $this->view->mkdir('container/shareddir/subdir');
     $this->view->mkdir('container/shareddirrestricted');
     $this->view->mkdir('container/shareddirrestricted/subdir');
     $this->view->file_put_contents('container/shareddir/textfile.txt', $textData);
     $this->view->file_put_contents('container/shareddirrestricted/textfile1.txt', $textData);
     list($this->ownerStorage, $internalPath) = $this->view->resolvePath('');
     $this->ownerCache = $this->ownerStorage->getCache();
     $this->ownerStorage->getScanner()->scan('');
     // share "shareddir" with user2
     $fileinfo = $this->view->getFileInfo('container/shareddir');
     \OCP\Share::shareItem('folder', $fileinfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $fileinfo2 = $this->view->getFileInfo('container/shareddirrestricted');
     \OCP\Share::shareItem('folder', $fileinfo2['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 7);
     // login as user2
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // retrieve the shared storage
     $this->secondView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER2);
     list($this->sharedStorage, $internalPath) = $this->secondView->resolvePath('files/shareddir');
     list($this->sharedStorageRestrictedShare, $internalPath) = $this->secondView->resolvePath('files/shareddirrestricted');
     $this->sharedCache = $this->sharedStorage->getCache();
     $this->sharedCacheRestrictedShare = $this->sharedStorageRestrictedShare->getCache();
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:30,代码来源:permissions.php

示例3: testSizePropagationWhenRecipientChangesFile

 public function testSizePropagationWhenRecipientChangesFile()
 {
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $recipientView = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $ownerView = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $ownerView->mkdir('/sharedfolder/subfolder');
     $ownerView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'bar');
     $sharedFolderInfo = $ownerView->getFileInfo('/sharedfolder', false);
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $sharedFolderInfo);
     \OCP\Share::shareItem('folder', $sharedFolderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER1, 31);
     $ownerRootInfo = $ownerView->getFileInfo('', false);
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->assertTrue($recipientView->file_exists('/sharedfolder/subfolder/foo.txt'));
     $recipientRootInfo = $recipientView->getFileInfo('', false);
     // when file changed as recipient
     $recipientView->file_put_contents('/sharedfolder/subfolder/foo.txt', 'foobar');
     // size of recipient's root stays the same
     $newRecipientRootInfo = $recipientView->getFileInfo('', false);
     $this->assertEquals($recipientRootInfo->getSize(), $newRecipientRootInfo->getSize());
     // size of owner's root increases
     $this->loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $newOwnerRootInfo = $ownerView->getFileInfo('', false);
     $this->assertEquals($ownerRootInfo->getSize() + 3, $newOwnerRootInfo->getSize());
 }
开发者ID:evanjt,项目名称:core,代码行数:25,代码来源:sizepropagation.php

示例4: setUp

 protected function setUp()
 {
     $app = new Application();
     $this->container = $app->getContainer();
     $this->container['Config'] = $this->getMockBuilder('\\OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $this->container['AppName'] = 'files_sharing';
     $this->container['UserSession'] = $this->getMockBuilder('\\OC\\User\\Session')->disableOriginalConstructor()->getMock();
     $this->container['URLGenerator'] = $this->getMockBuilder('\\OC\\URLGenerator')->disableOriginalConstructor()->getMock();
     $this->urlGenerator = $this->container['URLGenerator'];
     $this->shareController = $this->container['ShareController'];
     // Store current user
     $this->oldUser = \OC_User::getUser();
     // Create a dummy user
     $this->user = \OC::$server->getSecureRandom()->getLowStrengthGenerator()->generate(12, ISecureRandom::CHAR_LOWER);
     \OC_User::createUser($this->user, $this->user);
     \OC_Util::tearDownFS();
     \OC_User::setUserId('');
     Filesystem::tearDown();
     \OC_User::setUserId($this->user);
     \OC_Util::setupFS($this->user);
     // Create a dummy shared file
     $view = new View('/' . $this->user . '/files');
     $view->file_put_contents('file1.txt', 'I am such an awesome shared file!');
     $this->token = \OCP\Share::shareItem(Filesystem::getFileInfo('file1.txt')->getType(), Filesystem::getFileInfo('file1.txt')->getId(), \OCP\Share::SHARE_TYPE_LINK, 'IAmPasswordProtected!', 1);
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:25,代码来源:sharecontroller.php

示例5: setUpShares

 /**
  * "user1" is the admin who shares a folder "sub1/sub2/folder" with "user2" and "user3"
  * "user2" receives the folder and puts it in "sub1/sub2/folder"
  * "user3" receives the folder and puts it in "sub1/sub2/folder"
  * "user2" reshares the subdir "sub1/sub2/folder/inside" with "user4"
  * "user4" puts the received "inside" folder into "sub1/sub2/inside" (this is to check if it propagates across multiple subfolders)
  */
 private function setUpShares()
 {
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4] = [];
     $this->rootView = new View('');
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
     $view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     $view1->mkdir('/sub1/sub2/folder/inside');
     $view1->mkdir('/directReshare');
     $view1->mkdir('/sub1/sub2/folder/other');
     $view1->mkdir('/sub1/sub2/folder/other');
     $view1->file_put_contents('/foo.txt', 'foobar');
     $view1->file_put_contents('/sub1/sub2/folder/file.txt', 'foobar');
     $view1->file_put_contents('/sub1/sub2/folder/inside/file.txt', 'foobar');
     $folderInfo = $view1->getFileInfo('/sub1/sub2/folder');
     $fileInfo = $view1->getFileInfo('/foo.txt');
     \OCP\Share::shareItem('file', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER3, 31);
     $folderInfo = $view1->getFileInfo('/directReshare');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1][''] = $view1->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1]['sub1'] = $view1->getFileInfo('sub1')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1]['sub1/sub2'] = $view1->getFileInfo('sub1/sub2')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
     $view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $view2->mkdir('/sub1/sub2');
     $view2->rename('/folder', '/sub1/sub2/folder');
     $insideInfo = $view2->getFileInfo('/sub1/sub2/folder/inside');
     \OCP\Share::shareItem('folder', $insideInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER4, 31);
     $folderInfo = $view2->getFileInfo('/directReshare');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER4, 31);
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2][''] = $view2->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2]['sub1'] = $view2->getFileInfo('sub1')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2]['sub1/sub2'] = $view2->getFileInfo('sub1/sub2')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER3);
     $view3 = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
     $view3->mkdir('/sub1/sub2');
     $view3->rename('/folder', '/sub1/sub2/folder');
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3][''] = $view3->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3]['sub1'] = $view3->getFileInfo('sub1')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3]['sub1/sub2'] = $view3->getFileInfo('sub1/sub2')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER4);
     $view4 = new View('/' . self::TEST_FILES_SHARING_API_USER4 . '/files');
     $view4->mkdir('/sub1/sub2');
     $view4->rename('/inside', '/sub1/sub2/inside');
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4][''] = $view4->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4]['sub1'] = $view4->getFileInfo('sub1')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4]['sub1/sub2'] = $view4->getFileInfo('sub1/sub2')->getId();
     foreach ($this->fileIds as $user => $ids) {
         $this->loginAsUser($user);
         foreach ($ids as $id) {
             $path = $this->rootView->getPath($id);
             $this->fileEtags[$id] = $this->rootView->getFileInfo($path)->getEtag();
         }
     }
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:66,代码来源:etagpropagation.php

示例6: setUp

 public function setUp()
 {
     parent::setUp();
     $this->userBackend = new \Test\Util\User\Dummy();
     \OC::$server->getUserManager()->registerBackend($this->userBackend);
     $this->ownerUid = $this->getUniqueID('owner_');
     $this->recipientUid = $this->getUniqueID('recipient_');
     $this->userBackend->createUser($this->ownerUid, '');
     $this->userBackend->createUser($this->recipientUid, '');
     $this->loginAsUser($this->ownerUid);
     Filesystem::mkdir('/foo');
     Filesystem::file_put_contents('/foo/bar.txt', 'asd');
     $fileId = Filesystem::getFileInfo('/foo/bar.txt')->getId();
     \OCP\Share::shareItem('file', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->recipientUid, 31);
     $this->loginAsUser($this->recipientUid);
     $this->assertTrue(Filesystem::file_exists('bar.txt'));
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:17,代码来源:locking.php

示例7: setUpShares

 /**
  * "user1" creates /test, /test/sub and shares with group1
  * "user2" (in group1) reshares /test with group2 and reshared /test/sub with group3
  * "user3" (in group 2)
  * "user4" (in group 3)
  */
 protected function setUpShares()
 {
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3] = [];
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4] = [];
     $this->rootView = new View('');
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
     $view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     $view1->mkdir('/test/sub');
     $folderInfo = $view1->getFileInfo('/test');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group1', 31);
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1][''] = $view1->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1]['test'] = $view1->getFileInfo('test')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER1]['test/sub'] = $view1->getFileInfo('test/sub')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER2);
     $view2 = new View('/' . self::TEST_FILES_SHARING_API_USER2 . '/files');
     $folderInfo = $view2->getFileInfo('/test');
     $subFolderInfo = $view2->getFileInfo('/test/sub');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group2', 31);
     \OCP\Share::shareItem('folder', $subFolderInfo->getId(), \OCP\Share::SHARE_TYPE_GROUP, 'group3', 31);
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2][''] = $view2->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2]['test'] = $view2->getFileInfo('test')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER2]['test/sub'] = $view2->getFileInfo('test/sub')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER3);
     $view3 = new View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3][''] = $view3->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3]['test'] = $view3->getFileInfo('test')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER3]['test/sub'] = $view3->getFileInfo('test/sub')->getId();
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER4);
     $view4 = new View('/' . self::TEST_FILES_SHARING_API_USER4 . '/files');
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4][''] = $view4->getFileInfo('')->getId();
     $this->fileIds[self::TEST_FILES_SHARING_API_USER4]['sub'] = $view4->getFileInfo('sub')->getId();
     foreach ($this->fileIds as $user => $ids) {
         $this->loginAsUser($user);
         foreach ($ids as $id) {
             $path = $this->rootView->getPath($id);
             $this->fileEtags[$id] = $this->rootView->getFileInfo($path)->getEtag();
         }
     }
 }
开发者ID:loulancn,项目名称:core,代码行数:47,代码来源:groupetagpropagation.php

示例8: setUp

 protected function setUp()
 {
     parent::setUp();
     $user = $this->getMockBuilder('\\OCP\\IUser')->disableOriginalConstructor()->getMock();
     $user->method('getUID')->willReturn(self::TEST_FILES_SHARING_API_USER1);
     $userSession = $this->getMockBuilder('\\OCP\\IUserSession')->disableOriginalConstructor()->getMock();
     $userSession->method('getUser')->willReturn(selF::TEST_FILES_SHARING_API_USER1);
     $this->propagationManager = $this->getMockBuilder('OCA\\Files_Sharing\\Propagation\\PropagationManager')->disableOriginalConstructor()->getMock();
     $this->groupManager = \OC::$server->getGroupManager();
     $this->groupPropagationManager = new GroupPropagationManager($userSession, $this->groupManager, $this->propagationManager);
     $this->groupPropagationManager->globalSetup();
     // since the sharing code is not mockable, we have to create a real folder
     $this->loginAsUser(self::TEST_FILES_SHARING_API_USER1);
     $view1 = new View('/' . self::TEST_FILES_SHARING_API_USER1 . '/files');
     $view1->mkdir('/folder');
     $this->fileInfo = $view1->getFileInfo('/folder');
     $this->recipientGroup = $this->groupManager->get(self::TEST_FILES_SHARING_API_GROUP1);
     $this->recipientUser = \OC::$server->getUserManager()->get(self::TEST_FILES_SHARING_API_USER3);
     Share::shareItem('folder', $this->fileInfo['fileid'], Share::SHARE_TYPE_GROUP, $this->recipientGroup->getGID(), \OCP\Constants::PERMISSION_READ);
     $this->loginAsUser($this->recipientUser->getUID());
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:21,代码来源:grouppropagationmanager.php

示例9: shareLinks

 public function shareLinks($data, $passwordInfo)
 {
     $tokens = array();
     for ($i = 0; $i < sizeof($data); $i++) {
         $itemType = $data[$i]['type'];
         $itemSource = $data[$i]['id'];
         $itemSourceName = $data[$i]['name'];
         $permissions = $data[$i]['permissions'];
         $shareType = \OCP\Share::SHARE_TYPE_LINK;
         $password = null;
         $passwordChanged = $passwordInfo['passwordChanged'] === 'true';
         if ($passwordInfo['password'] === '') {
             $passwordInfo = null;
         } else {
             $password = $passwordInfo['password'];
         }
         $token = \OCP\Share::shareItem($itemType, $itemSource, $shareType, $password, $permissions, $itemSourceName, !empty($_POST['expiration']) ? new \DateTime((string) $_POST['expiration']) : null, $passwordChanged);
         $tokens[$itemSourceName] = $token;
     }
     json_encode($tokens, JSON_PRETTY_PRINT);
     return new DataResponse($tokens);
 }
开发者ID:inwinstack,项目名称:owncloud-files_sharing_ext,代码行数:22,代码来源:sharecontroller.php

示例10: testpreUnlink

 /**
  * @medium
  */
 function testpreUnlink()
 {
     $fileInfo2 = \OC\Files\Filesystem::getFileInfo($this->folder);
     $result = \OCP\Share::shareItem('folder', $fileInfo2->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, 31);
     $this->assertTrue($result);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // one folder should be shared with the user
     $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
     $this->assertSame(1, count($sharedFolders));
     // move shared folder to 'localDir'
     \OC\Files\Filesystem::mkdir('localDir');
     $result = \OC\Files\Filesystem::rename($this->folder, '/localDir/' . $this->folder);
     $this->assertTrue($result);
     \OC\Files\Filesystem::unlink('localDir');
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     // after the parent directory was deleted the share should be unshared
     $sharedFolders = \OCP\Share::getItemsSharedWith('folder');
     $this->assertTrue(empty($sharedFolders));
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     // the folder for the owner should still exists
     $this->assertTrue(\OC\Files\Filesystem::file_exists($this->folder));
 }
开发者ID:samj1912,项目名称:repo,代码行数:25,代码来源:proxy.php

示例11: testGetPathByIdShareSubFolder

 public function testGetPathByIdShareSubFolder()
 {
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     \OC\Files\Filesystem::mkdir('foo');
     \OC\Files\Filesystem::mkdir('foo/bar');
     \OC\Files\Filesystem::touch('foo/bar/test.txt', 'bar');
     $folderInfo = \OC\Files\Filesystem::getFileInfo('foo');
     $fileInfo = \OC\Files\Filesystem::getFileInfo('foo/bar/test.txt');
     \OCP\Share::shareItem('folder', $folderInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_FILES_SHARING_API_USER2, \OCP\PERMISSION_ALL);
     \OC_Util::tearDownFS();
     self::loginHelper(self::TEST_FILES_SHARING_API_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists('/foo'));
     list($sharedStorage) = \OC\Files\Filesystem::resolvePath('/' . self::TEST_FILES_SHARING_API_USER2 . '/files/foo');
     /**
      * @var \OC\Files\Storage\Shared $sharedStorage
      */
     $sharedCache = $sharedStorage->getCache();
     $this->assertEquals('', $sharedCache->getPathById($folderInfo->getId()));
     $this->assertEquals('bar/test.txt', $sharedCache->getPathById($fileInfo->getId()));
 }
开发者ID:Romua1d,项目名称:core,代码行数:20,代码来源:cache.php

示例12: testShareWithOwnerError

 public function testShareWithOwnerError()
 {
     \OC_User::setUserId($this->user1);
     $view = new \OC\Files\View('/' . $this->user1 . '/');
     $view->mkdir('files/folder1');
     $fileInfo = $view->getFileInfo('files/folder1');
     $this->assertInstanceOf('\\OC\\Files\\FileInfo', $fileInfo);
     $fileId = $fileInfo->getId();
     $this->assertTrue(\OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_ALL), 'Failed asserting that user 1 successfully shared "test" with user 2.');
     \OC_User::setUserId($this->user2);
     try {
         \OCP\Share::shareItem('folder', $fileId, \OCP\Share::SHARE_TYPE_USER, $this->user1, \OCP\Constants::PERMISSION_ALL);
         $this->fail();
     } catch (\Exception $e) {
         $this->assertEquals('Sharing failed, because the user ' . $this->user1 . ' is the original sharer', $e->getMessage());
     }
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:17,代码来源:ShareTest.php

示例13: updatePassword

 /**
  * update password for public link share
  * @param array $share information about the share
  * @param array $params 'password'
  * @return \OC_OCS_Result
  */
 private static function updatePassword($share, $params)
 {
     $itemSource = $share['item_source'];
     $itemType = $share['item_type'];
     if ((int) $share['share_type'] !== \OCP\Share::SHARE_TYPE_LINK) {
         return new \OC_OCS_Result(null, 400, "password protection is only supported for public shares");
     }
     $shareWith = isset($params['_put']['password']) ? $params['_put']['password'] : null;
     if ($shareWith === '') {
         $shareWith = null;
     }
     $items = \OCP\Share::getItemShared($itemType, $itemSource);
     $checkExists = false;
     foreach ($items as $item) {
         if ($item['share_type'] === \OCP\Share::SHARE_TYPE_LINK) {
             $checkExists = true;
             $permissions = $item['permissions'];
         }
     }
     if (!$checkExists) {
         return new \OC_OCS_Result(null, 404, "share doesn't exists, can't change password");
     }
     try {
         $result = \OCP\Share::shareItem($itemType, $itemSource, \OCP\Share::SHARE_TYPE_LINK, $shareWith, $permissions);
     } catch (\Exception $e) {
         return new \OC_OCS_Result(null, 403, $e->getMessage());
     }
     if ($result) {
         return new \OC_OCS_Result();
     }
     return new \OC_OCS_Result(null, 404, "couldn't set password");
 }
开发者ID:heldernl,项目名称:owncloud8-extended,代码行数:38,代码来源:local.php

示例14: testExpireOldFilesShared

 /**
  * test expiration of files older then the max storage time defined for the trash
  * in this test we delete a shared file and check if both trash bins, the one from
  * the owner of the file and the one from the user who deleted the file get expired
  * correctly
  */
 public function testExpireOldFilesShared()
 {
     $currentTime = time();
     $folder = "trashTest-" . $currentTime . '/';
     $expiredDate = $currentTime - 3 * 24 * 60 * 60;
     // create some files
     \OC\Files\Filesystem::mkdir($folder);
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-1.txt', 'file1');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-2.txt', 'file2');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-3.txt', 'file3');
     \OC\Files\Filesystem::file_put_contents($folder . 'user1-4.txt', 'file4');
     //share user1-4.txt with user2
     $fileInfo = \OC\Files\Filesystem::getFileInfo($folder);
     $result = \OCP\Share::shareItem('folder', $fileInfo->getId(), \OCP\Share::SHARE_TYPE_USER, self::TEST_TRASHBIN_USER2, 31);
     $this->assertTrue($result);
     // delete them so that they end up in the trash bin
     \OC\Files\Filesystem::unlink($folder . 'user1-1.txt');
     \OC\Files\Filesystem::unlink($folder . 'user1-2.txt');
     \OC\Files\Filesystem::unlink($folder . 'user1-3.txt');
     $filesInTrash = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1, 'name');
     $this->assertSame(3, count($filesInTrash));
     // every second file will get a date in the past so that it will get expired
     $this->manipulateDeleteTime($filesInTrash, $this->trashRoot1, $expiredDate);
     // login as user2
     self::loginHelper(self::TEST_TRASHBIN_USER2);
     $this->assertTrue(\OC\Files\Filesystem::file_exists($folder . "user1-4.txt"));
     // create some files
     \OC\Files\Filesystem::file_put_contents('user2-1.txt', 'file1');
     \OC\Files\Filesystem::file_put_contents('user2-2.txt', 'file2');
     // delete them so that they end up in the trash bin
     \OC\Files\Filesystem::unlink('user2-1.txt');
     \OC\Files\Filesystem::unlink('user2-2.txt');
     $filesInTrashUser2 = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2, 'name');
     $this->assertSame(2, count($filesInTrashUser2));
     // every second file will get a date in the past so that it will get expired
     $this->manipulateDeleteTime($filesInTrashUser2, $this->trashRoot2, $expiredDate);
     \OC\Files\Filesystem::unlink($folder . 'user1-4.txt');
     $this->runCommands();
     $filesInTrashUser2AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER2);
     // user2-1.txt should have been expired
     $this->verifyArray($filesInTrashUser2AfterDelete, array('user2-2.txt', 'user1-4.txt'));
     self::loginHelper(self::TEST_TRASHBIN_USER1);
     // user1-1.txt and user1-3.txt should have been expired
     $filesInTrashUser1AfterDelete = OCA\Files_Trashbin\Helper::getTrashFiles('/', self::TEST_TRASHBIN_USER1);
     $this->verifyArray($filesInTrashUser1AfterDelete, array('user1-2.txt', 'user1-4.txt'));
 }
开发者ID:loulancn,项目名称:core,代码行数:52,代码来源:trashbin.php

示例15: testStoreVersionAsRecipient

 /**
  * Test whether versions are created when overwriting as share recipient
  */
 public function testStoreVersionAsRecipient()
 {
     $this->loginAsUser(self::TEST_VERSIONS_USER);
     \OC\Files\Filesystem::mkdir('folder');
     \OC\Files\Filesystem::file_put_contents('folder/test.txt', 'test file');
     $fileInfo = \OC\Files\Filesystem::getFileInfo('folder');
     \OCP\Share::shareItem('folder', $fileInfo['fileid'], \OCP\Share::SHARE_TYPE_USER, self::TEST_VERSIONS_USER2, \OCP\Constants::PERMISSION_ALL);
     $this->loginAsUser(self::TEST_VERSIONS_USER2);
     $this->createAndCheckVersions(\OC\Files\Filesystem::getView(), 'folder/test.txt');
 }
开发者ID:nem0xff,项目名称:core,代码行数:13,代码来源:versions.php


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