ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilRepositoryExplorerGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php");
5
17{
18 protected $type_grps = array();
19 protected $session_materials = array();
20
24 public function __construct($a_parent_obj, $a_parent_cmd)
25 {
26 global $tree, $ilSetting, $objDefinition;
27
28 $this->cur_ref_id = (int) $_GET["ref_id"];
29
30 $this->top_node_id = 0;
31 if ($ilSetting->get("rep_tree_limit_grp_crs") && $this->cur_ref_id > 0)
32 {
33 $path = $tree->getPathId($this->cur_ref_id);
34 foreach ($path as $n)
35 {
36 if ($top_node > 0)
37 {
38 break;
39 }
41 array("crs", "grp")))
42 {
43 $this->top_node_id = $n;
44 }
45 }
46
47 }
48
49 parent::__construct("rep_exp", $a_parent_obj, $a_parent_cmd, $tree);
50
51 $this->setSkipRootNode(false);
52 $this->setAjax(true);
53 $this->setOrderField("title");
54
55 if ($ilSetting->get("repository_tree_pres") == "" ||
56 ($ilSetting->get("rep_tree_limit_grp_crs") && $this->top_node_id == 0))
57 {
58 $this->setTypeWhiteList($objDefinition->getExplorerContainerTypes());
59 }
60 else if ($ilSetting->get("repository_tree_pres") == "all_types")
61 {
62 $white = array();
63 foreach ($objDefinition->getSubObjectsRecursively("root") as $rtype)
64 {
65 if (/* $rtype["name"] != "itgr" && */ !$objDefinition->isSideBlock($rtype["name"]))
66 {
67 $white[] = $rtype["name"];
68 }
69 }
71 }
72 if ((int) $_GET["ref_id"] > 0)
73 {
74 $this->setPathOpen((int) $_GET["ref_id"]);
75 }
76 }
77
84 function getRootNode()
85 {
86 if ($this->top_node_id > 0)
87 {
88 return $this->getTree()->getNodeData($this->top_node_id);
89 }
90 else
91 {
92 return parent::getRootNode();
93 }
94 }
95
102 function getNodeContent($a_node)
103 {
104 global $lng;
105
106 $title = $a_node["title"];
107
108 if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
109 {
110 if ($title == "ILIAS")
111 {
112 $title = $lng->txt("repository");
113 }
114 }
115 else if($a_node["type"] == "sess" &&
116 !trim($title))
117 {
118 // #14367 - see ilObjSessionListGUI
119 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
120 $app_info = ilSessionAppointment::_lookupAppointment($a_node["obj_id"]);
121 $title = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'],$app_info['fullday']);
122 }
123
124 return $title;
125 }
126
133 function getNodeIcon($a_node)
134 {
135 $obj_id = ilObject::_lookupObjId($a_node["child"]);
136 return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
137 }
138
145 function getNodeIconAlt($a_node)
146 {
147 global $lng;
148
149 if ($a_node["child"] == $this->getNodeId($this->getRootNode()))
150 {
151 $title = $a_node["title"];
152 if ($title == "ILIAS")
153 {
154 $title = $lng->txt("repository");
155 }
156 return $lng->txt("icon")." ".$title;
157 }
158
159
160 return parent::getNodeIconAlt($a_node);
161 }
162
169 function isNodeHighlighted($a_node)
170 {
171 if ($a_node["child"] == $_GET["ref_id"] ||
172 ($_GET["ref_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode())))
173 {
174 return true;
175 }
176 return false;
177 }
178
185 function getNodeHref($a_node)
186 {
187 global $ilCtrl;
188
189 switch($a_node["type"])
190 {
191 case "root":
192 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
193 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
194 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
195 return $link;
196
197 case "cat":
198 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
199 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
200 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
201 return $link;
202
203 case "catr":
204 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
205 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
206 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
207 return $link;
208
209 case "grp":
210 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node["child"]);
211 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjgroupgui"), "");
212 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $_GET["ref_id"]);
213 return $link;
214
215 case "crs":
216 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node["child"]);
217 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
218 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
219 return $link;
220
221 case "crsr":
222 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
223 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
224 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
225 return $link;
226
227 case 'rcrs':
228 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
229 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
230 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
231 return $link;
232
233 case 'prg':
234 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node["child"]);
235 $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
236 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
237 return $link;
238
239 default:
240 include_once('./Services/Link/classes/class.ilLink.php');
241 return ilLink::_getStaticLink($a_node["child"], $a_node["type"], true);
242
243 }
244 }
245
252 function isNodeVisible($a_node)
253 {
254 global $ilAccess,$tree,$ilSetting;
255
256 if (!$ilAccess->checkAccess('visible', '', $a_node["child"]))
257 {
258 return false;
259 }
260
261 $is_course = false;
262 $container_parent_id = $tree->checkForParentType($a_node["child"], 'grp');
263 if(!$container_parent_id)
264 {
265 $is_course = true;
266 $container_parent_id = $tree->checkForParentType($a_node["child"], 'crs');
267 }
268 if($container_parent_id)
269 {
270 // do not display session materials for container course/group
271 if($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_node["child"])
272 {
273 // get container event items only once
274 if(!isset($this->session_materials[$container_parent_id]))
275 {
276 include_once './Modules/Session/classes/class.ilEventItems.php';
277 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
278 }
279 if(in_array($a_node["child"], $this->session_materials[$container_parent_id]))
280 {
281 return false;
282 }
283 }
284 }
285
286 return true;
287 }
288
297 function sortChilds($a_childs, $a_parent_node_id)
298 {
299 global $objDefinition, $ilAccess;
300
301 $parent_obj_id = ilObject::_lookupObjId($a_parent_node_id);
302 if ($parent_obj_id > 0)
303 {
304 $parent_type = ilObject::_lookupType($parent_obj_id);
305 }
306 else
307 {
308 $parent_type = "dummy";
309 $this->type_grps["dummy"] = array("root" => "dummy");
310 }
311
312 // alex: if this is not initialized, things are messed up
313 // see bug 0015978
314 $this->type_grps = array();
315
316 if (empty($this->type_grps[$parent_type]))
317 {
318 $this->type_grps[$parent_type] =
319 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
320 }
321
322 // #14465 - item groups
323 include_once('./Services/Object/classes/class.ilObjectActivation.php');
324 $group = array();
325 $igroup = array(); // used for item groups, see bug #0015978
326 $in_any_group = array();
327 foreach ($a_childs as $child)
328 {
329 // item group: get childs
330 if ($child["type"] == "itgr")
331 {
332 $g = $child["child"];
334 if ($items)
335 {
336 // add item group ref id to item group block
337 $this->type_grps[$parent_type]["itgr"]["ref_ids"][] = $g;
338
339 // #16697 - check item group permissions
340 $may_read = $ilAccess->checkAccess('read', '', $g);
341
342 // see bug #0015978
343 if ($may_read)
344 {
345 include_once("./Services/Container/classes/class.ilContainerSorting.php");
346 $items = ilContainerSorting::_getInstance($parent_obj_id)->sortSubItems('itgr', $child["obj_id"], $items);
347 }
348
349 foreach($items as $item)
350 {
351 $in_any_group[] = $item["child"];
352
353 if ($may_read)
354 {
355 $igroup[$g][] = $item;
356 $group[$g][] = $item;
357 }
358 }
359 }
360 }
361 // type group
362 else
363 {
364 $g = $objDefinition->getGroupOfObj($child["type"]);
365 if ($g == "")
366 {
367 $g = $child["type"];
368 }
369 $group[$g][] = $child;
370 }
371 }
372
373 $in_any_group = array_unique($in_any_group);
374
375 // custom block sorting?
376 include_once("./Services/Container/classes/class.ilContainerSorting.php");
377 $sort = ilContainerSorting::_getInstance($parent_obj_id);
378 $block_pos = $sort->getBlockPositions();
379 if (sizeof($block_pos))
380 {
381 $tmp = $this->type_grps[$parent_type];
382
383 $this->type_grps[$parent_type] = array();
384 foreach ($block_pos as $block_type)
385 {
386 // type group
387 if (!is_numeric($block_type) &&
388 array_key_exists($block_type, $tmp))
389 {
390 $this->type_grps[$parent_type][$block_type] = $tmp[$block_type];
391 unset($tmp[$block_type]);
392 }
393 // item group
394 else
395 {
396 // using item group ref id directly
397 $this->type_grps[$parent_type][$block_type] = array();
398 }
399 }
400
401 // append missing
402 if (sizeof($tmp))
403 {
404 foreach ($tmp as $block_type => $grp)
405 {
406 $this->type_grps[$parent_type][$block_type] = $grp;
407 }
408 }
409
410 unset($tmp);
411 }
412
413 $childs = array();
414 $done = array();
415
416 foreach ($this->type_grps[$parent_type] as $t => $g)
417 {
418 // type group
419 if (is_array($group[$t]))
420 {
421 // see bug #0015978
422 // custom sorted igroups
423 if (is_array($igroup[$t]))
424 {
425 foreach ($igroup[$t] as $k => $item)
426 {
427 if (!in_array($item["child"], $done))
428 {
429 $childs[] = $item;
430 $done[] = $item["child"];
431 }
432 }
433 }
434 else
435 {
436 // do we have to sort this group??
437 include_once("./Services/Container/classes/class.ilContainer.php");
438 include_once("./Services/Container/classes/class.ilContainerSorting.php");
439 $sort = ilContainerSorting::_getInstance($parent_obj_id);
440 $group = $sort->sortItems($group);
441
442 // need extra session sorting here
443 if ($t == "sess")
444 {
445
446 }
447
448 foreach ($group[$t] as $k => $item)
449 {
450 if (!in_array($item["child"], $done) &&
451 !in_array($item["child"], $in_any_group)) // #16697
452 {
453 $childs[] = $item;
454 $done[] = $item["child"];
455 }
456 }
457 }
458 }
459 // item groups (if not custom block sorting)
460 else if ($t == "itgr" &&
461 is_array($g["ref_ids"]))
462 {
463 foreach ($g["ref_ids"] as $ref_id)
464 {
465 if (isset($group[$ref_id]))
466 {
467 foreach ($group[$ref_id] as $k => $item)
468 {
469 if(!in_array($item["child"], $done))
470 {
471 $childs[] = $item;
472 $done[] = $item["child"];
473 }
474 }
475 }
476 }
477 }
478 }
479
480 return $childs;
481 }
482
489 function getChildsOfNode($a_parent_node_id)
490 {
491 global $rbacsystem;
492
493 if (!$rbacsystem->checkAccess("read", $a_parent_node_id))
494 {
495 return array();
496 }
497
498 $obj_id = ilObject::_lookupObjId($a_parent_node_id);
499 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_parent_node_id, $obj_id))
500 {
501 return array();
502 }
503
504 return parent::getChildsOfNode($a_parent_node_id);
505 }
506
513 function isNodeClickable($a_node)
514 {
515 global $rbacsystem,$tree,$ilDB,$ilUser,$ilAccess;
516
517 $obj_id = ilObject::_lookupObjId($a_node["child"]);
518 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_node["child"], $obj_id))
519 {
520 return false;
521 }
522
523 switch ($a_node["type"])
524 {
525 case "crs":
526 return $ilAccess->checkAccess("read", "", $a_node["child"]);
527
528 // visible groups can allways be clicked; group processing decides
529 // what happens next
530 case "grp":
531 return true;
532
533 case 'tst':
534 if(!$rbacsystem->checkAccess("read", $a_node["child"]))
535 {
536 return false;
537 }
538
539 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $obj_id);
540 $res = $ilDB->query($query);
541 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
542 {
543 return (bool) $row->complete;
544 }
545 return false;
546
547 case 'svy':
548 if(!$rbacsystem->checkAccess("read", $a_node["child"]))
549 {
550 return false;
551 }
552
553 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $obj_id);
554 $res = $ilDB->query($query);
555 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
556 {
557 return (bool) $row->complete;
558 }
559 return false;
560
561 // media pools can only be edited
562 case "mep":
563 if ($rbacsystem->checkAccess("read", $a_node["child"]))
564 {
565 return true;
566 }
567 else
568 {
569 return false;
570 }
571 break;
572
573 case 'crsr':
574 case 'catr':
575 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
576 return ilContainerReferenceAccess::_isAccessible($a_node["child"]);
577
578 case 'prg':
579 return $rbacsystem->checkAccess("visible", $a_node["child"]);
580
581 // all other types are only clickable, if read permission is given
582 default:
583 if ($rbacsystem->checkAccess("read", $a_node["child"]))
584 {
585 // check if lm is online
586 if ($a_node["type"] == "lm")
587 {
588 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
589 $lm_obj =& new ilObjLearningModule($a_node["child"]);
590 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
591 {
592 return false;
593 }
594 }
595 // check if fblm is online
596 if ($a_node["type"] == "htlm")
597 {
598 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
599 $lm_obj =& new ilObjFileBasedLM($a_node["child"]);
600 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
601 {
602 return false;
603 }
604 }
605 // check if fblm is online
606 if ($a_node["type"] == "sahs")
607 {
608 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
609 $lm_obj =& new ilObjSAHSLearningModule($a_node["child"]);
610 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
611 {
612 return false;
613 }
614 }
615 // check if glossary is online
616 if ($a_node["type"] == "glo")
617 {
618 $obj_id = ilObject::_lookupObjectId($a_node["child"]);
619 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
620 if((!ilObjGlossary::_lookupOnline($obj_id)) &&
621 (!$rbacsystem->checkAccess('write', $a_node["child"])))
622 {
623 return false;
624 }
625 }
626
627 return true;
628 }
629 else
630 {
631 return false;
632 }
633 break;
634 }
635 }
636
637}
638
639?>
$n
Definition: RandomTest.php:80
$_GET["client_id"]
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
_checkAllConditionsOfTarget($a_target_ref_id, $a_target_id, $a_target_type="", $a_usr_id=0)
checks wether all conditions of a target object are fulfilled
static _isAccessible($a_ref_id)
Check if target is accessible and not deleted.
static _getInstance($a_obj_id)
get instance by obj_id
_getItemsOfContainer($a_ref_id)
setSkipRootNode($a_val)
Set skip root node.
File Based Learning Module (HTML) object.
_lookupOnline($a_id)
check wether content object is online
Class ilObjLearningModule.
Class ilObjSCORMLearningModule.
static getItemsByItemGroup($a_item_group_ref_id)
Get materials of item group.
static _lookupObjId($a_id)
static _lookupObjectId($a_ref_id)
lookup object id
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
static _lookupType($a_id, $a_reference=false)
lookup object type
Repository explorer GUI class.
getNodeContent($a_node)
Get node content.
getChildsOfNode($a_parent_node_id)
Get childs of node.
isNodeHighlighted($a_node)
Is node highlighted?
getNodeHref($a_node)
Get href for node.
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
isNodeClickable($a_node)
Is node clickable?
isNodeVisible($a_node)
Is node visible.
getNodeIconAlt($a_node)
Get node icon alt text.
static _lookupAppointment($a_obj_id)
lookup appointment
static _appointmentToString($start, $end, $fulltime)
Explorer class that works on tree objects (Services/Tree)
setTypeWhiteList($a_val)
Set type white list.
setPathOpen($a_id)
Set node path to be opened.
getNodeId($a_node)
Get id for node.
setOrderField($a_val, $a_numeric=false)
Set order field.
$white
Definition: example_030.php:84
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$ref_id
Definition: sahs_server.php:39
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15