예제 #1
0
파일: manager.php 프로젝트: matt407/core
 /**
  * Check for pre share requirements for group shares
  *
  * @param IShare $share
  * @throws \Exception
  */
 protected function groupCreateChecks(IShare $share)
 {
     // Verify if the user can share with this group
     if ($this->shareWithGroupMembersOnly()) {
         if (!$share->getSharedWith()->inGroup($share->getSharedBy())) {
             throw new \Exception('Only sharing within your own groups is allowed');
         }
     }
     /*
      * TODO: Could be costly, fix
      *
      * Also this is not what we want in the future.. then we want to squash identical shares.
      */
     $provider = $this->factory->getProviderForType(\OCP\Share::SHARE_TYPE_GROUP);
     $existingShares = $provider->getSharesByPath($share->getPath());
     foreach ($existingShares as $existingShare) {
         if ($existingShare->getFullId() === $share->getFullId()) {
             continue;
         }
         if ($existingShare->getSharedWith() === $share->getSharedWith()) {
             throw new \Exception('Path already shared with this group');
         }
     }
 }