1
0

Hooks.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Björn Schießle <bjoern@schiessle.org>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Lukas Reschke <lukas@statuscode.ch>
  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. use OCA\FederatedFileSharing\DiscoveryManager;
  30. class Hooks {
  31. public static function deleteUser($params) {
  32. $manager = new External\Manager(
  33. \OC::$server->getDatabaseConnection(),
  34. \OC\Files\Filesystem::getMountManager(),
  35. \OC\Files\Filesystem::getLoader(),
  36. \OC::$server->getHTTPClientService(),
  37. \OC::$server->getNotificationManager(),
  38. \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
  39. \OC::$server->getCloudFederationProviderManager(),
  40. \OC::$server->getCloudFederationFactory(),
  41. \OC::$server->getGroupManager(),
  42. \OC::$server->getUserManager(),
  43. $params['uid']);
  44. $manager->removeUserShares($params['uid']);
  45. }
  46. public static function unshareChildren($params) {
  47. $path = Filesystem::getView()->getAbsolutePath($params['path']);
  48. $view = new \OC\Files\View('/');
  49. // find share mount points within $path and unmount them
  50. $mountManager = \OC\Files\Filesystem::getMountManager();
  51. $mountedShares = $mountManager->findIn($path);
  52. foreach ($mountedShares as $mount) {
  53. if ($mount->getStorage()->instanceOfStorage(ISharedStorage::class)) {
  54. $mountPoint = $mount->getMountPoint();
  55. $view->unlink($mountPoint);
  56. }
  57. }
  58. }
  59. }