Expire.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author Joas Schilling <coding@schilljs.com>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Robin Appelman <robin@icewind.nl>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. * @author Vincent Petry <vincent@nextcloud.com>
  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_Trashbin\Command;
  28. use OC\Command\FileAccess;
  29. use OCA\Files_Trashbin\Trashbin;
  30. use OCP\Command\ICommand;
  31. class Expire implements ICommand {
  32. use FileAccess;
  33. /**
  34. * @var string
  35. */
  36. private $user;
  37. /**
  38. * @param string $user
  39. */
  40. public function __construct($user) {
  41. $this->user = $user;
  42. }
  43. public function handle() {
  44. $userManager = \OC::$server->getUserManager();
  45. if (!$userManager->userExists($this->user)) {
  46. // User has been deleted already
  47. return;
  48. }
  49. \OC_Util::tearDownFS();
  50. \OC_Util::setupFS($this->user);
  51. Trashbin::expire($this->user);
  52. \OC_Util::tearDownFS();
  53. }
  54. }