ILIAS  Release_4_1_x_branch Revision 61804
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectGUIAdapter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 
14 // Whole class may be deprecated.
15 
17 {
18  var $gui_obj;
19  var $ilias;
20  var $tpl;
21  var $lng;
23 
24  var $cmd;
25  var $id;
27 
32  function ilObjectGUIAdapter($a_id,$a_call_by_reference,$a_prepare_output = true,$a_cmd = '')
33  {
35 
36 
37  $this->ilias =& $ilias;
38  $this->tpl =& $tpl;
39  $this->lng =& $lng;
40  $this->objDefinition =& $objDefinition;
41 
42  $this->setCommand($a_cmd);
43  $this->id = $a_id;
44  $this->call_by_reference = $a_call_by_reference;
45 
46  $this->__initGUIObject($a_call_by_reference,$a_prepare_output);
47  }
48  // SET/GET
49  function getId()
50  {
51  return $this->id;
52  }
53  function setCommand($a_cmd)
54  {
55  if($a_cmd == "gateway" || $a_cmd == "post")
56  {
57  @$this->cmd = key($_POST["cmd"]);
58  }
59  else
60  {
61  $this->cmd = $a_cmd;
62  }
63  }
64  function getCommand()
65  {
66  return $this->cmd;
67  }
68  function getType()
69  {
70  return $this->type;
71  }
72  function setType($a_type)
73  {
74  $this->type = $a_type;
75  }
76 
77  function performAction()
78  {
79  if($this->getCommand())
80  {
81  $method = $this->getCommand()."Object";
82  }
83  else
84  {
85  $method = $this->objDefinition->getFirstProperty($this->getType())."Object";
86  }
87  $this->gui_obj->$method();
88 
89  return true;
90  }
95 /* Deprecated
96  function setAdminTabs()
97  {
98  global $rbacsystem;
99 
100  $tabs = array();
101  $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
102 
103 // $properties = $this->objDefinition->getProperties($this->getType());
104 
105  foreach($properties as $key => $row)
106  {
107  $tabs[] = array($row["lng"], $row["name"]);
108  }
109 
110  // check for call_by_reference too to avoid hacking
111  if ($this->call_by_reference === false)
112  {
113  $object_link = "&obj_id=".$_GET["obj_id"];
114  }
115 
116  foreach ($tabs as $row)
117  {
118  $i++;
119 
120  if ($row[1] == $this->getCommand())
121  {
122  $tabtype = "tabactive";
123  $tab = $tabtype;
124  }
125  else
126  {
127  $tabtype = "tabinactive";
128  $tab = "tab";
129  }
130 
131  $show = true;
132 
133  // only check permissions for tabs if object is a permission object
134  if($this->call_by_reference)
135  {
136  // only show tab when the corresponding permission is granted
137  switch ($row[1])
138  {
139  case 'view':
140  if (!$rbacsystem->checkAccess('visible',$this->getId()))
141  {
142  $show = false;
143  }
144  break;
145 
146  case 'edit':
147  if (!$rbacsystem->checkAccess('write',$this->getId()))
148  {
149  $show = false;
150  }
151  break;
152 
153  case 'perm':
154  if (!$rbacsystem->checkAccess('edit_permission',$this->getId()))
155  {
156  $show = false;
157  }
158  break;
159  case 'trash':
160  if (!$this->gui_obj->tree->getSavedNodeData($this->getId()))
161  {
162  $show = false;
163  }
164  break;
165 
166  case 'newmembers':
167  case 'members':
168  if (!$rbacsystem->checkAccess('write',$this->getId()))
169  {
170  $show = false;
171  }
172  break;
173 
174  } //switch
175  }
176 
177  if (!$show)
178  {
179  continue;
180  }
181 
182  $this->tpl->setCurrentBlock("tab");
183  $this->tpl->setVariable("TAB_TYPE", $tabtype);
184  $this->tpl->setVariable("TAB_TYPE2", $tab);
185  $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
186  $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
187  $this->tpl->setVariable("TAB_LINK", $this->gui_obj->tab_target_script."?ref_id=".$this->getId().$object_link."&cmd=".$row[1]);
188  $this->tpl->setVariable("TAB_TEXT", $this->gui_obj->lng->txt($row[0]));
189  $this->tpl->parseCurrentBlock();
190  }
191  }
192 */
193 
194  // PRIVATE METHODS
195  function __initGUIObject($a_call_by_reference,$a_prepare_output = true)
196  {
197  global $objDefinition;
198 
199  include_once "./classes/class.ilObjectFactory.php";
200 
201  // GET TYPE
202  if($a_call_by_reference)
203  {
204  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->getId());
205  }
206  else
207  {
208  $tmp_obj =& ilObjectFactory::getInstanceByObjId($this->getId());
209  }
210  $this->setType($tmp_obj->getType());
211 
212  // INITIATE GUI CLASS
213  $class_name = $objDefinition->getClassName($this->getType());
214  $location = $objDefinition->getLocation($this->getType());
215  $class_constr = "ilObj".$class_name."GUI";
216 
217  //INCLUDE CLASS
218  include_once $location."/class.ilObj".$class_name."GUI.php";
219 
220  // CALL CONSTRUCTOR
221  $this->gui_obj =& new $class_constr(array(),$this->getId(),$a_call_by_reference,$a_prepare_output);
222 
223  return true;
224  }
225 } // END class.ilObjectGUIAdapter
226 ?>