ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilDAVContainer Class Reference
+ Inheritance diagram for ilDAVContainer:
+ Collaboration diagram for ilDAVContainer:

Public Member Functions

 __construct (protected ilObject $obj, protected ilObjUser $current_user, protected RequestInterface $request, protected ilWebDAVObjFactory $dav_factory, protected ilWebDAVRepositoryHelper $repository_helper)
 
 getName ()
 
 getChild ($name)
 
 getChildren ()
 
 childExists ($name)
 
 setName ($name)
 
 createFile ($name, $data=null)
 
 createDirectory ($name)
 
 delete ()
 
 getLastModified ()
 

Protected Member Functions

 getChildCollection ()
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilDAVContainer::__construct ( protected ilObject  $obj,
protected ilObjUser  $current_user,
protected RequestInterface  $request,
protected ilWebDAVObjFactory  $dav_factory,
protected ilWebDAVRepositoryHelper  $repository_helper 
)

Definition at line 36 of file class.ilDAVContainer.php.

42 {
43 }

Member Function Documentation

◆ childExists()

ilDAVContainer::childExists (   $name)

See also
\Sabre\DAV\ICollection::childExists()

Definition at line 80 of file class.ilDAVContainer.php.

80 : bool
81 {
82 return $this->checkIfChildExistsByParentRefId(
83 $this->repository_helper,
84 $this->dav_factory,
85 $this->obj->getRefId(),
86 $name
87 );
88 }

Referenced by createFile().

+ Here is the caller graph for this function:

◆ createDirectory()

ilDAVContainer::createDirectory (   $name)

See also
\Sabre\DAV\ICollection::createDirectory()

Definition at line 153 of file class.ilDAVContainer.php.

153 : void
154 {
155 $new_obj = $this->getChildCollection();
156
157 if (!$this->repository_helper->checkCreateAccessForType($this->obj->getRefId(), $new_obj->getType())) {
158 throw new Forbidden('Permission denied');
159 }
160
161 try {
162 $new_obj->setOwner($this->current_user->getId());
163 $new_obj->setTitle($name);
164 $this->dav_factory->createDAVObject($new_obj, $this->obj->getRefId());
166 throw new Forbidden('Forbidden characters in title');
167 }
168 }

References getChildCollection().

+ Here is the call graph for this function:

◆ createFile()

ilDAVContainer::createFile (   $name,
  $data = null 
)

See also
\Sabre\DAV\ICollection::createFile()

Definition at line 112 of file class.ilDAVContainer.php.

112 : ?string
113 {
114 if (!$this->repository_helper->checkCreateAccessForType($this->obj->getRefId(), 'file')) {
115 throw new Forbidden('Permission denied');
116 }
117
118 $size = (int) ($this->request->getHeader("Content-Length")[0] ?? 0);
119 if ($size === 0 && $this->request->hasHeader('X-Expected-Entity-Length')) {
120 $size = (int) ($this->request->getHeader('X-Expected-Entity-Length')[0] ?? 0);
121 }
122
124 throw new Forbidden('File is too big');
125 }
126
127 $name = $this->ensureSuffix($name, $this->extractSuffixFromFilename($name));
128
129 if ($this->childExists($name)) {
130 $file_dav = $this->getChild($name);
131 } else {
132 try {
133 $file_obj = new ilObjFile();
134 $file_obj->setTitle($name);
135
136 $file_dav = $this->dav_factory->createDAVObject($file_obj, $this->obj->getRefId());
138 throw new Forbidden('Forbidden characters in title');
139 }
140 }
141
142 try {
143 return $file_dav->put($data, $name);
144 } catch (Throwable) {
145 return null;
146 }
147 }
static getPhpUploadSizeLimitInBytes()
Class ilObjFile.
ensureSuffix(string $title, ?string $suffix=null)
extractSuffixFromFilename(string $filename)

References $data, childExists(), ensureSuffix(), extractSuffixFromFilename(), getChild(), ilFileUtils\getPhpUploadSizeLimitInBytes(), and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ delete()

ilDAVContainer::delete ( )

Definition at line 170 of file class.ilDAVContainer.php.

170 : void
171 {
172 $this->repository_helper->deleteObject($this->obj->getRefId());
173 }

◆ getChild()

ilDAVContainer::getChild (   $name)

See also
\Sabre\DAV\ICollection::getChild()

Definition at line 54 of file class.ilDAVContainer.php.

54 : INode
55 {
56 return $this->getChildByParentRefId(
57 $this->repository_helper,
58 $this->dav_factory,
59 $this->obj->getRefId(),
60 $name
61 );
62 }

Referenced by createFile().

+ Here is the caller graph for this function:

◆ getChildCollection()

ilDAVContainer::getChildCollection ( )
protected

Reimplemented in ilDAVContainerWithOverridenGetChildCollection.

Definition at line 180 of file class.ilDAVContainer.php.

181 {
182 if ($this->obj::class === 'ilObjCategory') {
183 return new ilObjCategory();
184 }
185
186 return new ilObjFolder();
187 }
Class ilContainer.
Class ilObjCategory.
Class ilObjFolder.

Referenced by createDirectory().

+ Here is the caller graph for this function:

◆ getChildren()

ilDAVContainer::getChildren ( )
Returns
ilObject[]

Definition at line 67 of file class.ilDAVContainer.php.

67 : array
68 {
69 return $this->getChildrenByParentRefId(
70 $this->repository_helper,
71 $this->dav_factory,
72 $this->obj->getRefId()
73 );
74 }

◆ getLastModified()

ilDAVContainer::getLastModified ( )

Definition at line 175 of file class.ilDAVContainer.php.

175 : ?int
176 {
177 return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
178 }

◆ getName()

ilDAVContainer::getName ( )

Definition at line 45 of file class.ilDAVContainer.php.

45 : string
46 {
47 return $this->obj->getTitle();
48 }

◆ setName()

ilDAVContainer::setName (   $name)

See also
\Sabre\DAV\INode::setName()

Definition at line 94 of file class.ilDAVContainer.php.

94 : void
95 {
96 if (!$this->repository_helper->checkAccess("write", $this->obj->getRefId())) {
97 throw new Forbidden('Permission denied');
98 }
99
100 if ($this->isDAVableObjTitle($name)) {
101 $this->obj->setTitle($name);
102 $this->obj->update();
103 } else {
104 throw new Forbidden('Forbidden characters in title');
105 }
106 }

The documentation for this class was generated from the following file: