proxy.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * ownCloud
  4. *
  5. * @author Bjoern Schiessle
  6. * @copyright 2014 Bjoern Schiessle <schiessle@owncloud.com>
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public
  19. * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. namespace OCA\Files\Share;
  23. use OCA\Files_Sharing\Helper;
  24. class Proxy extends \OC_FileProxy {
  25. /**
  26. * check if the deleted folder contains share mount points and unshare them
  27. *
  28. * @param string $path
  29. */
  30. public function preUnlink($path) {
  31. $this->unshareChildren($path);
  32. }
  33. /**
  34. * check if the deleted folder contains share mount points and unshare them
  35. *
  36. * @param string $path
  37. */
  38. public function preRmdir($path) {
  39. $this->unshareChildren($path);
  40. }
  41. /**
  42. * unshare shared items below the deleted folder
  43. *
  44. * @param string $path
  45. */
  46. private function unshareChildren($path) {
  47. $view = new \OC\Files\View('/');
  48. // find share mount points within $path and unmount them
  49. $mountManager = \OC\Files\Filesystem::getMountManager();
  50. $mountedShares = $mountManager->findIn($path);
  51. foreach ($mountedShares as $mount) {
  52. if ($mount->getStorage()->instanceOfStorage('OCA\Files_Sharing\ISharedStorage')) {
  53. $mountPoint = $mount->getMountPoint();
  54. $view->unlink($mountPoint);
  55. }
  56. }
  57. }
  58. }