ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjComponentSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2006 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 include_once("./classes/class.ilObjectGUI.php");
24 
25 
37 {
38  private static $ERROR_MESSAGE;
44  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
45  {
46  $this->type = 'cmps';
47  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
48 
49  $this->lng->loadLanguageModule('cmps');
50  }
51 
58  public function executeCommand()
59  {
60  global $rbacsystem,$ilErr,$ilAccess;
61 
62  $next_class = $this->ctrl->getNextClass($this);
63  $cmd = $this->ctrl->getCmd();
64 
65  $this->prepareOutput();
66 
67  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
68  {
69  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
70  }
71 
72  switch($next_class)
73  {
74  case 'ilpermissiongui':
75  $this->tabs_gui->setTabActive('perm_settings');
76  include_once("./classes/class.ilPermissionGUI.php");
77  $perm_gui =& new ilPermissionGUI($this);
78  $ret =& $this->ctrl->forwardCommand($perm_gui);
79  break;
80 
81  default:
82  if(!$cmd || $cmd == 'view')
83  {
84  $cmd = "listModules";
85  }
86 
87  $this->$cmd();
88  break;
89  }
90  return true;
91  }
92 
99  public function getAdminTabs()
100  {
101  global $rbacsystem, $ilAccess;
102  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
103  {
104  $this->tabs_gui->addTarget("cmps_modules",
105  $this->ctrl->getLinkTarget($this, "listModules"),
106  array("listModules", "view", "showPluginSlot"));
107 
108  $this->tabs_gui->addTarget("cmps_services",
109  $this->ctrl->getLinkTarget($this, "listServices"),
110  array("listServices"));
111  }
112 
113  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
114  {
115  $this->tabs_gui->addTarget("perm_settings",
116  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"),
117  array(),'ilpermissiongui');
118  }
119  }
120 
124  public function listModules()
125  {
126  global $ilCtrl, $lng, $ilSetting;
127 
128  $tpl = new ilTemplate("tpl.component_list.html", true, true, "Services/Component");
129 
130  /*
131  $tpl->setVariable("HREF_REFRESH_PLUGINS_INFORMATION",
132  $ilCtrl->getLinkTarget($this, "refreshPluginsInformation"));
133  $tpl->setVariable("TXT_REFRESH_PLUGINS_INFORMATION",
134  $lng->txt("cmps_refresh_plugins_inf"));
135  */
136 
137  include_once("./Services/Component/classes/class.ilComponentsTableGUI.php");
138  $comp_table = new ilComponentsTableGUI($this, "listModules");
139 
140  $tpl->setVariable("TABLE", $comp_table->getHTML());
141  $this->tpl->setContent($tpl->get());
142  }
143 
147  public function listServices()
148  {
149  global $ilCtrl, $lng, $ilSetting;
150 
151  $tpl = new ilTemplate("tpl.component_list.html", true, true, "Services/Component");
152 
153  $ilCtrl->setParameter($this, "mode", IL_COMP_SERVICE);
154  $tpl->setVariable("HREF_REFRESH_PLUGINS_INFORMATION",
155  $ilCtrl->getLinkTarget($this, "refreshPluginsInformation"));
156  $tpl->setVariable("TXT_REFRESH_PLUGINS_INFORMATION",
157  $lng->txt("cmps_refresh_plugins_inf"));
158 
159  include_once("./Services/Component/classes/class.ilComponentsTableGUI.php");
160  $comp_table = new ilComponentsTableGUI($this, "listServices", IL_COMP_SERVICE);
161 
162  $tpl->setVariable("TABLE", $comp_table->getHTML());
163  $this->tpl->setContent($tpl->get());
164  }
165 
169  function saveOptions()
170  {
171  global $ilSetting, $ilCtrl;
172 
173  // disable creation
174  if (is_array($_POST["obj_dis_creation"]))
175  {
176  foreach($_POST["obj_dis_creation"] as $k => $v)
177  {
178  $ilSetting->set("obj_dis_creation_".$k, $v);
179  }
180  }
181 
182  // disable creation
183  if (is_array($_POST["obj_pos"]))
184  {
185  foreach($_POST["obj_pos"] as $k => $v)
186  {
187  $ilSetting->set("obj_dis_creation_".$k, $_POST["obj_dis_creation"][$k]);
188  }
189  }
190 
191  // add new position
192  if (is_array($_POST["obj_pos"]))
193  {
194  reset($_POST["obj_pos"]);
195  foreach($_POST["obj_pos"] as $k => $v)
196  {
197  $ilSetting->set("obj_add_new_pos_".$k, $v);
198  }
199  }
200 
201  $ilCtrl->redirect($this, "listModules");
202  }
203 
207  function showPluginSlot()
208  {
209  global $tpl,$lng;
210 
211  //slot_id
212  $ptpl = new ilTemplate("tpl.plugin_slot.html", true, true,
213  "Services/Component");
214 
215  include_once("./Services/Component/classes/class.ilComponent.php");
216  $comp = ilComponent::getComponentObject($_GET["ctype"], $_GET["cname"]);
217  $ptpl->setVariable("TXT_COMPONENT", $lng->txt("cmps_component"));
218  $ptpl->setVariable("VAL_COMPONENT_NAME", $comp->getComponentType()."/".$comp->getName());
219  $ptpl->setVariable("VAL_COMPONENT_ID", $comp->getId());
220 
221  $ptpl->setVariable("TXT_PLUGIN_SLOT", $lng->txt("cmps_plugin_slot"));
222  $ptpl->setVariable("VAL_PLUGIN_SLOT", $comp->getPluginSlotName($_GET["slot_id"]));
223  $ptpl->setVariable("VAL_PLUGIN_SLOT_ID", $_GET["slot_id"]);
224 
225  // directories
226  $ptpl->setVariable("TXT_PLUGIN_DIR", $lng->txt("cmps_plugin_dirs"));
227  $ptpl->setVariable("VAL_PLUGIN_DIR",
228  $comp->getPluginSlotDirectory($_GET["slot_id"])."/&lt;Plugin_Name&gt;");
229  $ptpl->setVariable("TXT_MAIN_DIR", $lng->txt("cmps_main_dir"));
230  $ptpl->setVariable("TXT_PLUGIN_FILE", $lng->txt("cmps_plugin_file"));
231  $ptpl->setVariable("TXT_LANG_FILES", $lng->txt("cmps_lang_files"));
232  $ptpl->setVariable("TXT_DB_UPDATE", $lng->txt("cmps_db_update"));
233  $ptpl->setVariable("VAL_PLUGIN_FILE",
234  "&lt;".$lng->txt("cmps_main_dir")."&gt;".
235  "/classes/class.il&lt;Plugin_Name&gt;Plugin.php");
236  $ptpl->setVariable("VAL_LANG_FILES",
237  "&lt;".$lng->txt("cmps_main_dir")."&gt;".
238  "/lang/ilias_&lt;Language ID&gt;.lang");
239  $ptpl->setVariable("VAL_DB_UPDATE",
240  "&lt;".$lng->txt("cmps_main_dir")."&gt;".
241  "/sql/dbupdate.php");
242 
243  $ptpl->setVariable("TXT_PLUGIN_LANG_PREFIX", $lng->txt("cmps_plugin_lang_prefixes"));
244  $ptpl->setVariable("VAL_PLUGIN_LANG_PREFIX",
245  $comp->getPluginSlotLanguagePrefix($_GET["slot_id"])."&lt;Plugin_ID&gt;_");
246 
247  $ptpl->setVariable("TXT_PLUGIN_DB_PREFIX", $lng->txt("cmps_plugin_db_prefixes"));
248  $ptpl->setVariable("VAL_PLUGIN_DB_PREFIX",
249  "il_".$comp->getPluginSlotLanguagePrefix($_GET["slot_id"])."&lt;Plugin_ID&gt;_");
250 
251  // plugins table
252  include_once("./Services/Component/classes/class.ilPluginsTableGUI.php");
253  $plugins_table = new ilPluginsTableGUI($this, "showPluginSlot",
254  $_GET["ctype"], $_GET["cname"], $_GET["slot_id"]);
255  $ptpl->setVariable("PLUGIN_LIST", $plugins_table->getHTML());
256 
257  // set content and title
258  $tpl->setContent($ptpl->get());
259  $tpl->setTitle($comp->getComponentType()."/".$comp->getName().": ".
260  $lng->txt("cmps_plugin_slot")." \"".$comp->getPluginSlotName($_GET["slot_id"])."\"");
261  $tpl->setDescription("");
262  }
263 
268  {
269  global $ilCtrl;
270 die ("ilObjComponentSettigsGUI::refreshPluginsInformation: deprecated");
271  include_once("./Services/Component/classes/class.ilPlugin.php");
272  ilPlugin::refreshPluginXmlInformation();
273 
274  if ($_GET["mode"] == IL_COMP_SERVICE)
275  {
276  $ilCtrl->redirect($this, "listServices");
277  }
278  else
279  {
280  $ilCtrl->redirect($this, "listModules");
281  }
282  }
283 
287  function activatePlugin()
288  {
289  global $ilCtrl;
290 
291  include_once("./Services/Component/classes/class.ilPlugin.php");
292  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
293  $_GET["slot_id"], $_GET["pname"]);
294 
295  $result = $pl->activate();
296 
297  if ($result !== true)
298  {
299  ilUtil::sendInfo($result, true);
300  }
301 
302  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
303  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
304  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
305  $ilCtrl->redirect($this, "showPluginSlot");
306  }
307 
311  function updatePlugin()
312  {
313  global $ilCtrl;
314 
315  include_once("./Services/Component/classes/class.ilPlugin.php");
316  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
317  $_GET["slot_id"], $_GET["pname"]);
318 
319  $result = $pl->update();
320 
321  if ($result !== true)
322  {
323  ilUtil::sendInfo($pl->message, true);
324  }
325  else
326  {
327  ilUtil::sendInfo($pl->message, true);
328  }
329 
330  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
331  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
332  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
333  $ilCtrl->redirect($this, "showPluginSlot");
334  }
335 
339  function deactivatePlugin()
340  {
341  global $ilCtrl;
342 
343  include_once("./Services/Component/classes/class.ilPlugin.php");
344  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
345  $_GET["slot_id"], $_GET["pname"]);
346 
347  $result = $pl->deactivate();
348 
349  if ($result !== true)
350  {
351  ilUtil::sendInfo($result, true);
352  }
353 
354  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
355  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
356  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
357  $ilCtrl->redirect($this, "showPluginSlot");
358  }
359 
363  function refreshLanguages()
364  {
365  global $ilCtrl;
366 
367  include_once("./Services/Component/classes/class.ilPlugin.php");
368  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
369  $_GET["slot_id"], $_GET["pname"]);
370 
371  $result = $pl->updateLanguages();
372 
373  if ($result !== true)
374  {
375  ilUtil::sendInfo($result, true);
376  }
377 
378  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
379  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
380  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
381  $ilCtrl->redirect($this, "showPluginSlot");
382  }
383 
387  function updatePluginDB()
388  {
389  global $ilDB;
390 
391  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
392  $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"],
393  $_GET["slot_id"], $_GET["pname"], $ilDB, true);
394 
395  $dbupdate->applyUpdate();
396 
397  if ($dbupdate->updateMsg == "no_changes")
398  {
399  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
400  }
401  else
402  {
403  foreach ($dbupdate->updateMsg as $row)
404  {
405  $message .= $this->lng->txt($row["msg"]).": ".$row["nr"]."<br/>";
406  }
407  }
408 
409  ilUtil::sendInfo($message, true);
410 
411  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
412  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
413  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
414  $ilCtrl->redirect($this, "showPluginSlot");
415  }
416 
417 
418 }
419 ?>