ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjComponentSettingsGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./classes/class.ilObjectGUI.php");
4 
5 
17 {
18  private static $ERROR_MESSAGE;
24  public function __construct($a_data, $a_id, $a_call_by_reference = true, $a_prepare_output = true)
25  {
26  $this->type = 'cmps';
27  parent::ilObjectGUI($a_data, $a_id, $a_call_by_reference, $a_prepare_output);
28 
29  $this->lng->loadLanguageModule('cmps');
30  }
31 
38  public function executeCommand()
39  {
40  global $rbacsystem, $ilErr, $ilAccess, $ilCtrl;
41 
42  $next_class = $this->ctrl->getNextClass($this);
43  $cmd = $this->ctrl->getCmd();
44 
45  $this->prepareOutput();
46 
47  if(!$ilAccess->checkAccess('read','',$this->object->getRefId()))
48  {
49  $ilErr->raiseError($this->lng->txt('no_permission'),$ilErr->WARNING);
50  }
51 
52  switch($next_class)
53  {
54  case 'ilpermissiongui':
55  $this->tabs_gui->setTabActive('perm_settings');
56  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
57  $perm_gui =& new ilPermissionGUI($this);
58  $ret =& $this->ctrl->forwardCommand($perm_gui);
59  break;
60 
61  default:
62 
63  // configure classes
64  $config = false;
65  if (substr(strtolower($next_class), strlen($next_class) - 9) == "configgui")
66  {
67  $path = $ilCtrl->lookupClassPath(strtolower($next_class));
68  if ($path != "")
69  {
70  include_once($path);
71  $nc = new $next_class();
72 
74  $_GET["cname"], $_GET["slot_id"], $_GET["pname"]);
75 
76  $nc->setPluginObject($pl);
77 
78  $ret = $this->ctrl->forwardCommand($nc);
79  $config = true;
80  }
81  }
82 
83  if (!$config)
84  {
85  if(!$cmd || $cmd == 'view')
86  {
87  $cmd = "listPlugins";
88  }
89 
90  $this->$cmd();
91  }
92  break;
93  }
94  return true;
95  }
96 
103  public function getAdminTabs()
104  {
105  global $rbacsystem, $ilAccess, $lng;
106 
107  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
108  {
109  $this->tabs_gui->addTab("plugins",
110  $lng->txt("cmps_plugins"),
111  $this->ctrl->getLinkTarget($this, "listPlugins"));
112 
113  $this->tabs_gui->addTab("modules",
114  $lng->txt("cmps_modules"),
115  $this->ctrl->getLinkTarget($this, "listModules"));
116 
117  $this->tabs_gui->addTab("services",
118  $lng->txt("cmps_services"),
119  $this->ctrl->getLinkTarget($this, "listServices"));
120  }
121 
122  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
123  {
124  $this->tabs_gui->addTab("perm_settings",
125  $lng->txt("perm_settings"),
126  $this->ctrl->getLinkTargetByClass('ilpermissiongui',"perm"));
127  }
128 
129  if ($_GET["ctype"] == "Services")
130  {
131  $this->tabs_gui->activateTab("services");
132  }
133  }
134 
138  public function listModules()
139  {
140  global $ilCtrl, $lng, $ilSetting;
141 
142  $this->tabs_gui->activateTab('modules');
143 
144  $tpl = new ilTemplate("tpl.component_list.html", true, true, "Services/Component");
145 
146  /*
147  $tpl->setVariable("HREF_REFRESH_PLUGINS_INFORMATION",
148  $ilCtrl->getLinkTarget($this, "refreshPluginsInformation"));
149  $tpl->setVariable("TXT_REFRESH_PLUGINS_INFORMATION",
150  $lng->txt("cmps_refresh_plugins_inf"));
151  */
152 
153  include_once("./Services/Component/classes/class.ilComponentsTableGUI.php");
154  $comp_table = new ilComponentsTableGUI($this, "listModules");
155 
156  $tpl->setVariable("TABLE", $comp_table->getHTML());
157  $this->tpl->setContent($tpl->get());
158  }
159 
163  public function listServices()
164  {
165  global $ilCtrl, $lng, $ilSetting;
166 
167  $this->tabs_gui->activateTab('services');
168 
169  $tpl = new ilTemplate("tpl.component_list.html", true, true, "Services/Component");
170 
171  $ilCtrl->setParameter($this, "mode", IL_COMP_SERVICE);
172  $tpl->setVariable("HREF_REFRESH_PLUGINS_INFORMATION",
173  $ilCtrl->getLinkTarget($this, "refreshPluginsInformation"));
174  $tpl->setVariable("TXT_REFRESH_PLUGINS_INFORMATION",
175  $lng->txt("cmps_refresh_plugins_inf"));
176 
177  include_once("./Services/Component/classes/class.ilComponentsTableGUI.php");
178  $comp_table = new ilComponentsTableGUI($this, "listServices", IL_COMP_SERVICE);
179 
180  $tpl->setVariable("TABLE", $comp_table->getHTML());
181  $this->tpl->setContent($tpl->get());
182  }
183 
190  function listPlugins()
191  {
192  global $tpl, $ilTabs;
193 
194  $ilTabs->activateTab("plugins");
195  include_once("./Services/Component/classes/class.ilPluginsOverviewTableGUI.php");
196  $table = new ilPluginsOverviewTableGUI($this, "listPlugins");
197  $tpl->setContent($table->getHTML());
198  }
199 
203  function saveOptions()
204  {
205  global $ilSetting, $ilCtrl, $lng;
206 
207  // disable creation
208  if (is_array($_POST["obj_pos"]))
209  {
210  foreach($_POST["obj_pos"] as $k => $v)
211  {
212  $ilSetting->set("obj_dis_creation_".$k, (int) $_POST["obj_dis_creation"][$k]);
213  }
214  }
215 
216  // add new position
217  $double = $ex_pos = array();
218  if (is_array($_POST["obj_pos"]))
219  {
220  reset($_POST["obj_pos"]);
221  foreach($_POST["obj_pos"] as $k => $v)
222  {
223  if (in_array($v, $ex_pos))
224  {
225  $double[$v] = $v;
226  }
227  $ex_pos[] = $v;
228  $ilSetting->set("obj_add_new_pos_".$k, $v);
229  }
230  }
231 
232  if (count($double) == 0)
233  {
234  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
235  }
236  else
237  {
238  ilUtil::sendInfo($lng->txt("cmps_duplicate_positions")." ".implode($double, ", "), true);
239  }
240 
241  $ilCtrl->redirect($this, "listModules");
242  }
243 
248  {
249  global $tpl,$lng, $ilTabs, $ilCtrl;
250 
251  $ilTabs->clearTargets();
252  if ($_GET["ctype"] == "Services")
253  {
254  $ilTabs->setBackTarget($lng->txt("cmps_services"),
255  $ilCtrl->getLinkTarget($this, "listServices"));
256  }
257  else
258  {
259  $ilTabs->setBackTarget($lng->txt("cmps_modules"),
260  $ilCtrl->getLinkTarget($this, "listModules"));
261  }
262 
263  include_once("./Services/Component/classes/class.ilComponent.php");
264  $comp = ilComponent::getComponentObject($_GET["ctype"], $_GET["cname"]);
265 
266  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
267  $form = new ilPropertyFormGUI();
268 
269  // component
270  $ne = new ilNonEditableValueGUI($lng->txt("cmps_component"), "");
271  $ne->setValue($comp->getComponentType()."/".$comp->getName()." [".$comp->getId()."]");
272  $form->addItem($ne);
273 
274  // plugin slot
275  $ne = new ilNonEditableValueGUI($lng->txt("cmps_plugin_slot"), "");
276  $ne->setValue($comp->getPluginSlotName($_GET["slot_id"])." [".$_GET["slot_id"]."]");
277  $form->addItem($ne);
278 
279  // main dir
280  $ne = new ilNonEditableValueGUI($lng->txt("cmps_main_dir"), "");
281  $ne->setValue($comp->getPluginSlotDirectory($_GET["slot_id"])."/&lt;Plugin_Name&gt;");
282  $form->addItem($ne);
283 
284  // plugin file
285  $ne = new ilNonEditableValueGUI($lng->txt("cmps_plugin_file"), "");
286  $ne->setValue("&lt;".$lng->txt("cmps_main_dir")."&gt;".
287  "/classes/class.il&lt;Plugin_Name&gt;Plugin.php");
288  $form->addItem($ne);
289 
290  // language files
291  $ne = new ilNonEditableValueGUI($lng->txt("cmps_lang_files"), "");
292  $ne->setValue("&lt;".$lng->txt("cmps_main_dir")."&gt;".
293  "/lang/ilias_&lt;Language ID&gt;.lang");
294  $form->addItem($ne);
295 
296  // db update
297  $ne = new ilNonEditableValueGUI($lng->txt("cmps_db_update"), "");
298  $ne->setValue("&lt;".$lng->txt("cmps_main_dir")."&gt;".
299  "/sql/dbupdate.php");
300  $form->addItem($ne);
301 
302  // lang prefix
303  $ne = new ilNonEditableValueGUI($lng->txt("cmps_plugin_lang_prefixes"), "");
304  $ne->setValue($comp->getPluginSlotLanguagePrefix($_GET["slot_id"])."&lt;Plugin_ID&gt;_");
305  $form->addItem($ne);
306 
307  // db prefix
308  $ne = new ilNonEditableValueGUI($lng->txt("cmps_plugin_db_prefixes"), "");
309  $ne->setValue($comp->getPluginSlotLanguagePrefix($_GET["slot_id"])."&lt;Plugin_ID&gt;_");
310  $form->addItem($ne);
311 
312  $form->setTitle($lng->txt("cmps_plugin_slot"));
313 
314  // set content and title
315  $tpl->setContent($form->getHTML());
316  $tpl->setTitle($comp->getComponentType()."/".$comp->getName().": ".
317  $lng->txt("cmps_plugin_slot")." \"".$comp->getPluginSlotName($_GET["slot_id"])."\"");
318  $tpl->setDescription("");
319  }
320 
324  function showPluginSlot()
325  {
326  global $tpl, $lng, $ilTabs, $ilCtrl;
327 
328  $ilTabs->clearTargets();
329  $ilTabs->setBackTarget($lng->txt("cmps_plugins"),
330  $ilCtrl->getLinkTarget($this, "listPlugins"));
331 
332  include_once("./Services/Component/classes/class.ilComponent.php");
333  $comp = ilComponent::getComponentObject($_GET["ctype"], $_GET["cname"]);
334 
335  // plugins table
336  include_once("./Services/Component/classes/class.ilPluginsTableGUI.php");
337  $plugins_table = new ilPluginsTableGUI($this, "showPluginSlot",
338  $_GET["ctype"], $_GET["cname"], $_GET["slot_id"]);
339  $tpl->setContent($plugins_table->getHTML());
340 
341  // set content and title
342  $tpl->setTitle($comp->getComponentType()."/".$comp->getName().": ".
343  $lng->txt("cmps_plugin_slot")." \"".$comp->getPluginSlotName($_GET["slot_id"])."\"");
344  $tpl->setDescription("");
345  }
346 
351  {
352  global $ilCtrl;
353 die ("ilObjComponentSettigsGUI::refreshPluginsInformation: deprecated");
354  include_once("./Services/Component/classes/class.ilPlugin.php");
355  ilPlugin::refreshPluginXmlInformation();
356 
357  if ($_GET["mode"] == IL_COMP_SERVICE)
358  {
359  $ilCtrl->redirect($this, "listServices");
360  }
361  else
362  {
363  $ilCtrl->redirect($this, "listModules");
364  }
365  }
366 
370  function activatePlugin()
371  {
372  global $ilCtrl, $lng;
373 
374  include_once("./Services/Component/classes/class.ilPlugin.php");
375  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
376  $_GET["slot_id"], $_GET["pname"]);
377 
378  try
379  {
380  $result = $pl->activate();
381  if ($result !== true)
382  {
383  ilUtil::sendFailure($result, true);
384  }
385  else
386  {
387  ilUtil::sendSuccess($lng->txt("cmps_plugin_activated"), true);
388  }
389  }
390  catch(ilPluginException $e)
391  {
392  ilUtil::sendFailure($e->getMessage, true);
393  }
394 
395  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
396  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
397  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
398  $ilCtrl->redirect($this, "showPluginSlot");
399  }
400 
404  function updatePlugin()
405  {
406 
407  include_once("./Services/Component/classes/class.ilPlugin.php");
408  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
409  $_GET["slot_id"], $_GET["pname"]);
410 
411  $result = $pl->update();
412 
413  if ($result !== true)
414  {
415  ilUtil::sendFailure($pl->message, true);
416  }
417  else
418  {
419  ilUtil::sendSuccess($pl->message, true);
420  }
421 
422  // reinitialize control class
423  global $ilCtrl;
424  $ilCtrl->initBaseClass("iladministrationgui");
425  $_GET["cmd"] = "jumpToPluginSlot";
426  $ilCtrl->setParameterByClass("iladministrationgui", "ctype", $_GET["ctype"]);
427  $ilCtrl->setParameterByClass("iladministrationgui", "cname", $_GET["cname"]);
428  $ilCtrl->setParameterByClass("iladministrationgui", "slot_id", $_GET["slot_id"]);
429  $ilCtrl->setTargetScript("ilias.php");
430  $ilCtrl->callBaseClass();
431  //$ilCtrl->redirectByClass("iladministrationgui", );
432  }
433 
437  function deactivatePlugin()
438  {
439  global $ilCtrl, $lng;
440 
441  include_once("./Services/Component/classes/class.ilPlugin.php");
442  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
443  $_GET["slot_id"], $_GET["pname"]);
444 
445  $result = $pl->deactivate();
446 
447  if ($result !== true)
448  {
449  ilUtil::sendFailure($result, true);
450  }
451  else
452  {
453  ilUtil::sendSuccess($lng->txt("cmps_plugin_deactivated"), true);
454  }
455 
456  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
457  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
458  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
459  $ilCtrl->redirect($this, "showPluginSlot");
460  }
461 
465  function refreshLanguages()
466  {
467  global $ilCtrl;
468 
469  include_once("./Services/Component/classes/class.ilPlugin.php");
470  $pl = ilPlugin::getPluginObject($_GET["ctype"], $_GET["cname"],
471  $_GET["slot_id"], $_GET["pname"]);
472 
473  $result = $pl->updateLanguages();
474 
475  if ($result !== true)
476  {
477  ilUtil::sendFailure($result, true);
478  }
479 
480  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
481  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
482  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
483  $ilCtrl->redirect($this, "showPluginSlot");
484  }
485 
489  function updatePluginDB()
490  {
491  global $ilDB;
492 
493  include_once("./Services/Component/classes/class.ilPluginDBUpdate.php");
494  $dbupdate = new ilPluginDBUpdate($_GET["ctype"], $_GET["cname"],
495  $_GET["slot_id"], $_GET["pname"], $ilDB, true);
496 
497  $dbupdate->applyUpdate();
498 
499  if ($dbupdate->updateMsg == "no_changes")
500  {
501  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
502  }
503  else
504  {
505  foreach ($dbupdate->updateMsg as $row)
506  {
507  $message .= $this->lng->txt($row["msg"]).": ".$row["nr"]."<br/>";
508  }
509  }
510 
511  ilUtil::sendInfo($message, true);
512 
513  $ilCtrl->setParameter($this, "ctype", $_GET["ctype"]);
514  $ilCtrl->setParameter($this, "cname", $_GET["cname"]);
515  $ilCtrl->setParameter($this, "slot_id", $_GET["slot_id"]);
516  $ilCtrl->redirect($this, "showPluginSlot");
517  }
518 
519 
520 }
521 ?>