ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilClientNodeDAV.php
Go to the documentation of this file.
1<?php
2
3use Sabre\DAV\Exception\BadRequest;
4use Sabre\DAV\Exception\Forbidden;
5use Sabre\DAV\Exception\NotFound;
6
27class ilClientNodeDAV implements Sabre\DAV\ICollection
28{
30 protected $repo_helper;
31
33 protected $dav_helper;
34
37
42 {
43 global $DIC;
44
45 $this->repo_helper = $repo_helper;
46 $this->dav_helper = $dav_helper;
47 $this->client_name = $client_name;
48 $this->name_of_repository_root = 'ILIAS';
49 }
50
57 public function setName($name)
58 {
59 throw new Forbidden("You cant change the client name");
60 }
61
68 public function getChildren()
69 {
70 return array($this->getRepositoryRootPoint());
71 }
72
78 public function getName()
79 {
80 return $this->client_name;
81 }
82
88 public function getLastModified()
89 {
90 return strtotime('2000-01-01');
91 }
92
106 public function getChild($name)
107 {
108 if ($name == $this->name_of_repository_root) {
109 return $this->getRepositoryRootPoint();
110 } else {
111 return $this->getMountPointByReference($name);
112 }
113 }
114
123 protected function getMountPointByReference($name)
124 {
125 $ref_id = $this->getRefIdFromName($name);
126
127 if ($ref_id > 0) {
128 if ($this->repo_helper->checkAccess('read', $ref_id)) {
129 return $this->dav_helper->createDAVObjectForRefId($ref_id);
130 }
131
132 throw new Forbidden("No read permission for object with reference ID $ref_id ");
133 }
134
135 throw new BadRequest("Invalid parameter $name");
136 }
137
143 protected function getRepositoryRootPoint()
144 {
145 if ($this->repo_helper->checkAccess('read', ROOT_FOLDER_ID)) {
146 return new ilObjRepositoryRootDAV($this->name_of_repository_root, $this->repo_helper, $this->dav_helper);
147 }
148 throw new Forbidden("No read permission for ilias repository root");
149 }
150
159 public function childExists($name)
160 {
161 if ($name == $this->name_of_repository_root) {
162 return true;
163 }
164
165 $ref_id = $this->getRefIdFromName($name);
166 if ($ref_id > 0) {
167 return $this->repo_helper->objectWithRefIdExists($ref_id) && $this->repo_helper->checkAccess('read', $ref_id);
168 }
169 return false;
170 }
171
178 public function getRefIdFromName($name)
179 {
180 $ref_parts = explode('_', $name);
181 if (count($ref_parts) == 2) {
182 $ref_id = (int) $ref_parts[1];
183 return $this->checkIfRefIdIsValid($ref_id);
184 }
185
186 return 0;
187 }
188
195 protected function checkIfRefIdIsValid($ref_id)
196 {
197 if ($ref_id > 0
198 && $this->repo_helper->objectWithRefIdExists($ref_id)
199 && $this->dav_helper->isDAVableObject($ref_id, true, false)) {
200 return $ref_id;
201 }
202 }
203
210 public function createDirectory($name)
211 {
212 throw new Forbidden();
213 }
214
220 public function delete()
221 {
222 throw new Forbidden();
223 }
224
233 public function createFile($name, $data = null)
234 {
235 throw new Forbidden();
236 }
237}
An exception for terminatinating execution or to throw for unit testing.
Class ilClientNodeDAV.
getChildren()
Returns Repository Root Object.
checkIfRefIdIsValid($ref_id)
Check if object with ref_id exists and if is DAVable object.
childExists($name)
Either the given name is the name of the repository root of ILIAS or it is a reference to a node in t...
__construct(string $client_name, ilWebDAVRepositoryHelper $repo_helper, ilWebDAVObjDAVHelper $dav_helper)
createDirectory($name)
It is not allowed to create a directory here.
getRefIdFromName($name)
Gets ref_id from name.
getChild($name)
If the "ILIAS" is given as parameter, the repository root will be returned.
getMountPointByReference($name)
Create DAV-Object from ref_id.
getName()
Return name of client.
getRepositoryRootPoint()
Creates and returns Repository Root Object.
createFile($name, $data=null)
It is not allowed (and not even possible) to create a file here.
setName($name)
Overwrite parent function to throw an exception if called.
getLastModified()
Returns some date as return for last modified.
Class ilObjRepositoryRootDAV.
Class ilWebDAVObjDAVHelper.
Class ilWebDAVRepositoryHelper.
const ROOT_FOLDER_ID
Definition: constants.php:30
global $DIC
Definition: goto.php:24
if($format !==null) $name
Definition: metadata.php:230
$data
Definition: storeScorm.php:23