remote.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @author Joas Schilling <nickvergessen@owncloud.com>
  4. *
  5. * @copyright Copyright (c) 2015, ownCloud, Inc.
  6. * @license AGPL-3.0
  7. *
  8. * This code is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License, version 3,
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License, version 3,
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>
  19. *
  20. */
  21. namespace OCA\Files_Sharing\API;
  22. use OC\Files\Filesystem;
  23. use OCA\Files_Sharing\External\Manager;
  24. class Remote {
  25. /**
  26. * Accept a remote share
  27. *
  28. * @param array $params contains the shareID 'id' which should be accepted
  29. * @return \OC_OCS_Result
  30. */
  31. public static function getOpenShares($params) {
  32. $externalManager = new Manager(
  33. \OC::$server->getDatabaseConnection(),
  34. Filesystem::getMountManager(),
  35. Filesystem::getLoader(),
  36. \OC::$server->getHTTPHelper(),
  37. \OC_User::getUser()
  38. );
  39. return new \OC_OCS_Result($externalManager->getOpenShares());
  40. }
  41. /**
  42. * Accept a remote share
  43. *
  44. * @param array $params contains the shareID 'id' which should be accepted
  45. * @return \OC_OCS_Result
  46. */
  47. public static function acceptShare($params) {
  48. $externalManager = new Manager(
  49. \OC::$server->getDatabaseConnection(),
  50. Filesystem::getMountManager(),
  51. Filesystem::getLoader(),
  52. \OC::$server->getHTTPHelper(),
  53. \OC_User::getUser()
  54. );
  55. if ($externalManager->acceptShare($params['id'])) {
  56. return new \OC_OCS_Result();
  57. }
  58. return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
  59. }
  60. /**
  61. * Decline a remote share
  62. *
  63. * @param array $params contains the shareID 'id' which should be declined
  64. * @return \OC_OCS_Result
  65. */
  66. public static function declineShare($params) {
  67. $externalManager = new Manager(
  68. \OC::$server->getDatabaseConnection(),
  69. Filesystem::getMountManager(),
  70. Filesystem::getLoader(),
  71. \OC::$server->getHTTPHelper(),
  72. \OC_User::getUser()
  73. );
  74. if ($externalManager->declineShare($params['id'])) {
  75. return new \OC_OCS_Result();
  76. }
  77. return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
  78. }
  79. }