ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 153 of file class.ilDAVContainer.php.

References getChildCollection().

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());
165  } catch (ilWebDAVNotDavableException) {
166  throw new Forbidden('Forbidden characters in title');
167  }
168  }
+ 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, childExists(), ensureSuffix(), extractSuffixFromFilename(), getChild(), ilFileUtils\getPhpUploadSizeLimitInBytes(), ILIAS\Repository\int(), and null.

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());
137  } catch (ilWebDAVNotDavableException) {
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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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 170 of file class.ilDAVContainer.php.

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

◆ 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 180 of file class.ilDAVContainer.php.

Referenced by createDirectory().

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