ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 include_once("./Services/Repository/classes/class.ilRepUtil.php");
41 $repository_util = new ilRepUtil($this);
42 $parent = $this->tree->getParentId($a_ref_id);
43 $repository_util->deleteObjects($parent, array($a_ref_id));
44 }
45
53 public function checkAccess(string $a_permission, int $a_ref_id) : bool
54 {
55 return $this->access->checkAccess($a_permission, '', $a_ref_id);
56 }
57
65 public function checkCreateAccessForType(int $a_ref_id, string $a_type) : bool
66 {
67 return $this->access->checkAccess('create', '', $a_ref_id, $a_type);
68 }
69
76 public function objectWithRefIdExists(int $a_ref_id) : int
77 {
78 return ilObject::_exists($a_ref_id, true);
79 }
80
87 public function getObjectIdFromRefId(int $a_ref_id) : int
88 {
89 return ilObject::_lookupObjectId($a_ref_id);
90 }
91
98 public function getObjectTitleFromObjId(int $a_obj_id, bool $escape_forbidden_fileextension = false) : string
99 {
100 if ($escape_forbidden_fileextension && ilObject::_lookupType($a_obj_id) == 'file') {
102 } else {
103 $title = $this->getRawObjectTitleFromObjId($a_obj_id);
104 }
105
106 return is_string($title)? $title : '';
107 }
116 public function getFilenameWithSanitizedFileExtension(int $a_obj_id) : string
117 {
118 $unescaped_title = $this->getRawObjectTitleFromObjId($a_obj_id);
119
120 try {
121 $escaped_title = ilFileUtils::getValidFilename($unescaped_title);
122 } catch (ilFileUtilsException $e) {
123 $escaped_title = "";
124 }
125
126 return is_string($escaped_title) ? $escaped_title : '';
127 }
128
136 protected function getRawObjectTitleFromObjId(int $a_obj_id) : string
137 {
138 $title = ilObject::_lookupTitle($a_obj_id);
139 return is_string($title) ? $title : '';
140 }
141
148 public function getObjectTypeFromObjId(int $a_obj_id) : string
149 {
150 $type = ilObject::_lookupType($a_obj_id, false);
151 return $type === null ? '' : $type;
152 }
153
154
161 public function getObjectTitleFromRefId(int $a_ref_id, bool $escape_forbidden_fileextension = false) : string
162 {
163 $obj_id = $this->getObjectIdFromRefId($a_ref_id);
164
165 return $this->getObjectTitleFromObjId($obj_id, $escape_forbidden_fileextension);
166 }
167
174 public function getObjectTypeFromRefId(int $a_ref_id) : string
175 {
176 $type = ilObject::_lookupType($a_ref_id, true);
177 return is_string($type) ? $type : '';
178 }
179
186 public function getChildrenOfRefId(int $a_ref_id)
187 {
188 return $this->tree->getChildIds($a_ref_id);
189 }
190}
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
$a_type
Definition: workflow.php:92