You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rename.php 1.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * @author Christopher Schäpers <kondou@ts.unde.re>
  4. * @author Frank Karlitschek <frank@owncloud.org>
  5. * @author Jakob Sack <mail@jakobsack.de>
  6. * @author Jörn Friedrich Dreyer <jfd@butonic.de>
  7. * @author Lukas Reschke <lukas@owncloud.com>
  8. * @author Morris Jobke <hey@morrisjobke.de>
  9. * @author Robin Appelman <icewind@owncloud.com>
  10. * @author Vincent Petry <pvince81@owncloud.com>
  11. *
  12. * @copyright Copyright (c) 2015, ownCloud, Inc.
  13. * @license AGPL-3.0
  14. *
  15. * This code is free software: you can redistribute it and/or modify
  16. * it under the terms of the GNU Affero General Public License, version 3,
  17. * as published by the Free Software Foundation.
  18. *
  19. * This program is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Affero General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Affero General Public License, version 3,
  25. * along with this program. If not, see <http://www.gnu.org/licenses/>
  26. *
  27. */
  28. OCP\JSON::checkLoggedIn();
  29. OCP\JSON::callCheck();
  30. \OC::$server->getSession()->close();
  31. $l10n = \OC::$server->getL10N('files');
  32. $files = new \OCA\Files\App(
  33. \OC\Files\Filesystem::getView(),
  34. \OC::$server->getL10N('files')
  35. );
  36. try {
  37. $result = $files->rename(
  38. isset($_GET['dir']) ? (string)$_GET['dir'] : '',
  39. isset($_GET['file']) ? (string)$_GET['file'] : '',
  40. isset($_GET['newname']) ? (string)$_GET['newname'] : ''
  41. );
  42. } catch (\Exception $e) {
  43. $result = [
  44. 'success' => false,
  45. 'data' => [
  46. 'message' => $e->getMessage()
  47. ]
  48. ];
  49. }
  50. if($result['success'] === true){
  51. OCP\JSON::success(['data' => $result['data']]);
  52. } else {
  53. OCP\JSON::error(['data' => $result['data']]);
  54. }