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