ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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{
21 protected $settings;
22
26 protected $obj_definition;
27
31 protected $lng;
32
36 protected $ctrl;
37
41 protected $access;
42
46 protected $rbacsystem;
47
51 protected $db;
52
56 protected $user;
57
58 protected $type_grps = array();
59 protected $session_materials = array();
60
64 public function __construct($a_parent_obj, $a_parent_cmd)
65 {
66 global $DIC;
67
68 $this->tree = $DIC->repositoryTree();
69 $this->settings = $DIC->settings();
70 $this->obj_definition = $DIC["objDefinition"];
71 $this->lng = $DIC->language();
72 $this->ctrl = $DIC->ctrl();
73 $this->access = $DIC->access();
74 $this->rbacsystem = $DIC->rbac()->system();
75 $this->db = $DIC->database();
76 $this->user = $DIC->user();
77 $tree = $DIC->repositoryTree();
78 $ilSetting = $DIC->settings();
79 $objDefinition = $DIC["objDefinition"];
80
81 $this->cur_ref_id = (int) $_GET["ref_id"];
82
83 $this->top_node_id = 0;
84 if ($ilSetting->get("rep_tree_limit_grp_crs") && $this->cur_ref_id > 0) {
85 $path = $tree->getPathId($this->cur_ref_id);
86 foreach ($path as $n) {
87 if ($top_node > 0) {
88 break;
89 }
90 if (in_array(
92 array("crs", "grp")
93 )) {
94 $this->top_node_id = $n;
95 }
96 }
97 }
98
99 parent::__construct("rep_exp", $a_parent_obj, $a_parent_cmd, $tree);
100
101 $this->setSkipRootNode(false);
102 $this->setAjax(true);
103 $this->setOrderField("title");
104 if ($ilSetting->get("repository_tree_pres") == "" ||
105 ($ilSetting->get("rep_tree_limit_grp_crs") && $this->top_node_id == 0)) {
106 $this->setTypeWhiteList($objDefinition->getExplorerContainerTypes());
107 } elseif ($ilSetting->get("repository_tree_pres") == "all_types") {
108 $white = array();
109 foreach ($objDefinition->getSubObjectsRecursively("root") as $rtype) {
110 if (/* $rtype["name"] != "itgr" && */ !$objDefinition->isSideBlock($rtype["name"])) {
111 $white[] = $rtype["name"];
112 }
113 }
114 $this->setTypeWhiteList($white);
115 }
116 if ((int) $_GET["ref_id"] > 0) {
117 $this->setPathOpen((int) $_GET["ref_id"]);
118 }
119 }
120
127 public function getRootNode()
128 {
129 if ($this->top_node_id > 0) {
130 return $this->getTree()->getNodeData($this->top_node_id);
131 } else {
132 return parent::getRootNode();
133 }
134 }
135
142 public function getNodeContent($a_node)
143 {
145
146 $title = $a_node["title"];
147
148 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
149 if ($title == "ILIAS") {
150 $title = $lng->txt("repository");
151 }
152 } elseif ($a_node["type"] == "sess" &&
153 !trim($title)) {
154 // #14367 - see ilObjSessionListGUI
155 include_once('./Modules/Session/classes/class.ilSessionAppointment.php');
156 $app_info = ilSessionAppointment::_lookupAppointment($a_node["obj_id"]);
157 $title = ilSessionAppointment::_appointmentToString($app_info['start'], $app_info['end'], $app_info['fullday']);
158 }
159
160 return $title;
161 }
162
169 public function getNodeIcon($a_node)
170 {
171 $obj_id = ilObject::_lookupObjId($a_node["child"]);
172 return ilObject::_getIcon($obj_id, "tiny", $a_node["type"]);
173 }
174
181 public function getNodeIconAlt($a_node)
182 {
184
185 if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
186 $title = $a_node["title"];
187 if ($title == "ILIAS") {
188 $title = $lng->txt("repository");
189 }
190 return $lng->txt("icon") . " " . $title;
191 }
192
193
194 return parent::getNodeIconAlt($a_node);
195 }
196
203 public function isNodeHighlighted($a_node)
204 {
205 if ($a_node["child"] == $_GET["ref_id"] ||
206 ($_GET["ref_id"] == "" && $a_node["child"] == $this->getNodeId($this->getRootNode()))) {
207 return true;
208 }
209 return false;
210 }
211
218 public function getNodeHref($a_node)
219 {
221
222 switch ($a_node["type"]) {
223 case "root":
224 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
225 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
226 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
227 return $link;
228
229 case "cat":
230 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
231 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
232 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
233 return $link;
234
235 case "catr":
236 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
237 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
238 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
239 return $link;
240
241 case "grp":
242 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node["child"]);
243 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjgroupgui"), "");
244 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $_GET["ref_id"]);
245 return $link;
246
247 case "grpr":
248 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
249 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
250 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
251 return $link;
252
253 case "crs":
254 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node["child"]);
255 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
256 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
257 return $link;
258
259 case "crsr":
260 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
261 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
262 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
263 return $link;
264
265 case 'rcrs':
266 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
267 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
268 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
269 return $link;
270
271 case 'prg':
272 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node["child"]);
273 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjstudyprogrammegui"), "view");
274 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
275 return $link;
276
277 default:
278 include_once('./Services/Link/classes/class.ilLink.php');
279 return ilLink::_getStaticLink($a_node["child"], $a_node["type"], true);
280
281 }
282 }
283
290 public function isNodeVisible($a_node)
291 {
292 $ilAccess = $this->access;
295
296 if (!$ilAccess->checkAccess('visible', '', $a_node["child"])) {
297 return false;
298 }
299
300 $is_course = false;
301 $container_parent_id = $tree->checkForParentType($a_node["child"], 'grp');
302 if (!$container_parent_id) {
303 $is_course = true;
304 $container_parent_id = $tree->checkForParentType($a_node["child"], 'crs');
305 }
306 if ($container_parent_id) {
307 // do not display session materials for container course/group
308 if ($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_node["child"]) {
309 // get container event items only once
310 if (!isset($this->session_materials[$container_parent_id])) {
311 include_once './Modules/Session/classes/class.ilEventItems.php';
312 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
313 }
314 if (in_array($a_node["child"], $this->session_materials[$container_parent_id])) {
315 return false;
316 }
317 }
318 }
319
320 return true;
321 }
322
331 public function sortChilds($a_childs, $a_parent_node_id)
332 {
333 $objDefinition = $this->obj_definition;
334 $ilAccess = $this->access;
335
336 $parent_obj_id = ilObject::_lookupObjId($a_parent_node_id);
337 if ($parent_obj_id > 0) {
338 $parent_type = ilObject::_lookupType($parent_obj_id);
339 } else {
340 $parent_type = "dummy";
341 $this->type_grps["dummy"] = array("root" => "dummy");
342 }
343
344 // alex: if this is not initialized, things are messed up
345 // see bug 0015978
346 $this->type_grps = array();
347
348 if (empty($this->type_grps[$parent_type])) {
349 $this->type_grps[$parent_type] =
350 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
351 }
352
353 // #14465 - item groups
354 include_once('./Services/Object/classes/class.ilObjectActivation.php');
355 $group = array();
356 $igroup = array(); // used for item groups, see bug #0015978
357 $in_any_group = array();
358 foreach ($a_childs as $child) {
359 // item group: get childs
360 if ($child["type"] == "itgr") {
361 $g = $child["child"];
363 if ($items) {
364 // add item group ref id to item group block
365 $this->type_grps[$parent_type]["itgr"]["ref_ids"][] = $g;
366
367 // #16697 - check item group permissions
368 $may_read = $ilAccess->checkAccess('read', '', $g);
369
370 // see bug #0015978
371 if ($may_read) {
372 include_once("./Services/Container/classes/class.ilContainerSorting.php");
373 $items = ilContainerSorting::_getInstance($parent_obj_id)->sortSubItems('itgr', $child["obj_id"], $items);
374 }
375
376 foreach ($items as $item) {
377 $in_any_group[] = $item["child"];
378
379 if ($may_read) {
380 $igroup[$g][] = $item;
381 $group[$g][] = $item;
382 }
383 }
384 }
385 }
386 // type group
387 else {
388 $g = $objDefinition->getGroupOfObj($child["type"]);
389 if ($g == "") {
390 $g = $child["type"];
391 }
392 $group[$g][] = $child;
393 }
394 }
395
396 $in_any_group = array_unique($in_any_group);
397
398 // custom block sorting?
399 include_once("./Services/Container/classes/class.ilContainerSorting.php");
400 $sort = ilContainerSorting::_getInstance($parent_obj_id);
401 $block_pos = $sort->getBlockPositions();
402 if (is_array($block_pos) && count($block_pos) > 0) {
403 $tmp = $this->type_grps[$parent_type];
404
405 $this->type_grps[$parent_type] = array();
406 foreach ($block_pos as $block_type) {
407 // type group
408 if (!is_numeric($block_type) &&
409 array_key_exists($block_type, $tmp)) {
410 $this->type_grps[$parent_type][$block_type] = $tmp[$block_type];
411 unset($tmp[$block_type]);
412 }
413 // item group
414 else {
415 // using item group ref id directly
416 $this->type_grps[$parent_type][$block_type] = array();
417 }
418 }
419
420 // append missing
421 if (sizeof($tmp)) {
422 foreach ($tmp as $block_type => $grp) {
423 $this->type_grps[$parent_type][$block_type] = $grp;
424 }
425 }
426
427 unset($tmp);
428 }
429
430 $childs = array();
431 $done = array();
432
433 foreach ($this->type_grps[$parent_type] as $t => $g) {
434 // type group
435 if (is_array($group[$t])) {
436 // see bug #0015978
437 // custom sorted igroups
438 if (is_array($igroup[$t])) {
439 foreach ($igroup[$t] as $k => $item) {
440 if (!in_array($item["child"], $done)) {
441 $childs[] = $item;
442 $done[] = $item["child"];
443 }
444 }
445 } else {
446 // do we have to sort this group??
447 include_once("./Services/Container/classes/class.ilContainer.php");
448 include_once("./Services/Container/classes/class.ilContainerSorting.php");
449 $sort = ilContainerSorting::_getInstance($parent_obj_id);
450 $group = $sort->sortItems($group);
451
452 // need extra session sorting here
453 if ($t == "sess") {
454 }
455
456 foreach ($group[$t] as $k => $item) {
457 if (!in_array($item["child"], $done) &&
458 !in_array($item["child"], $in_any_group)) { // #16697
459 $childs[] = $item;
460 $done[] = $item["child"];
461 }
462 }
463 }
464 }
465 // item groups (if not custom block sorting)
466 elseif ($t == "itgr" &&
467 is_array($g["ref_ids"])) {
468 foreach ($g["ref_ids"] as $ref_id) {
469 if (isset($group[$ref_id])) {
470 foreach ($group[$ref_id] as $k => $item) {
471 if (!in_array($item["child"], $done)) {
472 $childs[] = $item;
473 $done[] = $item["child"];
474 }
475 }
476 }
477 }
478 }
479 }
480
481 return $childs;
482 }
483
490 public function getChildsOfNode($a_parent_node_id)
491 {
493
494 if (!$rbacsystem->checkAccess("read", $a_parent_node_id)) {
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 return array();
501 }
502
503 return parent::getChildsOfNode($a_parent_node_id);
504 }
505
512 public function isNodeClickable($a_node)
513 {
518 $ilAccess = $this->access;
519
520 $obj_id = ilObject::_lookupObjId($a_node["child"]);
521 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_node["child"], $obj_id)) {
522 return false;
523 }
524
525 switch ($a_node["type"]) {
526 case 'tst':
527 if (!$rbacsystem->checkAccess("read", $a_node["child"])) {
528 return false;
529 }
530
531 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $obj_id);
532 $res = $ilDB->query($query);
533 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
534 return (bool) $row->complete;
535 }
536 return false;
537
538 case 'svy':
539 if (!$rbacsystem->checkAccess("read", $a_node["child"])) {
540 return false;
541 }
542
543 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $obj_id);
544 $res = $ilDB->query($query);
545 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
546 return (bool) $row->complete;
547 }
548 return false;
549
550 // media pools can only be edited
551 case "mep":
552 if ($rbacsystem->checkAccess("read", $a_node["child"])) {
553 return true;
554 } else {
555 return false;
556 }
557 break;
558 case 'grpr':
559 case 'crsr':
560 case 'catr':
561 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
562 return ilContainerReferenceAccess::_isAccessible($a_node["child"]);
563
564 case 'prg':
565 return $rbacsystem->checkAccess("read", $a_node["child"]);
566
567 // all other types are only clickable, if read permission is given
568 default:
569 if ($rbacsystem->checkAccess("read", $a_node["child"])) {
570 // check if lm is online
571 if ($a_node["type"] == "lm") {
572 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
573 $lm_obj = new ilObjLearningModule($a_node["child"]);
574 if ((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"]))) {
575 return false;
576 }
577 }
578 // check if fblm is online
579 if ($a_node["type"] == "htlm") {
580 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
581 $lm_obj = new ilObjFileBasedLM($a_node["child"]);
582 if ((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"]))) {
583 return false;
584 }
585 }
586 // check if fblm is online
587 if ($a_node["type"] == "sahs") {
588 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
589 $lm_obj = new ilObjSAHSLearningModule($a_node["child"]);
590 if ((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"]))) {
591 return false;
592 }
593 }
594 // check if glossary is online
595 if ($a_node["type"] == "glo") {
596 $obj_id = ilObject::_lookupObjectId($a_node["child"]);
597 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
598 if ((!ilObjGlossary::_lookupOnline($obj_id)) &&
599 (!$rbacsystem->checkAccess('write', $a_node["child"]))) {
600 return false;
601 }
602 }
603
604 return true;
605 } else {
606 return false;
607 }
608 break;
609 }
610 }
611}
sprintf('%.4f', $callTime)
user()
Definition: user.php:4
$n
Definition: RandomTest.php:85
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
static _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
static _getItemsOfContainer($a_ref_id)
setSkipRootNode($a_val)
Set skip root node.
File Based Learning Module (HTML) object.
static _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 $ilSetting
Definition: privfeed.php:17
$query
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB
$ilUser
Definition: imgupload.php:18