ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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
5require_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
24 var $ctrl;
31 function ilRepositoryExplorer($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::ilExplorer($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 $this->addFilter("root");
53 $this->addFilter("cat");
54 $this->addFilter('catr');
55 $this->addFilter('rcat');
56 $this->addFilter("grp");
57 $this->addFilter("icrs");
58 $this->addFilter('rgrp');
59 $this->addFilter("crs");
60 $this->addFilter('crsr');
61 $this->addFilter('rcrs');
62 $this->setFiltered(true);
64 }
65 else if ($ilSetting->get("repository_tree_pres") == "all_types")
66 {
67 foreach ($objDefinition->getAllRBACObjects() as $rtype)
68 {
69 $this->addFilter($rtype);
70 }
71 $this->setFiltered(true);
73 }
74 }
75
79 function setForceOpenPath($a_path)
80 {
81 $this->force_open_path = $a_path;
82 }
83
87 function buildLinkTarget($a_node_id, $a_type)
88 {
89 global $ilCtrl;
90
91 $ilCtrl->setTargetScript("ilias.php");
92
93 switch($a_type)
94 {
95 case "cat":
96 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
97 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
98 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
99 return $link;
100
101 case "catr":
102 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
103 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
104 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
105 return $link;
106
107 case "grp":
108 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node_id);
109 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjgroupgui"), "");
110 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $_GET["ref_id"]);
111 return $link;
112
113 case "crs":
114 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node_id);
115 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
116 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
117 return $link;
118
119 case "crsr":
120 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
121 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
122 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
123 return $link;
124
125 case "icrs":
126 $ilCtrl->setParameterByClass("ilobjilinccoursegui", "ref_id", $a_node_id);
127 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjilinccoursegui"), "");
128 $ilCtrl->setParameterByClass("ilobjilinccoursegui", "ref_id", $_GET["ref_id"]);
129 return $link;
130
131 case 'rcrs':
132 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
133 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
134 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
135 return $link;
136
137 default:
138 include_once('./Services/Link/classes/class.ilLink.php');
139 return ilLink::_getStaticLink($a_node_id, $a_type, true);
140
141 }
142 }
143
150 function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
151 {
152 global $ilias;
153
154 switch($a_type)
155 {
156 case "cat":
157 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
158 return $t_frame;
159
160 case "catr":
161 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "catr");
162 return $t_frame;
163
164 case "grp":
165 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
166 return $t_frame;
167
168 case "crs":
169 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
170 return $t_frame;
171
172 case "crsr":
173 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crsr");
174 return $t_frame;
175
176 case 'rcrs':
177 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent",'rcrs');
178 return $t_frame;
179
180 default:
181 return "_top";
182 }
183 }
184
188 function getImage($a_name, $a_type = "", $a_obj_id = "")
189 {
190 if ($a_type != "")
191 {
192 return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
193 }
194
195 return parent::getImage($a_name);
196 }
197
198 function isClickable($a_type, $a_ref_id,$a_obj_id = 0)
199 {
200 global $rbacsystem,$tree,$ilDB,$ilUser,$ilAccess;
201
203 {
204 return false;
205 }
206
207 switch ($a_type)
208 {
209 case "crs":
210 return $ilAccess->checkAccess("read", "", $a_ref_id);
211
212 // visible groups can allways be clicked; group processing decides
213 // what happens next
214 case "grp":
215 return true;
216
217 case 'tst':
218 if(!$rbacsystem->checkAccess("read", $a_ref_id))
219 {
220 return false;
221 }
222
223 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",$a_obj_id);
224 $res = $ilDB->query($query);
225 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
226 {
227 return (bool) $row->complete;
228 }
229 return false;
230
231 case 'svy':
232 if(!$rbacsystem->checkAccess("read", $a_ref_id))
233 {
234 return false;
235 }
236
237 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s",$a_obj_id);
238 $res = $ilDB->query($query);
239 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
240 {
241 return (bool) $row->complete;
242 }
243 return false;
244
245 // media pools can only be edited
246 case "mep":
247 if ($rbacsystem->checkAccess("read", $a_ref_id))
248 {
249 return true;
250 }
251 else
252 {
253 return false;
254 }
255 break;
256
257 case 'crsr':
258 case 'catr':
259 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
261
262
263 // all other types are only clickable, if read permission is given
264 default:
265 if ($rbacsystem->checkAccess("read", $a_ref_id))
266 {
267 // check if lm is online
268 if ($a_type == "lm")
269 {
270 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
271 $lm_obj =& new ilObjLearningModule($a_ref_id);
272 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
273 {
274 return false;
275 }
276 }
277 // check if fblm is online
278 if ($a_type == "htlm")
279 {
280 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
281 $lm_obj =& new ilObjFileBasedLM($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 == "sahs")
289 {
290 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
291 $lm_obj =& new ilObjSAHSLearningModule($a_ref_id);
292 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
293 {
294 return false;
295 }
296 }
297 // check if glossary is online
298 if ($a_type == "glo")
299 {
300 $obj_id = ilObject::_lookupObjectId($a_ref_id);
301 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
302 if((!ilObjGlossary::_lookupOnline($obj_id)) &&
303 (!$rbacsystem->checkAccess('write',$a_ref_id)))
304 {
305 return false;
306 }
307 }
308
309 return true;
310 }
311 else
312 {
313 return false;
314 }
315 break;
316 }
317 }
318
319 function showChilds($a_ref_id,$a_obj_id = 0)
320 {
321 global $rbacsystem,$tree;
322//vd($a_ref_id);
323
324 if ($a_ref_id == 0)
325 {
326 return true;
327 }
329 {
330 return false;
331 }
332 if ($rbacsystem->checkAccess("read", $a_ref_id))
333 {
334 return true;
335 }
336 else
337 {
338 return false;
339 }
340 }
341
342 function isVisible($a_ref_id,$a_type)
343 {
344 global $ilAccess,$tree,$ilSetting;
345
346 if(!$ilAccess->checkAccess('visible', '', $a_ref_id))
347 {
348 return false;
349 }
350
351 $is_course = false;
352 $container_parent_id = $tree->checkForParentType($a_ref_id,'grp');
353 if(!$container_parent_id)
354 {
355 $is_course = true;
356 $container_parent_id = $tree->checkForParentType($a_ref_id,'crs');
357 }
358 if($container_parent_id)
359 {
360 // do not display session materials for container course/group
361 if($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id)
362 {
363 // get container event items only once
364 if(!isset($this->session_materials[$container_parent_id]))
365 {
366 include_once './Modules/Session/classes/class.ilEventItems.php';
367 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
368 }
369 // get item group items only once
370 if(!isset($this->item_group_items[$container_parent_id]))
371 {
372 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
373 $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
374 }
375 if(in_array($a_ref_id, $this->session_materials[$container_parent_id]))
376 {
377 return false;
378 }
379 if(in_array($a_ref_id, $this->item_group_items[$container_parent_id]))
380 {
381 return false;
382 }
383 }
384 }
385
386 return true;
387 }
388
389
390
398 function formatHeader(&$tpl, $a_obj_id,$a_option)
399 {
400 global $lng, $ilias, $tree, $ilCtrl;
401
402 // custom icons
403 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
404
405 $tpl->setCurrentBlock("icon");
406 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
407 $title = $nd["title"];
408 if ($title == "ILIAS")
409 {
410 $title = $lng->txt("repository");
411 }
412
413 $tpl->setVariable("ICON_IMAGE", $path);
414 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon")." ".$title);
415 $tpl->parseCurrentBlock();
416
417 $tpl->setCurrentBlock("link");
418 $tpl->setVariable("TITLE", $title);
419 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
420 $tpl->setVariable("LINK_TARGET",
421 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
422 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
423 $tpl->setVariable("TARGET", " target=\"_top\"");
424 $tpl->parseCurrentBlock();
425
426 $tpl->setCurrentBlock("element");
427 $tpl->parseCurrentBlock();
428 }
429
437 public function sortNodes($a_nodes,$a_parent_obj_id)
438 {
439 global $objDefinition;
440
441 if ($a_parent_obj_id > 0)
442 {
443 $parent_type = ilObject::_lookupType($a_parent_obj_id);
444 }
445 else
446 {
447 $parent_type = "dummy";
448 $this->type_grps["dummy"] = array("root" => "dummy");
449 }
450
451 if (empty($this->type_grps[$parent_type]))
452 {
453 $this->type_grps[$parent_type] =
454 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
455 }
456 $group = array();
457
458 foreach ($a_nodes as $node)
459 {
460 $g = $objDefinition->getGroupOfObj($node["type"]);
461 if ($g == "")
462 {
463 $g = $node["type"];
464 }
465 $group[$g][] = $node;
466 }
467
468 $nodes = array();
469 foreach ($this->type_grps[$parent_type] as $t => $g)
470 {
471 if (is_array($group[$t]))
472 {
473 // do we have to sort this group??
474 include_once("./Services/Container/classes/class.ilContainer.php");
475 include_once("./Services/Container/classes/class.ilContainerSorting.php");
476 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
477 $group = $sort->sortItems($group);
478
479 // need extra session sorting here
480 if ($t == "sess")
481 {
482
483 }
484
485 foreach ($group[$t] as $k => $item)
486 {
487 $nodes[] = $item;
488 }
489 }
490 }
491
492 return $nodes;
493 //return parent::sortNodes($a_nodes,$a_parent_obj_id);
494 }
495
502 function forceExpanded($a_node)
503 {
504 if (in_array($a_node, $this->force_open_path))
505 {
506 return true;
507 }
508 return false;
509 }
510
511} // END class ilRepositoryExplorer
512?>
global $tpl
Definition: ilias.php:8
$_GET["client_id"]
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
const IL_FM_POSITIVE
_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)
Class ilExplorer class for explorer view in admin frame.
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter @access public
setTitle($a_val)
Set title.
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
setFiltered($a_bool)
active/deactivate the filter @access public
static _getFrame($a_class, $a_type='')
Get content frame name.
File Based Learning Module (HTML) object.
_lookupOnline($a_id)
check wether content object is online
Class ilObjLearningModule.
Class ilObjSCORMLearningModule.
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
forceExpanded($a_node)
Force expansion of node.
isClickable($a_type, $a_ref_id, $a_obj_id=0)
getImage($a_name, $a_type="", $a_obj_id="")
get image path
formatHeader(&$tpl, $a_obj_id, $a_option)
overwritten method from base class @access public
sortNodes($a_nodes, $a_parent_obj_id)
sort nodes
buildLinkTarget($a_node_id, $a_type)
note: most of this stuff is used by ilCourseContentInterface too
setForceOpenPath($a_path)
set force open path
showChilds($a_ref_id, $a_obj_id=0)
ilRepositoryExplorer($a_target, $a_top_node=0)
Constructor @access public.
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
STATIC, do not use $this inside!
$nd
Definition: error.php:9
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
global $ilSetting
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15