UploadFolder.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @author Thomas Müller <thomas.mueller@tmit.eu>
  4. *
  5. * @copyright Copyright (c) 2016, 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\DAV\Upload;
  22. use OCA\DAV\Connector\Sabre\Directory;
  23. use Sabre\DAV\Exception\Forbidden;
  24. use Sabre\DAV\ICollection;
  25. class UploadFolder implements ICollection {
  26. private $node;
  27. function __construct(Directory $node) {
  28. $this->node = $node;
  29. }
  30. function createFile($name, $data = null) {
  31. // TODO: verify name - should be a simple number
  32. $this->node->createFile($name, $data);
  33. }
  34. function createDirectory($name) {
  35. throw new Forbidden('Permission denied to create file (filename ' . $name . ')');
  36. }
  37. function getChild($name) {
  38. if ($name === '.file') {
  39. return new FutureFile($this->node, '.file');
  40. }
  41. return $this->node->getChild($name);
  42. }
  43. function getChildren() {
  44. $children = $this->node->getChildren();
  45. $children[] = new FutureFile($this->node, '.file');
  46. return $children;
  47. }
  48. function childExists($name) {
  49. if ($name === '.file') {
  50. return true;
  51. }
  52. return $this->node->childExists($name);
  53. }
  54. function delete() {
  55. $this->node->delete();
  56. }
  57. function getName() {
  58. return $this->node->getName();
  59. }
  60. function setName($name) {
  61. throw new Forbidden('Permission denied to rename this folder');
  62. }
  63. function getLastModified() {
  64. return $this->node->getLastModified();
  65. }
  66. }