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


PHP Share::unshareFromSelf方法代码示例

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


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

示例1: unshareStorage

 /**
  * unshare complete storage, also the grouped shares
  *
  * @return bool
  */
 public function unshareStorage()
 {
     $result = true;
     if (!empty($this->share['grouped'])) {
         foreach ($this->share['grouped'] as $share) {
             $result = $result && \OCP\Share::unshareFromSelf($share['item_type'], $share['file_target']);
         }
     }
     $result = $result && \OCP\Share::unshareFromSelf($this->getItemType(), $this->getMountPoint());
     return $result;
 }
开发者ID:GrumpyCrouton,项目名称:core,代码行数:16,代码来源:sharedstorage.php

示例2: testShareWithUser


//.........这里部分代码省略.........
     }
     // Unshare
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2));
     // Attempt reshare without share permission
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user2);
     $message = 'Sharing test.txt failed, because resharing is not allowed';
     try {
         \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ);
         $this->fail('Exception was expected: ' . $message);
     } catch (\Exception $exception) {
         $this->assertEquals($message, $exception->getMessage());
     }
     // Owner grants share and update permission
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE | \OCP\Constants::PERMISSION_SHARE));
     // Attempt reshare with escalated permissions
     \OC_User::setUserId($this->user2);
     $message = 'Sharing test.txt failed, because the permissions exceed permissions granted to ' . $this->user2;
     try {
         \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
         $this->fail('Exception was expected: ' . $message);
     } catch (\Exception $exception) {
         $this->assertEquals($message, $exception->getMessage());
     }
     // Valid reshare
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE));
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemShared('test', 'test.txt', Backend::FORMAT_SOURCE));
     \OC_User::setUserId($this->user3);
     $this->assertEquals(array('test.txt'), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_SOURCE));
     $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_UPDATE), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
     // Attempt to escalate permissions
     \OC_User::setUserId($this->user2);
     $message = 'Setting permissions for test.txt failed, because the permissions exceed permissions granted to ' . $this->user2;
     try {
         \OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_DELETE);
         $this->fail('Exception was expected: ' . $message);
     } catch (\Exception $exception) {
         $this->assertEquals($message, $exception->getMessage());
     }
     // Remove update permission
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array(\OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
     \OC_User::setUserId($this->user3);
     $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
     // Remove share permission
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array(\OCP\Constants::PERMISSION_READ), \OCP\Share::getItemSharedWith('test', 'test.txt', Backend::FORMAT_PERMISSIONS));
     \OC_User::setUserId($this->user3);
     $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
     // Reshare again, and then have owner unshare
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::setPermissions('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ | \OCP\Constants::PERMISSION_SHARE));
     \OC_User::setUserId($this->user2);
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user3, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::unshare('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2));
     \OC_User::setUserId($this->user2);
     $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
     \OC_User::setUserId($this->user3);
     $this->assertSame(array(), \OCP\Share::getItemSharedWith('test', 'test.txt'));
     // Attempt target conflict
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user3);
     $this->assertTrue(\OCP\Share::shareItem('test', 'share.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user2);
     $to_test = \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET);
     $this->assertEquals(2, count($to_test));
     $this->assertTrue(in_array('test.txt', $to_test));
     $this->assertTrue(in_array('test1.txt', $to_test));
     // Unshare from self
     $this->assertTrue(\OCP\Share::unshareFromSelf('test', 'test.txt'));
     $this->assertEquals(array('test1.txt'), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
     // Unshare from self via source
     $this->assertTrue(\OCP\Share::unshareFromSelf('test', 'share.txt', true));
     $this->assertEquals(array(), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
     \OC_User::setUserId($this->user1);
     $this->assertTrue(\OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user3);
     $this->assertTrue(\OCP\Share::shareItem('test', 'share.txt', \OCP\Share::SHARE_TYPE_USER, $this->user2, \OCP\Constants::PERMISSION_READ));
     \OC_User::setUserId($this->user2);
     $to_test = \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET);
     $this->assertEquals(2, count($to_test));
     $this->assertTrue(in_array('test.txt', $to_test));
     $this->assertTrue(in_array('test1.txt', $to_test));
     // Remove user
     \OC_User::setUserId($this->user1);
     $user = \OC::$server->getUserManager()->get($this->user1);
     if ($user !== null) {
         $user->delete();
     }
     \OC_User::setUserId($this->user2);
     $this->assertEquals(array('test1.txt'), \OCP\Share::getItemsSharedWith('test', Backend::FORMAT_TARGET));
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:101,代码来源: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

示例4: unlink

 public function unlink($path)
 {
     // Delete the file if DELETE permission is granted
     if ($source = $this->getSourcePath($path)) {
         if ($this->isDeletable($path)) {
             list($storage, $internalPath) = \OC\Files\Filesystem::resolvePath($source);
             return $storage->unlink($internalPath);
         } else {
             if (dirname($path) == '/' || dirname($path) == '.') {
                 // Unshare the file from the user if in the root of the Shared folder
                 if ($this->is_dir($path)) {
                     $itemType = 'folder';
                 } else {
                     $itemType = 'file';
                 }
                 return \OCP\Share::unshareFromSelf($itemType, $path);
             }
         }
     }
     return false;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:21,代码来源:sharedstorage.php

示例5: removeMount

 /**
  * Remove the mount points
  *
  * @return bool
  */
 public function removeMount()
 {
     $mountManager = \OC\Files\Filesystem::getMountManager();
     $storage = $this->getStorage();
     $result = \OCP\Share::unshareFromSelf($storage->getItemType(), $storage->getMountPoint());
     $mountManager->removeMount($this->mountPoint);
     return $result;
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:13,代码来源:sharedmount.php


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