rename.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. *
  11. * @copyright Copyright (c) 2015, ownCloud, Inc.
  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. OCP\JSON::checkLoggedIn();
  28. OCP\JSON::callCheck();
  29. \OC::$server->getSession()->close();
  30. $files = new \OCA\Files\App(
  31. \OC\Files\Filesystem::getView(),
  32. \OC::$server->getL10N('files')
  33. );
  34. $result = $files->rename(
  35. isset($_GET['dir']) ? (string)$_GET['dir'] : '',
  36. isset($_GET['file']) ? (string)$_GET['file'] : '',
  37. isset($_GET['newname']) ? (string)$_GET['newname'] : ''
  38. );
  39. if($result['success'] === true){
  40. OCP\JSON::success(['data' => $result['data']]);
  41. } else {
  42. OCP\JSON::error(['data' => $result['data']]);
  43. }