UploadFolder.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Lukas Reschke <lukas@statuscode.ch>
  6. * @author Thomas Müller <thomas.mueller@tmit.eu>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCA\DAV\Upload;
  24. use OCA\DAV\Connector\Sabre\Directory;
  25. use Sabre\DAV\Exception\Forbidden;
  26. use Sabre\DAV\ICollection;
  27. class UploadFolder implements ICollection {
  28. private $node;
  29. function __construct(Directory $node) {
  30. $this->node = $node;
  31. }
  32. function createFile($name, $data = null) {
  33. // TODO: verify name - should be a simple number
  34. $this->node->createFile($name, $data);
  35. }
  36. function createDirectory($name) {
  37. throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
  38. }
  39. function getChild($name) {
  40. if ($name === '.file') {
  41. return new FutureFile($this->node, '.file');
  42. }
  43. return $this->node->getChild($name);
  44. }
  45. function getChildren() {
  46. $children = $this->node->getChildren();
  47. $children[] = new FutureFile($this->node, '.file');
  48. return $children;
  49. }
  50. function childExists($name) {
  51. if ($name === '.file') {
  52. return true;
  53. }
  54. return $this->node->childExists($name);
  55. }
  56. function delete() {
  57. $this->node->delete();
  58. }
  59. function getName() {
  60. return $this->node->getName();
  61. }
  62. function setName($name) {
  63. throw new Forbidden('Permission denied to rename this folder');
  64. }
  65. function getLastModified() {
  66. return $this->node->getLastModified();
  67. }
  68. }