/**
  * @param OutputInterface $output
  */
 private function restoreShares(OutputInterface $output)
 {
     $output->writeln("Restoring shares ...");
     $progress = new ProgressBar($output, count($this->shares));
     foreach ($this->shares as $share) {
         if ($share->getSharedWith() === $this->destinationUser) {
             // Unmount the shares before deleting, so we don't try to get the storage later on.
             $shareMountPoint = $this->mountManager->find('/' . $this->destinationUser . '/files' . $share->getTarget());
             if ($shareMountPoint) {
                 $this->mountManager->removeMount($shareMountPoint->getMountPoint());
             }
             $this->shareManager->deleteShare($share);
         } else {
             if ($share->getShareOwner() === $this->sourceUser) {
                 $share->setShareOwner($this->destinationUser);
             }
             if ($share->getSharedBy() === $this->sourceUser) {
                 $share->setSharedBy($this->destinationUser);
             }
             $this->shareManager->updateShare($share);
         }
         $progress->advance();
     }
     $progress->finish();
     $output->writeln('');
 }
Beispiel #2
0
 /**
  * Delete a share
  *
  * @param string $id
  * @return \OC_OCS_Result
  */
 public function deleteShare($id)
 {
     // Try both our default and our federated provider
     $share = null;
     try {
         $share = $this->shareManager->getShareById('ocinternal:' . $id);
     } catch (ShareNotFound $e) {
         //Ignore for now
         //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
     }
     // Could not find the share as internal share... maybe it is a federated share
     if ($share === null) {
         if (!$this->shareManager->outgoingServer2ServerSharesAllowed()) {
             return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
         }
         try {
             $share = $this->shareManager->getShareById('ocFederatedSharing:' . $id);
         } catch (ShareNotFound $e) {
             return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
         }
     }
     if (!$this->canAccessShare($share)) {
         return new \OC_OCS_Result(null, 404, 'could not delete share');
     }
     $this->shareManager->deleteShare($share);
     return new \OC_OCS_Result();
 }
Beispiel #3
0
 /**
  * Delete a share
  *
  * @param string $id
  * @return \OC_OCS_Result
  */
 public function deleteShare($id)
 {
     // Try both our default and our federated provider
     try {
         $share = $this->getShareById($id);
     } catch (ShareNotFound $e) {
         return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
     }
     if (!$this->canAccessShare($share)) {
         return new \OC_OCS_Result(null, 404, 'could not delete share');
     }
     $this->shareManager->deleteShare($share);
     return new \OC_OCS_Result();
 }
Beispiel #4
0
 function testGetFolderContentsWhenSubSubdirShared()
 {
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $rootFolder = \OC::$server->getUserFolder(self::TEST_FILES_SHARING_API_USER1);
     $node = $rootFolder->get('container/shareddir/subdir');
     $share = $this->shareManager->newShare();
     $share->setNode($node)->setShareType(\OCP\Share::SHARE_TYPE_USER)->setSharedWith(self::TEST_FILES_SHARING_API_USER3)->setSharedBy(self::TEST_FILES_SHARING_API_USER1)->setPermissions(\OCP\Constants::PERMISSION_ALL);
     $share = $this->shareManager->createShare($share);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER3);
     $thirdView = new \OC\Files\View('/' . self::TEST_FILES_SHARING_API_USER3 . '/files');
     $results = $thirdView->getDirectoryContent('/subdir');
     $this->verifyFiles(array(array('name' => 'another too.txt', 'path' => 'another too.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One'), array('name' => 'another.txt', 'path' => 'another.txt', 'mimetype' => 'text/plain', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One'), array('name' => 'not a text file.xml', 'path' => 'not a text file.xml', 'mimetype' => 'application/xml', 'uid_owner' => self::TEST_FILES_SHARING_API_USER1, 'displayname_owner' => 'User One')), $results);
     self::loginHelper(self::TEST_FILES_SHARING_API_USER1);
     $this->shareManager->deleteShare($share);
 }
Beispiel #5
0
 /**
  * Delete a share
  *
  * @param string $id
  * @return \OC_OCS_Result
  */
 public function deleteShare($id)
 {
     // Try both our default and our federated provider
     $share = null;
     try {
         $share = $this->shareManager->getShareById('ocinternal:' . $id);
     } catch (ShareNotFound $e) {
         //Ignore for now
         //return new \OC_OCS_Result(null, 404, 'wrong share ID, share doesn\'t exist.');
     }
     // Could not find the share as internal share... maybe it is a federated share
     if ($share === null) {
         return \OCA\Files_Sharing\API\Local::deleteShare(['id' => $id]);
     }
     if (!$this->canAccessShare($share)) {
         return new \OC_OCS_Result(null, 404, 'could not delete share');
     }
     $this->shareManager->deleteShare($share);
     return new \OC_OCS_Result();
 }
Beispiel #6
0
 /**
  * @param OutputInterface $output
  */
 private function restoreShares(OutputInterface $output)
 {
     $output->writeln("Restoring shares ...");
     $progress = new ProgressBar($output, count($this->shares));
     foreach ($this->shares as $share) {
         if ($share->getSharedWith() === $this->destinationUser) {
             $this->shareManager->deleteShare($share);
         } else {
             if ($share->getShareOwner() === $this->sourceUser) {
                 $share->setShareOwner($this->destinationUser);
             }
             if ($share->getSharedBy() === $this->sourceUser) {
                 $share->setSharedBy($this->destinationUser);
             }
             $this->shareManager->updateShare($share);
         }
         $progress->advance();
     }
     $progress->finish();
     $output->writeln('');
 }
 /**
  * Delete a share
  *
  * @param string $id
  * @return \OC_OCS_Result
  */
 public function deleteShare($id)
 {
     if (!$this->shareManager->shareApiEnabled()) {
         return new \OC_OCS_Result(null, 404, $this->l->t('Share API is disabled'));
     }
     try {
         $share = $this->getShareById($id);
     } catch (ShareNotFound $e) {
         return new \OC_OCS_Result(null, 404, $this->l->t('Wrong share ID, share doesn\'t exist'));
     }
     try {
         $share->getNode()->lock(ILockingProvider::LOCK_SHARED);
     } catch (LockedException $e) {
         return new \OC_OCS_Result(null, 404, 'could not delete share');
     }
     if (!$this->canAccessShare($share)) {
         $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
         return new \OC_OCS_Result(null, 404, $this->l->t('Could not delete share'));
     }
     $this->shareManager->deleteShare($share);
     $share->getNode()->unlock(ILockingProvider::LOCK_SHARED);
     return new \OC_OCS_Result();
 }