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


PHP Share::getItemsSharedWithUser方法代码示例

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


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

示例1: generateTarget

 /**
  * create unique target
  * @param string $filePath
  * @param string $shareWith
  * @param string $exclude
  * @return string
  */
 public function generateTarget($filePath, $shareWith, $exclude = null)
 {
     $shareFolder = \OCA\Files_Sharing\Helper::getShareFolder();
     $target = \OC\Files\Filesystem::normalizePath($shareFolder . '/' . basename($filePath));
     // for group shares we return the target right away
     if ($shareWith === false) {
         return $target;
     }
     \OC\Files\Filesystem::initMountPoints($shareWith);
     $view = new \OC\Files\View('/' . $shareWith . '/files');
     if (!$view->is_dir($shareFolder)) {
         $dir = '';
         $subdirs = explode('/', $shareFolder);
         foreach ($subdirs as $subdir) {
             $dir = $dir . '/' . $subdir;
             if (!$view->is_dir($dir)) {
                 $view->mkdir($dir);
             }
         }
     }
     $excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
     if (is_array($exclude)) {
         $excludeList = array_merge($excludeList, $exclude);
     }
     return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
 }
开发者ID:Combustible,项目名称:core,代码行数:33,代码来源:file.php

示例2: generateTarget

 public function generateTarget($itemSource, $shareWith, $exclude = null)
 {
     // Always make target be test.txt to cause conflicts
     if (substr($itemSource, 0, strlen('test')) !== 'test') {
         $target = "test.txt";
     } else {
         $target = $itemSource;
     }
     $shares = \OCP\Share::getItemsSharedWithUser('test', $shareWith);
     $knownTargets = array();
     foreach ($shares as $share) {
         $knownTargets[] = $share['item_target'];
     }
     if (in_array($target, $knownTargets)) {
         $pos = strrpos($target, '.');
         $name = substr($target, 0, $pos);
         $ext = substr($target, $pos);
         $append = '';
         $i = 1;
         while (in_array($name . $append . $ext, $knownTargets)) {
             $append = $i;
             $i++;
         }
         $target = $name . $append . $ext;
     }
     return $target;
 }
开发者ID:Romua1d,项目名称:core,代码行数:27,代码来源:backend.php

示例3: getMountsForUser

 /**
  * Get all mountpoints applicable for the user and check for shares where we need to update the etags
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $storageFactory
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
     $shares = array_filter($shares, function ($share) {
         return $share['permissions'] > 0;
     });
     $shares = array_map(function ($share) use($user, $storageFactory) {
         return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('share' => $share, 'user' => $user->getUID()), $storageFactory);
     }, $shares);
     // array_filter removes the null values from the array
     return array_filter($shares);
 }
开发者ID:evanjt,项目名称:core,代码行数:19,代码来源:mountprovider.php

示例4: generateTarget

 /**
  * create unique target
  * @param string $filePath
  * @param string $shareWith
  * @param string $exclude
  * @return string
  */
 public function generateTarget($filePath, $shareWith, $exclude = null)
 {
     $target = '/' . basename($filePath);
     // for group shares we return the target right away
     if ($shareWith === false) {
         return $target;
     }
     \OC\Files\Filesystem::initMountPoints($shareWith);
     $view = new \OC\Files\View('/' . $shareWith . '/files');
     $excludeList = \OCP\Share::getItemsSharedWithUser('file', $shareWith, self::FORMAT_TARGET_NAMES);
     if (is_array($exclude)) {
         $excludeList = array_merge($excludeList, $exclude);
     }
     return \OCA\Files_Sharing\Helper::generateUniqueTarget($target, $excludeList, $view);
 }
开发者ID:olucao,项目名称:owncloud-core,代码行数:22,代码来源:file.php

