ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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{
19 protected $lng;
20
24 protected $settings;
25
29 protected $obj_definition;
30
34 protected $rbacsystem;
35
39 protected $db;
40
44 protected $user;
45
49 protected $access;
50
51
57 public $root_id;
58 public $output;
59 public $ctrl;
66 public function __construct($a_target, $a_top_node = 0)
67 {
68 global $DIC;
69
70 $this->lng = $DIC->language();
71 $this->settings = $DIC->settings();
72 $this->obj_definition = $DIC["objDefinition"];
73 $this->rbacsystem = $DIC->rbac()->system();
74 $this->db = $DIC->database();
75 $this->user = $DIC->user();
76 $this->access = $DIC->access();
77 $tree = $DIC->repositoryTree();
78 $ilCtrl = $DIC->ctrl();
79 $lng = $DIC->language();
80 $ilSetting = $DIC->settings();
81 $objDefinition = $DIC["objDefinition"];
82
83 $this->ctrl = $ilCtrl;
84
85
86 $this->force_open_path = array();
87
88
89 parent::__construct($a_target);
90 $this->tree = $tree;
91 $this->root_id = $this->tree->readRootId();
92 $this->order_column = "title";
93 $this->setSessionExpandVariable("repexpand");
94 $this->setTitle($lng->txt("overview"));
95
96 // please do not uncomment this
97 if ($ilSetting->get("repository_tree_pres") == "" ||
98 ($ilSetting->get("rep_tree_limit_grp_crs") && $a_top_node == 0)) {
99 foreach ($objDefinition->getExplorerContainerTypes() as $type) {
100 $this->addFilter($type);
101 }
102 $this->setFiltered(true);
104 } elseif ($ilSetting->get("repository_tree_pres") == "all_types") {
105 foreach ($objDefinition->getAllRBACObjects() as $rtype) {
106 $this->addFilter($rtype);
107 }
108 $this->setFiltered(true);
110 }
111 }
112
116 public function setForceOpenPath($a_path)
117 {
118 $this->force_open_path = $a_path;
119 }
120
124 public function buildLinkTarget($a_node_id, $a_type)
125 {
127
128 switch ($a_type) {
129 case "cat":
130 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
131 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "");
132 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
133 return $link;
134
135 case "catr":
136 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
137 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
138 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
139 return $link;
140
141 case "grp":
142 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $a_node_id);
143 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjgroupgui"), "");
144 $ilCtrl->setParameterByClass("ilobjgroupgui", "ref_id", $_GET["ref_id"]);
145 return $link;
146 case "grpr":
147 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
148 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
149 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
150 return $link;
151
152 case "crs":
153 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $a_node_id);
154 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjcoursegui"), "view");
155 $ilCtrl->setParameterByClass("ilobjcoursegui", "ref_id", $_GET["ref_id"]);
156 return $link;
157
158 case "crsr":
159 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
160 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
161 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
162 return $link;
163
164 case 'rcrs':
165 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
166 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
167 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
168 return $link;
169
170 case 'prg':
171 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $a_node_id);
172 $link = $ilCtrl->getLinkTargetByClass("ilobjstudyprogrammegui", "view");
173 $ilCtrl->setParameterByClass("ilobjstudyprogrammegui", "ref_id", $_GET["ref_id"]);
174 return $link;
175
176 default:
177 include_once('./Services/Link/classes/class.ilLink.php');
178 return ilLink::_getStaticLink($a_node_id, $a_type, true);
179
180 }
181 }
182
189 public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
190 {
191 switch ($a_type) {
192 case "cat":
193 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
194 return $t_frame;
195
196 case "catr":
197 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "catr");
198 return $t_frame;
199
200 case "grp":
201 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
202 return $t_frame;
203
204 case "grpr":
205 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grpr");
206 return $t_frame;
207
208 case "crs":
209 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
210 return $t_frame;
211
212 case "crsr":
213 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crsr");
214 return $t_frame;
215
216 case 'rcrs':
217 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", 'rcrs');
218 return $t_frame;
219
220 case 'prg':
221 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", 'prg');
222 return $t_frame;
223
224 default:
225 return "_top";
226 }
227 }
228
232 public function getImage($a_name, $a_type = "", $a_obj_id = "")
233 {
234 if ($a_type != "") {
235 return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
236 }
237
238 return parent::getImage($a_name);
239 }
240
241 public function isClickable($a_type, $a_ref_id = 0, $a_obj_id = 0)
242 {
247 $ilAccess = $this->access;
248
249 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) {
250 return false;
251 }
252
253 switch ($a_type) {
254 case 'tst':
255 if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
256 return false;
257 }
258
259 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $a_obj_id);
260 $res = $ilDB->query($query);
261 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
262 return (bool) $row->complete;
263 }
264 return false;
265
266 case 'svy':
267 if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
268 return false;
269 }
270
271 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $a_obj_id);
272 $res = $ilDB->query($query);
273 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
274 return (bool) $row->complete;
275 }
276 return false;
277
278 // media pools can only be edited
279 case "mep":
280 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
281 return true;
282 } else {
283 return false;
284 }
285 break;
286 case 'grpr':
287 case 'crsr':
288 case 'catr':
289 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
291 case 'prg':
292 return $rbacsystem->checkAccess("visible", $a_ref_id);
293
294
295
296 // all other types are only clickable, if read permission is given
297 default:
298 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
299 // check if lm is online
300 if ($a_type == "lm") {
301 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
302 $lm_obj = new ilObjLearningModule($a_ref_id);
303 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
304 return false;
305 }
306 }
307 // check if fblm is online
308 if ($a_type == "htlm") {
309 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
310 $lm_obj = new ilObjFileBasedLM($a_ref_id);
311 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
312 return false;
313 }
314 }
315 // check if fblm is online
316 if ($a_type == "sahs") {
317 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
318 $lm_obj = new ilObjSAHSLearningModule($a_ref_id);
319 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
320 return false;
321 }
322 }
323 // check if glossary is online
324 if ($a_type == "glo") {
325 $obj_id = ilObject::_lookupObjectId($a_ref_id);
326 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
327 if ((!ilObjGlossary::_lookupOnline($obj_id)) &&
328 (!$rbacsystem->checkAccess('write', $a_ref_id))) {
329 return false;
330 }
331 }
332
333 return true;
334 } else {
335 return false;
336 }
337 break;
338 }
339 }
340
341 public function showChilds($a_ref_id, $a_obj_id = 0)
342 {
345 //vd($a_ref_id);
346
347 if ($a_ref_id == 0) {
348 return true;
349 }
350 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) {
351 return false;
352 }
353 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
354 return true;
355 } else {
356 return false;
357 }
358 }
359
360 public function isVisible($a_ref_id, $a_type)
361 {
362 $ilAccess = $this->access;
365
366 if (!$ilAccess->checkAccess('visible', '', $a_ref_id)) {
367 return false;
368 }
369
370 $is_course = false;
371 $container_parent_id = $tree->checkForParentType($a_ref_id, 'grp');
372 if (!$container_parent_id) {
373 $is_course = true;
374 $container_parent_id = $tree->checkForParentType($a_ref_id, 'crs');
375 }
376 if ($container_parent_id) {
377 // do not display session materials for container course/group
378 if ($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id) {
379 // get container event items only once
380 if (!isset($this->session_materials[$container_parent_id])) {
381 include_once './Modules/Session/classes/class.ilEventItems.php';
382 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
383 }
384 // get item group items only once
385 if (!isset($this->item_group_items[$container_parent_id])) {
386 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
387 $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
388 }
389 if (in_array($a_ref_id, $this->session_materials[$container_parent_id])) {
390 return false;
391 }
392 if (in_array($a_ref_id, $this->item_group_items[$container_parent_id])) {
393 return false;
394 }
395 }
396 }
397
398 return true;
399 }
400
401
402
410 public function formatHeader($tpl, $a_obj_id, $a_option)
411 {
415
416 // custom icons
417 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
418
419 $tpl->setCurrentBlock("icon");
420 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
421 $title = $nd["title"];
422 if ($title == "ILIAS") {
423 $title = $lng->txt("repository");
424 }
425
426 $tpl->setVariable("ICON_IMAGE", $path);
427 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon") . " " . $title);
428 $tpl->parseCurrentBlock();
429
430 $tpl->setCurrentBlock("link");
431 $tpl->setVariable("TITLE", $title);
432 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
433 $tpl->setVariable(
434 "LINK_TARGET",
435 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset")
436 );
437 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
438 $tpl->setVariable("TARGET", " target=\"_top\"");
439 $tpl->parseCurrentBlock();
440
441 $tpl->setCurrentBlock("element");
442 $tpl->parseCurrentBlock();
443 }
444
452 public function sortNodes($a_nodes, $a_parent_obj_id)
453 {
454 $objDefinition = $this->obj_definition;
455
456 if ($a_parent_obj_id > 0) {
457 $parent_type = ilObject::_lookupType($a_parent_obj_id);
458 } else {
459 $parent_type = "dummy";
460 $this->type_grps["dummy"] = array("root" => "dummy");
461 }
462
463 if (empty($this->type_grps[$parent_type])) {
464 $this->type_grps[$parent_type] =
465 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
466 }
467 $group = array();
468
469 foreach ($a_nodes as $node) {
470 $g = $objDefinition->getGroupOfObj($node["type"]);
471 if ($g == "") {
472 $g = $node["type"];
473 }
474 $group[$g][] = $node;
475 }
476
477 $nodes = array();
478 foreach ($this->type_grps[$parent_type] as $t => $g) {
479 if (is_array($group[$t])) {
480 // do we have to sort this group??
481 include_once("./Services/Container/classes/class.ilContainer.php");
482 include_once("./Services/Container/classes/class.ilContainerSorting.php");
483 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
484 $group = $sort->sortItems($group);
485
486 // need extra session sorting here
487 if ($t == "sess") {
488 }
489
490 foreach ($group[$t] as $k => $item) {
491 $nodes[] = $item;
492 }
493 }
494 }
495
496 return $nodes;
497 //return parent::sortNodes($a_nodes,$a_parent_obj_id);
498 }
499
506 public function forceExpanded($a_node)
507 {
508 if (in_array($a_node, $this->force_open_path)) {
509 return true;
510 }
511 return false;
512 }
513} // END class ilRepositoryExplorer
user()
Definition: user.php:4
$path
Definition: aliased.php:25
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const IL_FM_POSITIVE
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)
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.
static _getItemsOfContainer($a_ref_id)
File Based Learning Module (HTML) object.
static _lookupOnline($a_id)
check wether content object is online
Class ilObjLearningModule.
Class ilObjSCORMLearningModule.
static _lookupObjectId($a_ref_id)
lookup object id
static _lookupType($a_id, $a_reference=false)
lookup object type
forceExpanded($a_node)
Force expansion of node.
getImage($a_name, $a_type="", $a_obj_id="")
get image path
isClickable($a_type, $a_ref_id=0, $a_obj_id=0)
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
__construct($a_target, $a_top_node=0)
Constructor @access public.
setForceOpenPath($a_path)
set force open path
showChilds($a_ref_id, $a_obj_id=0)
formatHeader($tpl, $a_obj_id, $a_option)
overwritten method from base class @access public
buildFrameTarget($a_type, $a_child=0, $a_obj_id=0)
STATIC, do not use $this inside!
$nd
Definition: error.php:10
global $ilCtrl
Definition: ilias.php:18
$row
global $ilSetting
Definition: privfeed.php:17
$query
$type
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92