Blame view

sources/3rdparty/sabre/dav/lib/Sabre/DAV/Collection.php 2.91 KB
03e52840d   Kload   Init
1
  <?php
6d9380f96   Cédric Dupont   Update sources OC...
2
  namespace Sabre\DAV;
03e52840d   Kload   Init
3
4
5
6
7
8
  /**
   * Collection class
   *
   * This is a helper class, that should aid in getting collections classes setup.
   * Most of its methods are implemented, and throw permission denied exceptions
   *
6d9380f96   Cédric Dupont   Update sources OC...
9
10
11
   * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
   * @author Evert Pot (http://evertpot.com/)
   * @license http://sabre.io/license/ Modified BSD License
03e52840d   Kload   Init
12
   */
6d9380f96   Cédric Dupont   Update sources OC...
13
  abstract class Collection extends Node implements ICollection {
03e52840d   Kload   Init
14
15
16
17
18
19
20
21
  
      /**
       * Returns a child object, by its name.
       *
       * This method makes use of the getChildren method to grab all the child
       * nodes, and compares the name.
       * Generally its wise to override this, as this can usually be optimized
       *
6d9380f96   Cédric Dupont   Update sources OC...
22
       * This method must throw Sabre\DAV\Exception\NotFound if the node does not
03e52840d   Kload   Init
23
24
25
       * exist.
       *
       * @param string $name
6d9380f96   Cédric Dupont   Update sources OC...
26
27
       * @throws Exception\NotFound
       * @return INode
03e52840d   Kload   Init
28
29
30
31
32
33
34
35
       */
      public function getChild($name) {
  
          foreach($this->getChildren() as $child) {
  
              if ($child->getName()==$name) return $child;
  
          }
6d9380f96   Cédric Dupont   Update sources OC...
36
          throw new Exception\NotFound('File not found: ' . $name);
03e52840d   Kload   Init
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
  
      }
  
      /**
       * Checks is a child-node exists.
       *
       * It is generally a good idea to try and override this. Usually it can be optimized.
       *
       * @param string $name
       * @return bool
       */
      public function childExists($name) {
  
          try {
  
              $this->getChild($name);
              return true;
6d9380f96   Cédric Dupont   Update sources OC...
54
          } catch(Exception\NotFound $e) {
03e52840d   Kload   Init
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
  
              return false;
  
          }
  
      }
  
      /**
       * Creates a new file in the directory
       *
       * Data will either be supplied as a stream resource, or in certain cases
       * as a string. Keep in mind that you may have to support either.
       *
       * After succesful creation of the file, you may choose to return the ETag
       * of the new file here.
       *
       * The returned ETag must be surrounded by double-quotes (The quotes should
       * be part of the actual string).
       *
       * If you cannot accurately determine the ETag, you should not return it.
       * If you don't store the file exactly as-is (you're transforming it
       * somehow) you should also not return an ETag.
       *
       * This means that if a subsequent GET to this new file does not exactly
       * return the same contents of what was submitted here, you are strongly
       * recommended to omit the ETag.
       *
       * @param string $name Name of the file
       * @param resource|string $data Initial payload
       * @return null|string
       */
      public function createFile($name, $data = null) {
6d9380f96   Cédric Dupont   Update sources OC...
87
          throw new Exception\Forbidden('Permission denied to create file (filename ' . $name . ')');
03e52840d   Kload   Init
88
89
90
91
92
93
94
  
      }
  
      /**
       * Creates a new subdirectory
       *
       * @param string $name
6d9380f96   Cédric Dupont   Update sources OC...
95
       * @throws Exception\Forbidden
03e52840d   Kload   Init
96
97
98
       * @return void
       */
      public function createDirectory($name) {
6d9380f96   Cédric Dupont   Update sources OC...
99
          throw new Exception\Forbidden('Permission denied to create directory');
03e52840d   Kload   Init
100
101
102
103
104
  
      }
  
  
  }