示例5: getMountsForUser

 /**
  * Get all mountpoints applicable for the user and check for shares where we need to update the etags
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $storageFactory
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
     $propagator = $this->propagationManager->getSharePropagator($user->getUID());
     $propagator->propagateDirtyMountPoints($shares);
     $shares = array_filter($shares, function ($share) {
         return $share['permissions'] > 0;
     });
     $shares = array_map(function ($share) use($user, $storageFactory) {
         // for updating etags for the share owner when we make changes to this share.
         $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']);
         return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagationManager' => $this->propagationManager, 'propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory);
     }, $shares);
     // array_filter removes the null values from the array
     return array_filter($shares);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:23,代码来源:mountprovider.php

示例6: getMountsForUser

 /**
  * Get all mountpoints applicable for the user and check for shares where we need to update the etags
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $storageFactory
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
     $propagator = $this->propagationManager->getSharePropagator($user->getUID());
     $propagator->propagateDirtyMountPoints($shares);
     $shares = array_filter($shares, function ($share) {
         return $share['permissions'] > 0;
     });
     return array_map(function ($share) use($user, $storageFactory) {
         Filesystem::initMountPoints($share['uid_owner']);
         // for updating etags for the share owner when we make changes to this share.
         $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']);
         // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share)
         $this->propagationManager->listenToOwnerChanges($share['uid_owner'], $user->getUID());
         return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory);
     }, $shares);
 }
开发者ID:brunomilet,项目名称:owncloud-core,代码行数:24,代码来源:mountprovider.php

示例7: generateTarget

 /**
  * Generate a unique target for the item
  * @param string $itemType
  * @param string $itemSource
  * @param int $shareType SHARE_TYPE_USER, SHARE_TYPE_GROUP, or SHARE_TYPE_LINK
  * @param string $shareWith User or group the item is being shared with
  * @param string $uidOwner User that is the owner of shared item
  * @param string $suggestedTarget The suggested target originating from a reshare (optional)
  * @param int $groupParent The id of the parent group share (optional)
  * @throws \Exception
  * @return string Item target
  */
 public static function generateTarget($itemType, $itemSource, $shareType, $shareWith, $uidOwner, $suggestedTarget = null, $groupParent = null)
 {
     // FIXME: $uidOwner and $groupParent seems to be unused
     $backend = \OC\Share\Share::getBackend($itemType);
     if ($shareType == self::SHARE_TYPE_LINK) {
         if (isset($suggestedTarget)) {
             return $suggestedTarget;
         }
         return $backend->generateTarget($itemSource, false);
     } else {
         if ($itemType == 'file' || $itemType == 'folder') {
             $column = 'file_target';
             $columnSource = 'file_source';
         } else {
             $column = 'item_target';
             $columnSource = 'item_source';
         }
         if ($shareType == self::SHARE_TYPE_USER) {
             // Share with is a user, so set share type to user and groups
             $shareType = self::$shareTypeUserAndGroups;
         }
         $exclude = array();
         $result = \OCP\Share::getItemsSharedWithUser($itemType, $shareWith);
         foreach ($result as $row) {
             if ($row['permissions'] > 0) {
                 $exclude[] = $row[$column];
             }
         }
         // Check if suggested target exists first
         if (!isset($suggestedTarget)) {
             $suggestedTarget = $itemSource;
         }
         if ($shareType == self::SHARE_TYPE_GROUP) {
             $target = $backend->generateTarget($suggestedTarget, false, $exclude);
         } else {
             $target = $backend->generateTarget($suggestedTarget, $shareWith, $exclude);
         }
         return $target;
     }
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:52,代码来源:helper.php

示例8: getMountsForUser

 /**
  * Get all mountpoints applicable for the user and check for shares where we need to update the etags
  *
  * @param \OCP\IUser $user
  * @param \OCP\Files\Storage\IStorageFactory $storageFactory
  * @return \OCP\Files\Mount\IMountPoint[]
  */
 public function getMountsForUser(IUser $user, IStorageFactory $storageFactory)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $user->getUID());
     $propagator = $this->propagationManager->getSharePropagator($user->getUID());
     $propagator->propagateDirtyMountPoints($shares);
     $shares = array_filter($shares, function ($share) {
         return $share['permissions'] > 0;
     });
     $shares = array_map(function ($share) use($user, $storageFactory) {
         try {
             Filesystem::initMountPoints($share['uid_owner']);
         } catch (NoUserException $e) {
             \OC::$server->getLogger()->warning('The user \'' . $share['uid_owner'] . '\' of share with ID \'' . $share['id'] . '\' can\'t be retrieved.', array('app' => 'files_sharing'));
             return null;
         }
         // for updating etags for the share owner when we make changes to this share.
         $ownerPropagator = $this->propagationManager->getChangePropagator($share['uid_owner']);
         // for updating our etags when changes are made to the share from the owners side (probably indirectly by us trough another share)
         $this->propagationManager->listenToOwnerChanges($share['uid_owner'], $user->getUID());
         return new SharedMount('\\OC\\Files\\Storage\\Shared', '/' . $user->getUID() . '/' . $share['file_target'], array('propagator' => $ownerPropagator, 'share' => $share, 'user' => $user->getUID()), $storageFactory);
     }, $shares);
     // array_filter removes the null values from the array
     return array_filter($shares);
 }
