ILIAS  release_8 Revision v8.24
class.ilWebDAVObjFactory.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21use Sabre\DAV\Exception\NotFound;
23use Sabre\DAV\INode;
24use Sabre\DAV\Exception\Forbidden;
25use Psr\Http\Message\RequestInterface;
26
31{
32 use ilWebDAVCheckValidTitleTrait;
33
37 private array $davable_object_types = [
38 'cat',
39 'crs',
40 'fold',
41 'file',
42 'grp'
43 ];
44
48 protected RequestInterface $request;
50 protected string $client_id;
51 protected bool $versioning_enabled;
52
53 public function __construct(
57 RequestInterface $request,
59 string $client_id,
61 ) {
62 $this->repository_helper = $repository_helper;
63 $this->current_user = $current_user;
64 $this->resource_storage = $resource_storage;
65 $this->request = $request;
66 $this->language = $language;
67 $this->client_id = $client_id;
68 $this->versioning_enabled = $versioning_enabled;
69 }
70
72 {
73 if (!$this->checkReadAndVisibleAccessForObj($ref_id)) {
74 throw new Forbidden("No read permission for object with reference ID $ref_id");
75 }
76
78
79 if (!$ilias_object) {
80 throw new NotFound();
81 }
82
83 $ilias_object_type = $ilias_object->getType();
84
85 if (!in_array($ilias_object_type, $this->davable_object_types)) {
87 }
88
89 if ($this->isHiddenFile($ilias_object->getTitle())) {
91 }
92
93 if ($this->hasTitleForbiddenChars($ilias_object->getTitle())) {
95 }
96
97 if ($ilias_object_type === 'file') {
98 return new ilDAVFile(
99 $ilias_object,
100 $this->repository_helper,
101 $this->resource_storage,
102 $this->request,
103 $this,
104 $this->versioning_enabled
105 );
106 }
107
108 return new ilDAVContainer(
109 $ilias_object,
110 $this->current_user,
111 $this->request,
112 $this,
113 $this->repository_helper
114 );
115 }
116
117 public function createDAVObject(ilObject $ilias_object, int $parent_ref_id): INode
118 {
119 if (!$this->isDAVableObjTitle($ilias_object->getTitle())) {
121 }
122
123 if ($ilias_object->getType() === 'file' &&
124 !$this->hasValidFileExtension($ilias_object->getTitle())) {
126 }
127
128 $ilias_object->create();
129
130 $ilias_object->createReference();
131 $ilias_object->putInTree($parent_ref_id);
132 $ilias_object->setPermissions($parent_ref_id);
133
134 if ($ilias_object->getType() === 'file') {
135 return new ilDAVFile(
136 $ilias_object,
137 $this->repository_helper,
138 $this->resource_storage,
139 $this->request,
140 $this,
141 $this->versioning_enabled
142 );
143 }
144
145 return new ilDAVContainer(
146 $ilias_object,
147 $this->current_user,
148 $this->request,
149 $this,
150 $this->repository_helper
151 );
152 }
153
154 public function getProblemInfoFile(int $container_ref_id): ilDAVProblemInfoFile
155 {
156 return new ilDAVProblemInfoFile($container_ref_id, $this->repository_helper, $this, $this->language);
157 }
158
160 {
161 return new ilDAVMountPoint($this->client_id, $this, $this->repository_helper, $this->current_user);
162 }
163
164 public function getClientNode(string $name): ilDAVClientNode
165 {
166 if ($name !== $this->client_id) {
167 throw new NotFound();
168 }
169
170 return new ilDAVClientNode($this->client_id, $this, $this->repository_helper);
171 }
172
173 protected function checkReadAndVisibleAccessForObj(int $child_ref): bool
174 {
175 return $this->repository_helper->checkAccess("visible", $child_ref) && $this->repository_helper->checkAccess("read", $child_ref);
176 }
177}
This class represents the absolut Root-Node on a WebDAV request.
language handling
User class.
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setPermissions(int $parent_ref_id)
createReference()
creates reference for object
putInTree(int $parent_ref_id)
maybe this method should be in tree object!?
create()
note: title, description and type should be set when this function is called
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getProblemInfoFile(int $container_ref_id)
createDAVObject(ilObject $ilias_object, int $parent_ref_id)
__construct(ilWebDAVRepositoryHelper $repository_helper, ilObjUser $current_user, Services $resource_storage, RequestInterface $request, ilLanguage $language, string $client_id, bool $versioning_enabled)
ilWebDAVRepositoryHelper $repository_helper
checkReadAndVisibleAccessForObj(int $child_ref)
$ref_id
Definition: ltiauth.php:67
if($format !==null) $name
Definition: metadata.php:247
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: AsyncNode.php:21