ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
5 require_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 
139  if(!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id,$a_obj_id))
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  }
264  if(!ilConditionHandler::_checkAllConditionsOfTarget($a_ref_id,$a_obj_id))
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  /*
302  if ($this->ilias->getSetting("custom_icons"))
303  {
304  require_once("./Services/Container/classes/class.ilContainer.php");
305  if (($path = ilContainer::_lookupIconPath($a_obj_id, "tiny")) == "")
306  {
307  $path = ilUtil::getImagePath("icon_root_s.png");
308  }
309  }*/
310 
311  $path = ilObject::_getIcon($a_obj_id, "tiny", "root");
312 
313  $tpl->setCurrentBlock("icon");
314  $nd = $tree->getNodeData(ROOT_FOLDER_ID);
315  $title = $nd["title"];
316 
317  if ($title == "ILIAS")
318  {
319  $title = $lng->txt("repository");
320  }
321 
322  $tpl->setVariable("ICON_IMAGE", $path);
323  $tpl->setVariable("TXT_ALT_IMG", $lng->txt("icon")." ".$title);
324  $tpl->parseCurrentBlock();
325 
326  $tpl->setCurrentBlock("link");
327  $tpl->setVariable("TITLE", $title);
328  $tpl->setVariable("LINK_TARGET", "ilias.php?baseClass=ilshopcontroller&ref_id=1");
329 
330  #$tpl->setVariable("TARGET", " target=\"_self\"");
331  $tpl->parseCurrentBlock();
332 
333  $tpl->setCurrentBlock("element");
334  $tpl->parseCurrentBlock();
335  }
336 
344  public function sortNodes($a_nodes,$a_parent_obj_id)
345  {
346  global $objDefinition;
347 
348  if ($a_parent_obj_id > 0)
349  {
350  $parent_type = ilObject::_lookupType($a_parent_obj_id);
351  }
352  else
353  {
354  $parent_type = "dummy";
355  $this->type_grps["dummy"] = array("root" => "dummy");
356  }
357 
358  if (empty($this->type_grps[$parent_type]))
359  {
360  $this->type_grps[$parent_type] =
361  $objDefinition->getGroupedRepositoryObjectTypes($parent_type);
362  }
363  $group = array();
364 
365  foreach ($a_nodes as $node)
366  {
367  $g = $objDefinition->getGroupOfObj($node["type"]);
368  if ($g == "")
369  {
370  $g = $node["type"];
371  }
372  $group[$g][] = $node;
373  }
374 
375  $nodes = array();
376  foreach ($this->type_grps[$parent_type] as $t => $g)
377  {
378  if (is_array($group[$t]))
379  {
380  // do we have to sort this group??
381  include_once("./Services/Container/classes/class.ilContainer.php");
382  include_once("./Services/Container/classes/class.ilContainerSorting.php");
383  $sort = ilContainerSorting::_getInstance($a_parent_obj_id);
384  $group = $sort->sortItems($group);
385 
386  foreach ($group[$t] as $k => $item)
387  {
388  $nodes[] = $item;
389  }
390  }
391  }
392 
393  return $nodes;
394  //return parent::sortNodes($a_nodes,$a_parent_obj_id);
395  }
396 
403  function forceExpanded($a_node)
404  {
405  if (in_array($a_node, $this->force_open_path))
406  {
407  return true;
408  }
409  return false;
410  }
411 
412 
413 }
414 ?>
static _getIcon($a_obj_id="", $a_size="big", $a_type="", $a_offline=false)
Get icon for repository item.
formatHeader(&$tpl, $a_obj_id, $a_option)
overwritten method from base class public
__construct($a_target, $a_top_node=0)
Class ilObjLearningModule.
setFilterMode($a_mode=IL_FM_NEGATIVE)
set filter mode
buildLinkTarget($a_node_id, $a_type)
note: most of this stuff is used by ilCourseContentInterface too
getImage($a_name, $a_type="", $a_obj_id="")
get image path
$_GET["client_id"]
File Based Learning Module (HTML) object.
const IL_FM_POSITIVE
sortNodes($a_nodes, $a_parent_obj_id)
sort nodes
const DB_FETCHMODE_OBJECT
Definition: class.ilDB.php:11
setFiltered($a_bool)
active/deactivate the filter public
static _lookupObjectId($a_ref_id)
lookup object id
global $ilCtrl
Definition: ilias.php:18
_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.
isClickable($a_type, $a_ref_id, $a_obj_id=0)
setForceOpenPath($a_path)
set force open path
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilExplorer class for explorer view in admin frame.
global $ilUser
Definition: imgupload.php:15
forceExpanded($a_node)
Force expansion of node.
_lookupOnline($a_id)
check wether content object is online
global $lng
Definition: privfeed.php:40
$path
Definition: index.php:22
setSessionExpandVariable($a_var_name="expand")
set name of expand session variable
addFilter($a_item)
adds item to the filter public
static _getInstance($a_obj_id)
get instance by obj_id
Class ilObjSCORMLearningModule.