开发者ID:alfrescoo,项目名称:core,代码行数:31,代码来源:mountprovider.php

示例9: testGetShareSubItemsWhenUserNotInGroup

 public function testGetShareSubItemsWhenUserNotInGroup()
 {
     \OCP\Share::shareItem('test', 'test.txt', \OCP\Share::SHARE_TYPE_GROUP, $this->group1, \OCP\Constants::PERMISSION_READ);
     $result = \OCP\Share::getItemsSharedWithUser('test', $this->user2);
     $this->assertCount(1, $result);
     $groupShareId = array_keys($result)[0];
     // remove user from group
     $userObject = \OC::$server->getUserManager()->get($this->user2);
     \OC::$server->getGroupManager()->get($this->group1)->removeUser($userObject);
     $result = \OCP\Share::getItemsSharedWithUser('test', $this->user2);
     $this->assertCount(0, $result);
     // test with buggy data
     $qb = \OC::$server->getDatabaseConnection()->getQueryBuilder();
     $qb->insert('share')->values(['share_type' => $qb->expr()->literal(2), 'share_with' => $qb->expr()->literal($this->user2), 'parent' => $qb->expr()->literal($groupShareId), 'uid_owner' => $qb->expr()->literal($this->user1), 'item_type' => $qb->expr()->literal('test'), 'item_source' => $qb->expr()->literal('test.txt'), 'item_target' => $qb->expr()->literal('test.txt'), 'file_target' => $qb->expr()->literal('test2.txt'), 'permissions' => $qb->expr()->literal(1), 'stime' => $qb->expr()->literal(time())])->execute();
     $result = \OCP\Share::getItemsSharedWithUser('test', $this->user2);
     $this->assertCount(0, $result);
     $qb->delete('share')->execute();
 }
开发者ID:rchicoli,项目名称:owncloud-core,代码行数:18,代码来源:ShareTest.php

示例10: setup

 public static function setup($options)
 {
     $shares = \OCP\Share::getItemsSharedWithUser('file', $options['user']);
     $manager = Filesystem::getMountManager();
     $loader = Filesystem::getLoader();
     if (!\OCP\User::isLoggedIn() || \OCP\User::getUser() != $options['user'] || $shares) {
         foreach ($shares as $share) {
             // don't mount shares where we have no permissions
             if ($share['permissions'] > 0) {
                 $mount = new SharedMount('\\OC\\Files\\Storage\\Shared', $options['user_dir'] . '/' . $share['file_target'], array('share' => $share, 'user' => $options['user']), $loader);
                 $manager->addMount($mount);
             }
         }
     }
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:15,代码来源:sharedstorage.php

示例11: listAll

 /**
  * {@inheritDoc}
  */
 public function listAll($userId)
 {
     return array_merge(Share::getItemsSharedWithUser('calendar', $userId, ShareTypes::ENTITYLIST), Share::getItemsShared('object', ShareTypes::GROUPEDLIST));
 }
开发者ID:amin-hedayati,项目名称:calendar-rework,代码行数:7,代码来源:calendar.php

示例12: getUserShares

 private function getUserShares($targetUserId)
 {
     return \OCP\Share::getItemsSharedWithUser('file', $targetUserId);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:4,代码来源:grouppropagationmanager.php


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