remote.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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::$server->getNotificationManager(),
  38. \OC_User::getUser()
  39. );
  40. return new \OC_OCS_Result($externalManager->getOpenShares());
  41. }
  42. /**
  43. * Accept a remote share
  44. *
  45. * @param array $params contains the shareID 'id' which should be accepted
  46. * @return \OC_OCS_Result
  47. */
  48. public static function acceptShare($params) {
  49. $externalManager = new Manager(
  50. \OC::$server->getDatabaseConnection(),
  51. Filesystem::getMountManager(),
  52. Filesystem::getLoader(),
  53. \OC::$server->getHTTPHelper(),
  54. \OC::$server->getNotificationManager(),
  55. \OC_User::getUser()
  56. );
  57. if ($externalManager->acceptShare($params['id'])) {
  58. return new \OC_OCS_Result();
  59. }
  60. return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
  61. }
  62. /**
  63. * Decline a remote share
  64. *
  65. * @param array $params contains the shareID 'id' which should be declined
  66. * @return \OC_OCS_Result
  67. */
  68. public static function declineShare($params) {
  69. $externalManager = new Manager(
  70. \OC::$server->getDatabaseConnection(),
  71. Filesystem::getMountManager(),
  72. Filesystem::getLoader(),
  73. \OC::$server->getHTTPHelper(),
  74. \OC::$server->getNotificationManager(),
  75. \OC_User::getUser()
  76. );
  77. if ($externalManager->declineShare($params['id'])) {
  78. return new \OC_OCS_Result();
  79. }
  80. return new \OC_OCS_Result(null, 404, "wrong share ID, share doesn't exist.");
  81. }
  82. }