ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilClientNodeDAV.php
Go to the documentation of this file.
1 <?php
2 
6 
28 {
30  protected $repo_helper;
31 
34 
38  public function __construct(string $client_name, ilWebDAVRepositoryHelper $repo_helper, ilWebDAVObjDAVHelper $dav_helper)
39  {
40  global $DIC;
41 
42  $this->repo_helper = $repo_helper;
43  $this->dav_helper = $dav_helper;
44  $this->client_name = $client_name;
45  $this->name_of_repository_root = 'ILIAS';
46  }
47 
54  public function setName($name)
55  {
56  throw new Forbidden("You cant change the client name");
57  }
58 
65  public function getChildren()
66  {
67  return array($this->getRepositoryRootPoint());
68  }
69 
75  public function getName()
76  {
77  return $this->client_name;
78  }
79 
85  public function getLastModified()
86  {
87  return strtotime('2000-01-01');
88  }
89 
103  public function getChild($name)
104  {
105  if ($name == $this->name_of_repository_root) {
106  return $this->getRepositoryRootPoint();
107  } else {
108  return $this->getMountPointByReference($name);
109  }
110  }
111 
120  protected function getMountPointByReference($name)
121  {
122  $ref_id = $this->getRefIdFromName($name);
123 
124  if ($ref_id > 0) {
125  if ($this->repo_helper->checkAccess('read', $ref_id)) {
126  return $this->dav_helper->createDAVObjectForRefId($ref_id);
127  }
128 
129  throw new Forbidden("No read permission for object with reference ID $ref_id ");
130  }
131 
132  throw new BadRequest("Invalid parameter $name");
133  }
134 
140  protected function getRepositoryRootPoint()
141  {
142  if ($this->repo_helper->checkAccess('read', ROOT_FOLDER_ID)) {
143  return new ilObjRepositoryRootDAV($this->name_of_repository_root, $this->repo_helper, $this->dav_helper);
144  }
145  throw new Forbidden("No read permission for ilias repository root");
146  }
147 
156  public function childExists($name)
157  {
158  if ($name == $this->name_of_repository_root) {
159  return true;
160  }
161 
162  $ref_id = $this->getRefIdFromName($name);
163  if ($ref_id > 0) {
164  return $this->repo_helper->objectWithRefIdExists($ref_id) && $this->repo_helper->checkAccess('read', $ref_id);
165  }
166  return false;
167  }
168 
175  public function getRefIdFromName($name)
176  {
177  $ref_parts = explode('_', $name);
178  if (count($ref_parts) == 2) {
179  $ref_id = (int) $ref_parts[1];
180  return $this->checkIfRefIdIsValid($ref_id);
181  }
182 
183  return 0;
184  }
185 
192  protected function checkIfRefIdIsValid($ref_id)
193  {
194  if ($ref_id > 0 && $this->repo_helper->objectWithRefIdExists($ref_id) && $this->dav_helper->isDAVableObject($ref_id, true, false)) {
195  return $ref_id;
196  }
197  }
198 
205  public function createDirectory($name)
206  {
207  throw new Forbidden();
208  }
209 
215  public function delete()
216  {
217  throw new Forbidden();
218  }
219 
228  public function createFile($name, $data = null)
229  {
230  throw new Forbidden();
231  }
232 }
getMountPointByReference($name)
Create DAV-Object from ref_id.
global $DIC
Definition: saml.php:7
Class ilWebDAVRepositoryHelper.
getChild($name)
If the "ILIAS" is given as parameter, the repository root will be returned.
Class ilObjRepositoryRootDAV.
Class ilWebDAVObjDAVHelper.
getRefIdFromName($name)
Gets ref_id from name.
checkIfRefIdIsValid($ref_id)
Check if object with ref_id exists and if is DAVable object.
getName()
Return name of client.
Class ilClientNodeDAV.
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...
createFile($name, $data=null)
It is not allowed (and not even possible) to create a file here.
getChildren()
Returns Repository Root Object.
getRepositoryRootPoint()
Creates and returns Repository Root Object.
createDirectory($name)
It is not allowed to create a directory here.
__construct(string $client_name, ilWebDAVRepositoryHelper $repo_helper, ilWebDAVObjDAVHelper $dav_helper)
getLastModified()
Returns some date as return for last modified.
setName($name)
Overwrite parent function to throw an exception if called.
$data
Definition: bench.php:6