ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilWebDAVRepositoryHelper.php
Go to the documentation of this file.
1<?php
2
13{
15 protected $access;
16
18 protected $tree;
19
27 {
28 $this->access = $access;
29 $this->tree = $tree;
30 }
31
38 public function deleteObject(int $a_ref_id)
39 {
40 $repository_util = new ilRepUtil($this);
41 $parent = $this->tree->getParentId($a_ref_id);
42 $repository_util->deleteObjects($parent, array($a_ref_id));
43 }
44
52 public function checkAccess(string $a_permission, int $a_ref_id) : bool
53 {
54 return $this->access->checkAccess($a_permission, '', $a_ref_id);
55 }
56
64 public function checkCreateAccessForType(int $a_ref_id, string $a_type) : bool
65 {
66 return $this->access->checkAccess('create', '', $a_ref_id, $a_type);
67 }
68
75 public function objectWithRefIdExists(int $a_ref_id) : int
76 {
77 return ilObject::_exists($a_ref_id, true);
78 }
79
86 public function getObjectIdFromRefId(int $a_ref_id) : int
87 {
88 return ilObject::_lookupObjectId($a_ref_id);
89 }
90
97 public function getObjectTitleFromObjId(int $a_obj_id, bool $escape_forbidden_fileextension = false) : string
98 {
99 if ($escape_forbidden_fileextension && ilObject::_lookupType($a_obj_id) == 'file') {
100 $title = $this->getFilenameWithSanitizedFileExtension($a_obj_id);
101 } else {
102 $title = $this->getRawObjectTitleFromObjId($a_obj_id);
103 }
104
105 return is_string($title)? $title : '';
106 }
115 public function getFilenameWithSanitizedFileExtension(int $a_obj_id) : string
116 {
117 $unescaped_title = $this->getRawObjectTitleFromObjId($a_obj_id);
118
119 try {
120 $escaped_title = ilFileUtils::getValidFilename($unescaped_title);
121 } catch (ilFileUtilsException $e) {
122 $escaped_title = "";
123 }
124
125 return is_string($escaped_title) ? $escaped_title : '';
126 }
127
135 protected function getRawObjectTitleFromObjId(int $a_obj_id) : string
136 {
137 $title = ilObject::_lookupTitle($a_obj_id);
138 return is_string($title) ? $title : '';
139 }
140
147 public function getObjectTypeFromObjId(int $a_obj_id) : string
148 {
149 $type = ilObject::_lookupType($a_obj_id, false);
150 return $type === null ? '' : $type;
151 }
152
153
160 public function getObjectTitleFromRefId(int $a_ref_id, bool $escape_forbidden_fileextension = false) : string
161 {
162 $obj_id = $this->getObjectIdFromRefId($a_ref_id);
163
164 return $this->getObjectTitleFromObjId($obj_id, $escape_forbidden_fileextension);
165 }
166
173 public function getObjectTypeFromRefId(int $a_ref_id) : string
174 {
175 $type = ilObject::_lookupType($a_ref_id, true);
176 return is_string($type) ? $type : '';
177 }
178
185 public function getChildrenOfRefId(int $a_ref_id)
186 {
187 return $this->tree->getChildIds($a_ref_id);
188 }
189}
An exception for terminatinating execution or to throw for unit testing.
Class to report exception.
static getValidFilename($a_filename)
Get valid filename.
static _lookupTitle($a_id)
lookup object title
static _lookupObjectId($a_ref_id)
lookup object id
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI)
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
Class ilWebDAVRepositoryHelper.
getRawObjectTitleFromObjId(int $a_obj_id)
Wraps the static call to ilObject::_lookupTitle.
objectWithRefIdExists(int $a_ref_id)
Just a redirect to the ilObject::_exists.
getObjectTypeFromObjId(int $a_obj_id)
Just a redirect to the ilObject::_lookupType function.
getObjectIdFromRefId(int $a_ref_id)
Just a redirect to the ilObject::_lookupObjectId function.
deleteObject(int $a_ref_id)
I stole this method of deleting objects from ilObjectGUI->confirmedDeleteObject()
getChildrenOfRefId(int $a_ref_id)
Just a redirect to getChildIds of ilTree.
__construct(ilAccessHandler $access, ilTree $tree)
ilWebDAVRepositoryHelper constructor.
getObjectTitleFromObjId(int $a_obj_id, bool $escape_forbidden_fileextension=false)
Just a redirect to the ilObject::_lookupTitle function.
getObjectTitleFromRefId(int $a_ref_id, bool $escape_forbidden_fileextension=false)
Just a shortcut and redirect to get a title from a given ref_id.
checkCreateAccessForType(int $a_ref_id, string $a_type)
Just a redirect to the checkAccess method of ilAccess to check for creation of certain obj types.
getFilenameWithSanitizedFileExtension(int $a_obj_id)
Wraps the static call to ilObject::_lookupTitle.
checkAccess(string $a_permission, int $a_ref_id)
Just a redirect to the checkAccess method of ilAccess.
getObjectTypeFromRefId(int $a_ref_id)
Just a redirect to the ilObject::_lookupType function.
Interface ilAccessHandler.
$type