ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilRepositoryExplorer.php
Go to the documentation of this file.
1<?php
2
20
21/*
22 * Repository Explorer
23 *
24 * @author Alexander Killing <killing@leifos.de>
25 * @deprecated
26 * only use seems to be ilPasteIntoMultipleItemsExplorer
27 * which is still used in repository and workspace.
28 */
30{
32 protected ilDBInterface $db;
33 protected ilObjUser $user;
35 protected ilCtrl $ctrl;
36 protected array $force_open_path;
38 protected array $session_materials;
39 protected array $item_group_items;
40 protected array $type_grps;
41
42 public function __construct(string $a_target, int $a_top_node = 0)
43 {
45 global $DIC;
46
47 $this->lng = $DIC->language();
48 $this->settings = $DIC->settings();
49 $this->obj_definition = $DIC["objDefinition"];
50 $this->rbacsystem = $DIC->rbac()->system();
51 $this->db = $DIC->database();
52 $this->user = $DIC->user();
53 $this->access = $DIC->access();
54 $tree = $DIC->repositoryTree();
55 $ilCtrl = $DIC->ctrl();
56 $lng = $DIC->language();
57 $ilSetting = $DIC->settings();
58 $objDefinition = $DIC["objDefinition"];
59
60 $this->ctrl = $ilCtrl;
61
62
63 $this->force_open_path = [];
64 $this->request = $DIC->repository()->internal()->gui()->standardRequest();
65
66
67 parent::__construct($a_target);
68 $this->tree = $tree;
69 $this->root_id = $this->tree->readRootId();
70 $this->order_column = "title";
71 $this->setSessionExpandVariable("repexpand");
72 $this->setTitle($lng->txt("overview"));
73
74 // please do not uncomment this
75 if ($ilSetting->get("repository_tree_pres") == "" ||
76 ($ilSetting->get("rep_tree_limit_grp_crs") && $a_top_node === 0)) {
77 foreach ($objDefinition->getExplorerContainerTypes() as $type) {
78 $this->addFilter($type);
79 }
80 $this->setFiltered(true);
82 } elseif ($ilSetting->get("repository_tree_pres") === "all_types") {
83 foreach ($objDefinition->getAllRBACObjects() as $rtype) {
84 $this->addFilter($rtype);
85 }
86 $this->setFiltered(true);
88 }
89 }
90
94 public function setForceOpenPath(array $a_path): void
95 {
96 $this->force_open_path = $a_path;
97 }
98
102 public function buildLinkTarget($a_node_id, string $a_type): string
103 {
104 $ilCtrl = $this->ctrl;
105
106 $ref_id = $this->request->getRefId();
107
108 switch ($a_type) {
109 case "cat":
110 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
111 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
112 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
113 return $link;
114
115 case "grpr":
116 case "crsr":
117 case "catr":
118 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
119 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
120 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
121 return $link;
122
123 case "grp":
124 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node_id);
125 $link = $ilCtrl->getLinkTargetByClass(["ilrepositorygui", "ilobjgroupgui"], "");
126 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $ref_id);
127 return $link;
128
129 case "crs":
130 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node_id);
131 $link = $ilCtrl->getLinkTargetByClass(["ilrepositorygui", "ilobjcoursegui"], "view");
132 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $ref_id);
133 return $link;
134
135 case 'rcrs':
136 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
137 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
138 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $ref_id);
139 return $link;
140
141 case 'prg':
142 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node_id);
143 $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
144 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $ref_id);
145 return $link;
146
147 default:
148 return ilLink::_getStaticLink($a_node_id, $a_type, true);
149 }
150 }
151
152 public function getImage(string $a_name, string $a_type = "", $a_obj_id = ""): string
153 {
154 if ($a_type !== "") {
155 return ilObject::_getIcon((int) $a_obj_id, "tiny", $a_type);
156 }
157
158 return parent::getImage($a_name);
159 }
160
161 public function isClickable(string $type, int $ref_id = 0): bool
162 {
165
168 $ref_id,
169 $obj_id
170 )) {
171 return false;
172 }
173
174 switch ($type) {
175 case 'tst':
176 if (!$rbacsystem->checkAccess("read", $ref_id)) {
177 return false;
178 }
179
180 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $obj_id);
181 $res = $ilDB->query($query);
182 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
183 return (bool) $row->complete;
184 }
185 return false;
186
187 case 'svy':
188 if (!$rbacsystem->checkAccess("read", $ref_id)) {
189 return false;
190 }
191
192 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $obj_id);
193 $res = $ilDB->query($query);
194 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
195 return (bool) $row->complete;
196 }
197 return false;
198
199 // media pools can only be edited
200 case "mep":
201 if ($rbacsystem->checkAccess("read", $ref_id)) {
202 return true;
203 }
204 return false;
205 case 'grpr':
206 case 'crsr':
207 case 'catr':
209 case 'prg':
210 return $rbacsystem->checkAccess("visible", $ref_id);
211
212
213
214 // all other types are only clickable, if read permission is given
215 default:
216 if ($rbacsystem->checkAccess("read", $ref_id)) {
217 // check if lm is online
218 if ($type === "lm") {
219 $lm_obj = new ilObjLearningModule($ref_id);
220 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $ref_id))) {
221 return false;
222 }
223 }
224 // check if fblm is online
225 if ($type === "htlm") {
226 $lm_obj = new ilObjFileBasedLM($ref_id);
227 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $ref_id))) {
228 return false;
229 }
230 }
231 // check if fblm is online
232 if ($type === "sahs") {
233 $lm_obj = new ilObjSAHSLearningModule($ref_id);
234 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $ref_id))) {
235 return false;
236 }
237 }
238 // check if glossary is online
239 if ($type === "glo") {
241 if ((!ilObjGlossary::_lookupOnline($obj_id)) &&
242 (!$rbacsystem->checkAccess('write', $ref_id))) {
243 return false;
244 }
245 }
246
247 return true;
248 }
249 return false;
250 }
251 }
252
256 public function showChilds($a_parent_id, int $a_obj_id = 0): bool
257 {
259
260 if ($a_parent_id == 0) {
261 return true;
262 }
263 if (!ilConditionHandler::_checkAllConditionsOfTarget((int) $a_parent_id, $a_obj_id)) {
264 return false;
265 }
266 if ($rbacsystem->checkAccess("read", (int) $a_parent_id)) {
267 return true;
268 }
269
270 return false;
271 }
272
273 public function isVisible($a_ref_id, string $a_type): bool
274 {
275 $ilAccess = $this->access;
278
279 if (!$ilAccess->checkAccess('visible', '', $a_ref_id)) {
280 return false;
281 }
282
283 $is_course = false;
284 $container_parent_id = $tree->checkForParentType($a_ref_id, 'grp');
285 if (!$container_parent_id) {
286 $is_course = true;
287 $container_parent_id = $tree->checkForParentType($a_ref_id, 'crs');
288 }
289 if ($container_parent_id) {
290 // do not display session materials for container course/group
291 if ($container_parent_id !== $a_ref_id && $ilSetting->get("repository_tree_pres") === "all_types") {
292 // get container event items only once
293 if (!isset($this->session_materials[$container_parent_id])) {
294 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
295 }
296 // get item group items only once
297 if (!isset($this->item_group_items[$container_parent_id])) {
298 $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
299 }
300 if (in_array($a_ref_id, $this->session_materials[$container_parent_id])) {
301 return false;
302 }
303 if (in_array($a_ref_id, $this->item_group_items[$container_parent_id])) {
304 return false;
305 }
306 }
307 }
308
309 return true;
310 }
311
312
313 public function formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option): void
314 {
317 $ilCtrl = $this->ctrl;
318
319 // custom icons
320 $path = ilObject::_getIcon((int) $a_obj_id, "tiny", "root");
321
322 $tpl->setCurrentBlock("icon");
324 $title = $nd["title"];
325 if ($title === "ILIAS") {
326 $title = $lng->txt("repository");
327 }
328
329 $tpl->setVariable("ICON_IMAGE", $path);
330 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon") . " " . $title);
332
333 $tpl->setCurrentBlock("link");
334 $tpl->setVariable("TITLE", $title);
335 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
337 "LINK_TARGET",
338 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "")
339 );
340 $ilCtrl->setParameterByClass(
341 "ilrepositorygui",
342 "ref_id",
343 $this->request->getRefId()
344 );
345 $tpl->setVariable("TARGET", " target=\"_top\"");
347
348 $tpl->setCurrentBlock("element");
350 }
351
352 public function sortNodes(array $a_nodes, $a_parent_obj_id): array
353 {
354 $objDefinition = $this->obj_definition;
355
356 if ($a_parent_obj_id > 0) {
357 $parent_type = ilObject::_lookupType($a_parent_obj_id);
358 } else {
359 $parent_type = "dummy";
360 $this->type_grps["dummy"] = ["root" => "dummy"];
361 }
362
363 if (empty($this->type_grps[$parent_type])) {
364 $this->type_grps[$parent_type] = $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
365 }
366 $group = [];
367
368 foreach ($a_nodes as $node) {
369 $g = $objDefinition->getGroupOfObj($node["type"]);
370 if ($g == "") {
371 $g = $node["type"];
372 }
373 $group[$g][] = $node;
374 }
375
376 $nodes = [];
377 foreach ($this->type_grps[$parent_type] as $t => $g) {
378 if (array_key_exists($t, $group)
379 && is_array($group[$t])) {
380 // do we have to sort this group??
381 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
382 $group = $sort->sortItems($group);
383
384 foreach ($group[$t] as $k => $item) {
385 $nodes[] = $item;
386 }
387 }
388 }
389
390 return $nodes;
391 }
392
393 public function forceExpanded($a_obj_id): bool
394 {
395 if (in_array($a_obj_id, $this->force_open_path)) {
396 return true;
397 }
398 return false;
399 }
400}
const IL_FM_POSITIVE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _checkAllConditionsOfTarget(int $a_target_ref_id, int $a_target_id, string $a_target_type="", int $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
static _isAccessible(int $a_ref_id)
Check if target is accessible and not deleted.
static _getInstance(int $a_obj_id)
Class ilCtrl provides processing control methods.
static _getItemsOfContainer(int $a_ref_id)
class for explorer view in admin frame
setTitle(string $a_val)
addFilter(string $a_item)
ilRbacSystem $rbacsystem
setFilterMode(int $a_mode=IL_FM_NEGATIVE)
setSessionExpandVariable(string $a_var_name="expand")
ilObjectDefinition $obj_definition
ilLanguage $lng
setFiltered(bool $a_bool)
ilGlobalTemplateInterface $tpl
static _getItemsOfContainer(int $a_ref_id)
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
File Based Learning Module (HTML) object.
static _lookupOnline(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjSCORMLearningModule.
User class.
static _lookupObjectId(int $ref_id)
static _lookupType(int $id, bool $reference=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
static _lookupObjId(int $ref_id)
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
forceExpanded($a_obj_id)
force expansion of node
setForceOpenPath(array $a_path)
set force open path
showChilds($a_parent_id, int $a_obj_id=0)
isClickable(string $type, int $ref_id=0)
buildLinkTarget($a_node_id, string $a_type)
note: most of this stuff is used by ilCourseContentInterface too
formatHeader(ilTemplate $tpl, $a_obj_id, array $a_option)
getImage(string $a_name, string $a_type="", $a_obj_id="")
sortNodes(array $a_nodes, $a_parent_obj_id)
sort nodes and put adm object to the end of sorted array
isVisible($a_ref_id, string $a_type)
ILIAS Setting Class.
special template class to simplify handling of ITX/PEAR
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
const ROOT_FOLDER_ID
Definition: constants.php:32
$nd
Definition: error.php:30
setVariable(string $variable, $value='')
Sets the given variable to the given value.
parseCurrentBlock(string $block_name=self::DEFAULT_BLOCK)
Parses the given block.
setCurrentBlock(string $part=self::DEFAULT_BLOCK)
Sets the template to the given block.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
Interface ilDBInterface.
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26