hooks.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * ownCloud - trash bin
  4. *
  5. * @author Bjoern Schiessle
  6. * @copyright 2013 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. /**
  23. * This class contains all hooks.
  24. */
  25. namespace OCA\Files_Trashbin;
  26. class Hooks {
  27. /**
  28. * @brief Copy files to trash bin
  29. * @param array
  30. *
  31. * This function is connected to the delete signal of OC_Filesystem
  32. * to copy the file to the trash bin
  33. */
  34. public static function remove_hook($params) {
  35. if ( \OCP\App::isEnabled('files_trashbin') ) {
  36. $path = $params['path'];
  37. Trashbin::move2trash($path);
  38. }
  39. }
  40. /**
  41. * @brief clean up user specific settings if user gets deleted
  42. * @param array with uid
  43. *
  44. * This function is connected to the pre_deleteUser signal of OC_Users
  45. * to remove the used space for the trash bin stored in the database
  46. */
  47. public static function deleteUser_hook($params) {
  48. if( \OCP\App::isEnabled('files_trashbin') ) {
  49. $uid = $params['uid'];
  50. Trashbin::deleteUser($uid);
  51. }
  52. }
  53. public static function post_write_hook($params) {
  54. Trashbin::resizeTrash(\OCP\User::getUser());
  55. }
  56. }