ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 include_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  }
70  $this->setTypeWhiteList($white);
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 "grpr":
216  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
217  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
218  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
219  return $link;
220 
221  case "crs":
222  $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node["child"]);
223  $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
224  $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
225  return $link;
226 
227  case "crsr":
228  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
229  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
230  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
231  return $link;
232 
233  case 'rcrs':
234  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node["child"]);
235  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
236  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
237  return $link;
238 
239  case 'prg':
240  $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node["child"]);
241  $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
242  $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
243  return $link;
244 
245  default:
246  include_once('./Services/Link/classes/class.ilLink.php');
247  return ilLink::_getStaticLink($a_node["child"], $a_node["type"], true);
248 
249  }
250  }
251 
258  function isNodeVisible($a_node)
259  {
260  global $ilAccess,$tree,$ilSetting;
261 
262  if (!$ilAccess->checkAccess('visible', '', $a_node["child"]))
263  {
264  return false;
265  }
266 
267  $is_course = false;
268  $container_parent_id = $tree->checkForParentType($a_node["child"], 'grp');
269  if(!$container_parent_id)
270  {
271  $is_course = true;
272  $container_parent_id = $tree->checkForParentType($a_node["child"], 'crs');
273  }
274  if($container_parent_id)
275  {
276  // do not display session materials for container course/group
277  if($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_node["child"])
278  {
279  // get container event items only once
280  if(!isset($this->session_materials[$container_parent_id]))
281  {
282  include_once './Modules/Session/classes/class.ilEventItems.php';
283  $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
284  }
285  if(in_array($a_node["child"], $this->session_materials[$container_parent_id]))
286  {
287  return false;
288  }
289  }
290  }
291 
292  return true;
293  }
294 
303  function sortChilds($a_childs, $a_parent_node_id)
304  {
305  global $objDefinition, $ilAccess;
306 
307  $parent_obj_id = ilObject::_lookupObjId($a_parent_node_id);
308  if ($parent_obj_id > 0)
309  {
310  $parent_type = ilObject::_lookupType($parent_obj_id);
311  }
312  else
313  {
314  $parent_type = "dummy";
315  $this->type_grps["dummy"] = array("root" => "dummy");
316  }
317 
318  // alex: if this is not initialized, things are messed up
319  // see bug 0015978
320  $this->type_grps = array();
321 
322  if (empty($this->type_grps[$parent_type]))
323  {
324  $this->type_grps[$parent_type] =
325  $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
326  }
327 
328  // #14465 - item groups
329  include_once('./Services/Object/classes/class.ilObjectActivation.php');
330  $group = array();
331  $igroup = array(); // used for item groups, see bug #0015978
332  $in_any_group = array();
333  foreach ($a_childs as $child)
334  {
335  // item group: get childs
336  if ($child["type"] == "itgr")
337  {
338  $g = $child["child"];
340  if ($items)
341  {
342  // add item group ref id to item group block
343  $this->type_grps[$parent_type]["itgr"]["ref_ids"][] = $g;
344 
345  // #16697 - check item group permissions
346  $may_read = $ilAccess->checkAccess('read', '', $g);
347 
348  // see bug #0015978
349  if ($may_read)
350  {
351  include_once("./Services/Container/classes/class.ilContainerSorting.php");
352  $items = ilContainerSorting::_getInstance($parent_obj_id)->sortSubItems('itgr', $child["obj_id"], $items);
353  }
354 
355  foreach($items as $item)
356  {
357  $in_any_group[] = $item["child"];
358 
359  if ($may_read)
360  {
361  $igroup[$g][] = $item;
362  $group[$g][] = $item;
363  }
364  }
365  }
366  }
367  // type group
368  else
369  {
370  $g = $objDefinition->getGroupOfObj($child["type"]);
371  if ($g == "")
372  {
373  $g = $child["type"];
374  }
375  $group[$g][] = $child;
376  }
377  }
378 
379  $in_any_group = array_unique($in_any_group);
380 
381  // custom block sorting?
382  include_once("./Services/Container/classes/class.ilContainerSorting.php");
383  $sort = ilContainerSorting::_getInstance($parent_obj_id);
384  $block_pos = $sort->getBlockPositions();
385  if (sizeof($block_pos))
386  {
387  $tmp = $this->type_grps[$parent_type];
388 
389  $this->type_grps[$parent_type] = array();
390  foreach ($block_pos as $block_type)
391  {
392  // type group
393  if (!is_numeric($block_type) &&
394  array_key_exists($block_type, $tmp))
395  {
396  $this->type_grps[$parent_type][$block_type] = $tmp[$block_type];
397  unset($tmp[$block_type]);
398  }
399  // item group
400  else
401  {
402  // using item group ref id directly
403  $this->type_grps[$parent_type][$block_type] = array();
404  }
405  }
406 
407  // append missing
408  if (sizeof($tmp))
409  {
410  foreach ($tmp as $block_type => $grp)
411  {
412  $this->type_grps[$parent_type][$block_type] = $grp;
413  }
414  }
415 
416  unset($tmp);
417  }
418 
419  $childs = array();
420  $done = array();
421 
422  foreach ($this->type_grps[$parent_type] as $t => $g)
423  {
424  // type group
425  if (is_array($group[$t]))
426  {
427  // see bug #0015978
428  // custom sorted igroups
429  if (is_array($igroup[$t]))
430  {
431  foreach ($igroup[$t] as $k => $item)
432  {
433  if (!in_array($item["child"], $done))
434  {
435  $childs[] = $item;
436  $done[] = $item["child"];
437  }
438  }
439  }
440  else
441  {
442  // do we have to sort this group??
443  include_once("./Services/Container/classes/class.ilContainer.php");
444  include_once("./Services/Container/classes/class.ilContainerSorting.php");
445  $sort = ilContainerSorting::_getInstance($parent_obj_id);
446  $group = $sort->sortItems($group);
447 
448  // need extra session sorting here
449  if ($t == "sess")
450  {
451 
452  }
453 
454  foreach ($group[$t] as $k => $item)
455  {
456  if (!in_array($item["child"], $done) &&
457  !in_array($item["child"], $in_any_group)) // #16697
458  {
459  $childs[] = $item;
460  $done[] = $item["child"];
461  }
462  }
463  }
464  }
465  // item groups (if not custom block sorting)
466  else if ($t == "itgr" &&
467  is_array($g["ref_ids"]))
468  {
469  foreach ($g["ref_ids"] as $ref_id)
470  {
471  if (isset($group[$ref_id]))
472  {
473  foreach ($group[$ref_id] as $k => $item)
474  {
475  if(!in_array($item["child"], $done))
476  {
477  $childs[] = $item;
478  $done[] = $item["child"];
479  }
480  }
481  }
482  }
483  }
484  }
485 
486  return $childs;
487  }
488 
495  function getChildsOfNode($a_parent_node_id)
496  {
497  global $rbacsystem;
498 
499  if (!$rbacsystem->checkAccess("read", $a_parent_node_id))
500  {
501  return array();
502  }
503 
504  $obj_id = ilObject::_lookupObjId($a_parent_node_id);
505  if (!ilConditionHandler::_checkAllConditionsOfTarget($a_parent_node_id, $obj_id))
506  {
507  return array();
508  }
509 
510  return parent::getChildsOfNode($a_parent_node_id);
511  }
512 
519  function isNodeClickable($a_node)
520  {
521  global $rbacsystem,$tree,$ilDB,$ilUser,$ilAccess;
522 
523  $obj_id = ilObject::_lookupObjId($a_node["child"]);
524  if (!ilConditionHandler::_checkAllConditionsOfTarget($a_node["child"], $obj_id))
525  {
526  return false;
527  }
528 
529  switch ($a_node["type"])
530  {
531  case "crs":
532  return $ilAccess->checkAccess("read", "", $a_node["child"]);
533 
534  // visible groups can allways be clicked; group processing decides
535  // what happens next
536  case "grp":
537  return true;
538 
539  case 'tst':
540  if(!$rbacsystem->checkAccess("read", $a_node["child"]))
541  {
542  return false;
543  }
544 
545  $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $obj_id);
546  $res = $ilDB->query($query);
547  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
548  {
549  return (bool) $row->complete;
550  }
551  return false;
552 
553  case 'svy':
554  if(!$rbacsystem->checkAccess("read", $a_node["child"]))
555  {
556  return false;
557  }
558 
559  $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $obj_id);
560  $res = $ilDB->query($query);
561  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
562  {
563  return (bool) $row->complete;
564  }
565  return false;
566 
567  // media pools can only be edited
568  case "mep":
569  if ($rbacsystem->checkAccess("read", $a_node["child"]))
570  {
571  return true;
572  }
573  else
574  {
575  return false;
576  }
577  break;
578  case 'grpr':
579  case 'crsr':
580  case 'catr':
581  include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
582  return ilContainerReferenceAccess::_isAccessible($a_node["child"]);
583 
584  case 'prg':
585  return $rbacsystem->checkAccess("visible", $a_node["child"]);
586 
587  // all other types are only clickable, if read permission is given
588  default:
589  if ($rbacsystem->checkAccess("read", $a_node["child"]))
590  {
591  // check if lm is online
592  if ($a_node["type"] == "lm")
593  {
594  include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
595  $lm_obj = new ilObjLearningModule($a_node["child"]);
596  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
597  {
598  return false;
599  }
600  }
601  // check if fblm is online
602  if ($a_node["type"] == "htlm")
603  {
604  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
605  $lm_obj = new ilObjFileBasedLM($a_node["child"]);
606  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
607  {
608  return false;
609  }
610  }
611  // check if fblm is online
612  if ($a_node["type"] == "sahs")
613  {
614  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
615  $lm_obj = new ilObjSAHSLearningModule($a_node["child"]);
616  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write', $a_node["child"])))
617  {
618  return false;
619  }
620  }
621  // check if glossary is online
622  if ($a_node["type"] == "glo")
623  {
624  $obj_id = ilObject::_lookupObjectId($a_node["child"]);
625  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
626  if((!ilObjGlossary::_lookupOnline($obj_id)) &&
627  (!$rbacsystem->checkAccess('write', $a_node["child"])))
628  {
629  return false;
630  }
631  }
632 
633  return true;
634  }
635  else
636  {
637  return false;
638  }
639  break;
640  }
641  }
642 
643 }
644 
645 ?>
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
$path
Definition: aliased.php:25
Class ilObjLearningModule.
getNodeIconAlt($a_node)
Get node icon alt text.
$_GET["client_id"]
__construct($a_parent_obj, $a_parent_cmd)
Constructor.
static _getItemsOfContainer($a_ref_id)
setSkipRootNode($a_val)
Set skip root node.
File Based Learning Module (HTML) object.
getChildsOfNode($a_parent_node_id)
Get childs of node.
setPathOpen($a_id)
Set node path to be opened.
isNodeHighlighted($a_node)
Is node highlighted?
getNodeHref($a_node)
Get href for node.
setTypeWhiteList($a_val)
Set type white list.
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
static _isAccessible($a_ref_id)
Check if target is accessible and not deleted.
static _lookupObjId($a_id)
Repository explorer GUI class.
static _appointmentToString($start, $end, $fulltime)
sortChilds($a_childs, $a_parent_node_id)
Sort childs.
$ilUser
Definition: imgupload.php:18
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
$n
Definition: RandomTest.php:80
getNodeId($a_node)
Get id for node.
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
isNodeClickable($a_node)
Is node clickable?
getNodeContent($a_node)
Get node content.
$white
Definition: example_030.php:84
$ref_id
Definition: sahs_server.php:39
global $ilSetting
Definition: privfeed.php:17
Explorer class that works on tree objects (Services/Tree)
global $lng
Definition: privfeed.php:17
static _lookupAppointment($a_obj_id)
lookup appointment
global $ilDB
setOrderField($a_val, $a_numeric=false)
Set order field.
static getItemsByItemGroup($a_item_group_ref_id)
Get materials of item group.
isNodeVisible($a_node)
Is node visible.
static _getInstance($a_obj_id)
get instance by obj_id
Class ilObjSCORMLearningModule.
static _lookupOnline($a_id)
check wether content object is online