ILIAS  release_7 Revision v7.30-3-g800a261c036
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 {
126 $ilCtrl = $this->ctrl;
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 case 'prg':
177 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
178 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "redirect");
179 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
180 return $link;
181
182 default:
183 include_once('./Services/Link/classes/class.ilLink.php');
184 return ilLink::_getStaticLink($a_node_id, $a_type, true);
185
186 }
187 }
188
195 public function buildFrameTarget($a_type, $a_child = 0, $a_obj_id = 0)
196 {
197 switch ($a_type) {
198 case "cat":
199 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "cat");
200 return $t_frame;
201
202 case "catr":
203 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "catr");
204 return $t_frame;
205
206 case "grp":
207 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grp");
208 return $t_frame;
209
210 case "grpr":
211 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "grpr");
212 return $t_frame;
213
214 case "crs":
215 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crs");
216 return $t_frame;
217
218 case "crsr":
219 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "crsr");
220 return $t_frame;
221
222 case 'rcrs':
223 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", 'rcrs');
224 return $t_frame;
225
226 case 'prg':
227 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", 'prg');
228 return $t_frame;
229 case "prgr":
230 $t_frame = ilFrameTargetInfo::_getFrame("RepositoryContent", "prgr");
231 return $t_frame;
232
233 default:
234 return "_top";
235 }
236 }
237
241 public function getImage($a_name, $a_type = "", $a_obj_id = "")
242 {
243 if ($a_type != "") {
244 return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
245 }
246
247 return parent::getImage($a_name);
248 }
249
250 public function isClickable($a_type, $a_ref_id = 0, $a_obj_id = 0)
251 {
256 $ilAccess = $this->access;
257
258 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) {
259 return false;
260 }
261
262 switch ($a_type) {
263 case 'tst':
264 if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
265 return false;
266 }
267
268 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s", $a_obj_id);
269 $res = $ilDB->query($query);
270 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
271 return (bool) $row->complete;
272 }
273 return false;
274
275 case 'svy':
276 if (!$rbacsystem->checkAccess("read", $a_ref_id)) {
277 return false;
278 }
279
280 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s", $a_obj_id);
281 $res = $ilDB->query($query);
282 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
283 return (bool) $row->complete;
284 }
285 return false;
286
287 // media pools can only be edited
288 case "mep":
289 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
290 return true;
291 } else {
292 return false;
293 }
294 break;
295 case 'grpr':
296 case 'crsr':
297 case 'catr':
298 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
300 case 'prg':
301 return $rbacsystem->checkAccess("visible", $a_ref_id);
302
303
304
305 // all other types are only clickable, if read permission is given
306 default:
307 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
308 // check if lm is online
309 if ($a_type == "lm") {
310 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
311 $lm_obj = new ilObjLearningModule($a_ref_id);
312 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
313 return false;
314 }
315 }
316 // check if fblm is online
317 if ($a_type == "htlm") {
318 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
319 $lm_obj = new ilObjFileBasedLM($a_ref_id);
320 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
321 return false;
322 }
323 }
324 // check if fblm is online
325 if ($a_type == "sahs") {
326 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
327 $lm_obj = new ilObjSAHSLearningModule($a_ref_id);
328 if (($lm_obj->getOfflineStatus()) && (!$rbacsystem->checkAccess('write', $a_ref_id))) {
329 return false;
330 }
331 }
332 // check if glossary is online
333 if ($a_type == "glo") {
334 $obj_id = ilObject::_lookupObjectId($a_ref_id);
335 if ((!ilObjGlossary::_lookupOnline($obj_id)) &&
336 (!$rbacsystem->checkAccess('write', $a_ref_id))) {
337 return false;
338 }
339 }
340
341 return true;
342 } else {
343 return false;
344 }
345 break;
346 }
347 }
348
349 public function showChilds($a_ref_id, $a_obj_id = 0)
350 {
353 //vd($a_ref_id);
354
355 if ($a_ref_id == 0) {
356 return true;
357 }
358 if (!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id, $a_obj_id)) {
359 return false;
360 }
361 if ($rbacsystem->checkAccess("read", $a_ref_id)) {
362 return true;
363 } else {
364 return false;
365 }
366 }
367
368 public function isVisible($a_ref_id, $a_type)
369 {
370 $ilAccess = $this->access;
373
374 if (!$ilAccess->checkAccess('visible', '', $a_ref_id)) {
375 return false;
376 }
377
378 $is_course = false;
379 $container_parent_id = $tree->checkForParentType($a_ref_id, 'grp');
380 if (!$container_parent_id) {
381 $is_course = true;
382 $container_parent_id = $tree->checkForParentType($a_ref_id, 'crs');
383 }
384 if ($container_parent_id) {
385 // do not display session materials for container course/group
386 if ($ilSetting->get("repository_tree_pres") == "all_types" && $container_parent_id != $a_ref_id) {
387 // get container event items only once
388 if (!isset($this->session_materials[$container_parent_id])) {
389 include_once './Modules/Session/classes/class.ilEventItems.php';
390 $this->session_materials[$container_parent_id] = ilEventItems::_getItemsOfContainer($container_parent_id);
391 }
392 // get item group items only once
393 if (!isset($this->item_group_items[$container_parent_id])) {
394 include_once './Modules/ItemGroup/classes/class.ilItemGroupItems.php';
395 $this->item_group_items[$container_parent_id] = ilItemGroupItems::_getItemsOfContainer($container_parent_id);
396 }
397 if (in_array($a_ref_id, $this->session_materials[$container_parent_id])) {
398 return false;
399 }
400 if (in_array($a_ref_id, $this->item_group_items[$container_parent_id])) {
401 return false;
402 }
403 }
404 }
405
406 return true;
407 }
408
409
410
418 public function formatHeader($tpl, $a_obj_id, $a_option)
419 {
422 $ilCtrl = $this->ctrl;
423
424 // custom icons
425 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
426
427 $tpl->setCurrentBlock("icon");
428 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
429 $title = $nd["title"];
430 if ($title == "ILIAS") {
431 $title = $lng->txt("repository");
432 }
433
434 $tpl->setVariable("ICON_IMAGE", $path);
435 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon") . " " . $title);
436 $tpl->parseCurrentBlock();
437
438 $tpl->setCurrentBlock("link");
439 $tpl->setVariable("TITLE", $title);
440 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", "1");
441 $tpl->setVariable(
442 "LINK_TARGET",
443 $ilCtrl->getLinkTargetByClass("ilrepositorygui", "frameset")
444 );
445 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
446 $tpl->setVariable("TARGET", " target=\"_top\"");
447 $tpl->parseCurrentBlock();
448
449 $tpl->setCurrentBlock("element");
450 $tpl->parseCurrentBlock();
451 }
452
460 public function sortNodes($a_nodes, $a_parent_obj_id)
461 {
462 $objDefinition = $this->obj_definition;
463
464 if ($a_parent_obj_id > 0) {
465 $parent_type = ilObject::_lookupType($a_parent_obj_id);
466 } else {
467 $parent_type = "dummy";
468 $this->type_grps["dummy"] = array("root" => "dummy");
469 }
470
471 if (empty($this->type_grps[$parent_type])) {
472 $this->type_grps[$parent_type] =
473 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
474 }
475 $group = array();
476
477 foreach ($a_nodes as $node) {
478 $g = $objDefinition->getGroupOfObj($node["type"]);
479 if ($g == "") {
480 $g = $node["type"];
481 }
482 $group[$g][] = $node;
483 }
484
485 $nodes = array();
486 foreach ($this->type_grps[$parent_type] as $t => $g) {
487 if (is_array($group[$t])) {
488 // do we have to sort this group??
489 include_once("./Services/Container/classes/class.ilContainer.php");
490 include_once("./Services/Container/classes/class.ilContainerSorting.php");
491 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
492 $group = $sort->sortItems($group);
493
494 // need extra session sorting here
495 if ($t == "sess") {
496 }
497
498 foreach ($group[$t] as $k => $item) {
499 $nodes[] = $item;
500 }
501 }
502 }
503
504 return $nodes;
505 //return parent::sortNodes($a_nodes,$a_parent_obj_id);
506 }
507
514 public function forceExpanded($a_node)
515 {
516 if (in_array($a_node, $this->force_open_path)) {
517 return true;
518 }
519 return false;
520 }
521} // END class ilRepositoryExplorer
user()
Definition: user.php:4
$_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 _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.
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!
const ROOT_FOLDER_ID
Definition: constants.php:30
$nd
Definition: error.php:12
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $ilSetting
Definition: privfeed.php:17
$query
$type
foreach($_POST as $key=> $value) $res
settings()
Definition: settings.php:2
global $ilDB