ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjectGUIAdapter.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 
34 // Whole class may be deprecated.
35 
37 {
38  var $gui_obj;
39  var $ilias;
40  var $tpl;
41  var $lng;
43 
44  var $cmd;
45  var $id;
47 
52  function ilObjectGUIAdapter($a_id,$a_call_by_reference,$a_prepare_output = true,$a_cmd = '')
53  {
55 
56 
57  $this->ilias =& $ilias;
58  $this->tpl =& $tpl;
59  $this->lng =& $lng;
60  $this->objDefinition =& $objDefinition;
61 
62  $this->setCommand($a_cmd);
63  $this->id = $a_id;
64  $this->call_by_reference = $a_call_by_reference;
65 
66  $this->__initGUIObject($a_call_by_reference,$a_prepare_output);
67  }
68  // SET/GET
69  function getId()
70  {
71  return $this->id;
72  }
73  function setCommand($a_cmd)
74  {
75  if($a_cmd == "gateway" || $a_cmd == "post")
76  {
77  @$this->cmd = key($_POST["cmd"]);
78  }
79  else
80  {
81  $this->cmd = $a_cmd;
82  }
83  }
84  function getCommand()
85  {
86  return $this->cmd;
87  }
88  function getType()
89  {
90  return $this->type;
91  }
92  function setType($a_type)
93  {
94  $this->type = $a_type;
95  }
96 
97  function performAction()
98  {
99  if($this->getCommand())
100  {
101  $method = $this->getCommand()."Object";
102  }
103  else
104  {
105  $method = $this->objDefinition->getFirstProperty($this->getType())."Object";
106  }
107  $this->gui_obj->$method();
108 
109  return true;
110  }
115 /* Deprecated
116  function setAdminTabs()
117  {
118  global $rbacsystem;
119 
120  $tabs = array();
121  $this->tpl->addBlockFile("TABS", "tabs", "tpl.tabs.html");
122 
123 // $properties = $this->objDefinition->getProperties($this->getType());
124 
125  foreach($properties as $key => $row)
126  {
127  $tabs[] = array($row["lng"], $row["name"]);
128  }
129 
130  // check for call_by_reference too to avoid hacking
131  if ($this->call_by_reference === false)
132  {
133  $object_link = "&obj_id=".$_GET["obj_id"];
134  }
135 
136  foreach ($tabs as $row)
137  {
138  $i++;
139 
140  if ($row[1] == $this->getCommand())
141  {
142  $tabtype = "tabactive";
143  $tab = $tabtype;
144  }
145  else
146  {
147  $tabtype = "tabinactive";
148  $tab = "tab";
149  }
150 
151  $show = true;
152 
153  // only check permissions for tabs if object is a permission object
154  if($this->call_by_reference)
155  {
156  // only show tab when the corresponding permission is granted
157  switch ($row[1])
158  {
159  case 'view':
160  if (!$rbacsystem->checkAccess('visible',$this->getId()))
161  {
162  $show = false;
163  }
164  break;
165 
166  case 'edit':
167  if (!$rbacsystem->checkAccess('write',$this->getId()))
168  {
169  $show = false;
170  }
171  break;
172 
173  case 'perm':
174  if (!$rbacsystem->checkAccess('edit_permission',$this->getId()))
175  {
176  $show = false;
177  }
178  break;
179  case 'trash':
180  if (!$this->gui_obj->tree->getSavedNodeData($this->getId()))
181  {
182  $show = false;
183  }
184  break;
185 
186  case 'newmembers':
187  case 'members':
188  if (!$rbacsystem->checkAccess('write',$this->getId()))
189  {
190  $show = false;
191  }
192  break;
193 
194  } //switch
195  }
196 
197  if (!$show)
198  {
199  continue;
200  }
201 
202  $this->tpl->setCurrentBlock("tab");
203  $this->tpl->setVariable("TAB_TYPE", $tabtype);
204  $this->tpl->setVariable("TAB_TYPE2", $tab);
205  $this->tpl->setVariable("IMG_LEFT", ilUtil::getImagePath("eck_l.gif"));
206  $this->tpl->setVariable("IMG_RIGHT", ilUtil::getImagePath("eck_r.gif"));
207  $this->tpl->setVariable("TAB_LINK", $this->gui_obj->tab_target_script."?ref_id=".$this->getId().$object_link."&cmd=".$row[1]);
208  $this->tpl->setVariable("TAB_TEXT", $this->gui_obj->lng->txt($row[0]));
209  $this->tpl->parseCurrentBlock();
210  }
211  }
212 */
213 
214  // PRIVATE METHODS
215  function __initGUIObject($a_call_by_reference,$a_prepare_output = true)
216  {
217  global $objDefinition;
218 
219  include_once "./classes/class.ilObjectFactory.php";
220 
221  // GET TYPE
222  if($a_call_by_reference)
223  {
224  $tmp_obj =& ilObjectFactory::getInstanceByRefId($this->getId());
225  }
226  else
227  {
228  $tmp_obj =& ilObjectFactory::getInstanceByObjId($this->getId());
229  }
230  $this->setType($tmp_obj->getType());
231 
232  // INITIATE GUI CLASS
233  $class_name = $objDefinition->getClassName($this->getType());
234  $location = $objDefinition->getLocation($this->getType());
235  $class_constr = "ilObj".$class_name."GUI";
236 
237  //INCLUDE CLASS
238  include_once $location."/class.ilObj".$class_name."GUI.php";
239 
240  // CALL CONSTRUCTOR
241  $this->gui_obj =& new $class_constr(array(),$this->getId(),$a_call_by_reference,$a_prepare_output);
242 
243  return true;
244  }
245 } // END class.ilObjectGUIAdapter
246 ?>