ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilSetupGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
6 
7 require_once "./setup/classes/class.ilSetup.php";
8 
18 {
19  const UI_PASSWORD_PLACEHOLDER = '********';
20 
21  public $tpl; // template object
22  public $lng; // language objet
23  public $log; // log object
24 
25  public $btn_prev_on = false; // toggle previous button on/off
26  public $btn_prev_cmd; // command processed when previous button was clicked
27  public $btn_prev_lng; // previous button label
28 
29  public $btn_next_on = false; // toggle NEXT button on/off
30  public $btn_next_cmd; // command processed when next button was clicked
31  public $btn_next_lng; // next button label
32 
33  public $revision; // cvs revision of this script
34  public $version; // cvs version of this script
35  public $lang; // current language (lang_key)
36 
37  public $cmd; // command variable
38  public $display_mode = "view"; // view mode (setup or details)
39 
44  public function __construct()
45  {
46  global $tpl, $lng, $DIC;
47 
48  $this->tpl = $tpl;
49  $this->lng = $lng;
50 
51  // note: this is currently only used for subtabs, alex 8.1.2012
52  include_once("./Services/UIComponent/Tabs/classes/class.ilTabsGUI.php");
53  $this->tabs = new ilTabsGUI();
54  $this->tabs->setSetupMode(true);
55 
56  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
57  iljQueryUtil::initjQuery($this->tpl);
58  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
60 
61  $tpl->addJavaScript("./Services/JavaScript/js/Basic.js", 0);
62 
63  include_once("./Services/UICore/classes/class.ilUIFramework.php");
64  ilUIFramework::init($this->tpl);
65 
66  // CVS - REVISION - DO NOT MODIFY
67  $this->revision = '$Revision$';
68  $this->version = "2 " . substr(substr($this->revision, 1), 0, -2);
69  $this->lang = $this->lng->lang_key;
70 
71  // init setup
72  require_once 'setup/classes/class.ilSetupPasswordManager.php';
73  require_once 'setup/classes/class.ilSetupPasswordEncoderFactory.php';
74  $this->setup = new ilSetup(
76  'password_encoder' => 'bcryptphp',
77  'encoder_factory' => new \ilSetupPasswordEncoderFactory([
78  'default_password_encoder' => 'bcryptphp'
79  ])
80  ]),
81  $_SESSION["auth"],
82  $_SESSION["access_mode"]
83  );
84 
85  // init client object if exists
86  $client_id = ($_GET["client_id"]) ? $_GET["client_id"] : $_SESSION["ClientId"];
87  if ($_POST["client_id"] != "") {
88  $client_id = $_POST["client_id"];
89  }
90 
91  // for security
92  if (!$this->setup->isAdmin() and $client_id != $_SESSION["ClientId"]) {
93  $client_id = $_SESSION["ClientId"];
94  }
95 
96  $this->client_id = $client_id;
97 
98  $this->setup->ini_client_exists = $this->setup->newClient($client_id);
99  if (is_object($this->setup->getClient())) {
100  $this->setup->getClient()->status = $this->setup->getStatus($client_id);
101  }
102 
103  // determine command
104  if (($this->cmd = $_GET["cmd"]) == "gateway") {
105  // surpress warning if POST is not set
106  @$this->cmd = key($_POST["cmd"]);
107  }
108 
109  // determine display mode here
110  // TODO: depending on previous setting (session)
111  // OR switch to 'setup'-mode if someone logs in as client and client's setup wasn't finished (-> entry in settings table does not exist)
112  if ($this->setup->isAuthenticated() and !$this->setup->getClient()->status["finish"]["status"] and $this->cmd != "clientlist" and $this->cmd != "") {
113  $this->setDisplayMode("setup");
114  } else {
115  $this->setDisplayMode($_SESSION["display_mode"]);
116  }
117 
118  // output starts here
119 
120 
121  // main cmd handling
122  if (!$this->setup->isAuthenticated() or !$this->setup->isInstalled()) {
123  // check for first time installation or migrate an old one first
124  if (!$this->setup->isInstalled() or !($this->setup->ini->readVariable("clients", "path"))) {
125  $this->cmdInstall();
126  } else {
127  if ($this->cmd == "performLogin" || $this->cmd == "performMLogin") {
128  $cmd = $this->cmd;
129  $this->$cmd();
130  } else {
131  $this->displayLogin();
132  }
133  }
134  } else {
135  if ($this->setup->isAdmin()) {
136  $this->cmdAdmin();
137  } else {
138  $this->cmdClient();
139  }
140  }
141 
142  // display header
143  $this->displayHeader();
144 
145  if (DEBUG) {
146  echo "cmd: " . $this->cmd . " | access: " . $this->setup->access_mode . " | display: " . $this->display_mode;
147  var_dump($this->setup->getClient()->status);
148  }
149 
150  // display footer
151  $this->displayFooter();
152 
153  // end output
154  } // end constructor
155 
156  // cmd subsets
157 
161  public function cmdInstall()
162  {
163  $cmd = $this->cmd;
164  switch ($this->cmd) {
165  case null:
166  case "preliminaries":
167  $this->setup->checkPreliminaries();
168  $this->displayPreliminaries();
169  break;
170 
171  case "install":
172  $this->displayMasterSetup();
173  break;
174 
175  case "determineToolsPathInstall":
176  $this->determineToolsPathInstall();
177  break;
178 
179  case "saveBasicSettings":
180  $this->$cmd();
181  break;
182 
183  default:
184  $this->displayError($this->lng->txt("unknown_command") . ": '" . $this->cmd . "'");
185  break;
186  }
187  }
188 
192  public function cmdAdmin()
193  {
194  $cmd = $this->cmd;
195  switch ($this->cmd) {
196  case null:
197  case "clientlist":
198 
199  $this->setDisplayMode("view");
200  $this->displayClientList();
201  $this->active_tab = "clientlist";
202  break;
203 
204  case "savemasterpassword":
205  $this->setDisplayMode("view");
206  $this->saveMasterPassword();
207  $this->active_tab = "password";
208  break;
209 
210  case "changemasterpassword":
211  $this->setDisplayMode("view");
212  $this->changeMasterPassword();
213  $this->active_tab = "password";
214  break;
215 
216  case "mastersettings":
217  $this->setDisplayMode("view");
218  $this->changeMasterSettings();
219  $this->active_tab = "basicsettings";
220  break;
221 
222  case "determineToolsPath":
223  $this->setDisplayMode("view");
224  $this->determineToolsPath();
225  break;
226 
227  case "changedefault":
228  $this->changeDefaultClient();
229  break;
230 
231  case "newclient":
232  $this->cmd = "selectdb";
233  $this->setDisplayMode("setup");
234  $this->setup->ini_client_exists = $this->setup->newClient();
235  $this->selectDBType();
236  break;
237 
238  case "selectdbtype":
239  case "displayIni":
240  $this->cmd = "ini";
241  $this->setDisplayMode("setup");
242  //$this->setup->ini_client_exists = $this->setup->newClient($this->client_id);
243  $this->displayIni();
244  break;
245 
246  case "startup":
247  $this->setDisplayMode("setup");
248  $this->setup->ini_client_exists = $this->setup->newClient();
249  $this->displayStartup();
250  break;
251 
252  case "delete":
253  $this->setDisplayMode("view");
254  $this->displayDeleteConfirmation();
255  break;
256 
257  case "togglelist":
258  $this->setDisplayMode("view");
259  $this->toggleClientList();
260  break;
261 
262  case "preliminaries":
263  $this->setup->checkPreliminaries();
264  $this->displayPreliminaries();
265  $this->active_tab = "preliminaries";
266  break;
267 
268  case "updateBasicSettings":
269  case "performLogin":
270  case "performMLogin":
271  $this->$cmd();
272  break;
273 
274  default:
275  $this->cmdClient();
276  break;
277  }
278  }
279 
283  public function cmdClient()
284  {
285  $cmd = $this->cmd;
286  switch ($this->cmd) {
287  case null:
288  case "view":
289  if ($this->setup->getClient()->db_installed) {
290  $this->setDisplayMode("view");
291  $this->displayClientOverview();
292  } else {
293  $this->cmd = "db";
294  $this->displayDatabase();
295  }
296  break;
297 
298  case "ini":
299  // only allow access to ini if db does not exist yet
300  //if ($this->setup->getClient()->db_installed)
301  //{
302  // $this->cmd = "db";
303  // $this->displayDatabase();
304  //}
305  //else
306  //{
307  $this->displayIni();
308  //}
309  break;
310 
311  case "db":
312  $this->displayDatabase();
313  break;
314 
315  case "dbslave":
316  $this->displayDatabaseSlave();
317  break;
318 
319  case "sess":
320  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "sess" and $this->setup->error === true) {
322  } else {
323  $this->displaySessions();
324  }
325  break;
326 
327  case "lang":
328  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->setup->error === true) {
330  } else {
331  $this->displayLanguages();
332  }
333  break;
334 
335  case "contact":
336  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "contact") {
338  } else {
339  $this->displayContactData();
340  }
341  break;
342 
343  case "proxy":
344  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "proxy") {
346  } else {
347  $this->displayProxy();
348  }
349  break;
350 
351  case "cache":
352  $this->displayCache();
353  break;
354 
355 
356  case "nic":
357  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "nic") {
359  } else {
360  $this->displayNIC();
361  }
362  break;
363 
364  case "finish":
365  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "finish") {
367  } else {
368  $this->displayFinishSetup();
369  }
370  break;
371 
372  case "changeaccess":
373  $this->changeAccessMode($_GET["back"]);
374  break;
375 
376  case "logout":
377  $this->displayLogout();
378  break;
379 
380  case "login":
381  session_destroy();
382  ilUtil::redirect(ILIAS_HTTP_PATH . "/login.php?client_id=" . $this->setup->getClient()->getId());
383  break;
384 
385  case "login_new":
386  if ($this->setup->getClient()->ini->readVariable("client", "access") != "1") {
387  $this->setup->getClient()->ini->setVariable("client", "access", "1");
388  $this->setup->getClient()->ini->write();
389  }
390 
391  session_destroy();
392  ilUtil::redirect(ILIAS_HTTP_PATH . "/login.php?client_id=" . $this->setup->getClient()->getId());
393  break;
394 
395  case "tools":
396  $this->displayTools();
397  break;
398 
399  case "reloadStructure":
400  $this->reloadControlStructure();
401  break;
402 
403  case 'switchTree':
404  $this->switchTree();
405  break;
406 
407  case "saveClientIni":
408  case "installDatabase":
409  case "displayDatabase":
410  case "updateDatabase":
411  case "showUpdateSteps":
412  case "saveLanguages":
413  case "saveContact":
414  case "displayContactData":
415  case "displayNIC":
416  case "saveRegistration":
417  case "applyHotfix":
418  case "showHotfixSteps":
419  case "applyCustomUpdates":
420  case "changeSettingsType":
421  case "showLongerSettings":
422  case "cloneSelectSource":
423  case "cloneSaveSource":
424  case "saveProxy":
425  case "displayPassword":
426  case "savePassword":
427  case "saveDbSlave":
428  case "saveCache":
429  case "addMemcacheServer":
430  case "deleteMemcacheServer":
431  case "editMemcacheServer":
432  case "createMemcacheServer":
433  case "updateMemcacheServer":
434  case "flushCache":
435  case "background_tasks":
436  case "edit_background_tasks":
437  case "save_background_tasks":
438  case "kill_waiting_tasks":
439  $this->$cmd();
440  break;
441 
442  default:
443  $this->setDisplayMode("setup");
444  $this->displayError($this->lng->txt("unknown_command") . ": '" . $this->cmd . "'");
445  break;
446  }
447  }
448 
449  // end cmd subsets
450 
454 
463  public function setDisplayMode($a_mode)
464  {
465  // security
466  if ($a_mode != "view" and $a_mode != "setup") {
467  return false;
468  }
469 
470  $this->display_mode = $a_mode;
471  $_SESSION["display_mode"] = $this->display_mode;
472 
473  return true;
474  }
475 
479  public function displayHeader()
480  {
481  $languages = $this->lng->getLanguages();
482 
483  $count = (int) round(count($languages) / 2);
484  $num = 1;
485 
486  sort($languages); // #16837
487  foreach ($languages as $lang_key) {
488  /*
489  if ($num === $count)
490  {
491  $this->tpl->touchBlock("lng_new_row");
492  }
493  */
494  $this->tpl->setCurrentBlock("languages");
495  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=" . $this->cmd . "&amp;lang=" . $lang_key);
496  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_" . $lang_key));
497  $this->tpl->setVariable("LANG_ICON", $lang_key);
498  $this->tpl->setVariable("LANG_KEY", $lang_key);
499  $this->tpl->setVariable("BORDER", 0);
500  $this->tpl->setVariable("VSPACE", 0);
501  $this->tpl->parseCurrentBlock();
502 
503  $num++;
504  }
505 
506  if ($this->cmd != "logout" and $this->setup->isInstalled() and $this->setup->isAuthenticated()) {
507  // add client link
508  if ($this->setup->isAdmin()) {
509  if ($this->display_mode == "view" ||
510  $this->cmd == "clientlist" ||
511  $this->cmd == "changemasterpassword" ||
512  $this->cmd == 'savemasterpassword' ||
513  $this->cmd == "mastersettings") {
514  $this->tpl->setCurrentBlock("add_client");
515  $this->tpl->setVariable("TXT_ADD_CLIENT", ucfirst($this->lng->txt("new_client")));
516  $this->tpl->parseCurrentBlock();
517  }
518 
519  // client list link
520  $class = ($this->active_tab == "clientlist")
521  ? "ilSMActive"
522  : "ilSMInactive";
523  $this->tpl->setCurrentBlock("display_list");
524  $this->tpl->setVariable("TXT_LIST", ucfirst($this->lng->txt("list_clients")));
525  $this->tpl->setVariable("TAB_CLASS", $class);
526  $this->tpl->parseCurrentBlock();
527 
528  // client list link
529  $class = ($this->active_tab == "background_tasks")
530  ? "ilSMActive"
531  : "ilSMInactive";
532  $this->tpl->setCurrentBlock("display_list");
533  $this->tpl->setVariable("TXT_BACKGROUND_TASKS", ucfirst($this->lng->txt("background_tasks")));
534  $this->tpl->setVariable("BACKGROUND_TASKS_CLASS", $class);
535  $this->tpl->parseCurrentBlock();
536 
537  // edit paths link
538  $class = ($this->active_tab == "basicsettings")
539  ? "ilSMActive"
540  : "ilSMInactive";
541  $this->tpl->setCurrentBlock("edit_pathes");
542  $this->tpl->setVariable("TXT_EDIT_PATHES", $this->lng->txt("basic_settings"));
543  $this->tpl->setVariable("TAB_CLASS", $class);
544  $this->tpl->parseCurrentBlock();
545 
546  // preliminaries
547  $class = ($this->active_tab == "preliminaries")
548  ? "ilSMActive"
549  : "ilSMInactive";
550  $this->tpl->setCurrentBlock("preliminaries");
551  $this->tpl->setVariable("TXT_PRELIMINARIES", $this->lng->txt("preliminaries"));
552  $this->tpl->setVariable("TAB_CLASS", $class);
553  $this->tpl->parseCurrentBlock();
554 
555  // change password link
556  $class = ($this->active_tab == "password")
557  ? "ilSMActive"
558  : "ilSMInactive";
559  $this->tpl->setCurrentBlock("change_password");
560  $this->tpl->setVariable("TXT_CHANGE_PASSWORD", ucfirst($this->lng->txt("password")));
561  $this->tpl->setVariable("TAB_CLASS", $class);
562  $this->tpl->parseCurrentBlock();
563  }
564 
565  // logout link
566  if ($this->setup->isAuthenticated()) {
567  $this->tpl->setCurrentBlock("logout");
568  $this->tpl->setVariable("TXT_LOGOUT", $this->lng->txt("logout"));
569  $this->tpl->parseCurrentBlock();
570  }
571  }
572 
573  $this->tpl->setVariable("VAL_CMD", htmlspecialchars($_GET["cmd"]));
574  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE", $this->lng->txt("choose_language"));
575  $this->tpl->setVariable("PAGETITLE", "Setup");
576  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
577  $this->tpl->setVariable("LOCATION_STYLESHEET", "../templates/default/delos.css");
578  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", "./css/setup.css");
579  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS " . ILIAS_VERSION);
580  $this->tpl->setVariable("TXT_SETUP", $this->lng->txt("setup"));
581  $this->tpl->setVariable("VERSION", $this->version);
582  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
583  $this->tpl->setVariable("LANG", $this->lang);
584  }
585 
589  public function displayFooter()
590  {
591  // footer (not really)
592  if ($this->cmd != "logout") {
593  if ($this->setup->ini_ilias_exists and $this->display_mode == "setup" and $this->setup->getClient()->getId() != "") {
594  $this->tpl->setVariable("TXT_ACCESS_MODE", "(" . $this->lng->txt("client_id") . ": " . $this->setup->getClient()->getId() . ")");
595  } elseif ($this->setup->isAdmin()) {
596  $this->tpl->setVariable("TXT_ACCESS_MODE", "(" . $this->lng->txt("root_access") . ")");
597  }
598 
599  $this->displayNavButtons();
600  }
601 
602  $this->tpl->show();
603  }
604 
610  public function displayNavButtons()
611  {
612  if (!$this->btn_prev_on and !$this->btn_next_on) {
613  return false;
614  }
615 
616  $ntpl = new ilTemplate("tpl.navbuttons.html", true, true, "setup");
617  //$this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html", "setup");
618 
619  $ntpl->setVariable("FORMACTION_BUTTONS", "setup.php?cmd=gateway");
620 
621  if ($this->btn_prev_on) {
622  $ntpl->setCurrentBlock("btn_back");
623  $ntpl->setVariable("TXT_PREV", $this->btn_prev_lng);
624  $ntpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
625  $ntpl->parseCurrentBlock();
626  }
627 
628  if ($this->btn_next_on) {
629  $ntpl->setCurrentBlock("btn_forward");
630  $ntpl->setVariable("TXT_NEXT", $this->btn_next_lng);
631  $ntpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
632  $ntpl->parseCurrentBlock();
633  }
634 
635  $nav_html = $ntpl->get();
636  $this->tpl->setVariable("NAVBUTTONS", $nav_html);
637  if (!$this->no_second_nav) {
638  $this->tpl->setVariable("NAVBUTTONS2", $nav_html);
639  }
640  return true;
641  }
642 
649  public function SetButtonPrev($a_cmd = 0, $a_lng = 0)
650  {
651  $this->btn_prev_on = true;
652  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
653  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("prev");
654  }
655 
662  public function SetButtonNext($a_cmd, $a_lng = 0)
663  {
664  $this->btn_next_on = true;
665  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
666  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next");
667  }
668 
672 
676  public function displayClientOverview()
677  {
678  $this->checkDisplayMode();
679 
680  // disable/enable button
681  $btpl = new ilTemplate("tpl.buttons.html", true, true, "setup");
682  $btpl->setCurrentBlock("btn");
683  $btpl->setVariable("CMD", "changeaccess");
684  $access_button = ($this->setup->getClient()->status["access"]["status"]) ? "disable" : "enable";
685  $btpl->setVariable("TXT", $this->lng->txt($access_button));
686  $btpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
687  $btpl->parseCurrentBlock();
688  $this->tpl->setVariable("BUTTONS", $btpl->get());
689 
690  $this->initClientOverviewForm();
691  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
692 
693  $this->displayStatusPanel();
694  }
695 
699  public function initClientOverviewForm()
700  {
701  global $lng, $ilCtrl;
702 
703  $settings = $this->setup->getClient()->getAllSettings();
704 
705  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
706  $this->form = new ilPropertyFormGUI();
707 
708  $this->form->setTitle($lng->txt("client_info"));
709 
710  // installation name
711  $ne = new ilNonEditableValueGUI($lng->txt("inst_name"), "inst_name");
712  $ne->setValue(($this->setup->getClient()->getName())
713  ? $this->setup->getClient()->getName()
714  : "&lt;" . $this->lng->txt("no_client_name") . "&gt;");
715  $ne->setInfo($this->setup->getClient()->getDescription());
716  $this->form->addItem($ne);
717 
718  // client id
719  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "client_id");
720  $ne->setValue($this->setup->getClient()->getId());
721  $this->form->addItem($ne);
722 
723  // nic id
724  $ne = new ilNonEditableValueGUI($lng->txt("ilias_nic_id"), "nic_id");
725  $ne->setValue(($this->setup->getClient()->db_installed)
726  ? $settings["inst_id"]
727  : $txt_no_database);
728  $this->form->addItem($ne);
729 
730  // database version
731  $ne = new ilNonEditableValueGUI($lng->txt("db_version"), "db_vers");
732  $ne->setValue(($this->setup->getClient()->db_installed)
733  ? $settings["db_version"]
734  : $txt_no_database);
735  $this->form->addItem($ne);
736 
737  // access status
738  $ne = new ilNonEditableValueGUI($lng->txt("access_status"), "status");
739  //$access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->setup->getClient()->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
740  $access_status = ($this->setup->getClient()->status["access"]["status"]) ? "online" : "disabled";
741  $ne->setValue($this->lng->txt($access_status) . $access_link);
742  $this->form->addItem($ne);
743 
744  // server information
745  $sh = new ilFormSectionHeaderGUI();
746  $sh->setTitle($this->lng->txt("server_info"));
747  $this->form->addItem($sh);
748 
749  // ilias version
750  $ne = new ilNonEditableValueGUI($lng->txt("ilias_version"), "il_vers");
751  $ne->setValue(ILIAS_VERSION);
752  $this->form->addItem($ne);
753 
754  // host
755  $ne = new ilNonEditableValueGUI($lng->txt("host"), "host");
756  $ne->setValue($_SERVER["SERVER_NAME"]);
757  $this->form->addItem($ne);
758 
759  // ip address and port
760  $ne = new ilNonEditableValueGUI($lng->txt("ip_address") . " & " .
761  $lng->txt("port"));
762  $ne->setValue($_SERVER["SERVER_ADDR"] . ":" . $_SERVER["SERVER_PORT"]);
763  $this->form->addItem($ne);
764 
765  // server software
766  $ne = new ilNonEditableValueGUI($lng->txt("server_software"), "server_softw");
767  $ne->setValue($_SERVER["SERVER_SOFTWARE"]);
768  $this->form->addItem($ne);
769 
770  // http path
771  $ne = new ilNonEditableValueGUI($lng->txt("http_path"), "http_path");
773  $this->form->addItem($ne);
774 
775  // absolute path
776  $ne = new ilNonEditableValueGUI($lng->txt("absolute_path"), "absolute_path");
777  $ne->setValue(ILIAS_ABSOLUTE_PATH);
778  $this->form->addItem($ne);
779 
780  // third party tools
781  $sh = new ilFormSectionHeaderGUI();
782  $sh->setTitle($this->lng->txt("3rd_party_software"));
783  $this->form->addItem($sh);
784 
785  $tools = array("convert", "zip", "unzip", "ghostscript", "java", "ffmpeg", "phantomjs");
786 
787  foreach ($tools as $tool) {
788  // tool
789  $ne = new ilNonEditableValueGUI($lng->txt($tool . "_path"), $tool . "_path");
790  $p = $this->setup->ini->readVariable("tools", $tool);
791  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
792  $this->form->addItem($ne);
793  }
794 
795  // latex
796  $ne = new ilNonEditableValueGUI($lng->txt("url_to_latex"), "latex_url");
797  $p = $this->setup->ini->readVariable("tools", "latex"); // #13109
798  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
799  $this->form->addItem($ne);
800 
801  // virus scanner
802  $ne = new ilNonEditableValueGUI($lng->txt("virus_scanner"), "vscan");
803  $ne->setValue($this->setup->ini->readVariable("tools", "vscantype"));
804  $this->form->addItem($ne);
805 
806  // scan command
807  $ne = new ilNonEditableValueGUI($lng->txt("scan_command"), "scan");
808  $p = $this->setup->ini->readVariable("tools", "scancommand");
809  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
810  $this->form->addItem($ne);
811 
812  // clean command
813  $ne = new ilNonEditableValueGUI($lng->txt("clean_command"), "clean");
814  $p = $this->setup->ini->readVariable("tools", "cleancommand");
815  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
816  $this->form->addItem($ne);
817 
818 
819  // system styles
820  $sh = new ilFormSectionHeaderGUI();
821  $sh->setTitle($this->lng->txt("system_styles"));
822  $this->form->addItem($sh);
823 
824  // system styles activation
825  $ne = new ilNonEditableValueGUI($lng->txt("enable_system_styles_management"), "enable_system_styles_management");
826  $p = $this->setup->ini->readVariable("tools", "enable_system_styles_management");
827  $ne->setValue($p ? $this->lng->txt("enabled") : $this->lng->txt("not_enabled"));
828  $this->form->addItem($ne);
829 
830  // lessc command
831  $ne = new ilNonEditableValueGUI($lng->txt("lessc"), "lessc");
832  $p = $this->setup->ini->readVariable("tools", "lessc");
833  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
834  $this->form->addItem($ne);
835 
836 
837  $this->form->setFormAction("setup.php?cmd=gateway");
838  }
839 
843 
847  public function displayPreliminaries()
848  {
849  $OK = "<font color=\"green\"><strong>OK</strong></font>";
850  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
851 
852  $this->tpl->addBlockFile("CONTENT", "content", "tpl.preliminaries.html", "setup");
853 
854  $this->tpl->setVariable("TXT_SETUP_TITLE", $this->lng->txt("ilias_setup"));
855  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
856  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
857  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
858  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
859  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
860  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
861 
862  $server_os = php_uname();
863  $server_web = $_SERVER["SERVER_SOFTWARE"];
864  $environment = $this->lng->txt("env_using") . " " . $server_os . " <br/>" . $this->lng->txt("with") . " " . $server_web;
865 
866  if ((stristr($server_os, "linux") || stristr($server_os, "windows")) && stristr($server_web, "apache")) {
867  $env_comment = $this->lng->txt("env_ok");
868  } else {
869  $env_comment = "<font color=\"red\">" . $this->lng->txt("env_warning") . "</font>";
870  }
871 
872  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
873  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
874  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
875 
876  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
877  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
878 
879  $preliminaries = array("php", "root", "folder_create",
880  "cookies_enabled", "dom", "xsl", "gd", "memory");
881 
882  foreach ($preliminaries as $preliminary) {
883  $this->tpl->setCurrentBlock("preliminary");
884  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_" . $preliminary));
885  if ($this->setup->preliminaries_result[$preliminary]["status"] == true) {
886  $this->tpl->setVariable("STATUS_PRE", $OK);
887  } else {
888  $this->tpl->setVariable("STATUS_PRE", $FAILED);
889  }
890  $this->tpl->setVariable("COMMENT_PRE", $this->setup->preliminaries_result[$preliminary]["comment"]);
891  $this->tpl->parseCurrentBlock();
892  }
893 
894  // summary
895  if ($this->setup->preliminaries === true) {
896  if ($this->setup->isInstalled()) {
897  $cmd = "mastersettings";
898  } else {
899  $cmd = "install";
900  }
901  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
902  //echo "-".$this->display_mode."-";
903  $this->setButtonNext($cmd, $btn_text);
904  } else {
905  $this->tpl->setCurrentBlock("premessage");
906  $this->tpl->setVariable("TXT_PRE_ERR", sprintf(
907  $this->lng->txt("pre_error"),
908  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"
909  ));
910  $this->tpl->parseCurrentBlock();
911  }
912  }
913 
917 
921  public function displayMasterSetup($a_omit_init = false)
922  {
923  $this->tpl->addBlockFile("CONTENT", "content", "tpl.std_layout.html", "setup");
924  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
925  $this->tpl->setVariable(
926  "TXT_INFO",
927  $this->lng->txt("info_text_first_install") . "<br/>" . $this->lng->txt("info_text_pathes")
928  );
929 
930  $this->setButtonPrev("preliminaries");
931 
932  if ($this->setup->isInstalled()) {
933  $this->setButtonNext("list");
934  }
935 
936  if (!$a_omit_init) {
937  $this->initBasicSettingsForm(true);
938  }
939  $this->tpl->setVariable("SETUP_CONTENT", "<br>" . $this->form->getHTML() . "<br>");
940  }
941 
945  public function changeMasterSettings($a_omit_init = false)
946  {
947  $this->tpl->addBlockFile("CONTENT", "content", "tpl.std_layout.html", "setup");
948  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
949  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
950 
951  $this->btn_next_on = true;
952  $this->btn_next_lng = $this->lng->txt("create_new_client") . "...";
953  $this->btn_next_cmd = "newclient";
954 
955  if (!$a_omit_init) {
956  $this->initBasicSettingsForm();
957  $this->getBasicSettingsValues();
958  }
959  $this->tpl->setVariable("SETUP_CONTENT", "<br>" . $this->form->getHTML() . "<br>");
960  }
961 
965  public function initBasicSettingsForm($a_install = false)
966  {
967  global $lng, $ilCtrl;
968 
969  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
970  $this->form = new ilPropertyFormGUI();
971 
972  // webspace dir
973  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
974  if ($a_install) {
975  $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
976  }
977  $cwd = ilUtil::isWindows()
978  ? str_replace("\\", "/", getcwd())
979  : getcwd();
980 
981  $ne->setValue($cwd . "/data");
982  $this->form->addItem($ne);
983 
984  // data dir
985  if ($a_install) {
986  $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
987  $ti->setInfo($lng->txt("data_directory_info"));
988  $ti->setRequired(true);
989  $this->form->addItem($ti);
990  } else {
991  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
992  $this->form->addItem($ne);
993  }
994 
995  $lvext = (ilUtil::isWindows())
996  ? "_win"
997  : "";
998 
999 
1000  // logging
1001  $sh = new ilFormSectionHeaderGUI();
1002  $sh->setTitle($lng->txt("logging"));
1003  $this->form->addItem($sh);
1004 
1005  // path to log file
1006  $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
1007  $ti->setInfo($lng->txt("log_path_comment" . $lvext));
1008  $this->form->addItem($ti);
1009 
1010  // disable logging
1011  $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
1012  $this->form->addItem($cb);
1013 
1014  // path to error log dir
1015  $ti = new ilTextInputGUI($lng->txt("error_log_path"), "error_log_path");
1016  $ti->setInfo($lng->txt("error_log_path_comment" . $lvext));
1017  $this->form->addItem($ti);
1018 
1019  // server settings
1020  $sh = new ilFormSectionHeaderGUI();
1021  $sh->setTitle($lng->txt("server_settings"));
1022  $this->form->addItem($sh);
1023 
1024  // time zone
1025  include_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
1026  $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
1027  $si->setOptions(array_merge(
1028  array("" => "-- " . $lng->txt("please_select") . " --"),
1030  ));
1031  $si->setRequired(true);
1032  $this->form->addItem($si);
1033 
1034  // https settings
1035  $sh = new ilFormSectionHeaderGUI();
1036  $sh->setTitle($lng->txt("https_settings"));
1037  $this->form->addItem($sh);
1038 
1039  $check = new ilCheckboxInputGUI($lng->txt('ps_auto_https'), 'auto_https_detect_enabled');
1040  $check->setOptionTitle($lng->txt('ps_auto_https_description'));
1041  $check->setValue(1);
1042 
1043  $text = new ilTextInputGUI($lng->txt('ps_auto_https_header_name'), 'auto_https_detect_header_name');
1044  $text->setSize(24);
1045  $text->setMaxLength(64);
1046  $text->setRequired(true);
1047  $check->addSubItem($text);
1048 
1049  $text = new ilTextInputGUI($lng->txt('ps_auto_https_header_value'), 'auto_https_detect_header_value');
1050  $text->setSize(24);
1051  $text->setMaxLength(64);
1052  $text->setRequired(true);
1053  $check->addSubItem($text);
1054 
1055  $this->form->addItem($check);
1056 
1057  // required 3rd party tools
1058  $sh = new ilFormSectionHeaderGUI();
1059  $sh->setTitle($lng->txt("3rd_party_software_req"));
1060  $this->form->addItem($sh);
1061 
1062  // convert path
1063  $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
1064  $ti->setInfo($lng->txt("convert_path_comment" . $lvext));
1065  $ti->setRequired(true);
1066  $this->form->addItem($ti);
1067 
1068  // zip path
1069  $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
1070  $ti->setInfo($lng->txt("zip_path_comment" . $lvext));
1071  $ti->setRequired(true);
1072  $this->form->addItem($ti);
1073 
1074  // unzip path
1075  $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
1076  $ti->setInfo($lng->txt("unzip_path_comment" . $lvext));
1077  $ti->setRequired(true);
1078  $this->form->addItem($ti);
1079 
1080  // optional 3rd party tools
1081  $sh = new ilFormSectionHeaderGUI();
1082  $sh->setTitle($lng->txt("3rd_party_software_opt"));
1083  $this->form->addItem($sh);
1084 
1085  // ghostscript path
1086  $ti = new ilTextInputGUI($lng->txt("ghostscript_path"), "ghostscript_path");
1087  $ti->setInfo($lng->txt("ghostscript_path_comment" . $lvext));
1088  $this->form->addItem($ti);
1089 
1090  // ffmpeg path
1091  $ti = new ilTextInputGUI($lng->txt("ffmpeg_path"), "ffmpeg_path");
1092  $ti->setInfo($lng->txt("ffmpeg_path_comment"));
1093  $this->form->addItem($ti);
1094 
1095  // phantomjs path
1096  $pj = new ilTextInputGUI($lng->txt("phantomjs_path"), "phantomjs_path");
1097  $pj->setInfo($lng->txt("phantomjs_path_comment"));
1098  $this->form->addItem($pj);
1099 
1100  // latex
1101  $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
1102  $ti->setInfo($lng->txt("latex_url_comment"));
1103  $this->form->addItem($ti);
1104 
1105  // virus scanner
1106  $options = array(
1107  "none" => $lng->txt("none"),
1108  "sophos" => $lng->txt("sophos"),
1109  "antivir" => $lng->txt("antivir"),
1110  "clamav" => $lng->txt("clamav")
1111  );
1112  $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
1113  $si->setOptions($options);
1114  $this->form->addItem($si);
1115 
1116  // scan command
1117  $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
1118  $this->form->addItem($ti);
1119 
1120  // clean command
1121  $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
1122  $this->form->addItem($ti);
1123 
1124  // system styles
1125  $sh = new ilFormSectionHeaderGUI();
1126  $sh->setTitle($this->lng->txt("system_styles"));
1127  $this->form->addItem($sh);
1128 
1129  // enabled system styles mangesment
1130  $check = new ilCheckboxInputGUI($lng->txt('enable_system_styles_management'), 'enable_system_styles_management');
1131  $check->setInfo($lng->txt('enable_system_styles_management_info'));
1132  $check->setValue(1);
1133 
1134  // lessc command
1135  $lessc = new ilTextInputGUI($lng->txt("lessc_path"), "lessc_path");
1136  $lessc->setInfo($lng->txt("lessc_path_comment"));
1137  $check->addSubItem($lessc);
1138 
1139  $this->form->addItem($check);
1140 
1141 
1142  if ($a_install) {
1143  $sh = new ilFormSectionHeaderGUI();
1144  $sh->setTitle($lng->txt("master_password"));
1145  $this->form->addItem($sh);
1146 
1147  // password
1148  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1149  $pi->setRequired(true);
1150  $pi->setSkipSyntaxCheck(true);
1151  $pi->setInfo($lng->txt("password_info"));
1152  $this->form->addItem($pi);
1153  }
1154 
1155  if ($a_install) {
1156  $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
1157  } else {
1158  $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
1159  $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
1160  }
1161 
1162  $this->form->setTitle($lng->txt("data_directories"));
1163  $this->form->setFormAction("setup.php?cmd=gateway");
1164 
1165  if ($a_install) {
1166  $det = $this->determineTools();
1167  $this->form->setValuesByArray($det);
1168  }
1169  }
1170 
1174  public function getBasicSettingsValues()
1175  {
1176  $values = array();
1177 
1178  $values["webspace_dir"] = getcwd() . "/data";
1179  $values["data_dir"] = $this->setup->ini->readVariable("clients", "datadir");
1180  $values["convert_path"] = $this->setup->ini->readVariable("tools", "convert");
1181  $values["zip_path"] = $this->setup->ini->readVariable("tools", "zip");
1182  $values["unzip_path"] = $this->setup->ini->readVariable("tools", "unzip");
1183  $values["ghostscript_path"] = $this->setup->ini->readVariable("tools", "ghostscript");
1184  //$values["mkisofs_path"] = $this->setup->ini->readVariable("tools","mkisofs");
1185  $values["ffmpeg_path"] = $this->setup->ini->readVariable("tools", "ffmpeg");
1186  $values["phantomjs_path"] = $this->setup->ini->readVariable("tools", "phantomjs");
1187  $values["latex_url"] = $this->setup->ini->readVariable("tools", "latex");
1188  $values["fop_path"] = $this->setup->ini->readVariable("tools", "fop");
1189  $values["vscanner_type"] = $this->setup->ini->readVariable("tools", "vscantype");
1190  $values["scan_command"] = $this->setup->ini->readVariable("tools", "scancommand");
1191  $values["clean_command"] = $this->setup->ini->readVariable("tools", "cleancommand");
1192  $values["enable_system_styles_management"] = $this->setup->ini->readVariable("tools", "enable_system_styles_management");
1193  $values["lessc_path"] = $this->setup->ini->readVariable("tools", "lessc");
1194  $values["log_path"] = $this->setup->ini->readVariable("log", "path") . "/" .
1195  $this->setup->ini->readVariable("log", "file");
1196  $values["chk_log_status"] = !$this->setup->ini->readVariable("log", "enabled");
1197  $values["error_log_path"] = $this->setup->ini->readVariable("log", "error_path");
1198  $values["time_zone"] = $this->setup->ini->readVariable("server", "timezone");
1199 
1200  // https settings
1201  $values["auto_https_detect_enabled"] = $this->setup->ini->readVariable("https", "auto_https_detect_enabled");
1202  $values["auto_https_detect_header_name"] = $this->setup->ini->readVariable("https", "auto_https_detect_header_name");
1203  $values["auto_https_detect_header_value"] = $this->setup->ini->readVariable("https", "auto_https_detect_header_value");
1204 
1205  $this->form->setValuesByArray($values);
1206  }
1207 
1211  public function saveBasicSettings()
1212  {
1213  global $tpl, $lng, $ilCtrl;
1214 
1215  $this->initBasicSettingsForm(true);
1216 
1217  if ($this->form->checkInput()) {
1218  // correct paths on windows
1219  if (ilUtil::isWindows()) {
1220  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1221  "unzip_path", "ghostscript_path", "ffmpeg_path","lessc_path", "phantomjs_path");
1222  foreach ($fs as $f) {
1223  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1224  }
1225  }
1226  $_POST["setup_pass"] = $_POST["password"];
1227  $_POST["setup_pass2"] = $_POST["password_retype"];
1228  if (!$this->setup->checkDataDirSetup($_POST)) {
1229  $i = $this->form->getItemByPostVar("datadir_path");
1230  $i->setAlert($this->lng->txt($this->setup->getError()));
1231  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"), true);
1232  } elseif (!$this->setup->checkLogSetup($_POST)) {
1233  $i = $this->form->getItemByPostVar("log_path");
1234  $i->setAlert($this->lng->txt($this->setup->getError()));
1235  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"), true);
1236  } elseif (!$this->setup->checkErrorLogSetup($_POST["error_log_path"])) {
1237  $i = $this->form->getItemByPostVar("error_log_path");
1238  $i->setAlert($this->lng->txt($this->setup->getError()));
1239  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"), true);
1240  } elseif (!$this->setup->checkPasswordSetup($_POST)) {
1241  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
1242  } elseif (!$this->setup->saveMasterSetup($_POST)) {
1243  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
1244  } else {
1245  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1246  ilUtil::redirect("setup.php?cmd=mastersettings");
1247  }
1248  }
1249 
1250  $this->form->setValuesByPost();
1251  $this->displayMasterSetup(true);
1252  }
1253 
1257  public function updateBasicSettings()
1258  {
1259  global $tpl, $lng, $ilCtrl;
1260 
1261  $this->initBasicSettingsForm();
1262 
1263  if ($this->form->checkInput()) {
1264  if (ilUtil::isWindows()) {
1265  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1266  "unzip_path", "ghostscript_path", "ffmpeg_path","lessc_path", "phantomjs_path");
1267  foreach ($fs as $f) {
1268  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1269  }
1270  }
1271 
1272  if (!$this->setup->checkLogSetup($_POST)) {
1273  $i = $this->form->getItemByPostVar("log_path");
1274  $i->setAlert($this->lng->txt($this->setup->getError()));
1275  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"), true);
1276  } elseif (!$this->setup->checkErrorLogSetup($_POST["error_log_path"])) {
1277  $i = $this->form->getItemByPostVar("error_log_path");
1278  $i->setAlert($this->lng->txt($this->setup->getError()));
1279  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"), true);
1280  } elseif (!$this->setup->updateMasterSettings($_POST)) {
1281  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
1282  } else {
1283  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1284  ilUtil::redirect("setup.php?cmd=mastersettings");
1285  }
1286  }
1287 
1288  $this->form->setValuesByPost();
1289  $this->changeMasterSettings(true);
1290  }
1291 
1295 
1299  public function loginClient()
1300  {
1301  session_destroy();
1302 
1303  ilUtil::redirect(ILIAS_HTTP_PATH . "/login.php?client_id=" . $this->setup->getClient()->getId());
1304  }
1305 
1309  public function displayLogin($a_omit_minit = false, $a_omit_cinit = false)
1310  {
1311  global $lng;
1312  $this->tpl->setVariable("SETUP_LOGIN_CLASS", " ilSetupLogin");
1313  $this->tpl->addBlockFile("CONTENT", "content", "tpl.std_layout.html", "setup");
1314 
1315  if ($a_omit_minit) {
1316  $m_form = $this->form->getHTML();
1317  }
1318  if (!$a_omit_cinit) {
1319  $this->initClientLoginForm();
1320  }
1321  $cl_form = $this->form->getHTML();
1322  if (!$a_omit_minit) {
1323  $this->initMasterLoginForm();
1324  $m_form = $this->form->getHTML();
1325  }
1326  $this->tpl->setVariable("SETUP_CONTENT", $cl_form . "<br>" . $m_form);
1327  $this->tpl->setVariable("TXT_HEADER", $lng->txt("login"));
1328  }
1329 
1333  public function performMLogin()
1334  {
1335  $this->initMasterLoginForm();
1336  if ($this->form->checkInput()) {
1337  $i = $this->form->getItemByPostVar('mpassword');
1338  if (!$this->setup->loginAsAdmin($_POST['mpassword'])) {
1339  $i->setAlert($this->lng->txt('login_invalid'));
1340  } else {
1341  // everything ok -> we are authenticated
1342  ilUtil::redirect('setup.php');
1343  }
1344  }
1345 
1346  // something wrong -> display login again
1347  $this->form->setValuesByPost();
1348  $this->displayLogin(true);
1349  }
1350 
1354  public function performLogin()
1355  {
1356  $this->initClientLoginForm();
1357  if ($this->form->checkInput()) {
1358  $i = $this->form->getItemByPostVar("password");
1359  if (!$this->setup->loginAsClient(
1360  array("client_id" => $_POST["client_id"],
1361  "username" => $_POST["username"], "password" => $_POST["password"])
1362  )) {
1363  $i->setAlert($this->setup->getError());
1364  } else {
1365  // everything ok -> we are authenticated
1366  ilUtil::redirect("setup.php");
1367  }
1368  }
1369 
1370  // something wrong -> display login again
1371  $this->form->setValuesByPost();
1372  $this->displayLogin(false, true);
1373  }
1374 
1378  public function initClientLoginForm()
1379  {
1380  global $lng, $ilCtrl;
1381 
1382  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1383  $this->form = new ilPropertyFormGUI();
1384  $this->form->setId("client_login");
1385 
1386  // client id
1387  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1388  $ti->setMaxLength(32);
1389  $ti->setSize(20);
1390  $this->form->addItem($ti);
1391 
1392  // username
1393  $ti = new ilTextInputGUI($lng->txt("username"), "username");
1394  $ti->setSize(20);
1395  $this->form->addItem($ti);
1396 
1397  // password
1398  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1399  $pi->setSize(20);
1400  $pi->setRetype(false);
1401  $pi->setSkipSyntaxCheck(true);
1402  $this->form->addItem($pi);
1403 
1404  $this->form->addCommandButton("performLogin", $lng->txt("login"));
1405 
1406  $this->form->setTitle($lng->txt("client_login"));
1407  $this->form->setFormAction("setup.php?cmd=gateway");
1408  }
1409 
1413  public function initMasterLoginForm()
1414  {
1415  global $lng, $ilCtrl;
1416 
1417  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1418  $this->form = new ilPropertyFormGUI();
1419  $this->form->setId("master_login");
1420  // password
1421  $pi = new ilPasswordInputGUI($lng->txt("password"), "mpassword");
1422  $pi->setSize(20);
1423  $pi->setRetype(false);
1424  $pi->setSkipSyntaxCheck(true);
1425  $this->form->addItem($pi);
1426 
1427  $this->form->addCommandButton("performMLogin", $lng->txt("login"));
1428 
1429  $this->form->setTitle($lng->txt("admin_login"));
1430  $this->form->setFormAction("setup.php?cmd=gateway");
1431  }
1432 
1436 
1440  public function displayClientList()
1441  {
1442  $_SESSION["ClientId"] = "";
1443 
1444  $this->tpl->addBlockFile("CONTENT", "content", "tpl.clientlist.html", "setup");
1445  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1446  ilUtil::sendInfo();
1447 
1448  // common
1449  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("list_clients"));
1450  $this->tpl->setVariable("TXT_LISTSTATUS", ($this->setup->ini->readVariable("clients", "list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1451  $this->tpl->setVariable("TXT_TOGGLELIST", ($this->setup->ini->readVariable("clients", "list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1452 
1453  include_once("./setup/classes/class.ilClientListTableGUI.php");
1454  $tab = new ilClientListTableGUI($this->setup);
1455  $this->tpl->setVariable("CLIENT_LIST", $tab->getHTML());
1456 
1457  // create new client button
1458  $this->btn_next_on = true;
1459  $this->btn_next_lng = $this->lng->txt("create_new_client") . "...";
1460  $this->btn_next_cmd = "newclient";
1461  }
1462 
1466  public function determineToolsPath()
1467  {
1468  $_POST = $this->determineTools($_POST);
1469  $this->updateBasicSettings();
1470  }
1471 
1475  public function determineToolsPathInstall()
1476  {
1477  $this->displayMasterSetup(true);
1478  }
1479 
1483  public function determineTools($a_tools = array())
1484  {
1485  $cwd = ilUtil::isWindows()
1486  ? str_replace("\\", "/", getcwd())
1487  : getcwd();
1488  if (!ilUtil::isWindows()) {
1489  $tools = array("convert" => "convert",
1490  "zip" => "zip", "unzip" => "unzip", "ghostscript" => "gs",
1491  "java" => "java", "ffmpeg" => "ffmpeg", "lessc" => "lessc", "phantomjs" => "phantomjs");
1492  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin", "/usr/bin");
1493  } else {
1494  $tools = array("convert" => "convert.exe",
1495  "zip" => "zip.exe", "unzip" => "unzip.exe");
1496  $dirs = array();
1497  }
1498  foreach ($tools as $k => $tool) {
1499  // try which command
1500  unset($ret);
1501  @exec("which " . $tool, $ret);
1502  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/") {
1503  $a_tools[$k . "_path"] = $ret[0];
1504  continue;
1505  }
1506 
1507  // try common directories
1508  foreach ($dirs as $dir) {
1509  if (@is_file($dir . "/" . $tool)) {
1510  $a_tools[$k . "_path"] = $dir . "/" . $tool;
1511  continue;
1512  }
1513  }
1514  }
1515  return $a_tools;
1516  }
1517 
1518 
1522 
1527  public function selectDBType()
1528  {
1529  $this->checkDisplayMode("create_new_client");
1530 
1531  unset($_SESSION["db_type"]);
1532  $this->initDBSelectionForm();
1533  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1534 
1535  if ($this->setup->getClient()->status["ini"]["status"]) {
1536  $this->setButtonNext("db");
1537  }
1538 
1539  $this->checkPanelMode();
1540  }
1541 
1545  public function initDBSelectionForm()
1546  {
1547  global $lng;
1548 
1549  require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
1550  $this->form = new ilPropertyFormGUI();
1551 
1552  // db type
1553  $options = ilDBConstants::getAvailableTypes(true);
1554  $si = new ilSelectInputGUI($lng->txt("db_type"), "db_type");
1555  $si->setOptions($options);
1556  $si->setInfo($lng->txt(""));
1557  $this->form->addItem($si);
1558 
1559  $this->form->addCommandButton("selectdbtype", $lng->txt("save"));
1560 
1561  $this->form->setTitle($lng->txt("db_selection"));
1562  $this->form->setFormAction("setup.php?cmd=gateway");
1563  }
1564 
1568 
1572  public function displayIni($a_omit_form_init = false)
1573  {
1574  $this->checkDisplayMode("create_new_client");
1575 
1576  if ($_POST["db_type"] != "") {
1577  $_SESSION["db_type"] = $_POST["db_type"];
1578  } else {
1579  $_POST["db_type"] = $_SESSION["db_type"];
1580  }
1581 
1582  $has_ini = $this->setup->getClient()->status["ini"]["status"];
1583 
1584  // use value from client ini if setup was resumed (no value in session)
1585  if (!$_SESSION["db_type"] && $has_ini) {
1586  $_SESSION["db_type"] = $this->setup->getClient()->getDbType();
1587  }
1588 
1589  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1590  if (!$a_omit_form_init) {
1591  $this->initClientIniForm();
1592  $this->getClientIniValues();
1593  }
1594  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1595 
1596  if ($has_ini) {
1597  $this->setButtonNext("db");
1598  }
1599 
1600  $this->checkPanelMode();
1601  }
1602 
1606  protected function initClientIniForm()
1607  {
1608  global $lng;
1609 
1610  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1611  $this->form = new ilPropertyFormGUI();
1612 
1613  // client id
1614  if ($this->setup->ini_client_exists) {
1615  $hi = new ilHiddenInputGUI("client_id");
1616  $hi->setValue($this->client_id);
1617  $this->form->addItem($hi);
1618 
1619  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "hh");
1620  $ne->setValue($this->client_id);
1621  $this->form->addItem($ne);
1622  } else {
1623  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1624  $ti->setMaxLength(32);
1625  $ti->setRequired(true);
1626  $this->form->addItem($ti);
1627  }
1628 
1629  // database connection
1630  $sh = new ilFormSectionHeaderGUI();
1631  $sh->setTitle($lng->txt("db_conn"));
1632  $this->form->addItem($sh);
1633 
1634  // db type
1635  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "dbt");
1637  $ne->setValue($at[$_SESSION["db_type"]]);
1638  $this->form->addItem($ne);
1639 
1640  // db host
1641  $ti = new ilTextInputGUI($lng->txt("db_host"), "db_host");
1642  $ti->setMaxLength(120);
1643  $ti->setRequired(true);
1644  $this->form->addItem($ti);
1645 
1646  // db name
1647  $ti = new ilTextInputGUI($lng->txt("db_name"), "db_name");
1648  $ti->setRequired(true);
1649  $ti->setMaxLength(40);
1650  $this->form->addItem($ti);
1651 
1652  // db user
1653  $ti = new ilTextInputGUI($lng->txt("db_user"), "db_user");
1654  $ti->setMaxLength(40);
1655  $ti->setRequired(true);
1656  $this->form->addItem($ti);
1657 
1658  // db port
1659  $ti = new ilTextInputGUI($lng->txt("db_port"), "db_port");
1660  $ti->setMaxLength(8);
1661  $this->form->addItem($ti);
1662 
1663  $sqlPassword = new \ilPasswordInputGUI($lng->txt('db_pass'), 'db_pass');
1664  $sqlPassword->setDisableHtmlAutoComplete(true);
1665  $sqlPassword->setValidateAuthPost(false);
1666  $sqlPassword->setSkipSyntaxCheck(true);
1667  $sqlPassword->setRequired(false);
1668  $sqlPassword->setMaxLength(40);
1669  $sqlPassword->setRetype(false);
1670  $this->form->addItem($sqlPassword);
1671 
1672  $this->form->addCommandButton("saveClientIni", $lng->txt("save"));
1673 
1674  $this->form->setTitle($lng->txt("inst_identification"));
1675  $this->form->setFormAction("setup.php?cmd=gateway");
1676  }
1677 
1681  public function getClientIniValues()
1682  {
1683  $values = array();
1684 
1685  $values["db_host"] = $this->setup->getClient()->getDbHost();
1686  $values["db_user"] = $this->setup->getClient()->getDbUser();
1687  $values["db_port"] = $this->setup->getClient()->getDbPort();
1688  $password = '';
1689  if (is_string($this->setup->getClient()->getDbPass()) && strlen($this->setup->getClient()->getDbPass())) {
1690  $password = self::UI_PASSWORD_PLACEHOLDER;
1691  }
1692  $values["db_pass"] = $password;
1693  $values["db_name"] = $this->setup->getClient()->getDbName();
1694  $values["client_id"] = $this->setup->getClient()->getId();
1695 
1696  $this->form->setValuesByArray($values);
1697  }
1698 
1702  public function saveClientIni()
1703  {
1704  $this->initClientIniForm();
1705  if ($this->form->checkInput()) {
1706  if (strlen($_POST["client_id"]) != strlen(urlencode(($_POST["client_id"])))
1707  || !$this->setup->isValidClientId($_POST["client_id"])
1708  ) {
1709  $i = $this->form->getItemByPostVar("client_id");
1710  $i->setAlert($this->lng->txt("ini_client_id_invalid"));
1711  ilUtil::sendFailure($this->lng->txt("ini_client_id_invalid"), true);
1712  } else {
1713  if (strlen($_POST["client_id"]) < 4) {
1714  $i = $this->form->getItemByPostVar("client_id");
1715  $i->setAlert($this->lng->txt("ini_client_id_too_short"));
1716  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_short"), true);
1717  } else {
1718  if (strlen($_POST["client_id"]) > 32) {
1719  $i = $this->form->getItemByPostVar("client_id");
1720  $i->setAlert($this->lng->txt("ini_client_id_too_long"));
1721  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_long"), true);
1722  } else {
1723  if (!$this->setup->ini_client_exists && file_exists(ILIAS_ABSOLUTE_PATH . "/" . ILIAS_WEB_DIR . "/" . $_POST["client_id"])) {
1724  $i = $this->form->getItemByPostVar("client_id");
1725  $i->setAlert($this->lng->txt("ini_client_id_exists"));
1726  ilUtil::sendFailure($this->lng->txt("ini_client_id_exists"), true);
1727  } else {
1728 
1729  // save some old values
1730  $old_db_name = $this->setup->getClient()->getDbName();
1731  $old_db_type = $this->setup->getClient()->getDbType();
1732  $old_client_id = $this->setup->getClient()->getId();
1733 
1734  // create new client object if it does not exist
1735  if (!$this->setup->ini_client_exists) {
1736  $client_id = $_POST["client_id"];
1737  $this->setup->newClient($client_id);
1738  }
1739 
1740  // set client data
1741  $this->setup->getClient()->setId($_POST["client_id"]);
1742  $this->setup->getClient()->setDbHost($_POST["db_host"]);
1743  $this->setup->getClient()->setDbName($_POST["db_name"]);
1744  $this->setup->getClient()->setDbUser($_POST["db_user"]);
1745  $this->setup->getClient()->setDbPort($_POST["db_port"]);
1746  $dbPassword = (string) ($_POST["db_pass"] ?? '');
1747  if ('' === $dbPassword || $dbPassword !== self::UI_PASSWORD_PLACEHOLDER) {
1748  $this->setup->getClient()->setDbPass($dbPassword);
1749  }
1750  $this->setup->getClient()->setDbType($_SESSION["db_type"]);
1751  $this->setup->getClient()->setDSN();
1752 
1753  // try to connect to database
1754  if (!$this->setup->getClient()->getDBSetup(false)->isConnectable()) {
1755  $i = $this->form->getItemByPostVar("db_host");
1756  $i->setAlert($this->lng->txt($this->setup->getClient()->getError()));
1757  ilUtil::sendFailure($this->setup->getClient()->getError(), true);
1758  } else {
1759  // check if db exists
1760  $db_installed = $this->setup->getClient()->getDBSetup(false)->isDatabaseInstalled();
1761 
1762  if ($db_installed and (!$this->setup->ini_ilias_exists or ($this->setup->getClient()->getDbName() != $old_db_name))) {
1763  $_POST["db_name"] = $old_db_name;
1764  $message = ucfirst($this->lng->txt("database")) . " \"" . $this->setup->getClient()->getDbName() . "\" "
1765  . $this->lng->txt("ini_db_name_exists");
1766  $i = $this->form->getItemByPostVar("db_name");
1767  $i->setAlert($message);
1769  } else {
1770  // all ok. create client.ini and save posted data
1771  if (!$this->setup->ini_client_exists) {
1772  if ($this->setup->saveNewClient()) {
1773  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1774  $this->setup->getClient()->status["ini"]["status"] = true;
1775  $_SESSION["ClientId"] = $client_id;
1776  ilUtil::redirect("setup.php?cmd=displayIni&client_id=" . $client_id);
1777  } else {
1778  $err = $this->setup->getError();
1779  ilUtil::sendFailure($this->lng->txt("save_error") . ": " . $err, true);
1780  $this->setup->getClient()->status["ini"]["status"] = false;
1781  $this->setup->getClient()->status["ini"]["comment"] = $err;
1782  }
1783  } else {
1784  if ($this->setup->getClient()->ini->write()) {
1785  ilUtil::sendSuccess($this->lng->txt("settings_changed"));
1786  $this->setup->getClient()->status["ini"]["status"] = true;
1787  ilUtil::redirect("setup.php?cmd=displayIni");
1788  } else {
1789  $err = $this->setup->getClient()->ini->getError();
1790  ilUtil::sendFailure($this->lng->txt("save_error") . ": " . $err, true);
1791  $this->setup->getClient()->status["ini"]["status"] = false;
1792  $this->setup->getClient()->status["ini"]["comment"] = $err;
1793  }
1794  }
1795  }
1796  }
1797  }
1798  }
1799  }
1800  }
1801  }
1802 
1803  $this->form->setValuesByPost();
1804  $this->displayIni(true);
1805  }
1806 
1812  public function displayError($a_message)
1813  {
1814  $this->setDisplayMode("view");
1815 
1816  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html", "setup");
1817 
1818  $this->tpl->setCurrentBlock("content");
1819  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1820  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1821  $this->tpl->setVariable("ERROR_MESSAGE", ($a_message));
1822  $this->tpl->parseCurrentBlock();
1823 
1824  // $this->tpl->show();
1825 // exit();
1826  }
1827 
1831  public function displayLogout()
1832  {
1833  $this->tpl->addBlockFile("CONTENT", "content", "tpl.logout.html", "setup");
1834 
1835  session_destroy();
1836 
1837  $this->logged_out = true;
1838  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("logged_out"));
1839  $this->tpl->setCurrentBlock("home_link");
1840  $this->tpl->setVariable("TXT_INDEX", $this->lng->txt("ilias_homepage"));
1841  $this->tpl->setVariable("LNK_INDEX", ILIAS_HTTP_PATH . "/index.php");
1842  $this->tpl->parseCurrentBlock();
1843  }
1844 
1848  public function displayProcessPanel()
1849  {
1850  include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
1851  $checklist = new ilChecklistGUI();
1852  $checklist->setHeading($this->lng->txt("setup_process_status"));
1853 
1854 
1855  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1856 
1857  $steps = $this->setup->getStatus();
1858 
1859  // #16846
1860  $first = array("selectdb" => array(
1861  "status" => ((bool) $_SESSION["db_type"] || (bool) $steps["ini"]["status"]),
1862  "text" => $this->lng->txt("db_selection"),
1863  "comment" => ""
1864  ));
1865 
1866  $steps = $first + $steps;
1867 
1868  // remove access step
1869  unset($steps["access"]);
1870 
1871  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1872  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1873  //$steps["sess"]["text"] = $this->lng->txt("setup_process_step_sess");
1874  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1875  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1876  $steps["proxy"]["text"] = $this->lng->txt("setup_process_step_proxy");
1877  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1878  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1879 
1880  $stpl = new ilTemplate("tpl.process_panel.html", true, true, "setup");
1881 
1882  $num = 1;
1883 
1884  foreach ($steps as $key => $val) {
1885  $stpl->setCurrentBlock("menu_row");
1886  $stpl->setVariable("TXT_STEP", $this->lng->txt("step") . " " . $num . ": &nbsp;");
1887  $stpl->setVariable("TXT_ACTION", $val["text"]);
1888  $stpl->setVariable("IMG_ARROW", "spacer.png");
1889 
1890  if ($this->cmd == $key and isset($this->cmd)) {
1891  $stpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1892  }
1893 
1894  $status = ($val["status"]) ? $OK : "";
1895 
1896  $stpl->setVariable("TXT_STATUS", $status);
1897  $stpl->parseCurrentBlock();
1898 
1899  $checklist->addEntry(
1900  $num . ". " . $val["text"],
1901  "",
1902  ($val["status"]) ?
1904  ($this->cmd == $key and isset($this->cmd)),
1905  ""
1906  );
1907 
1908  $num++;
1909  }
1910 
1911  $stpl->setVariable("TXT_SETUP_PROCESS_STATUS", $this->lng->txt("setup_process_status"));
1912 
1913  $this->tpl->setVariable("PROCESS_MENU", $checklist->getHTML());
1914  }
1915 
1919  public function displayStatusPanel()
1920  {
1921  include_once("./Services/UIComponent/Checklist/classes/class.ilChecklistGUI.php");
1922  $checklist = new ilChecklistGUI();
1923  $checklist->setHeading($this->lng->txt("overall_status"));
1924 
1925  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1926 
1927  //$this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html", "setup");
1928 
1929  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1930  // display status
1931  if ($this->setup->getClient()->status) {
1932  foreach ($this->setup->getClient()->status as $key => $val) {
1933  $status = ($val["status"]) ? $OK : "&nbsp;";
1934  // $this->tpl->setCurrentBlock("status_row");
1935  // $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1936  // $this->tpl->setVariable("TXT_STATUS",$status);
1937 
1938 
1939  // $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1940  // $this->tpl->parseCurrentBlock();
1941 
1942  $checklist->addEntry(
1943  $this->lng->txt("step_" . $key),
1944  "",
1945  ($val["status"]) ?
1947  false,
1948  $val["comment"]
1949  );
1950  }
1951  }
1952  $this->tpl->setVariable("STATUS_PANEL", $checklist->getHTML());
1953  }
1954 
1960  public function checkDisplayMode($a_title = "")
1961  {
1962  switch ($this->display_mode) {
1963  case "view":
1964  $this->tpl->addBlockFile("CONTENT", "content", "tpl.clientview.html", "setup");
1965  // display tabs
1966  include "./setup/include/inc.client_tabs.php";
1967  $client_name = ($this->setup->getClient()->getName()) ? $this->setup->getClient()->getName() : $this->lng->txt("no_client_name");
1968  $this->tpl->setVariable("TXT_HEADER", $client_name . " (" . $this->lng->txt("client_id") . ": " . $this->setup->getClient()->getId() . ")");
1969  break;
1970 
1971  case "setup":
1972  $this->tpl->addBlockFile("CONTENT", "content", "tpl.clientsetup.html", "setup");
1973  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($a_title));
1974  break;
1975 
1976  default:
1977  $this->displayError($this->lng->txt("unknown_display_mode"));
1978  exit();
1979  break;
1980  }
1981  }
1982 
1989  public function displaySubTabs()
1990  {
1991  $sub_tab_html = $this->tabs->getSubTabHTML();
1992  if ($sub_tab_html != "") {
1993  $this->tpl->setVariable("SUBTABS", $sub_tab_html);
1994  }
1995  }
1996 
1997 
2001  public function checkPanelMode()
2002  {
2003  switch ($this->display_mode) {
2004  case "view":
2005  $this->displayStatusPanel();
2006  break;
2007 
2008  case "setup":
2009  $this->displayProcessPanel();
2010  break;
2011  }
2012  }
2013 
2017  public function displayStartup()
2018  {
2019  $this->tpl->addBlockFile("CONTENT", "content", "tpl.clientsetup.html", "setup");
2020 
2021  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_first_client"));
2022  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("setup_first_client"));
2023 
2024  $this->displayProcessPanel();
2025 
2026  $this->setButtonNext("ini");
2027  }
2028 
2032 
2036  public function displayDatabase()
2037  {
2038  global $ilErr,$ilDB,$ilLog;
2039 
2040  $this->checkDisplayMode("setup_database");
2041 
2042  // database is intalled
2043  if ($this->setup->getClient()->getDBSetup()->isDatabaseInstalled()) {
2044  $this->setDbSubTabs("db");
2045 
2046  $ilDB = $this->setup->getClient()->getDB();
2047  $this->lng->setDbHandler($ilDB);
2048  $dbupdate = new ilDBUpdate($ilDB);
2049  $db_status = $dbupdate->getDBVersionStatus();
2050  $hotfix_available = $dbupdate->hotfixAvailable();
2051  $custom_updates_available = $dbupdate->customUpdatesAvailable();
2052  $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available, $custom_updates_available);
2053  $this->getClientDbFormValues($dbupdate);
2054  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2055 
2056  if ($db_status) {
2057  $this->setButtonNext("lang");
2058  }
2059  } else { // database is not installed
2060  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db") . "<br />" .
2061  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>" .
2062  "<p><b>" . $this->lng->txt("info_text_db2") . "</b></p><br/>");
2063 
2064  $this->initClientDbForm();
2065  $this->getClientDbFormValues();
2066  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2067  $this->setButtonPrev("ini");
2068  }
2069 
2070  $this->checkPanelMode();
2071 
2072  $this->displaySubTabs();
2073  }
2074 
2075 
2076 
2077  protected function bt_tabs($edit = false)
2078  {
2079  $tabs = new ilTemplate("tpl.tabs.html", true, true, "Services/UIComponent/Tabs");
2080 
2081  $tabs->setCurrentBlock("tab");
2082  $tabs->setVariable("TAB_TYPE", !$edit? "active" : "");
2083  $tabs->setVariable("TAB_TEXT", $this->lng->txt('overview'));
2084  $tabs->setVariable("TAB_LINK", "setup.php?cmd=background_tasks");
2085  $tabs->parseCurrentBlock();
2086 
2087  $tabs->setCurrentBlock("tab");
2088  $tabs->setVariable("TAB_TYPE", $edit? "active" : "");
2089  $tabs->setVariable("TAB_TEXT", $this->lng->txt('settings'));
2090  $tabs->setVariable("TAB_LINK", "setup.php?cmd=edit_background_tasks");
2091  $tabs->parseCurrentBlock();
2092 
2093  return $tabs;
2094  }
2095 
2096  protected function displayCache()
2097  {
2098  require_once('Services/Form/classes/class.ilPropertyFormGUI.php');
2099  require_once('Services/GlobalCache/classes/class.ilGlobalCache.php');
2100  require_once('./Services/GlobalCache/classes/Settings/class.ilGlobalCacheSettings.php');
2101  $this->checkDisplayMode('setup_cache');
2106  $ilGlobalCacheSettings = new ilGlobalCacheSettings();
2107  $ilGlobalCacheSettings->readFromIniFile($this->setup->getClient()->ini);
2108 
2109  $cache_form = new ilPropertyFormGUI();
2110  $cache_form->setTitle($this->lng->txt('global_cache_configuration'));
2111  $cache_form->addCommandButton('saveCache', $this->lng->txt('save'));
2112  $cache_form->setFormAction('setup.php?cmd=gateway');
2113 
2114  $some_inactive = false;
2115  $message = '';
2116  $service_type = new ilRadioGroupInputGUI($this->lng->txt('global_cache_service_type'), 'global_cache_service_type');
2117 
2118  $option = new ilRadioOption($this->lng->txt('none'), -1);
2119  $service_type->addOption($option);
2120 
2121  foreach (ilGlobalCache::getAllTypes() as $type) {
2122  $option = new ilRadioOption($this->lng->txt('global_cache_service_type_' . $type->getServiceType()), $type->getServiceType());
2123  $option->setInfo($this->lng->txt('global_cache_install_info_' . $type->getServiceType()));
2124  if (!$type->isCacheServiceInstallable()) {
2125  $option->setDisabled(true);
2126  $message .= $this->lng->txt('global_cache_service_type_' . $type->getServiceType()) . ': ' . $type->getInstallationFailureReason()
2127  . '; ';
2128  $some_inactive = true;
2129  }
2130  $service_type->addOption($option);
2131  }
2132 
2133  if ($some_inactive) {
2134  $service_type->setAlert($message);
2135  ilUtil::sendInfo($this->lng->txt('global_cache_supported_services'));
2136  }
2137 
2138  $service_type->setValue($ilGlobalCacheSettings->isActive() ? $ilGlobalCacheSettings->getService() : -1);
2139  $cache_form->addItem($service_type);
2140  if ($ilGlobalCacheSettings->isActive()) {
2141  $h = new ilFormSectionHeaderGUI();
2142  $h->setTitle($this->lng->txt('cache_activated_components'));
2143  $cache_form->addItem($h);
2144 
2145  foreach (ilGlobalCache::getAvailableComponents() as $comp) {
2146  $cc = new ilCheckboxInputGUI($this->lng->txt('cache_activate_' . $comp), 'activate[' . $comp . ']');
2147  $cc->setChecked($ilGlobalCacheSettings->isComponentActivated($comp));
2148  $cache_form->addItem($cc);
2149  }
2150 
2151  $cc = new ilCheckboxInputGUI($this->lng->txt('cache_activate_all'), 'activate[all]');
2152  $cc->setChecked($ilGlobalCacheSettings->areAllComponentActivated());
2153  $cache_form->addItem($cc);
2154  }
2155 
2156  $table_html = '';
2157  require_once('./Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php');
2158  require_once('./Services/UIComponent/Button/classes/class.ilLinkButton.php');
2159  $ilToolbarGUI = new ilToolbarGUI();
2160  if ($ilGlobalCacheSettings->isActive()) {
2162  $b->setCaption('cache_flush');
2163  $b->setUrl('setup.php?cmd=flushCache');
2164  $ilToolbarGUI->addButtonInstance($b);
2165  }
2166 
2167  if ($ilGlobalCacheSettings->getService() == ilGlobalCache::TYPE_MEMCACHED) {
2168  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServerTableGUI.php');
2170  $b->setCaption('memcache_add');
2171  $b->setUrl('setup.php?cmd=addMemcacheServer');
2172  $ilToolbarGUI->addButtonInstance($b);
2173  $ilMemcacheServerTableGUI = new ilMemcacheServerTableGUI(null);
2174  $table_html = $ilMemcacheServerTableGUI->getHTML();
2175  }
2176 
2177  $this->tpl->setVariable('SETUP_CONTENT', $ilToolbarGUI->getHTML() . $cache_form->getHTML() . $table_html);
2178  }
2179 
2180 
2181  protected function flushCache()
2182  {
2183  require_once('Services/GlobalCache/classes/class.ilGlobalCache.php');
2184  ilGlobalCache::flushAll();
2185  ilUtil::redirect('setup.php?cmd=cache');
2186  }
2187 
2188 
2189  protected function addMemcacheServer()
2190  {
2191  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServerFormGUI.php');
2192  $this->checkDisplayMode('setup_cache');
2193  $ilMemcacheServerFormGUI = new ilMemcacheServerFormGUI(new ilMemcacheServer());
2194  $this->tpl->setVariable('SETUP_CONTENT', $ilMemcacheServerFormGUI->getHTML());
2195  }
2196 
2197 
2198  protected function createMemcacheServer()
2199  {
2200  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServerFormGUI.php');
2201  $this->checkDisplayMode('setup_cache');
2202  $ilMemcacheServerFormGUI = new ilMemcacheServerFormGUI(new ilMemcacheServer());
2203  $ilMemcacheServerFormGUI->setValuesByPost();
2204  if ($ilMemcacheServerFormGUI->saveObject()) {
2205  ilUtil::redirect('setup.php?cmd=cache');
2206  }
2207  $this->tpl->setVariable('SETUP_CONTENT', $ilMemcacheServerFormGUI->getHTML());
2208  }
2209 
2210 
2211  protected function editMemcacheServer()
2212  {
2213  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServerFormGUI.php');
2214  $this->checkDisplayMode('setup_cache');
2215  $ilMemcacheServerFormGUI = new ilMemcacheServerFormGUI(ilMemcacheServer::find($_GET['mcsid']));
2216  $ilMemcacheServerFormGUI->fillForm();
2217  $this->tpl->setVariable('SETUP_CONTENT', $ilMemcacheServerFormGUI->getHTML());
2218  }
2219 
2220 
2221  protected function updateMemcacheServer()
2222  {
2223  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServerFormGUI.php');
2224  $this->checkDisplayMode('setup_cache');
2225 
2226  $ilMemcacheServerFormGUI = new ilMemcacheServerFormGUI(ilMemcacheServer::find($_GET['mcsid']));
2227  $ilMemcacheServerFormGUI->setValuesByPost();
2228  if ($ilMemcacheServerFormGUI->saveObject()) {
2229  ilUtil::redirect('setup.php?cmd=cache');
2230  }
2231  $this->tpl->setVariable('SETUP_CONTENT', $ilMemcacheServerFormGUI->getHTML());
2232  }
2233 
2234 
2235  protected function deleteMemcacheServer()
2236  {
2237  require_once('./Services/GlobalCache/classes/Memcache/class.ilMemcacheServer.php');
2238  $ilMemcacheServer = ilMemcacheServer::find($_GET['mcsid']);
2239  $ilMemcacheServer->delete();
2240  ilUtil::redirect('setup.php?cmd=cache');
2241  }
2242 
2243 
2244  public function saveCache()
2245  {
2249  require_once('Services/GlobalCache/classes/class.ilGlobalCache.php');
2250  require_once('./Services/GlobalCache/classes/Settings/class.ilGlobalCacheSettings.php');
2251  ilGlobalCache::flushAll();
2252  $ini = $this->setup->getClient()->ini;
2253 
2254  $ilGlobalCacheSettings = new ilGlobalCacheSettings();
2255  $ilGlobalCacheSettings->readFromIniFile($ini);
2256  $service_type = $_POST['global_cache_service_type'];
2257  $ilGlobalCacheSettings->setActive(($service_type >= 0) ? true : false);
2258  $ilGlobalCacheSettings->setService($service_type);
2259  $ilGlobalCacheSettings->resetActivatedComponents();
2260  if (is_array($_POST['activate']) && count($_POST['activate']) > 0) {
2261  foreach ($_POST['activate'] as $comp => $a) {
2262  if ($comp == 'all') {
2263  $ilGlobalCacheSettings->activateAll();
2264  break;
2265  }
2266  $ilGlobalCacheSettings->addActivatedComponent($comp);
2267  }
2268  }
2269 
2270  $ilGlobalCacheSettings->writeToIniFile($ini);
2271 
2272  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
2273  ilUtil::redirect('setup.php?cmd=cache');
2274  }
2275 
2276 
2280  public function displayDatabaseSlave($a_from_save = false)
2281  {
2282  global $ilErr,$ilDB,$ilLog;
2283 
2284  $this->checkDisplayMode("setup_database");
2285 
2286  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
2287 
2288  // database is intalled
2289  if (!$this->setup->getClient()->db_installed) {
2290  return;
2291  }
2292 
2293  $this->setDbSubTabs("repl");
2294 
2295  if (!$a_from_save) {
2296  $ilDB = $this->setup->getClient()->db;
2297  $this->lng->setDbHandler($ilDB);
2298  }
2299 
2300  ilUtil::sendInfo($this->lng->txt("mysql_replication_info_alpha"));
2301 
2302  if (!$a_from_save) {
2303  $this->initDbSlaveForm();
2304  }
2305 
2306  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2307 
2308  $this->checkPanelMode();
2309 
2310  $this->displaySubTabs();
2311  }
2312 
2316  public function initDbSlaveForm()
2317  {
2318  global $lng, $ilCtrl, $ilDB;
2319 
2320  $client = $this->setup->getClient();
2321 
2322  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2323  $this->form = new ilPropertyFormGUI();
2324 
2325  // db type
2326  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "slave_type");
2327  $ne->setValue($lng->txt("db_" . $ilDB->getDbType()));
2328  $this->form->addItem($ne);
2329 
2330  // activate slave
2331  $act = new ilCheckboxInputGUI($this->lng->txt("db_active"), "slave_active");
2332  $act->setChecked($client->getDbSlaveActive());
2333  $this->form->addItem($act);
2334 
2335  // slave host
2336  $ti = new ilTextInputGUI($lng->txt("db_host"), "slave_host");
2337  $ti->setValue($client->getDbSlaveHost());
2338  $ti->setMaxLength(120);
2339  $ti->setRequired(true);
2340  $act->addSubItem($ti);
2341 
2342  // slave name
2343  $ti = new ilTextInputGUI($lng->txt("db_name"), "slave_name");
2344  $ti->setValue($client->getDbSlaveName());
2345  $ti->setRequired(true);
2346  $ti->setMaxLength(40);
2347  $act->addSubItem($ti);
2348 
2349  // slave user
2350  $ti = new ilTextInputGUI($lng->txt("db_user"), "slave_user");
2351  $ti->setValue($client->getDbSlaveUser());
2352  $ti->setMaxLength(40);
2353  $ti->setRequired(true);
2354  $act->addSubItem($ti);
2355 
2356  // slave port
2357  $ti = new ilTextInputGUI($lng->txt("db_port"), "slave_port");
2358  $ti->setValue($client->getDbSlavePort());
2359  $ti->setMaxLength(8);
2360  $act->addSubItem($ti);
2361 
2362  // set password
2363  $set_pw = new ilCheckboxInputGUI($this->lng->txt("db_set_password"), "set_slave_password");
2364  $act->addSubItem($set_pw);
2365 
2366  // slave password
2367  $ti = new ilTextInputGUI($lng->txt("db_pass"), "slave_pass");
2368  $ti->setMaxLength(40);
2369  $set_pw->addSubItem($ti);
2370 
2371  $this->form->addCommandButton("saveDbSlave", $lng->txt("save"));
2372 
2373  $this->form->setTitle($lng->txt("db_slave_settings"));
2374  $this->form->setFormAction("setup.php?cmd=gateway");
2375  }
2376 
2380  public function saveDbSlave()
2381  {
2382  global $tpl, $lng, $ilCtrl, $ilDB;
2383 
2384  $client = $this->setup->getClient();
2385 
2386  $ilDB = $this->setup->getClient()->db;
2387  $this->lng->setDbHandler($ilDB);
2388 
2389  $this->initDbSlaveForm();
2390  if ($this->form->checkInput()) {
2391  $client->setDbSlaveActive($this->form->getInput("slave_active"));
2392  if ($this->form->getInput("slave_active")) {
2393  $client->setDbSlaveHost($this->form->getInput("slave_host"));
2394  $client->setDbSlaveUser($this->form->getInput("slave_user"));
2395  $client->setDbSlavePort($this->form->getInput("slave_port"));
2396  $client->setDbSlaveName($this->form->getInput("slave_name"));
2397  if ($this->form->getInput("set_slave_password")) {
2398  $client->setDbSlavePass($this->form->getInput("slave_pass"));
2399  }
2400  }
2401  $client->writeIni();
2402 
2403  ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
2404  ilUtil::redirect("setup.php?cmd=dbslave");
2405  } else {
2406  $this->form->setValuesByPost();
2407  $this->displayDatabaseSlave(true);
2408  }
2409  }
2410 
2411 
2418  public function setDbSubtabs($a_subtab_id = "db")
2419  {
2420  global $ilDB;
2421 
2422  if ($ilDB->getDbType() == "mysql") {
2423  $this->tabs->addSubTab("db", $this->lng->txt("db_master"), "setup.php?client_id=" . $this->client_id . "&cmd=db");
2424  $this->tabs->addSubTab("repl", $this->lng->txt("db_slave"), "setup.php?client_id=" . $this->client_id . "&cmd=dbslave");
2425  }
2426 
2427  $this->tabs->activateSubTab($a_subtab_id);
2428  }
2429 
2430 
2431 
2435  public function initClientDbForm($a_install = true, $dbupdate = null, $db_status = false, $hotfix_available = false, $custom_updates_available = false)
2436  {
2437  global $lng, $ilCtrl;
2438 
2439  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2440  $this->form = new ilPropertyFormGUI();
2441 
2442  // type
2443  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "db_type");
2444  $this->form->addItem($ne);
2445 
2446  // version
2447  if ($this->setup->getClient()->getDBSetup()->isDatabaseInstalled()
2448  && in_array($this->setup->getClient()->getDbType(), array(
2451  ))
2452  ) {
2453  $ne = new ilNonEditableValueGUI($lng->txt("version"), "db_version");
2454  $ilDB = $this->setup->getClient()->db;
2455  $ne->setValue($ilDB->getDBVersion());
2456  $this->form->addItem($ne);
2457  }
2458 
2459  // host
2460  $ne = new ilNonEditableValueGUI($lng->txt("host"), "db_host");
2461  $this->form->addItem($ne);
2462 
2463  // name
2464  $ne = new ilNonEditableValueGUI($lng->txt("name"), "db_name");
2465  $this->form->addItem($ne);
2466 
2467  // user
2468  $ne = new ilNonEditableValueGUI($lng->txt("user"), "db_user");
2469  $this->form->addItem($ne);
2470 
2471  // port
2472  $ne = new ilNonEditableValueGUI($lng->txt("port"), "db_port");
2473  $this->form->addItem($ne);
2474 
2475  // creation / collation for mysql
2476  if ((in_array($this->setup->getClient()->getDBType(), ilDBConstants::getInstallableTypes()) && $a_install)) {
2477  // create database
2478  $cb = new ilCheckboxInputGUI($lng->txt("database_create"), "chk_db_create");
2479 
2480  // collation
2481  $collations = array(
2482  "utf8_unicode_ci",
2483  "utf8_general_ci",
2484  "utf8_czech_ci",
2485  "utf8_danish_ci",
2486  "utf8_estonian_ci",
2487  "utf8_icelandic_ci",
2488  "utf8_latvian_ci",
2489  "utf8_lithuanian_ci",
2490  "utf8_persian_ci",
2491  "utf8_polish_ci",
2492  "utf8_roman_ci",
2493  "utf8_romanian_ci",
2494  "utf8_slovak_ci",
2495  "utf8_slovenian_ci",
2496  "utf8_spanish2_ci",
2497  "utf8_spanish_ci",
2498  "utf8_swedish_ci",
2499  "utf8_turkish_ci"
2500  );
2501  foreach ($collations as $collation) {
2502  $options[$collation] = $collation;
2503  }
2504  $si = new ilSelectInputGUI($lng->txt("collation"), "collation");
2505  $si->setOptions($options);
2506  $si->setInfo($this->lng->txt("info_text_db_collation2") . " " .
2507  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">" .
2508  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2509  $cb->addSubItem($si);
2510 
2511  $this->form->addItem($cb);
2512  }
2513 
2514  if ($a_install) {
2515  $this->form->addCommandButton("installDatabase", $lng->txt("database_install"));
2516  } else {
2517  $ilDB = $this->setup->getClient()->db;
2518  $this->lng->setDbHandler($ilDB);
2519  $dbupdate = new ilDBUpdate($ilDB);
2520 
2521  // database version
2522  $ne = new ilNonEditableValueGUI($lng->txt("database_version"), "curv");
2523  $ne->setValue($dbupdate->currentVersion);
2524  $this->form->addItem($ne);
2525 
2526  // file version
2527  $ne = new ilNonEditableValueGUI($lng->txt("file_version"), "filev");
2528  $ne->setValue($dbupdate->fileVersion);
2529  $this->form->addItem($ne);
2530 
2531  if (!$db_status = $dbupdate->getDBVersionStatus()) {
2532  // next update step
2533  $options = array();
2534  for ($i = $dbupdate->currentVersion + 1; $i <= $dbupdate->fileVersion; $i++) {
2535  $options[$i] = $i;
2536  }
2537  if (count($options) > 1) {
2538  $si = new ilSelectInputGUI($lng->txt("next_update_break"), "update_break");
2539  $si->setOptions($options);
2540  $si->setInfo($lng->txt("next_update_break_info"));
2541  $this->form->addItem($si);
2542  }
2543 
2544  if ($dbupdate->getRunningStatus() > 0) {
2545  ilUtil::sendFailure($this->lng->txt("db_update_interrupted") . " (Step " . $dbupdate->getRunningStatus() . ") <br /><br />" .
2546  $this->lng->txt("db_update_interrupted_avoid"));
2547  } else {
2548  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2549  }
2550  $this->form->addCommandButton("updateDatabase", $lng->txt("database_update"));
2551  $this->form->addCommandButton("showUpdateSteps", $lng->txt("show_update_steps"));
2552  } elseif ($hotfix_available) {
2553  // hotfix current version
2554  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2555  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2556  $this->form->addItem($ne);
2557 
2558  // hotfix file version
2559  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2560  $ne->setValue($dbupdate->getHotfixFileVersion());
2561  $this->form->addItem($ne);
2562 
2563  $this->form->addCommandButton("applyHotfix", $lng->txt("apply_hotfixes"));
2564  $this->form->addCommandButton("showHotfixSteps", $lng->txt("show_update_steps"));
2565  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2566  } elseif ($custom_updates_available) {
2567  // custom updates current version
2568  $ne = new ilNonEditableValueGUI($lng->txt("applied_custom_updates"), "curcu");
2569  $ne->setValue($dbupdate->getCustomUpdatesCurrentVersion());
2570  $this->form->addItem($ne);
2571 
2572  // custom updates file version
2573  $ne = new ilNonEditableValueGUI($lng->txt("available_custom_updates"), "filecu");
2574  $ne->setValue($dbupdate->getCustomUpdatesFileVersion());
2575  $this->form->addItem($ne);
2576 
2577  $this->form->addCommandButton("applyCustomUpdates", $lng->txt("apply_custom_updates"));
2578  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2579  } else {
2580  if ($dbupdate->getHotfixFileVersion() > 0) {
2581  // hotfix current version
2582  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2583  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2584  $this->form->addItem($ne);
2585 
2586  // hotfix file version
2587  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2588  $ne->setValue($dbupdate->getHotfixFileVersion());
2589  $this->form->addItem($ne);
2590  }
2591  if ($dbupdate->getCustomUpdatesFileVersion() > 0) {
2592  // custom updates current version
2593  $ne = new ilNonEditableValueGUI($lng->txt("applied_custom_updates"), "curcu");
2594  $ne->setValue($dbupdate->getCustomUpdatesCurrentVersion());
2595  $this->form->addItem($ne);
2596 
2597  // custom updates file version
2598  $ne = new ilNonEditableValueGUI($lng->txt("available_custom_updates"), "filecu");
2599  $ne->setValue($dbupdate->getCustomUpdatesFileVersion());
2600  $this->form->addItem($ne);
2601  }
2602  ilUtil::sendSuccess($this->lng->txt("database_is_uptodate"));
2603  }
2604  }
2605 
2606  $this->form->setTitle($lng->txt("database"));
2607  $this->form->setFormAction("setup.php?cmd=gateway");
2608  }
2609 
2614  public function getClientDbFormValues($dbupdate = null)
2615  {
2616  $values = array();
2617  $values["db_host"] = $this->setup->getClient()->getDbHost();
2618  $values["db_name"] = $this->setup->getClient()->getDbName();
2619  $values["db_user"] = $this->setup->getClient()->getDbUser();
2620  $values["db_port"] = $this->setup->getClient()->getDbPort();
2621  $values["db_type"] = ilDBConstants::describe($this->setup->getClient()->getDbType());
2622  if (is_object($dbupdate)) {
2623  $values["update_break"] = $dbupdate->fileVersion;
2624  if (($dbupdate->fileVersion - $dbupdate->currentVersion) >= 200) {
2625  $values["update_break"] = $dbupdate->currentVersion + 200 -
2626  ($dbupdate->currentVersion % 100);
2627  }
2628  }
2629 
2630  $this->form->setValuesByArray($values);
2631  }
2632 
2636 
2643  public function installDatabase()
2644  {
2645  if (!$this->setup->getClient()->getDBSetup()->isDatabaseExisting()) {
2646  if ($_POST["chk_db_create"]) {
2647  if (!$this->setup->createDatabase($_POST["collation"])) {
2648  echo "installation failed";
2649  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2650  ilUtil::redirect("setup.php?cmd=displayDatabase");
2651  }
2652  } else {
2653  ilUtil::sendFailure($this->lng->txt("database_not_exists_create_first"), true);
2654  ilUtil::redirect("setup.php?cmd=displayDatabase");
2655  }
2656  }
2657  if (!$this->setup->installDatabase()) {
2658  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2659  } else {
2660  ilUtil::sendSuccess($this->lng->txt("database_installed"), true);
2661  }
2662  ilUtil::redirect("setup.php?cmd=displayDatabase");
2663  }
2664 
2668 
2672  public function updateDatabase()
2673  {
2674  global $ilCtrlStructureReader;
2675 
2676  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2677  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2678  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2679  include_once "./Services/Tree/classes/class.ilTree.php";
2680  include_once "./Services/Xml/classes/class.ilSaxParser.php";
2681  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2682 
2683 
2684  // referencing db handler in language class
2685  $ilDB = $this->setup->getClient()->db;
2686  $this->lng->setDbHandler($ilDB);
2687 
2688  // run dbupdate
2689  $dbupdate = new ilDBUpdate($ilDB, $this->setup->getClient()->ini);
2690  $dbupdate->applyUpdate((int) $_POST["update_break"]);
2691 
2692  if ($dbupdate->updateMsg == "no_changes") {
2693  $message = $this->lng->txt("no_changes") . ". " . $this->lng->txt("database_is_uptodate");
2694  } else {
2695  $sep = "";
2696  foreach ($dbupdate->updateMsg as $row) {
2697  if ($row["msg"] == "update_applied") {
2698  $a_message .= $sep . $row["nr"];
2699  $sep = ", ";
2700  } else {
2701  $e_message .= "<br/>" . $this->lng->txt($row["msg"]) . ": " . $row["nr"];
2702  }
2703  }
2704  if ($a_message != "") {
2705  $a_message = $this->lng->txt("update_applied") . ": " . $a_message;
2706  }
2707  }
2708 
2709  ilUtil::sendInfo($a_message . $e_message, true);
2710  ilUtil::redirect("setup.php?cmd=displayDatabase");
2711  }
2712 
2716 
2723  public function showHotfixSteps()
2724  {
2725  $this->showUpdateSteps(true);
2726  }
2727 
2728 
2732  public function showUpdateSteps($a_hotfix = false)
2733  {
2734  global $ilCtrlStructureReader;
2735 
2736  $this->checkDisplayMode("setup_database");
2737 
2738  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
2739 
2740  // database is intalled
2741  if ($this->setup->getClient()->db_installed) {
2742  $ilDB = $this->setup->getClient()->db;
2743  $this->lng->setDbHandler($ilDB);
2744  $dbupdate = new ilDBUpdate($ilDB);
2745  $db_status = $dbupdate->getDBVersionStatus();
2746  $hotfix_available = $dbupdate->hotfixAvailable();
2747  $custom_updates_available = $dbupdate->customUpdatesAvailable();
2748  // $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available, $custom_updates_available);
2749  // $this->getClientDbFormValues($dbupdate);
2750 
2751  $ntpl = new ilTemplate("tpl.setup_steps.html", true, true, "setup");
2752  if ($a_hotfix) {
2753  $ntpl->setVariable("CONTENT", $dbupdate->getHotfixSteps());
2754  } else {
2755  $ntpl->setVariable("CONTENT", $dbupdate->getUpdateSteps($_POST["update_break"]));
2756  }
2757  $ntpl->setVariable("BACK", $this->lng->txt("back"));
2758  $ntpl->setVariable("HREF_BACK", "./setup.php?client_id=&cmd=db");
2759  $this->tpl->setVariable("SETUP_CONTENT", $ntpl->get());
2760  }
2761  }
2762 
2763 
2767 
2771  public function applyHotfix()
2772  {
2773  global $ilCtrlStructureReader;
2774 
2775  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2776 
2777  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2778  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2779  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2780  include_once "./Services/Tree/classes/class.ilTree.php";
2781  include_once "./Services/Xml/classes/class.ilSaxParser.php";
2782  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2783 
2784  // referencing db handler in language class
2785  $ilDB = $this->setup->getClient()->db;
2786  $this->lng->setDbHandler($ilDB);
2787 
2788  // run dbupdate
2789  $dbupdate = new ilDBUpdate($ilDB, $this->setup->getClient()->ini);
2790  $dbupdate->applyHotfix();
2791 
2792  if ($dbupdate->updateMsg == "no_changes") {
2793  $message = $this->lng->txt("no_changes") . ". " . $this->lng->txt("database_is_uptodate");
2794  } else {
2795  $sep = "";
2796  foreach ($dbupdate->updateMsg as $row) {
2797  if ($row["msg"] == "update_applied") {
2798  $a_message .= $sep . $row["nr"];
2799  $sep = ", ";
2800  } else {
2801  $e_message .= "<br/>" . $this->lng->txt($row["msg"]) . ": " . $row["nr"];
2802  }
2803  }
2804  if ($a_message != "") {
2805  $a_message = $this->lng->txt("update_applied") . ": " . $a_message;
2806  }
2807  }
2808 
2809  ilUtil::sendInfo($a_message . $e_message, true);
2810  ilUtil::redirect("setup.php?cmd=displayDatabase");
2811  }
2812 
2816 
2820  public function displaySessions()
2821  {
2822  require_once('Services/Authentication/classes/class.ilSessionControl.php');
2823 
2824  $this->checkDisplayMode("setup_sessions");
2825 
2826  if (!$this->setup->getClient()->db_installed) {
2827  // program should never come to this place
2828  $message = "No database found! Please install database first.";
2830  }
2831 
2832  $setting_fields = ilSessionControl::getSettingFields();
2833 
2834  $valid = true;
2835  $settings = array();
2836 
2837  foreach ($setting_fields as $field) {
2838  if ($field == 'session_allow_client_maintenance') {
2839  if (isset($_POST[$field])) {
2840  $_POST[$field] = '1';
2841  } else {
2842  $_POST[$field] = '0';
2843  }
2844  }
2845 
2846  if (isset($_POST[$field]) && $_POST[$field] != '') {
2847  $settings[$field] = $_POST[$field];
2848  } else {
2849  $valid = false;
2850  break;
2851  }
2852  }
2853 
2854  if ($valid) {
2855  $this->setup->setSessionSettings($settings);
2856  }
2857 
2858  $settings = $this->setup->getSessionSettings();
2859 
2860  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2861  $form = new ilPropertyFormGUI();
2862 
2863  include_once 'Services/Authentication/classes/class.ilSession.php';
2864 
2865  // BEGIN SESSION SETTINGS
2866  // create session handling radio group
2867  $ssettings = new ilRadioGroupInputGUI($this->lng->txt('sess_mode'), 'session_handling_type');
2868  $ssettings->setValue($settings['session_handling_type'], ilSession::SESSION_HANDLING_FIXED);
2869 
2870  // first option, fixed session duration
2871  $fixed = new ilRadioOption($this->lng->txt('sess_fixed_duration'), ilSession::SESSION_HANDLING_FIXED);
2872 
2873  // add session handling to radio group
2874  $ssettings->addOption($fixed);
2875 
2876  // second option, session control
2877  $ldsh = new ilRadioOption($this->lng->txt('sess_load_dependent_session_handling'), ilSession::SESSION_HANDLING_LOAD_DEPENDENT);
2878 
2879  // this is the max count of active sessions
2880  // that are getting started simlutanously
2881  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
2882  $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
2883  $ti->setMaxLength(5);
2884  $ti->setSize(5);
2885  $ti->setValue($settings['session_max_count']);
2886  $ldsh->addSubItem($ti);
2887 
2888  // after this (min) idle time the session can be deleted,
2889  // if there are further requests for new sessions,
2890  // but max session count is reached yet
2891  $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
2892  $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
2893  $ti->setMaxLength(5);
2894  $ti->setSize(5);
2895  $ti->setValue($settings['session_min_idle']);
2896  $ldsh->addSubItem($ti);
2897 
2898  // after this (max) idle timeout the session expires
2899  // and become invalid, so it is not considered anymore
2900  // when calculating current count of active sessions
2901  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
2902  $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
2903  $ti->setMaxLength(5);
2904  $ti->setSize(5);
2905  $ti->setValue($settings['session_max_idle']);
2906  $ldsh->addSubItem($ti);
2907 
2908  // this is the max duration that can elapse between the first and the secnd
2909  // request to the system before the session is immidietly deleted
2910  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
2911  $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
2912  $ti->setMaxLength(5);
2913  $ti->setSize(5);
2914  $ti->setValue($settings['session_max_idle_after_first_request']);
2915  $ldsh->addSubItem($ti);
2916 
2917  // add session control to radio group
2918  $ssettings->addOption($ldsh);
2919 
2920  $form->addItem($ssettings);
2921 
2922  // controls the ability t maintenance the following
2923  // settings in client administration
2924  $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
2925  $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
2926  $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
2927  $form->addItem($chkb);
2928  // END SESSION SETTINGS
2929 
2930  // save and cancel commands
2931  $form->addCommandButton("sess", $this->lng->txt('save'));
2932 
2933  $form->setTitle($this->lng->txt("sess_sessions"));
2934  $form->setFormAction('setup.php?client_id=' . $this->client_id . '&cmd=sess');
2935 
2936  $this->tpl->setVariable("TXT_SETUP_TITLE", ucfirst(trim($this->lng->txt('sess_sessions'))));
2937  $this->tpl->setVariable("TXT_INFO", '');
2938  $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
2939 
2940  /*$this->setButtonPrev("db");
2941 
2942  if($this->setup->checkClientSessionSettings($this->client,true))
2943  {
2944  $this->setButtonNext("lang");
2945  }*/
2946 
2947  $this->checkPanelMode();
2948  }
2949 
2953 
2957  public function displayLanguages()
2958  {
2959  $this->checkDisplayMode("setup_languages");
2960 
2961  if (!$this->setup->getClient()->db_installed) {
2962  // program should never come to this place
2963  $message = "No database found! Please install database first.";
2965  }
2966 
2967  include_once("./setup/classes/class.ilSetupLanguageTableGUI.php");
2968  $tab = new ilSetupLanguageTableGUI($this->setup->getClient());
2969  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2970 
2971  $this->tpl->setVariable("TXT_SETUP_TITLE", ucfirst(trim($this->lng->txt("setup_languages"))));
2972  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2973 
2974  $installed_langs = $this->lng->getInstalledLanguages();
2975  $lang_count = count($installed_langs);
2976  if ($lang_count > 0) {
2977  $this->setup->getClient()->status["lang"]["status"] = true;
2978  $this->setup->getClient()->status["lang"]["comment"] = $lang_count . " " . $this->lng->txt("languages_installed");
2979  } else {
2980  $this->setup->getClient()->status["lang"]["status"] = false;
2981  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2982  }
2983 
2984  $this->setButtonPrev("lang");
2985 
2986  if ($lang_count > 0) {
2987  $this->setButtonNext("contact");
2988  }
2989 
2990  $this->checkPanelMode();
2991  }
2992 
2999  public function saveLanguages()
3000  {
3001  if (empty($_POST["form"]["lang_id"])) {
3002  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
3003  ilUtil::redirect("setup.php?cmd=lang");
3004  }
3005 
3006  if (!in_array($_POST["form"]["lang_default"], $_POST["form"]["lang_id"])) {
3007  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
3008  ilUtil::redirect("setup.php?cmd=lang");
3009  }
3010 
3011  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
3012 
3013  if (is_array($result)) {
3014  $count = count($result);
3015  $txt = "tet";
3016 
3017  foreach ($result as $key => $lang_key) {
3018  $list .= $this->lng->txt("lang_" . $lang_key);
3019 
3020  if ($count > $key + 1) {
3021  $list .= ", ";
3022  }
3023  }
3024  }
3025 
3026  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
3027  $message = $this->lng->txt("languages_installed");
3028 
3029  if ($result !== true) {
3030  $message .= "<br/>(" . $this->lng->txt("langs_not_valid_not_installed") . ": " . $list . ")";
3031  }
3032  ilUtil::sendInfo($message, true);
3033  ilUtil::redirect("setup.php?cmd=lang");
3034  }
3035 
3039 
3043  public function displayContactData($a_omit_init = false)
3044  {
3045  $this->checkDisplayMode("setup_contact_data");
3046  $settings = $this->setup->getClient()->getAllSettings();
3047 
3048  if (!$a_omit_init) {
3049  $this->initContactDataForm();
3050  $this->getContactValues();
3051  }
3052  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
3053  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
3054  $this->setButtonPrev("lang");
3055 
3056  $check = $this->setup->checkClientContact($this->setup->client);
3057 
3058  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
3059  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
3060 
3061  if ($check["status"]) {
3062  $this->setButtonNext("proxy");
3063  }
3064 
3065  $this->checkPanelMode();
3066  }
3067 
3073  public function initContactDataForm()
3074  {
3075  global $lng, $ilCtrl;
3076 
3077  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3078  $this->form = new ilPropertyFormGUI();
3079 
3080  // name
3081  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
3082  $ti->setMaxLength(64);
3083  $ti->setSize(30);
3084  $ti->setRequired(true);
3085  $this->form->addItem($ti);
3086 
3087  // description
3088  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
3089  $ti->setMaxLength(64);
3090  $ti->setSize(30);
3091  $this->form->addItem($ti);
3092 
3093  // institution
3094  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
3095  $ti->setMaxLength(64);
3096  $ti->setSize(30);
3097  $this->form->addItem($ti);
3098 
3099  // contact data
3100  $sh = new ilFormSectionHeaderGUI();
3101  $sh->setTitle($lng->txt("contact_data"));
3102  $this->form->addItem($sh);
3103 
3104  // first name
3105  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
3106  $ti->setMaxLength(64);
3107  $ti->setSize(30);
3108  $ti->setRequired(true);
3109  $this->form->addItem($ti);
3110 
3111  // last name
3112  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
3113  $ti->setMaxLength(64);
3114  $ti->setSize(30);
3115  $ti->setRequired(true);
3116  $this->form->addItem($ti);
3117 
3118  $fs = array(
3119  "title" => array("max" => 64, "size" => 30),
3120  "position" => array("max" => 64, "size" => 30),
3121  "institution" => array("max" => 200, "size" => 30),
3122  "street" => array("max" => 64, "size" => 30),
3123  "zipcode" => array("max" => 10, "size" => 5),
3124  "city" => array("max" => 64, "size" => 30),
3125  "country" => array("max" => 64, "size" => 30),
3126  "phone" => array("max" => 64, "size" => 30)
3127  );
3128  foreach ($fs as $f => $op) {
3129  // field
3130  $ti = new ilTextInputGUI($lng->txt($f), "admin_" . $f);
3131  $ti->setMaxLength($op["max"]);
3132  $ti->setSize($op["size"]);
3133  $ti->setInfo($lng->txt(""));
3134  $this->form->addItem($ti);
3135  }
3136 
3137  // email
3138  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
3139  $ti->setRequired(true);
3140  $ti->allowRFC822(true);
3141  $this->form->addItem($ti);
3142 
3143  // feedback recipient
3144  /*$ti = new ilEmailInputGUI($lng->txt("feedback_recipient"), "feedback_recipient");
3145  $ti->setInfo($lng->txt("feedback_recipient_info"));
3146  $ti->setRequired(true);
3147  $ti->allowRFC822(true);
3148  $this->form->addItem($ti);*/
3149 
3150  // error recipient
3151  /*$ti = new ilEmailInputGUI($lng->txt("error_recipient"), "error_recipient");
3152  $ti->allowRFC822(true);
3153  $this->form->addItem($ti);*/
3154 
3155  $this->form->addCommandButton("saveContact", $lng->txt("save"));
3156 
3157  $this->form->setTitle($lng->txt("client_data"));
3158  $this->form->setFormAction("setup.php?cmd=gateway");
3159  }
3160 
3164  public function getContactValues()
3165  {
3166  $settings = $this->setup->getClient()->getAllSettings();
3167 
3168  $values = $settings;
3169 
3170  $values["inst_name"] = ($this->setup->getClient()->getName())
3171  ? $this->setup->getClient()->getName()
3172  : $this->setup->getClient()->getId();
3173  $values["inst_info"] = $this->setup->getClient()->getDescription();
3174 
3175  $this->form->setValuesByArray($values);
3176  }
3177 
3181  public function saveContact()
3182  {
3183  global $tpl, $lng, $ilCtrl;
3184 
3185  $this->initContactDataForm();
3186  if ($this->form->checkInput()) {
3187  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
3188  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
3189  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
3190  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
3191  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
3192  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
3193  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
3194  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
3195  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
3196  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
3197  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
3198  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
3199  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
3200  //$this->setup->getClient()->setSetting("feedback_recipient", $_POST["feedback_recipient"]);
3201  //$this->setup->getClient()->setSetting("error_recipient", $_POST["error_recipient"]);
3202 
3203  // update client.ini
3204  $this->setup->getClient()->setName($_POST["inst_name"]);
3205  $this->setup->getClient()->setDescription($_POST["inst_info"]);
3206  $this->setup->getClient()->ini->write();
3207 
3208  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3209  ilUtil::redirect("setup.php?cmd=displayContactData");
3210  }
3211 
3212  $this->form->setValuesByPost();
3213  $this->displayContactData(true);
3214  }
3215 
3219 
3223  public function displayNIC($a_omit_init = false)
3224  {
3225  $this->checkDisplayMode("nic_registration");
3226  $settings = $this->setup->getClient()->getAllSettings();
3227  $nic_key = $this->setup->getClient()->getNICkey();
3228 
3229  // reload settings
3230  $settings = $this->setup->getClient()->getAllSettings();
3231  //var_dump($settings);
3232  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0) {
3233  $this->no_second_nav = true;
3234  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic3") . " " . $settings["inst_id"] . ".");
3235  } else {
3236  // reload settings
3237  $settings = $this->setup->getClient()->getAllSettings();
3238 
3239  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
3240  if (!$a_omit_init) {
3241  $this->initRegistrationForm();
3242  $this->getRegistrationValues();
3243  }
3244  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
3245 
3246  if (isset($settings["nic_enabled"])) {
3247  $this->setup->getClient()->status["nic"]["status"] = true;
3248  }
3249  }
3250 
3251  $this->setButtonPrev("proxy");
3252 
3253  if ($this->setup->getClient()->status["nic"]["status"]) {
3254  $this->setButtonNext("finish", "finish");
3255  }
3256 
3257  $this->checkPanelMode();
3258  }
3259 
3265  public function initRegistrationForm($a_mode = "edit")
3266  {
3267  global $lng, $ilCtrl;
3268 
3269  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3270  $this->form = new ilPropertyFormGUI();
3271 
3272  // registration type
3273  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
3274  $radg->setValue(1);
3275  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
3276  $radg->addOption($op1);
3277  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
3278  $radg->addOption($op1);
3279  $this->form->addItem($radg);
3280 
3281  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
3282  $this->form->setFormAction("setup.php?cmd=gateway");
3283  }
3284 
3288  public function getRegistrationValues()
3289  {
3290  $settings = $this->setup->getClient()->getAllSettings();
3291  $nic_key = $this->setup->getClient()->getNICkey();
3292 
3293 
3294  $values = array();
3295 
3296  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1") {
3297  $values["register"] = 1;
3298  }
3299  /*elseif ($settings["nic_enabled"] == "2")
3300  {
3301  $this->tpl->setVariable("EMAIL",$checked);
3302  }*/
3303  else {
3304  $values["register"] = 0;
3305  }
3306 
3307  $this->form->setValuesByArray($values);
3308  }
3309 
3313  public function saveRegistration()
3314  {
3315  global $tpl, $lng, $ilCtrl;
3316 
3317  $this->initRegistrationForm();
3318  if ($this->form->checkInput()) {
3319  // check register option
3320  if ($_POST["register"] == 1) {
3321  // update nic
3322  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
3323  //var_dump($this->setup->getClient()->nic_status);
3324  // online registration failed
3325  if (empty($this->setup->getClient()->nic_status[2])) {
3326  $this->setup->getClient()->setSetting("nic_enabled", "-1");
3327  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
3328  ilUtil::redirect("setup.php?cmd=displayNIC");
3329  } else {
3330  $this->setup->getClient()->setSetting("inst_id", $this->setup->getClient()->nic_status[2]);
3331  $this->setup->getClient()->setSetting("nic_enabled", "1");
3332  $this->setup->getClient()->status["nic"]["status"] = true;
3333  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
3334  ilUtil::redirect("setup.php?cmd=displayNIC");
3335  }
3336  }
3337  /*elseif ($_POST["form"]["register"] == 2)
3338  {
3339  $nic_by_email = (int) $_POST["form"]["nic_id"];
3340 
3341  $checksum = md5($nic_key.$nic_by_email);
3342 
3343  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
3344  {
3345  $message = $this->lng->txt("nic_reg_enter_correct_id");
3346  }
3347  else
3348  {
3349  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
3350  $this->setup->getClient()->setSetting("nic_enabled","1");
3351  $message = $this->lng->txt("nic_reg_enabled");
3352  }
3353  }*/
3354  else {
3355  $this->setup->getClient()->setSetting("inst_id", "0");
3356  $this->setup->getClient()->setSetting("nic_enabled", "0");
3357  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
3358  ilUtil::redirect("setup.php?cmd=displayNIC");
3359  }
3360  }
3361 
3362  $this->form->setValuesByPost();
3363  $this->displayNIC(true);
3364  }
3365 
3369 
3373  public function displayTools()
3374  {
3375  $this->checkDisplayMode();
3376 
3377  // output
3378  ilUtil::sendInfo();
3379 
3380  // use property forms and add the settings type switch
3381  $ctrl_structure_form = $this->initControlStructureForm();
3382  $settings_type_form = $this->initSettingsTypeForm();
3383  $mp_ns_form = $this->initTreeImplementationForm();
3384 
3385  $this->tpl->setVariable(
3386  "SETUP_CONTENT",
3387  $ctrl_structure_form->getHTML() . "<br />" .
3388  $settings_type_form->getHTML() . '<br />' .
3389  $mp_ns_form->getHTML()
3390  );
3391  }
3392 
3393  public function initTreeImplementationForm()
3394  {
3395  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3396  $form = new ilPropertyFormGUI();
3397 
3398  $form->setId('tree_impl');
3399  $form->setTitle($this->lng->txt('tree_implementation'));
3400  $form->setFormAction('setup.php?cmd=gateway');
3401 
3402 
3403  $options = new ilRadioGroupInputGUI('', 'tree_impl_type');
3404  #$options->setRequired(true);
3405 
3406  $set = new ilSetting('common');
3407  $type = ($set->get('main_tree_impl', 'ns') == 'ns' ? 'ns' : 'mp');
3408 
3409 
3410  $options->setValue($type);
3411 
3412  $ns = new ilRadioOption($this->lng->txt('tree_implementation_ns'), 'ns');
3413  $options->addOption($ns);
3414 
3415  $mp = new ilRadioOption($this->lng->txt('tree_implementation_mp'), 'mp');
3416  $options->addOption($mp);
3417 
3418  $form->addItem($options);
3419  $form->addCommandButton('switchTree', $this->lng->txt('tree_implementation_switch_btn'));
3420  $form->setShowTopButtons(false);
3421 
3422  return $form;
3423  }
3424 
3425  public function switchTree()
3426  {
3427  $set = new ilSetting('common');
3428  $type = ($set->get('main_tree_impl', 'ns') == 'ns' ? 'ns' : 'mp');
3429 
3430  if ($type == 'ns' and $_POST['tree_impl_type'] == 'mp') {
3431  // To mp
3432  include_once './Services/Tree/classes/class.ilMaterializedPathTree.php';
3434 
3435  $GLOBALS['ilDB']->dropIndexByFields('tree', array('lft'));
3436  $GLOBALS['ilDB']->dropIndexByFields('tree', array('path'));
3437  $GLOBALS['ilDB']->addIndex('tree', array('path'), 'i4');
3438 
3439  $set->set('main_tree_impl', 'mp');
3440  } elseif ($type == 'mp' and $_POST['tree_impl_type'] == 'ns') {
3441  include_once './Services/Tree/classes/class.ilTree.php';
3442  $GLOBALS['ilSetting'] = $set;
3443  $GLOBALS["DIC"]["ilSetting"] = function ($c) {
3444  return $GLOBALS["ilSetting"];
3445  };
3446  $tree = new ilTree(1);
3447  $tree->renumber(1);
3448 
3449  $GLOBALS['ilDB']->dropIndexByFields('tree', array('lft'));
3450  $GLOBALS['ilDB']->dropIndexByFields('tree', array('path'));
3451  $GLOBALS['ilDB']->addIndex('tree', array('lft'), 'i4');
3452 
3453  $set->set('main_tree_impl', 'ns');
3454  }
3455 
3456  ilUtil::sendInfo($this->lng->txt("tree_implementation_switched"), true);
3457  $this->displayTools();
3458  }
3459 
3465  public function initControlStructureForm()
3466  {
3467  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3468  $form = new ilPropertyFormGUI();
3469 
3470  $form->setId("control_structure");
3471  $form->setTitle($this->lng->txt("ctrl_structure"));
3472  $form->setFormAction("setup.php?cmd=gateway");
3473 
3474  $ilDB = $this->setup->getClient()->db;
3475  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
3476  $crec = $ilDB->fetchAssoc($cset);
3477 
3478  $item = new ilCustomInputGUI($this->lng->txt("ctrl_structure_reload"));
3479  if ($crec["cnt"] == 0) {
3480  $item->setInfo($this->lng->txt("ctrl_missing_desc"));
3481  } else {
3482  $item->setInfo($this->lng->txt("ctrl_structure_desc"));
3483  }
3484  $form->addItem($item);
3485 
3486  $form->addCommandButton("reloadStructure", $this->lng->txt("reload"));
3487  return $form;
3488  }
3489 
3490 
3494  public function reloadControlStructure()
3495  {
3496  global $ilCtrlStructureReader;
3497 
3498  if (!$this->setup->getClient()->db_installed) {
3499  ilUtil::sendInfo($this->lng->txt("no_db"), true);
3500  $this->displayTools();
3501  return;
3502  }
3503 
3504  // referencing does not work in dbupdate-script
3505  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
3506  $GLOBALS["DIC"]["ilDB"] = function ($c) {
3507  return $GLOBALS["ilDB"];
3508  };
3509  // BEGIN WebDAV
3510  // read module and service information into db
3511 
3512  $modules = ilModule::getAvailableCoreModules();
3514 
3515  $ilCtrlStructureReader->readStructure(true);
3516 
3517  // clear tables
3518  $mr = new ilModuleReader("", "", "");
3519  $mr->clearTables();
3520  foreach ($modules as $module) {
3521  $mr = new ilModuleReader(
3522  ILIAS_ABSOLUTE_PATH . "/Modules/" . $module["subdir"] . "/module.xml",
3523  $module["subdir"],
3524  "Modules"
3525  );
3526  $mr->getModules();
3527  unset($mr);
3528  }
3529 
3530  // clear tables
3531  $sr = new ilServiceReader("", "", "");
3532  $sr->clearTables();
3533  foreach ($services as $service) {
3534  $sr = new ilServiceReader(
3535  ILIAS_ABSOLUTE_PATH . "/Services/" . $service["subdir"] . "/service.xml",
3536  $service["subdir"],
3537  "Services"
3538  );
3539  $sr->getServices();
3540  unset($sr);
3541  }
3542  // END WebDAV
3543 
3544  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
3545  $this->displayTools();
3546  }
3547 
3553  public function initSettingsTypeForm()
3554  {
3555  include_once("./Services/Administration/classes/class.ilSetting.php");
3557 
3558  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3559  $form = new ilPropertyFormGUI();
3560 
3561  $form->setId("settings_type");
3562  $form->setTitle($this->lng->txt("settings_type"));
3563  $form->setFormAction("setup.php?cmd=gateway");
3564 
3565  $item = new ilNonEditableValueGUI($this->lng->txt('settings_type_current'));
3566  $item->setValue(strtoupper($type));
3567 
3568  if ($type == "clob") {
3569  $item->setInfo($this->lng->txt('settings_info_clob'));
3570  $form->addCommandButton("showLongerSettings", $this->lng->txt("settings_show_longer"));
3571  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_text"));
3572  } else {
3573  $item->setInfo($this->lng->txt('settings_info_text'));
3574  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_clob"));
3575  }
3576  $form->addItem($item);
3577 
3578  if (is_array($this->longer_settings)) {
3579  $item = new ilCustomInputGUI($this->lng->txt('settings_longer_values'));
3580 
3581  if (count($this->longer_settings)) {
3582  foreach ($this->longer_settings as $row) {
3583  $subitem = new ilCustomInputGUI(sprintf($this->lng->txt('settings_key_info'), $row['module'], $row['keyword']));
3584  $subitem->setInfo($row['value']);
3585  $item->addSubItem($subitem);
3586  }
3587  } else {
3588  $item->setHTML($this->lng->txt('settings_no_longer_values'));
3589  }
3590  $form->addItem($item);
3591  }
3592 
3593  return $form;
3594  }
3595 
3596 
3600  public function changeSettingsType()
3601  {
3602  include_once("./Services/Administration/classes/class.ilSetting.php");
3603  $old_type = ilSetting::_getValueType();
3604 
3605  if ($old_type == "clob") {
3606  $longer_settings = ilSetting::_getLongerSettings();
3607  if (count($longer_settings)) {
3608  $this->longer_settings = $longer_settings;
3609  ilUtil::sendFailure($this->lng->txt("settings_too_long"));
3610  } else {
3612  }
3613  } else {
3615  }
3616 
3617  if ($changed) {
3618  ilUtil::sendInfo($this->lng->txt("settings_type_changed"));
3619  }
3620 
3621  $this->displayTools();
3622  }
3623 
3624 
3629  public function showLongerSettings()
3630  {
3631  include_once("./Services/Administration/classes/class.ilSetting.php");
3632  $this->longer_settings = ilSetting::_getLongerSettings();
3633  $this->displayTools();
3634  }
3635 
3639  protected function getMasterPasswordForm()
3640  {
3641  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
3642  $form = new \ilPropertyFormGUI();
3643  $form->setTitle($this->lng->txt('change_password'));
3644 
3645  $currentPassword = new \ilPasswordInputGUI($this->lng->txt('set_oldpasswd'), 'pass_old');
3646  $currentPassword->setDisableHtmlAutoComplete(true);
3647  $currentPassword->setValidateAuthPost(false);
3648  $currentPassword->setSkipSyntaxCheck(true);
3649  $currentPassword->setRequired(true);
3650  $currentPassword->setRetype(false);
3651  $form->addItem($currentPassword);
3652 
3653  $newPassword = new \ilPasswordInputGUI($this->lng->txt('set_newpasswd'), 'pass');
3654  $newPassword->setDisableHtmlAutoComplete(true);
3655  $newPassword->setValidateAuthPost(false);
3656  $newPassword->setSkipSyntaxCheck(true);
3657  $newPassword->setRequired(true);
3658  $newPassword->setRetype(true);
3659  $form->addItem($newPassword);
3660 
3661  $form->setFormAction('setup.php?cmd=gateway');
3662  $form->addCommandButton('savemasterpassword', $this->lng->txt('save'));
3663 
3664  return $form;
3665  }
3666 
3670  protected function saveMasterPassword()
3671  {
3672  $form = $this->getMasterPasswordForm();
3673 
3674  $isValid = $form->checkInput();
3675  $form->setValuesByPost();
3676 
3677  if (!$isValid) {
3678  return $this->changeMasterPassword($form);
3679  }
3680 
3681  $cp = $form->getInput('pass_old');
3682  $np = $form->getInput('pass');
3683 
3684  if (!$this->setup->verifyMasterPassword($cp)) {
3685  \ilUtil::sendFailure($this->lng->txt('password_old_wrong'));
3686  return $this->changeMasterPassword($form);
3687  }
3688 
3689  if (!$this->setup->storeMasterPassword($np)) {
3690  \ilUtil::sendFailure($this->lng->txt('save_error'));
3691  return $this->changeMasterPassword($form);
3692  }
3693 
3694  \ilUtil::sendInfo($this->lng->txt('password_changed'), true);
3695  \ilUtil::redirect("setup.php");
3696  }
3697 
3702  protected function changeMasterPassword(\ilPropertyFormGUI $form = null)
3703  {
3704  if (null === $form) {
3705  $form = $this->getMasterPasswordForm();
3706  }
3707 
3708  $this->tpl->addBlockFile('CONTENT', 'content', 'tpl.std_layout.html', 'setup');
3709  $this->tpl->setVariable('TXT_HEADER', $this->lng->txt('password_new_master'));
3710  $this->tpl->setVariable('TXT_INFO', $this->lng->txt('info_text_password'));
3711  $this->tpl->setVariable('SETUP_CONTENT', $form->getHTML());
3712  }
3713 
3717  public function displayFinishSetup()
3718  {
3719  $this->checkDisplayMode("finish_setup");
3720  $this->no_second_nav = true;
3721  //echo "<b>1</b>";
3722  if ($this->validateSetup()) {
3723  $txt_info = $this->lng->txt("info_text_finish1") . "<br /><br />" .
3724  "<p>" . $this->lng->txt("user") . ": <b>root</b><br />" .
3725  $this->lng->txt("password") . ": <b>homer</b></p>";
3726  $this->setButtonNext("login_new", "login");
3727  //echo "<b>2</b>";
3728  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
3729  // the setup_ok fails (with MDB2 and a larger
3730  // client list), alex 17.1.2008
3731  $this->setup->getClient()->setSetting("setup_ok", 1);
3732  //$this->setup->getClient()->setSetting("zzz", "Z");
3733  //echo "<b>3</b>";
3734  $this->setup->getClient()->status["finish"]["status"] = true;
3735  //echo "<b>4</b>";
3736  } else {
3737  $txt_info = $this->lng->txt("info_text_finish2");
3738  }
3739 
3740  //echo "<b>5</b>";
3741  // output
3742  $this->tpl->addBlockFile("SETUP_CONTENT", "setup_content", "tpl.clientsetup_finish.html", "setup");
3743  $this->tpl->setVariable("TXT_INFO", $txt_info);
3744 
3745  $this->setButtonPrev("nic");
3746  //echo "<b>6</b>";
3747  $this->checkPanelMode();
3748  //echo "<b>7</b>";
3749  }
3750 
3754  public function displayDeleteConfirmation()
3755  {
3756  $this->checkDisplayMode();
3757 
3758  // formular sent
3759  if ($_POST["form"]["delete"]) {
3760  $ini = true;
3761  $db = false;
3762  $files = false;
3763 
3764  /* disabled
3765  switch ($_POST["form"]["delete"])
3766  {
3767  case 1:
3768  $ini = true;
3769  break;
3770 
3771  case 2:
3772  $ini = true;
3773  $db = true;
3774  break;
3775 
3776  case 3:
3777  $ini = true;
3778  $db = true;
3779  $files = true;
3780  break;
3781  }
3782  */
3783 
3784  $msg = $this->setup->getClient()->delete($ini, $db, $files);
3785 
3786  ilUtil::sendInfo($this->lng->txt("client_deleted"), true);
3787  ilUtil::redirect("setup.php");
3788  }
3789 
3790  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3791 
3792  // output
3793  $this->tpl->addBlockFile("SETUP_CONTENT", "setup_content", "tpl.form_delete_client.html", "setup");
3794 
3795  // delete panel
3796  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3797  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3798  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3799  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3800 
3801  $this->checkPanelMode();
3802  }
3803 
3809  public function changeAccessMode($a_back)
3810  {
3811  if ($this->setup->getClient()->status["finish"]["status"]) {
3812  $val = ($this->setup->getClient()->ini->readVariable("client", "access")) ? "0" : true;
3813  $this->setup->getClient()->ini->setVariable("client", "access", $val);
3814  $this->setup->getClient()->ini->write();
3815  $message = "client_access_mode_changed";
3816  } else {
3817  $message = "client_setup_not_finished";
3818  }
3819 
3820  ilUtil::sendInfo($this->lng->txt($message), true);
3821 
3822  ilUtil::redirect("setup.php?cmd=" . $a_back);
3823  }
3824 
3828  public function changeDefaultClient()
3829  {
3830  if ($_POST["form"]) {
3831  $client = new ilClient($_POST["form"]["default"]);
3832 
3833  if (!$client->init()) {
3834  \ilUtil::sendFailure($this->lng->txt("no_valid_client_id"), true);
3835  \ilUtil::redirect("setup.php?cmd=clientlist");
3836  }
3837 
3838  $status = $this->setup->getStatus($client);
3839 
3840  if ($status["finish"]["status"]) {
3841  $this->setup->ini->setVariable("clients", "default", $client->getId());
3842  $this->setup->ini->write();
3843  $message = "default_client_changed";
3844  } else {
3845  $message = "client_setup_not_finished";
3846  }
3847  }
3848 
3849  ilUtil::sendInfo($this->lng->txt($message), true);
3850 
3851  ilUtil::redirect("setup.php");
3852  }
3853 
3858  public function validateSetup()
3859  {
3860  foreach ($this->setup->getClient()->status as $key => $val) {
3861  if ($key != "finish" and $key != "access") {
3862  if ($val["status"] != true) {
3863  return false;
3864  }
3865  }
3866  }
3867 
3868  //$this->setup->getClient()->setSetting("zzz", "V");
3869  $clientlist = new ilClientList();
3870  //$this->setup->getClient()->setSetting("zzz", "W");
3871  $list = $clientlist->getClients();
3872  //$this->setup->getClient()->setSetting("zzz", "X");
3873  if (count($list) == 1) {
3874  $this->setup->ini->setVariable("clients", "default", $this->setup->getClient()->getId());
3875  $this->setup->ini->write();
3876 
3877  $this->setup->getClient()->ini->setVariable("client", "access", 1);
3878  $this->setup->getClient()->ini->write();
3879  }
3880  //$this->setup->getClient()->setSetting("zzz", "Y");
3881  return true;
3882  }
3883 
3888  {
3889  if (!$this->setup->getClient()->status["db"]["status"]) {
3890  $this->cmd = "db";
3891  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3892  $this->displayDatabase();
3893  } elseif (!$this->setup->getClient()->status["lang"]["status"]) {
3894  $this->cmd = "lang";
3895  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3896  $this->displayLanguages();
3897  } elseif (!$this->setup->getClient()->status["contact"]["status"]) {
3898  $this->cmd = "contact";
3899  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3900  $this->displayContactData();
3901  } elseif (!$this->setup->getClient()->status['proxy']['status']) {
3902  $this->cmd = "proxy";
3903  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3904  $this->displayProxy();
3905  } elseif (!$this->setup->getClient()->status["nic"]["status"]) {
3906  $this->cmd = "nic";
3907  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3908  $this->displayNIC();
3909  } elseif (!$this->setup->getClient()->status["finish"]["status"]) {
3910  $this->cmd = "finish";
3911  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"), true);
3912  $this->displayFinishSetup();
3913  } else {
3914  return false;
3915  }
3916  }
3917 
3921  public function toggleClientList()
3922  {
3923  if ($this->setup->ini->readVariable("clients", "list")) {
3924  $this->setup->ini->setVariable("clients", "list", "0");
3925  $this->setup->ini->write();
3926  ilUtil::sendInfo($this->lng->txt("list_disabled"), true);
3927  } else {
3928  $this->setup->ini->setVariable("clients", "list", "1");
3929  $this->setup->ini->write();
3930  ilUtil::sendInfo($this->lng->txt("list_enabled"), true);
3931  }
3932 
3933  ilUtil::redirect("setup.php");
3934  }
3935 
3939 
3940  public function applyCustomUpdates()
3941  {
3942  global $ilCtrlStructureReader;
3943 
3944  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
3945 
3946  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
3947  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
3948  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
3949  include_once "./Services/Tree/classes/class.ilTree.php";
3950  include_once "./Services/Xml/classes/class.ilSaxParser.php";
3951  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
3952 
3953  // referencing db handler in language class
3954  $ilDB = $this->setup->getClient()->db;
3955  $this->lng->setDbHandler($ilDB);
3956 
3957  // run dbupdate
3958 
3959  $dbupdate = new ilDBUpdate($ilDB, $this->setup->getClient()->ini);
3960  $dbupdate->applyCustomUpdates();
3961 
3962  if ($dbupdate->updateMsg == "no_changes") {
3963  $message = $this->lng->txt("no_changes") . ". " . $this->lng->txt("database_is_uptodate");
3964  } else {
3965  $sep = "";
3966  foreach ($dbupdate->updateMsg as $row) {
3967  if ($row["msg"] == "update_applied") {
3968  $a_message .= $sep . $row["nr"];
3969  $sep = ", ";
3970  } else {
3971  $e_message .= "<br/>" . $this->lng->txt($row["msg"]) . ": " . $row["nr"];
3972  }
3973  }
3974  if ($a_message != "") {
3975  $a_message = $this->lng->txt("update_applied") . ": " . $a_message;
3976  }
3977  }
3978 
3979  ilUtil::sendInfo($a_message . $e_message, true);
3980  ilUtil::redirect("setup.php?cmd=displayDatabase");
3981  }
3982 
3986  public function cloneInitForm()
3987  {
3988  global $lng, $ilCtrl;
3989 
3990  $this->checkDisplayMode();
3991 
3992  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3993  $this->form = new ilPropertyFormGUI();
3994 
3995  $this->form->setId("clone_form");
3996  $this->form->setFormAction("setup.php?cmd=gateway");
3997 
3998  if ($this->setup->getClient()->status["access"]["status"] === false and stripos($this->setup->getClient()->getName(), "master") === false and $this->setup->getClient()->getdbType() == "mysql" and $this->setup->getClient()->db_exists) {
3999  $this->form->setTitle($this->lng->txt("clone_source"));
4000  $clients = array();
4001  $clientlist = new ilClientList();
4002  $list = $clientlist->getClients();
4003  $clientlistarray = array();
4004 
4005  foreach ($list as $key => $client) {
4006  if ((strcmp($key, $this->setup->getClient()->getId()) != '0') && ($client->getDbType() == 'mysql')) { // You cannot clone yourself
4007  $clientlistarray[$client->id] = $client->id;
4008  }
4009  }
4010 
4011  $si = new ilSelectInputGUI($lng->txt("clone_selectsource"), "source");
4012 
4013  $si->setOptions(array_merge(
4014  array("" => "-- " . $lng->txt("please_select") . " --"),
4015  $clientlistarray
4016  ));
4017  $si->setRequired(true);
4018  $this->form->addItem($si);
4019 
4020  $cb = new ilCheckboxInputGUI($lng->txt("clone_areyousure"), "iamsure");
4021  $cb->setRequired(true);
4022  $this->form->addItem($cb);
4023 
4024  $this->form->addCommandButton("cloneSaveSource", $lng->txt("cloneit"));
4025  } else {
4026  $disabledmessage = "<h1>" . $this->lng->txt("clone_disabledmessage") . "</h1><br>";
4027  if (!$this->setup->getClient()->status["access"]["status"] === false) {
4028  $disabledmessage .= $this->lng->txt("clone_clientnotdisabled") . "<br>";
4029  }
4030  if (!stripos($this->setup->getClient()->getName(), "aster") === false) {
4031  $disabledmessage .= $this->lng->txt("clone_clientismaster") . "<br>";
4032  }
4033  if ($this->setup->getClient()->getdbType() != "mysql") {
4034  $disabledmessage .= $this->lng->txt("clone_clientisnotmysql") . "<br>";
4035  }
4036  if (!$this->setup->getClient()->db_exists) {
4037  $disabledmessage .= $this->lng->txt("clone_clientnodatabase") . "<br>";
4038  }
4039  $this->form->setTitle($disabledmessage);
4040  }
4041  }
4042 
4043  public function cloneSelectSource()
4044  {
4045  if (!$this->setup->isAdmin()) {
4046  return;
4047  }
4048 
4049  $this->cloneInitForm();
4050  $this->form->setValuesByPost();
4051  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_clone"));
4052  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4053  }
4054 
4055  public function cloneSaveSource()
4056  {
4057  global $lng, $ilCtrl;
4058 
4059  if (!$this->setup->isAdmin()) {
4060  return;
4061  }
4062 
4063  $this->cloneInitForm();
4064 
4065  if ($this->form->checkInput()) {
4066  $error = '';
4067 
4068  if ($this->form->getInput("iamsure") != "1") {
4069  $error = $this->lng->txt('clone_youmustcheckiamsure');
4070  }
4071 
4072  if (!$this->setup->cloneFromSource($this->form->getInput("source"))) {
4073  $error = $this->lng->txt('clone_error') . ' -> ' . $this->setup->error;
4074  }
4075 
4076  if (0 === strlen($error)) {
4077  \ilUtil::sendInfo($this->lng->txt('client_cloned'));
4078  } else {
4079  \ilUtil::sendFailure($error);
4080  }
4081  }
4082  $this->form->setValuesByPost();
4083  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_clone"));
4084  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4085  }
4086 
4087  public function displayProxy($a_omit_init = false)
4088  {
4089  $this->checkDisplayMode("proxy");
4090  $settings = $this->setup->getClient()->getAllSettings();
4091 
4092  if (!$a_omit_init) {
4093  include_once("./Services/Administration/classes/class.ilSetting.php");
4094  $this->initProxyForm();
4095  $this->form->setValuesByArray(array(
4096  'proxy_status' => (bool) $settings['proxy_status'],
4097  'proxy_host' => $settings['proxy_host'],
4098  'proxy_port' => $settings['proxy_port']
4099  ));
4100  if ((bool) $settings['proxy_status']) {
4101  $this->setup->printProxyStatus($this->setup->client);
4102  }
4103  }
4104  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4105  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_proxy"));
4106 
4107 
4108  $check = $this->setup->checkClientProxySettings($this->setup->client);
4109 
4110  $this->setup->getClient()->status["proxy"]["status"] = $check["status"];
4111  $this->setup->getClient()->status["proxy"]["comment"] = $check["comment"];
4112  $this->setup->getClient()->status["proxy"]["text"] = $check["comment"];
4113 
4114  if ($check["status"]) {
4115  $this->setButtonNext("nic");
4116  }
4117 
4118  $this->setButtonPrev("contact");
4119  $this->checkPanelMode();
4120  }
4121  private function initProxyForm()
4122  {
4123  global $lng;
4124 
4125  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
4126  $this->form = new ilPropertyFormGUI();
4127  $this->form->setFormAction("setup.php?cmd=gateway");
4128 
4129  // Proxy status
4130  $proxs = new ilCheckboxInputGUI($lng->txt('proxy_status'), 'proxy_status');
4131  $proxs->setInfo($lng->txt('proxy_status_info'));
4132  $proxs->setValue(1);
4133  $this->form->addItem($proxs);
4134 
4135  // Proxy availability
4136  $proxa = new ilCustomInputGUI('', 'proxy_availability');
4137  $proxs->addSubItem($proxa);
4138 
4139  // Proxy
4140  $prox = new ilTextInputGUI($lng->txt('proxy_host'), 'proxy_host');
4141  $prox->setInfo($lng->txt('proxy_host_info'));
4142  $proxs->addSubItem($prox);
4143 
4144  // Proxy Port
4145  $proxp = new ilTextInputGUI($lng->txt('proxy_port'), 'proxy_port');
4146  $proxp->setInfo($lng->txt('proxy_port_info'));
4147  $proxp->setSize(10);
4148  $proxp->setMaxLength(10);
4149  $proxs->addSubItem($proxp);
4150 
4151  // save and cancel commands
4152  $this->form->addCommandButton('saveProxy', $lng->txt('save'));
4153  }
4154 
4162  public function saveProxy()
4163  {
4164  global $lng;
4165 
4166  $this->initProxyForm();
4167  $isFormValid = $this->form->checkInput();
4168 
4169  $new_settings['proxy_status'] = (int) $this->form->getInput('proxy_status');
4170  $new_settings['proxy_host'] = trim($this->form->getInput('proxy_host'));
4171  $new_settings['proxy_port'] = trim($this->form->getInput('proxy_port'));
4172 
4173  if ($isFormValid) {
4174  if ($new_settings['proxy_status'] == true) {
4175  if (!strlen($new_settings['proxy_host'])) {
4176  $isFormValid = false;
4177  $this->form->getItemByPostVar('proxy_host')->setAlert($lng->txt('msg_input_is_required'));
4178  }
4179  if (!strlen($new_settings['proxy_port'])) {
4180  $isFormValid = false;
4181  $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('msg_input_is_required'));
4182  }
4183  if (!preg_match('/[0-9]{1,}/', $new_settings['proxy_port']) ||
4184  $new_settings['proxy_port'] < 0 ||
4185  $new_settings['proxy_port'] > 65535) {
4186  $isFormValid = false;
4187  $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('proxy_port_numeric'));
4188  }
4189  }
4190 
4191  if ($isFormValid) {
4192  $this->setup->saveProxySettings($new_settings);
4193 
4194  ilUtil::sendSuccess($lng->txt('saved_successfully'));
4195  $settings = $this->setup->getClient()->getAllSettings();
4196  if ($settings['proxy_status'] == true) {
4197  $this->setup->printProxyStatus($this->setup->client);
4198  }
4199  } else {
4200  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
4201  }
4202  }
4203 
4204  $this->form->setValuesByPost();
4205  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4206 
4207 
4208  $this->displayProxy(true);
4209  }
4210 
4211  protected function background_tasks()
4212  {
4213  $this->setDisplayMode("view");
4214  $this->tpl->addBlockFile("CONTENT", "content", "tpl.std_layout.html", "setup");
4215 
4216  include_once("./setup/classes/class.ilBackgroundTaskTableGUI.php");
4217  $table = new ilBackgroundTaskTableGUI($this->setup);
4218 
4219  $this->tpl->setVariable("SETUP_CONTENT", $this->bt_tabs()->get() . $table->getHTML());
4220  }
4221 
4222 
4226  protected function createBackgroundTasksForm()
4227  {
4228  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
4229 
4230  $form = new ilPropertyFormGUI();
4231  $form->setTitle($this->lng->txt('background_task_configuration'));
4232  $form->addCommandButton('save_background_tasks', $this->lng->txt('save'));
4233  $form->addCommandButton('background_tasks', $this->lng->txt('cancel'));
4234  $form->setFormAction('setup.php?cmd=gateway');
4235 
4236  $rgroup = new ilRadioGroupInputGUI($this->lng->txt("type"), "concurrency");
4237 
4238  $cc = new ilRadioOption($this->lng->txt('sync'), 'sync');
4239  $rgroup->addOption($cc);
4240 
4241  $cc = new ilRadioOption($this->lng->txt('async'), 'async');
4242  $rgroup->addOption($cc);
4243 
4244  $form->addItem($rgroup);
4245 
4246  $i = new ilNumberInputGUI($this->lng->txt('max_number_of_concurrent_tasks'), 'number_of_concurrent_tasks');
4247  $form->addItem($i);
4248 
4249  return $form;
4250  }
4251 
4252  protected function edit_background_tasks()
4253  {
4254  require_once('Services/Form/classes/class.ilPropertyFormGUI.php');
4255  $this->setDisplayMode("view");
4256  $this->tpl->addBlockFile("CONTENT", "content", "tpl.std_layout.html", "setup");
4257 
4258  $form = $this->createBackgroundTasksForm();
4259  $this->fillBackgroundTasksForm($form);
4260 
4261  $this->tpl->setVariable("SETUP_CONTENT", $this->bt_tabs(true)->get() . $form->getHTML());
4262  }
4263 
4267  private function fillBackgroundTasksForm(&$form)
4268  {
4269  $n_of_tasks = $this->setup->ini->readVariable("background_tasks", "number_of_concurrent_tasks");
4270  $sync = $this->setup->ini->readVariable("background_tasks", "concurrency");
4271 
4272  $n_of_tasks = $n_of_tasks ? $n_of_tasks : 5;
4273  $sync = $sync ? $sync : 'sync'; // The default value is sync.
4274 
4275  $form->setValuesByArray([
4276  'concurrency' => $sync,
4277  'number_of_concurrent_tasks' => $n_of_tasks
4278  ]);
4279  }
4280 
4281  public function save_background_tasks()
4282  {
4283  $form = $this->createBackgroundTasksForm();
4284  $form->setValuesByPost();
4285 
4286  // If something goes wrong we display the content with warnings again.
4287  if (!$form->checkInput()) {
4288  $this->tpl->setVariable('CONTENT', $this->bt_tabs(true)->get() . $form->getHTML());
4289  return;
4290  }
4291 
4292  if ($this->saveBTFormToIni($form)) {
4293  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
4294  } else {
4295  ilUtil::sendFailure($this->lng->txt('permission_denied'), true);
4296  }
4297 
4298  ilUtil::redirect("setup.php?cmd=edit_background_tasks");
4299  }
4300 
4301 
4305  private function saveBTFormToIni(&$form)
4306  {
4307  if (!$this->setup->ini->groupExists('background_tasks')) {
4308  $this->setup->ini->addGroup('background_tasks');
4309  $this->setup->ini->write();
4310  }
4311 
4312  $this->setup->ini->setVariable("background_tasks", "concurrency", $form->getInput('concurrency'));
4313  $this->setup->ini->setVariable("background_tasks", "number_of_concurrent_tasks", $form->getInput('number_of_concurrent_tasks'));
4314 
4315  return $this->setup->ini->write();
4316  }
4317 
4318  public function kill_waiting_tasks()
4319  {
4320  $client_id = $_GET['client_id'];
4321  $this->setup->newClient($client_id);
4322  $client = $this->setup->getClient();
4323  $client->provideGlobalDB();
4324 
4325  $persistence = BasicPersistence::instance();
4326  $bucket_ids = $persistence->getBucketIdsByState(State::SCHEDULED);
4327  foreach ($bucket_ids as $bucket_id) {
4328  $persistence->deleteBucketById($bucket_id);
4329  }
4330 
4331  ilUtil::sendSuccess($this->lng->txt('terminated_waiting_tasks'), true);
4332  ilUtil::redirect("setup.php?cmd=background_tasks");
4333  }
4334 } // END class.ilSetupGUI
Class ilMemcacheServerTableGUI.
checkDisplayMode($a_title="")
determine display mode and load according html layout
This class represents an option in a radio group.
performLogin()
Login.
changeDefaultClient()
set defualt client
determineToolsPathInstall()
Determine tools paths.
exit
Definition: login.php:29
const ILIAS_VERSION
getMasterPasswordForm()
return
displayError($a_message)
display error page
jumpToFirstUnfinishedSetupStep()
if setting up a client was not finished, jump back to the first uncompleted setup step ...
displayPreliminaries()
display preliminaries page
$_SESSION["AccountId"]
$result
Tabs GUI.
static _getLongerSettings($a_limit='4000')
get a list of setting records with values loger than a limit
$steps
Definition: latex.php:3
setDisplayMode($a_mode)
set display mode to &#39;view&#39; or &#39;setup&#39; &#39;setup&#39; -> show status panel and (prev/next) navigation buttons...
This class represents a property form user interface.
static _changeValueType($a_new_type='text')
change the type of the value column in the database
$type
Setup GUI class.
static _getValueType()
Get the type of the value column in the database.
displayIni($a_omit_form_init=false)
display setup in step
getRegistrationValues()
Get current values for registration from.
$_GET["client_id"]
changeMasterPassword(\ilPropertyFormGUI $form=null)
display change password form and process form input
This class represents a section header in a property form.
initDbSlaveForm()
Init db slave form.
displayClientOverview()
display client overview panel
Class ilGlobalCacheSettings.
installDatabase()
Install the database.
fillBackgroundTasksForm(&$form)
setInfo($a_info)
Set Information Text.
Class ilServiceReader.
$valid
updateBasicSettings()
Update basic settings form.
displayFinishSetup()
display finish setup page
initDBSelectionForm()
Init db selection form.
displayDatabaseSlave($a_from_save=false)
Display database slave.
$ilCtrlStructureReader
if($_SERVER['argc']< 4) $client
Definition: cron.php:12
showUpdateSteps($a_hotfix=false)
Update database.
toggleClientList()
enable/disable client list on index page
This class represents a checkbox property in a property form.
initSettingsTypeForm()
Init the form to change the settings value type.
static getAllTypes($only_available=true)
getClientDbFormValues($dbupdate=null)
Get current values for client db from.
saveBasicSettings()
Save basic settings form.
initClientLoginForm()
Init client login form.
applyHotfix()
Apply hotfixes.
applyHotfix()
Apply hotfix.
static getSettingFields()
returns the array of setting fields
saveLanguages()
Save languages.
const SESSION_HANDLING_FIXED
static _getShortTimeZoneList()
get short timezone list
saveBTFormToIni(&$form)
displaySessions()
display sessions form and process form input
setInfo($a_info)
Set Info.
determineTools($a_tools=array())
Determine Tools.
displayTools()
display tools
initContactDataForm()
Init contact data form.
displayLanguages()
display language form and process form input
$ilErr
Definition: raiseError.php:18
static isWindows()
check wether the current client system is a windows system
showLongerSettings()
show a list of setting values that are loger than 4000 characters
displayDatabase()
display database form and process form input
determineToolsPath()
Determine tools paths.
global $ilCtrl
Definition: ilias.php:18
__construct()
Constructor.
client management
const DEBUG
setInfo($a_info)
Set Information Text.
Class ilBackgroundTaskTableGUI.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
displayFooter()
page output and set title
setChecked($a_checked)
Set Checked.
static describe($type)
This class represents a hidden form property in a property form.
saveProxy()
Save proxy settings.
This class represents a property in a property form.
setValue($a_value)
Set Value.
displayLogout()
display logout page
saveContact()
Save contact form.
displayMasterSetup($a_omit_init=false)
display master setup form & process form input
initBasicSettingsForm($a_install=false)
Init basic settings form.
getClientIniValues()
Get current values for client ini from.
static getAvailableComponents()
displayHeader()
display header with admin links and language flags
This class represents a number property in a property form.
static getAvailableCoreServices()
Get all available core services.
$_SERVER['HTTP_HOST']
Definition: raiseError.php:10
checkPanelMode()
determine display mode and load correct panel
changeMasterSettings($a_omit_init=false)
display master settings and process form input
SetButtonPrev($a_cmd=0, $a_lng=0)
set previous navigation button
$service
Definition: result.php:17
showHotfixSteps()
Show hotfix steps.
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
cmdAdmin()
process valid commands for admins
This class represents a password property in a property form.
changeAccessMode($a_back)
enable/disable access to a client
displayProxy($a_omit_init=false)
displayDeleteConfirmation()
display delete client confirmation form and process form input
static initDomEvent(ilGlobalTemplateInterface $a_main_tpl=null)
Init YUI DomEvent.
static getAvailableTypes($with_descriptions=true)
Database Update class.
initControlStructureForm()
Init the form to reload the control structure.
$txt
Definition: error.php:13
displayProcessPanel()
display process panel
displayContactData($a_omit_init=false)
display contact data form and process form input
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
performMLogin()
Master Login.
cmdClient()
process valid commands for all clients
displaySubTabs()
Show subtabs.
updateDatabase()
Update database.
initMasterLoginForm()
Init master login form.
saveClientIni()
Save client ini form.
initClientOverviewForm()
Init client overview form.
$password
Definition: cron.php:14
getBasicSettingsValues()
Get current values for basic settings from.
loginClient()
login to a client
This class represents a custom property in a property form.
reloadControlStructure()
reload control structure
Client Management.
This class represents a non editable value in a property form.
saveRegistration()
Save registration form.
displayStartup()
display intro page for the first client installation
static initjQuery(ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
static init(ilGlobalTemplateInterface $a_tpl=null)
Init.
displayStatusPanel()
display status panel
cloneInitForm()
Initialize clone form.
global $ilDB
$ret
Definition: parser.php:6
$DIC
Definition: xapitoken.php:46
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
cmdInstall()
process valid commands for pre-installation status
displayNavButtons()
display navigation buttons
$message
Definition: xapiexit.php:14
displayNIC($a_omit_init=false)
display nic registration form and process form input
const SESSION_HANDLING_LOAD_DEPENDENT
Class ilMemcacheServer.
$client_id
setDbSubtabs($a_subtab_id="db")
Set db subtabs.
setOptionTitle($a_optiontitle)
Set Option Title (optional).
displayClientList()
display client list and process form input
SetButtonNext($a_cmd, $a_lng=0)
set next navigation button
static getInstallableTypes()
static redirect($a_script)
initClientIniForm()
Init client ini form.
initClientDbForm($a_install=true, $dbupdate=null, $db_status=false, $hotfix_available=false, $custom_updates_available=false)
Init client db form.
changeSettingsType()
change the type of the value field in settings table
saveDbSlave()
Save db slave form.
Class ilMemcacheServerFormGUI.
getContactValues()
Get current values for contact from.
bt_tabs($edit=false)
setDisabled($a_disabled)
Set Disabled.
selectDBType()
Select database type.
$_POST["username"]
validateSetup()
validatesetup status again and set access mode of the first client to online
initRegistrationForm($a_mode="edit")
Init registration form.
setRequired($a_required)
Set Required.
const UI_PASSWORD_PLACEHOLDER
Class ilModuleReader.
applyUpdate($a_break=0)
Apply update.
static getAvailableCoreModules()
Get all available core modules.
$ini
Definition: raiseError.php:4
$i
Definition: metadata.php:24
Class ilSetupPasswordManager.
displayLogin($a_omit_minit=false, $a_omit_cinit=false)
display login form and process form
Setup class.