ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilRepositoryExplorer.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once("./Services/UIComponent/Explorer/classes/class.ilExplorer.php");
6 
7 /*
8  * Repository Explorer
9  *
10  * @author Alex Killing <alex.killing@gmx.de>
11  * @version $Id$
12  * @ingroup ServicesRepository
13  */
15 {
16 
22  var $root_id;
23  var $output;
24  var $ctrl;
31  function __construct($a_target, $a_top_node = 0)
32  {
33  global $tree, $ilCtrl, $lng, $ilSetting, $objDefinition;
34 
35  $this->ctrl = $ilCtrl;
36 
37 
38  $this->force_open_path = array();
39 
40 
41  parent::__construct($a_target);
42  $this->tree = $tree;
43  $this->root_id = $this->tree->readRootId();
44  $this->order_column = "title";
45  $this->setSessionExpandVariable("repexpand");
46  $this->setTitle($lng->txt("overview"));
47 
48  // please do not uncomment this
49  if ($ilSetting->get("repository_tree_pres") == "" ||
50  ($ilSetting->get("rep_tree_limit_grp_crs") && $a_top_node == 0))
51  {
52  foreach($objDefinition->getExplorerContainerTypes() as $type)
53  {
54  $this->addFilter($type);
55  }
56  $this->setFiltered(true);
58  }
59  else if ($ilSetting->get("repository_tree_pres") == "all_types")
60  {
61  foreach ($objDefinition->getAllRBACObjects() as $rtype)
62  {
63  $this->addFilter($rtype);
64  }
65  $this->setFiltered(true);
67  }
68  }
69 
73  function setForceOpenPath($a_path)
74  {
75  $this->force_open_path = $a_path;
76  }
77 
81  function buildLinkTarget($a_node_id, $a_type)
82  {
83  global $ilCtrl;
84 
85  $ilCtrl->setTargetScript("ilias.php");
86 
87  switch($a_type)
88  {
89  case "cat":
90  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
91  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
92  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
93  return $link;
94 
95  case "catr":
96  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
97  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
98  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
99  return $link;
100 
101  case "grp":
102  $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node_id);
103  $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjgroupgui"), "");
104  $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $_GET["ref_id"]);
105  return $link;
106  case "grpr":
107  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
108  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
109  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
110  return $link;
111 
112  case "crs":
113  $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node_id);
114  $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
115  $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
116  return $link;
117 
118  case "crsr":
119  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
120  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
121  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
122  return $link;
123 
124  case 'rcrs':
125  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
126  $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
127  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
128  return $link;
129 
130  case 'prg':
131  $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node_id);
132  $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
133  $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
134  return $link;
135 
136  default:
137  include_once('./Services/Link/classes/class.ilLink.php');
138  return ilLink::_getStaticLink($a_node_id, $a_type, true);
139 
140  }
141  }
142 
149  function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
150  {
151  global $ilias;
152 
153  switch($a_type)
154  {
155  case "cat":
156  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
157  return $t_frame;
158 
159  case "catr":
160  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "catr");
161  return $t_frame;
162 
163  case "grp":
164  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
165  return $t_frame;
166 
167  case "grpr":
168  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grpr");
169  return $t_frame;
170 
171  case "crs":
172  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
173  return $t_frame;
174 
175  case "crsr":
176  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crsr");
177  return $t_frame;
178 
179  case 'rcrs':
180  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent",'rcrs');
181  return $t_frame;
182 
183  case 'prg':
184  $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent",'prg');
185  return $t_frame;
186 
187  default:
188  return "_top";
189  }
190  }
191 
195  function getImage($a_name, $a_type = "", $a_obj_id = "")
196  {
197  if ($a_type != "")
198  {
199  return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
200  }
201 
202  return parent::getImage($a_name);
203  }
204 
205  function isClickable($a_type, $a_ref_id = 0,$a_obj_id = 0)
206  {
207  global $rbacsystem,$tree,$ilDB,$ilUser,$ilAccess;
208 
209  if(!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id,$a_obj_id))
210  {
211  return false;
212  }
213 
214  switch ($a_type)
215  {
216  case "crs":
217  return $ilAccess->checkAccess("read", "", $a_ref_id);
218 
219  // visible groups can allways be clicked; group processing decides
220  // what happens next
221  case "grp":
222  return true;
223 
224  case 'tst':
225  if(!$rbacsystem->checkAccess("read", $a_ref_id))
226  {
227  return false;
228  }
229 
230  $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",$a_obj_id);
231  $res = $ilDB->query($query);
232  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
233  {
234  return (bool) $row->complete;
235  }
236  return false;
237 
238  case 'svy':
239  if(!$rbacsystem->checkAccess("read", $a_ref_id))
240  {
241  return false;
242  }
243 
244  $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s",$a_obj_id);
245  $res = $ilDB->query($query);
246  while($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT))
247  {
248  return (bool) $row->complete;
249  }
250  return false;
251 
252  // media pools can only be edited
253  case "mep":
254  if ($rbacsystem->checkAccess("read", $a_ref_id))
255  {
256  return true;
257  }
258  else
259  {
260  return false;
261  }
262  break;
263  case 'grpr':
264  case 'crsr':
265  case 'catr':
266  include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
268  case 'prg':
269  return $rbacsystem->checkAccess("visible", $a_ref_id);
270 
271 
272 
273  // all other types are only clickable, if read permission is given
274  default:
275  if ($rbacsystem->checkAccess("read", $a_ref_id))
276  {
277  // check if lm is online
278  if ($a_type == "lm")
279  {
280  include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
281  $lm_obj = new ilObjLearningModule($a_ref_id);
282  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
283  {
284  return false;
285  }
286  }
287  // check if fblm is online
288  if ($a_type == "htlm")
289  {
290  include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
291  $lm_obj = new ilObjFileBasedLM($a_ref_id);
292  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
293  {
294  return false;
295  }
296  }
297  // check if fblm is online
298  if ($a_type == "sahs")
299  {
300  include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
301  $lm_obj = new ilObjSAHSLearningModule($a_ref_id);
302  if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
303  {
304  return false;
305  }
306  }
307  // check if glossary is online
308  if ($a_type == "glo")
309  {
310  $obj_id = ilObject::_lookupObjectId($a_ref_id);
311  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
312  if((!ilObjGlossary::_lookupOnline($obj_id)) &&
313  (!$rbacsystem->checkAccess('write',$a_ref_id)))
314  {
315  return false;
316  }
317  }
318 
319  return true;
320  }
321  else
322  {
323  return false;
324  }
325  break;
326  }
327  }
328 
329  function showChilds($a_ref_id,$a_obj_id = 0)
330  {
331  global $rbacsystem,$tree;
332 //vd($a_ref_id);
333 
334  if ($a_ref_id == 0)
335  {
336  return true;
337  }
338  if(!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id,$a_obj_id))
339  {
340  return false;
341  }
342  if ($rbacsystem->checkAccess("read", $a_ref_id))
343  {
344  return true;
345  }
346  else
347  {
348  return false;
349  }
350  }
351 
352  function isVisible($a_ref_id,$a_type)
353  {
354  global $ilAccess,$tree,$ilSetting;
355 
356  if(!$ilAccess->checkAccess('visible', '', $a_ref_id))
357  {
358  return false;
359  }
360 
361  $is_course = false;
362  $container_parent_id = $tree->checkForParentType($a_ref_id,'grp');
363  if(!$container_parent_id)
364  {
365  $is_course = true;
366  $container_parent_id = $tree->checkForParentType($a_ref_id,'crs');
367  }
368  if($container_parent_id)
369  {
370  // do not display session materials for container course/group
371  if($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id)
372  {
373  // get container event items only once
374  if(!isset($this->session_materials[$container_parent_id]))
375  {
376  include_once './Modules/Session/classes/class.ilEventItems.php';
377  $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
378  }
379  // get item group items only once
380  if(!isset($this->item_group_items[$container_parent_id]))
381  {
382  include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
383  $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
384  }
385  if(in_array($a_ref_id, $this->session_materials[$container_parent_id]))
386  {
387  return false;
388  }
389  if(in_array($a_ref_id, $this->item_group_items[$container_parent_id]))
390  {
391  return false;
392  }
393  }
394  }
395 
396  return true;
397  }
398 
399 
400 
408  function formatHeader($tpl, $a_obj_id,$a_option)
409  {
410  global $lng, $ilias, $tree, $ilCtrl;
411 
412  // custom icons
413  $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
414 
415  $tpl->setCurrentBlock("icon");
416  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
417  $title = $nd["title"];
418  if ($title == "ILIAS")
419  {
420  $title = $lng->txt("repository");
421  }
422 
423  $tpl->setVariable("ICON_IMAGE", $path);
424  $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon")." ".$title);
425  $tpl->parseCurrentBlock();
426 
427  $tpl->setCurrentBlock("link");
428  $tpl->setVariable("TITLE", $title);
429  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
430  $tpl->setVariable("LINK_TARGET",
431  $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
432  $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
433  $tpl->setVariable("TARGET", " target=\"_top\"");
434  $tpl->parseCurrentBlock();
435 
436  $tpl->setCurrentBlock("element");
437  $tpl->parseCurrentBlock();
438  }
439 
447  public function sortNodes($a_nodes,$a_parent_obj_id)
448  {
449  global $objDefinition;
450 
451  if ($a_parent_obj_id > 0)
452  {
453  $parent_type = ilObject::_lookupType($a_parent_obj_id);
454  }
455  else
456  {
457  $parent_type = "dummy";
458  $this->type_grps["dummy"] = array("root" => "dummy");
459  }
460 
461  if (empty($this->type_grps[$parent_type]))
462  {
463  $this->type_grps[$parent_type] =
464  $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
465  }
466  $group = array();
467 
468  foreach ($a_nodes as $node)
469  {
470  $g = $objDefinition->getGroupOfObj($node["type"]);
471  if ($g == "")
472  {
473  $g = $node["type"];
474  }
475  $group[$g][] = $node;
476  }
477 
478  $nodes = array();
479  foreach ($this->type_grps[$parent_type] as $t => $g)
480  {
481  if (is_array($group[$t]))
482  {
483  // do we have to sort this group??
484  include_once("./Services/Container/classes/class.ilContainer.php");
485  include_once("./Services/Container/classes/class.ilContainerSorting.php");
486  $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
487  $group = $sort->sortItems($group);
488 
489  // need extra session sorting here
490  if ($t == "sess")
491  {
492 
493  }
494 
495  foreach ($group[$t] as $k => $item)
496  {
497  $nodes[] = $item;
498  }
499  }
500  }
501 
502  return $nodes;
503  //return parent::sortNodes($a_nodes,$a_parent_obj_id);
504  }
505 
512  function forceExpanded($a_node)
513  {
514  if (in_array($a_node, $this->force_open_path))
515  {
516  return true;
517  }
518  return false;
519  }
520 
521 } // END class ilRepositoryExplorer
522 ?>
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.
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
buildLinkTarget($a_node_id, $a_type)
note: most of this stuff is used by ilCourseContentInterface too
$_GET["client_id"]
static _getItemsOfContainer($a_ref_id)
File Based Learning Module (HTML) object.
const IL_FM_POSITIVE
setFiltered($a_bool)
active/deactivate the filter public
global $tpl
Definition: ilias.php:8
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
$a_type
Definition: workflow.php:93
static _getItemsOfContainer($a_ref_id)
$nd
Definition: error.php:11
isClickable($a_type, $a_ref_id=0, $a_obj_id=0)
sortNodes($a_nodes, $a_parent_obj_id)
sort nodes
formatHeader($tpl, $a_obj_id, $a_option)
overwritten method from base class public
static _isAccessible($a_ref_id)
Check if target is accessible and not deleted.
getImage($a_name, $a_type="", $a_obj_id="")
get image path
$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
forceExpanded($a_node)
Force expansion of node.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
STATIC, do not use $this inside!
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
setForceOpenPath($a_path)
set force open path
Class ilExplorer class for explorer view in admin frame.
static _getFrame($a_class, $a_type='')
Get content frame name.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
global $ilDB
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter public
static _getInstance($a_obj_id)
get instance by obj_id
__construct($a_target, $a_top_node=0)
Constructor public.
showChilds($a_ref_id, $a_obj_id=0)
setTitle($a_val)
Set title.
Class ilObjSCORMLearningModule.
static _lookupOnline($a_id)
check wether content object is online