ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 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
107 case "crs":
108 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node_id);
109 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
110 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
111 return $link;
112
113 case "crsr":
114 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
115 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
116 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
117 return $link;
118
119 case 'rcrs':
120 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
121 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
122 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
123 return $link;
124
125 case 'prg':
126 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node_id);
127 $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
128 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
129 return $link;
130
131 default:
132 include_once('./Services/Link/classes/class.ilLink.php');
133 return ilLink::_getStaticLink($a_node_id, $a_type, true);
134
135 }
136 }
137
144 function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
145 {
146 global $ilias;
147
148 switch($a_type)
149 {
150 case "cat":
151 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
152 return $t_frame;
153
154 case "catr":
155 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "catr");
156 return $t_frame;
157
158 case "grp":
159 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
160 return $t_frame;
161
162 case "crs":
163 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
164 return $t_frame;
165
166 case "crsr":
167 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crsr");
168 return $t_frame;
169
170 case 'rcrs':
171 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent",'rcrs');
172 return $t_frame;
173
174 case 'prg':
175 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent",'prg');
176 return $t_frame;
177
178 default:
179 return "_top";
180 }
181 }
182
186 function getImage($a_name, $a_type = "", $a_obj_id = "")
187 {
188 if ($a_type != "")
189 {
190 return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
191 }
192
193 return parent::getImage($a_name);
194 }
195
196 function isClickable($a_type, $a_ref_id,$a_obj_id = 0)
197 {
198 global $rbacsystem,$tree,$ilDB,$ilUser,$ilAccess;
199
201 {
202 return false;
203 }
204
205 switch ($a_type)
206 {
207 case "crs":
208 return $ilAccess->checkAccess("read", "", $a_ref_id);
209
210 // visible groups can allways be clicked; group processing decides
211 // what happens next
212 case "grp":
213 return true;
214
215 case 'tst':
216 if(!$rbacsystem->checkAccess("read", $a_ref_id))
217 {
218 return false;
219 }
220
221 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",$a_obj_id);
222 $res = $ilDB->query($query);
223 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
224 {
225 return (bool) $row->complete;
226 }
227 return false;
228
229 case 'svy':
230 if(!$rbacsystem->checkAccess("read", $a_ref_id))
231 {
232 return false;
233 }
234
235 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s",$a_obj_id);
236 $res = $ilDB->query($query);
237 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
238 {
239 return (bool) $row->complete;
240 }
241 return false;
242
243 // media pools can only be edited
244 case "mep":
245 if ($rbacsystem->checkAccess("read", $a_ref_id))
246 {
247 return true;
248 }
249 else
250 {
251 return false;
252 }
253 break;
254
255 case 'crsr':
256 case 'catr':
257 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
259 case 'prg':
260 return $rbacsystem->checkAccess("visible", $a_ref_id);
261
262
263
264 // all other types are only clickable, if read permission is given
265 default:
266 if ($rbacsystem->checkAccess("read", $a_ref_id))
267 {
268 // check if lm is online
269 if ($a_type == "lm")
270 {
271 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
272 $lm_obj =& new ilObjLearningModule($a_ref_id);
273 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
274 {
275 return false;
276 }
277 }
278 // check if fblm is online
279 if ($a_type == "htlm")
280 {
281 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
282 $lm_obj =& new ilObjFileBasedLM($a_ref_id);
283 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
284 {
285 return false;
286 }
287 }
288 // check if fblm is online
289 if ($a_type == "sahs")
290 {
291 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
292 $lm_obj =& new ilObjSAHSLearningModule($a_ref_id);
293 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
294 {
295 return false;
296 }
297 }
298 // check if glossary is online
299 if ($a_type == "glo")
300 {
301 $obj_id = ilObject::_lookupObjectId($a_ref_id);
302 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
303 if((!ilObjGlossary::_lookupOnline($obj_id)) &&
304 (!$rbacsystem->checkAccess('write',$a_ref_id)))
305 {
306 return false;
307 }
308 }
309
310 return true;
311 }
312 else
313 {
314 return false;
315 }
316 break;
317 }
318 }
319
320 function showChilds($a_ref_id,$a_obj_id = 0)
321 {
322 global $rbacsystem,$tree;
323//vd($a_ref_id);
324
325 if ($a_ref_id == 0)
326 {
327 return true;
328 }
330 {
331 return false;
332 }
333 if ($rbacsystem->checkAccess("read", $a_ref_id))
334 {
335 return true;
336 }
337 else
338 {
339 return false;
340 }
341 }
342
343 function isVisible($a_ref_id,$a_type)
344 {
345 global $ilAccess,$tree,$ilSetting;
346
347 if(!$ilAccess->checkAccess('visible', '', $a_ref_id))
348 {
349 return false;
350 }
351
352 $is_course = false;
353 $container_parent_id = $tree->checkForParentType($a_ref_id,'grp');
354 if(!$container_parent_id)
355 {
356 $is_course = true;
357 $container_parent_id = $tree->checkForParentType($a_ref_id,'crs');
358 }
359 if($container_parent_id)
360 {
361 // do not display session materials for container course/group
362 if($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id)
363 {
364 // get container event items only once
365 if(!isset($this->session_materials[$container_parent_id]))
366 {
367 include_once './Modules/Session/classes/class.ilEventItems.php';
368 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
369 }
370 // get item group items only once
371 if(!isset($this->item_group_items[$container_parent_id]))
372 {
373 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
374 $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
375 }
376 if(in_array($a_ref_id, $this->session_materials[$container_parent_id]))
377 {
378 return false;
379 }
380 if(in_array($a_ref_id, $this->item_group_items[$container_parent_id]))
381 {
382 return false;
383 }
384 }
385 }
386
387 return true;
388 }
389
390
391
399 function formatHeader(&$tpl, $a_obj_id,$a_option)
400 {
401 global $lng, $ilias, $tree, $ilCtrl;
402
403 // custom icons
404 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
405
406 $tpl->setCurrentBlock("icon");
407 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
408 $title = $nd["title"];
409 if ($title == "ILIAS")
410 {
411 $title = $lng->txt("repository");
412 }
413
414 $tpl->setVariable("ICON_IMAGE", $path);
415 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon")." ".$title);
416 $tpl->parseCurrentBlock();
417
418 $tpl->setCurrentBlock("link");
419 $tpl->setVariable("TITLE", $title);
420 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
421 $tpl->setVariable("LINK_TARGET",
422 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset"));
423 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
424 $tpl->setVariable("TARGET", " target=\"_top\"");
425 $tpl->parseCurrentBlock();
426
427 $tpl->setCurrentBlock("element");
428 $tpl->parseCurrentBlock();
429 }
430
438 public function sortNodes($a_nodes,$a_parent_obj_id)
439 {
440 global $objDefinition;
441
442 if ($a_parent_obj_id > 0)
443 {
444 $parent_type = ilObject::_lookupType($a_parent_obj_id);
445 }
446 else
447 {
448 $parent_type = "dummy";
449 $this->type_grps["dummy"] = array("root" => "dummy");
450 }
451
452 if (empty($this->type_grps[$parent_type]))
453 {
454 $this->type_grps[$parent_type] =
455 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
456 }
457 $group = array();
458
459 foreach ($a_nodes as $node)
460 {
461 $g = $objDefinition->getGroupOfObj($node["type"]);
462 if ($g == "")
463 {
464 $g = $node["type"];
465 }
466 $group[$g][] = $node;
467 }
468
469 $nodes = array();
470 foreach ($this->type_grps[$parent_type] as $t => $g)
471 {
472 if (is_array($group[$t]))
473 {
474 // do we have to sort this group??
475 include_once("./Services/Container/classes/class.ilContainer.php");
476 include_once("./Services/Container/classes/class.ilContainerSorting.php");
477 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
478 $group = $sort->sortItems($group);
479
480 // need extra session sorting here
481 if ($t == "sess")
482 {
483
484 }
485
486 foreach ($group[$t] as $k => $item)
487 {
488 $nodes[] = $item;
489 }
490 }
491 }
492
493 return $nodes;
494 //return parent::sortNodes($a_nodes,$a_parent_obj_id);
495 }
496
503 function forceExpanded($a_node)
504 {
505 if (in_array($a_node, $this->force_open_path))
506 {
507 return true;
508 }
509 return false;
510 }
511
512} // END class ilRepositoryExplorer
513?>
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:11
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