當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。