Hooks.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Bjoern Schiessle <bjoern@schiessle.org>
  6. * @author Björn Schießle <bjoern@schiessle.org>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <robin@icewind.nl>
  10. * @author Roeland Jago Douma <roeland@famdouma.nl>
  11. *
  12. * @license AGPL-3.0
  13. *
  14. * This code is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Affero General Public License, version 3,
  16. * as published by the Free Software Foundation.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU Affero General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU Affero General Public License, version 3,
  24. * along with this program. If not, see <http://www.gnu.org/licenses/>
  25. *
  26. */
  27. namespace OCA\Files_Sharing;
  28. use OC\Files\Filesystem;
  29. class Hooks {
  30. public static function deleteUser($params) {
  31. $manager = \OC::$server->get(External\Manager::class);
  32. $manager->removeUserShares($params['uid']);
  33. }
  34. public static function unshareChildren($params) {
  35. $path = Filesystem::getView()->getAbsolutePath($params['path']);
  36. $view = new \OC\Files\View('/');
  37. // find share mount points within $path and unmount them
  38. $mountManager = \OC\Files\Filesystem::getMountManager();
  39. $mountedShares = $mountManager->findIn($path);
  40. foreach ($mountedShares as $mount) {
  41. if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
  42. $mountPoint = $mount->getMountPoint();
  43. $view->unlink($mountPoint);
  44. }
  45. }
  46. }
  47. }