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