ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilShopRepositoryExplorer.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*/
10{
16 public $root_id;
17 public $output;
18 public $ctrl;
19
24 public function __construct($a_target, $a_top_node = 0)
25 {
26 global $tree, $ilCtrl;
27
28 $this->ctrl = $ilCtrl;
29
30 $this->force_open_path = array();
31
32 parent::ilExplorer($a_target);
33 $this->tree = $tree;
34 $this->root_id = $this->tree->readRootId();
35 $this->order_column = "title";
36 $this->frame_target = false;
37 $this->setSessionExpandVariable("repexpand");
38 #$this->setTitle($lng->txt("overview"));
39
40# Es sollen nur container angezeigt werden, die entweder als container (z.B. Kurse) kaufbar sind oder kaufbare Objekte enthalten können!
41
42/* if ($ilSetting->get("repository_tree_pres") == "" ||
43 ($ilSetting->get("rep_tree_limit_grp_crs") && $a_top_node == 0))
44 {*/
45 $this->addFilter("root");
46 $this->addFilter("cat");
47 $this->addFilter('catr');
48 $this->addFilter("grp");
49 $this->addFilter("icrs");
50 $this->addFilter("crs");
51 $this->addFilter('crsr');
52 $this->addFilter('rcrs');
53
54# $this->addFilter("file");
55# $this->addFilter("tst");
56# $this->addFilter("exc");
57 $this->setFiltered(true);
59/* }
60 else if ($ilSetting->get("repository_tree_pres") == "all_types")
61 {
62 foreach ($objDefinition->getAllRBACObjects() as $rtype)
63 {
64 $this->addFilter($rtype);
65 }
66 $this->setFiltered(true);
67 $this->setFilterMode(IL_FM_POSITIVE);
68 }*/
69 }
70
74 function setForceOpenPath($a_path)
75 {
76 $this->force_open_path = $a_path;
77 }
78
82 function buildLinkTarget($a_node_id, $a_type)
83 {
84 global $ilCtrl;
85 switch($a_type)
86 {
87
88 case "cat":
89 return "ilias.php?baseClass=ilshopcontroller&ref_id=".$a_node_id;
90
91 case "catr":
92 return "ilias.php?cmd=redirect&baseClass=ilshopcontroller&ref_id=".$a_node_id;
93
94 case "grp":
95 return "ilias.php?baseClass=ilshopcontroller&ref_id=".$a_node_id;
96
97 case "crs":
98 return "ilias.php?baseClass=ilshopcontroller&ref_id=".$a_node_id;
99
100 case "crsr":
101 return "ilias.php?cmd=redirect&baseClass=ilshopcontroller&ref_id=".$a_node_id;
102
103 case "icrs":
104 $ilCtrl->setParameterByClass("ilobjilinccoursegui", "ref_id", $a_node_id);
105 $link = $ilCtrl->getLinkTargetByClass(array("ilrepositorygui", "ilobjilinccoursegui"), "");
106 $ilCtrl->setParameterByClass("ilobjilinccoursegui", "ref_id", $_GET["ref_id"]);
107 return $link;
108
109 case 'rcrs':
110 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $a_node_id);
111 $link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", "infoScreen");
112 $ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $_GET["ref_id"]);
113 return $link;
114
115 default:
116 include_once('./Services/Link/classes/class.ilLink.php');
117 return ilLink::_getStaticLink($a_node_id, $a_type, true);
118
119 }
120 }
121
125 function getImage($a_name, $a_type = "", $a_obj_id = "")
126 {
127 if ($a_type != "")
128 {
129 return ilObject::_getIcon($a_obj_id, "tiny", $a_type);
130 }
131
132 return parent::getImage($a_name);
133 }
134
135 function isClickable($a_type, $a_ref_id,$a_obj_id = 0)
136 {
137 global $rbacsystem,$ilDB,$ilUser,$ilAccess;
138
140 {
141 return false;
142 }
143
144 switch ($a_type)
145 {
146 case "crs":
147 return $ilAccess->checkAccess("read", "", $a_ref_id);
148
149 // visible groups can allways be clicked; group processing decides
150 // what happens next
151 case "grp":
152 return true;
153
154 case 'tst':
155 if(!$rbacsystem->checkAccess("read", $a_ref_id))
156 {
157 return false;
158 }
159
160 $query = sprintf("SELECT * FROM tst_tests WHERE obj_fi=%s",$a_obj_id);
161 $res = $ilDB->query($query);
162 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
163 {
164 return (bool) $row->complete;
165 }
166 return false;
167
168 case 'svy':
169 if(!$rbacsystem->checkAccess("read", $a_ref_id))
170 {
171 return false;
172 }
173
174 $query = sprintf("SELECT * FROM svy_svy WHERE obj_fi=%s",$a_obj_id);
175 $res = $ilDB->query($query);
176 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
177 {
178 return (bool) $row->complete;
179 }
180 return false;
181
182 // media pools can only be edited
183 case "mep":
184 if ($rbacsystem->checkAccess("read", $a_ref_id))
185 {
186 return true;
187 }
188 else
189 {
190 return false;
191 }
192 break;
193
194 case 'crsr':
195 case 'catr':
196 include_once('./Services/ContainerReference/classes/class.ilContainerReferenceAccess.php');
198
199
200 // all other types are only clickable, if read permission is given
201 default:
202 if ($rbacsystem->checkAccess("read", $a_ref_id))
203 {
204 // check if lm is online
205 if ($a_type == "lm")
206 {
207 include_once("./Modules/LearningModule/classes/class.ilObjLearningModule.php");
208 $lm_obj =& new ilObjLearningModule($a_ref_id);
209 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
210 {
211 return false;
212 }
213 }
214 // check if fblm is online
215 if ($a_type == "htlm")
216 {
217 include_once("./Modules/HTMLLearningModule/classes/class.ilObjFileBasedLM.php");
218 $lm_obj =& new ilObjFileBasedLM($a_ref_id);
219 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
220 {
221 return false;
222 }
223 }
224 // check if fblm is online
225 if ($a_type == "sahs")
226 {
227 include_once("./Modules/ScormAicc/classes/class.ilObjSAHSLearningModule.php");
228 $lm_obj =& new ilObjSAHSLearningModule($a_ref_id);
229 if((!$lm_obj->getOnline()) && (!$rbacsystem->checkAccess('write',$a_ref_id)))
230 {
231 return false;
232 }
233 }
234 // check if glossary is online
235 if ($a_type == "glo")
236 {
237 $obj_id = ilObject::_lookupObjectId($a_ref_id);
238 include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
239 if((!ilObjGlossary::_lookupOnline($obj_id)) &&
240 (!$rbacsystem->checkAccess('write',$a_ref_id)))
241 {
242 return false;
243 }
244 }
245
246 return true;
247 }
248 else
249 {
250 return false;
251 }
252 break;
253 }
254 }
255
256 function showChilds($a_ref_id, $a_obj_id = 0)
257 {
258 global $rbacsystem;
259
260 if ($a_ref_id == 0)
261 {
262 return true;
263 }
265 {
266 return false;
267 }
268 if ($rbacsystem->checkAccess("read", $a_ref_id))
269 {
270 return true;
271 }
272 else
273 {
274 return false;
275 }
276 }
277
278 function isVisible($a_ref_id,$a_type)
279 {
280 global $ilAccess,$tree;
281
282 if(!$ilAccess->checkAccess('visible', '', $a_ref_id))
283 {
284 return false;
285 }
286 return true;
287 }
288
296 function formatHeader(&$tpl, $a_obj_id,$a_option)
297 {
298 global $lng, $tree;
299
300 // custom icons
301 $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
302
303 $tpl->setCurrentBlock("icon");
304 $nd = $tree->getNodeData(ROOT_FOLDER_ID);
305 $title = $nd["title"];
306
307 if ($title == "ILIAS")
308 {
309 $title = $lng->txt("repository");
310 }
311
312 $tpl->setVariable("ICON_IMAGE", $path);
313 $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon")." ".$title);
314 $tpl->parseCurrentBlock();
315
316 $tpl->setCurrentBlock("link");
317 $tpl->setVariable("TITLE", $title);
318 $tpl->setVariable("LINK_TARGET", "ilias.php?baseClass=ilshopcontroller&ref_id=1");
319
320 #$tpl->setVariable("TARGET", " target=\"_self\"");
321 $tpl->parseCurrentBlock();
322
323 $tpl->setCurrentBlock("element");
324 $tpl->parseCurrentBlock();
325 }
326
334 public function sortNodes($a_nodes,$a_parent_obj_id)
335 {
336 global $objDefinition;
337
338 if ($a_parent_obj_id > 0)
339 {
340 $parent_type = ilObject::_lookupType($a_parent_obj_id);
341 }
342 else
343 {
344 $parent_type = "dummy";
345 $this->type_grps["dummy"] = array("root" => "dummy");
346 }
347
348 if (empty($this->type_grps[$parent_type]))
349 {
350 $this->type_grps[$parent_type] =
351 $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
352 }
353 $group = array();
354
355 foreach ($a_nodes as $node)
356 {
357 $g = $objDefinition->getGroupOfObj($node["type"]);
358 if ($g == "")
359 {
360 $g = $node["type"];
361 }
362 $group[$g][] = $node;
363 }
364
365 $nodes = array();
366 foreach ($this->type_grps[$parent_type] as $t => $g)
367 {
368 if (is_array($group[$t]))
369 {
370 // do we have to sort this group??
371 include_once("./Services/Container/classes/class.ilContainer.php");
372 include_once("./Services/Container/classes/class.ilContainerSorting.php");
373 $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
374 $group = $sort->sortItems($group);
375
376 foreach ($group[$t] as $k => $item)
377 {
378 $nodes[] = $item;
379 }
380 }
381 }
382
383 return $nodes;
384 //return parent::sortNodes($a_nodes,$a_parent_obj_id);
385 }
386
393 function forceExpanded($a_node)
394 {
395 if (in_array($a_node, $this->force_open_path))
396 {
397 return true;
398 }
399 return false;
400 }
401
402
403}
404?>
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
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
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
setFiltered($a_bool)
active/deactivate the filter @access public
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
setForceOpenPath($a_path)
set force open path
getImage($a_name, $a_type="", $a_obj_id="")
get image path
forceExpanded($a_node)
Force expansion of node.
buildLinkTarget($a_node_id, $a_type)
note: most of this stuff is used by ilCourseContentInterface too
__construct($a_target, $a_top_node=0)
isClickable($a_type, $a_ref_id, $a_obj_id=0)
formatHeader(&$tpl, $a_obj_id, $a_option)
overwritten method from base class @access public
sortNodes($a_nodes, $a_parent_obj_id)
sort nodes
$nd
Definition: error.php:9
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
global $ilDB
global $ilUser
Definition: imgupload.php:15