ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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
::childExists()

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

Referenced by createFile().

80  : bool
81  {
82  return $this->checkIfChildExistsByParentRefId(
83  $this->repository_helper,
84  $this->dav_factory,
85  $this->obj->getRefId(),
86  $name
87  );
88  }
+ Here is the caller graph for this function:

◆ createDirectory()

ilDAVContainer::createDirectory (   $name)

See also
::createDirectory()

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

References getChildCollection().

157  : void
158  {
159  $new_obj = $this->getChildCollection();
160 
161  if (!$this->repository_helper->checkCreateAccessForType($this->obj->getRefId(), $new_obj->getType())) {
162  throw new Forbidden('Permission denied');
163  }
164 
165  try {
166  $new_obj->setOwner($this->current_user->getId());
167  $new_obj->setTitle($name);
168  $this->dav_factory->createDAVObject($new_obj, $this->obj->getRefId());
169  } catch (ilWebDAVNotDavableException) {
170  throw new Forbidden('Forbidden characters in title');
171  }
172  }
+ Here is the call graph for this function:

◆ createFile()

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

See also
::createFile()

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

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

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

◆ delete()

ilDAVContainer::delete ( )

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

174  : void
175  {
176  $this->repository_helper->deleteObject($this->obj->getRefId());
177  }

◆ getChild()

ilDAVContainer::getChild (   $name)

See also
::getChild()

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

Referenced by createFile().

54  : INode
55  {
56  return $this->getChildByParentRefId(
57  $this->repository_helper,
58  $this->dav_factory,
59  $this->obj->getRefId(),
60  $name
61  );
62  }
+ Here is the caller graph for this function:

◆ getChildCollection()

ilDAVContainer::getChildCollection ( )
protected

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

Referenced by createDirectory().

184  : ilContainer
185  {
186  if ($this->obj::class === 'ilObjCategory') {
187  return new ilObjCategory();
188  }
189 
190  return new ilObjFolder();
191  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ 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 179 of file class.ilDAVContainer.php.

179  : ?int
180  {
181  return $this->retrieveLastModifiedAsIntFromObjectLastUpdateString($this->obj->getLastUpdateDate());
182  }

◆ 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
::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: