ILIAS  Release_4_2_x_branch Revision 61807
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
4 require_once "./setup/classes/class.ilSetup.php";
5 
15 {
16  var $tpl; // template object
17  var $lng; // language objet
18  var $log; // log object
19 
20  var $btn_prev_on = false; // toggle previous button on/off
21  var $btn_prev_cmd; // command processed when previous button was clicked
22  var $btn_prev_lng; // previous button label
23 
24  var $btn_next_on = false; // toggle NEXT button on/off
25  var $btn_next_cmd; // command processed when next button was clicked
26  var $btn_next_lng; // next button label
27 
28  var $revision; // cvs revision of this script
29  var $version; // cvs version of this script
30  var $lang; // current language (lang_key)
31 
32  var $cmd; // command variable
33  var $display_mode = "view"; // view mode (setup or details)
34 
39  function ilSetupGUI()
40  {
41  global $tpl, $lng;
42 
43  $this->tpl = $tpl;
44  $this->lng = $lng;
45 
46  // CVS - REVISION - DO NOT MODIFY
47  $this->revision = '$Revision: 49124 $';
48  $this->version = "2 ".substr(substr($this->revision,1),0,-2);
49  $this->lang = $this->lng->lang_key;
50 
51  // init setup
52  $this->setup = new ilSetup($_SESSION["auth"],$_SESSION["access_mode"]);
53 
54  // init client object if exists
55  $client_id = ($_GET["client_id"]) ? $_GET["client_id"] : $_SESSION["ClientId"];
56  if ($_POST["client_id"] != "")
57  {
58  $client_id = $_POST["client_id"];
59  }
60 
61 /*if ($_POST["client_id"] == "")
62 {
63 echo "<br>+".$_GET["client_id"];
64 echo "<br>+".$_POST["client_id"];
65 echo "<br>+".$_SESSION["ClientId"];
66 echo "<br>+".$client_id;
67 }*/
68  // for security
69  if (!$this->setup->isAdmin() and $client_id != $_SESSION["ClientId"])
70  {
71  $client_id = $_SESSION["ClientId"];
72  }
73 
74  $this->client_id = $client_id;
75 
76  $this->setup->ini_client_exists = $this->setup->newClient($client_id);
77  $this->setup->getClient()->status = $this->setup->getStatus($client_id);
78 
79  // determine command
80  if (($this->cmd = $_GET["cmd"]) == "gateway")
81  {
82  // surpress warning if POST is not set
83  @$this->cmd = key($_POST["cmd"]);
84  }
85 
86  // determine display mode here
87  // TODO: depending on previous setting (session)
88  // 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)
89  if ($this->setup->isAuthenticated() and !$this->setup->getClient()->status["finish"]["status"] and $this->cmd != "clientlist" and $this->cmd != "")
90  {
91  $this->setDisplayMode("setup");
92  }
93  else
94  {
95  $this->setDisplayMode($_SESSION["display_mode"]);
96  }
97 
98  // output starts here
99 
100 
101  // main cmd handling
102  if (!$this->setup->isAuthenticated() or !$this->setup->isInstalled())
103  {
104  // check for first time installation or migrate an old one first
105  if (!$this->setup->isInstalled() or !($this->setup->ini->readVariable("clients","path")))
106  {
107  $this->cmdInstall();
108  }
109  else
110  {
111  if ($this->cmd == "performLogin" || $this->cmd == "performMLogin")
112  {
113  $cmd = $this->cmd;
114  $this->$cmd();
115  }
116  else
117  {
118  $this->displayLogin();
119  }
120  }
121  }
122  else
123  {
124  if ($this->setup->isAdmin())
125  {
126  $this->cmdAdmin();
127  }
128  else
129  {
130  $this->cmdClient();
131  }
132  }
133 
134  // display header
135  $this->displayHeader();
136 
137  if (DEBUG)
138  {
139  echo "cmd: ".$this->cmd." | access: ".$this->setup->access_mode." | display: ".$this->display_mode;
140  var_dump($this->setup->getClient()->status);
141  }
142 
143  // display footer
144  $this->displayFooter();
145 
146  // end output
147 
148  } // end constructor
149 
150  // cmd subsets
151 
155  function cmdInstall()
156  {
157  $cmd = $this->cmd;
158  switch ($this->cmd)
159  {
160  case NULL:
161  case "preliminaries":
162  $this->setup->checkPreliminaries();
163  $this->displayPreliminaries();
164  break;
165 
166  case "install":
167  $this->displayMasterSetup();
168  break;
169 
170  case "determineToolsPathInstall":
171  $this->determineToolsPathInstall();
172  break;
173 
174  case "saveBasicSettings":
175  $this->$cmd();
176  break;
177 
178  default:
179  $this->displayError($this->lng->txt("unknown_command"));
180  break;
181  }
182  }
183 
187  function cmdAdmin()
188  {
189  $cmd = $this->cmd;
190 
191  switch ($this->cmd)
192  {
193  case NULL:
194  case "clientlist":
195  $this->setDisplayMode("view");
196  $this->displayClientList();
197  $this->active_tab = "clientlist";
198  break;
199 
200  case "changepassword":
201  $this->setDisplayMode("view");
202  $this->changeMasterPassword();
203  $this->active_tab = "password";
204  break;
205 
206  case "mastersettings":
207  $this->setDisplayMode("view");
208  $this->changeMasterSettings();
209  $this->active_tab = "basicsettings";
210  break;
211 
212  case "determineToolsPath":
213  $this->setDisplayMode("view");
214  $this->determineToolsPath();
215  break;
216 
217  case "changedefault":
218  $this->changeDefaultClient();
219  break;
220 
221  case "newclient":
222  $this->cmd = "selectdb";
223  $this->setDisplayMode("setup");
224  $this->setup->ini_client_exists = $this->setup->newClient();
225  $this->selectDBType();
226  break;
227 
228  case "selectdbtype":
229  case "displayIni":
230  $this->cmd = "ini";
231  $this->setDisplayMode("setup");
232  //$this->setup->ini_client_exists = $this->setup->newClient($this->client_id);
233  $this->displayIni();
234  break;
235 
236  case "startup":
237  $this->setDisplayMode("setup");
238  $this->setup->ini_client_exists = $this->setup->newClient();
239  $this->displayStartup();
240  break;
241 
242  case "delete":
243  $this->setDisplayMode("view");
244  $this->displayDeleteConfirmation();
245  break;
246 
247  case "togglelist":
248  $this->setDisplayMode("view");
249  $this->toggleClientList();
250  break;
251 
252  case "preliminaries":
253  $this->setup->checkPreliminaries();
254  $this->displayPreliminaries();
255  $this->active_tab = "preliminaries";
256  break;
257 
258  case "updateBasicSettings":
259  case "performLogin":
260  case "performMLogin":
261  $this->$cmd();
262  break;
263 
264  default:
265  $this->cmdClient();
266  break;
267  }
268  }
269 
273  function cmdClient()
274  {
275  $cmd = $this->cmd;
276  switch ($this->cmd)
277  {
278  case NULL:
279  case "view":
280  if ($this->setup->getClient()->db_installed)
281  {
282  $this->setDisplayMode("view");
283  $this->displayClientOverview();
284  }
285  else
286  {
287  $this->cmd = "db";
288  $this->displayDatabase();
289  }
290  break;
291 
292  case "ini":
293  // only allow access to ini if db does not exist yet
294  //if ($this->setup->getClient()->db_installed)
295  //{
296  // $this->cmd = "db";
297  // $this->displayDatabase();
298  //}
299  //else
300  //{
301  $this->displayIni();
302  //}
303  break;
304 
305  case "db":
306  $this->displayDatabase();
307  break;
308 
309  case "sess":
310  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "sess" and $this->setup->error === true)
311  {
313  }
314  else
315  {
316  $this->displaySessions();
317  }
318  break;
319 
320  case "lang":
321  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->setup->error === true)
322  {
324  }
325  else
326  {
327  $this->displayLanguages();
328  }
329  break;
330 
331  case "contact":
332  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "contact")
333  {
335  }
336  else
337  {
338  $this->displayContactData();
339  }
340  break;
341 
342  case "nic":
343  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "nic")
344  {
346  }
347  else
348  {
349  $this->displayNIC();
350  }
351  break;
352 
353  case "finish":
354  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "finish")
355  {
357  }
358  else
359  {
360  $this->displayFinishSetup();
361  }
362  break;
363 
364  case "changeaccess":
365  $this->changeAccessMode($_GET["back"]);
366  break;
367 
368  case "logout":
369  $this->displayLogout();
370  break;
371 
372  case "login":
373  session_destroy();
374  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
375  break;
376 
377  case "login_new":
378  if ($this->setup->getClient()->ini->readVariable("client","access") != "1")
379  {
380  $this->setup->getClient()->ini->setVariable("client","access","1");
381  $this->setup->getClient()->ini->write();
382  }
383 
384  session_destroy();
385  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
386  break;
387 
388  case "tools":
389  $this->displayTools();
390  break;
391 
392  case "reloadStructure":
393  $this->reloadControlStructure();
394  break;
395 
396  case "saveClientIni":
397  case "installDatabase":
398  case "displayDatabase":
399  case "updateDatabase":
400  case "saveLanguages":
401  case "saveContact":
402  case "displayContactData":
403  case "displayNIC":
404  case "saveRegistration":
405  case "applyHotfix":
406  case "changeSettingsType":
407  case "showLongerSettings":
408  $this->$cmd();
409  break;
410 
411  default:
412  $this->displayError($this->lng->txt("unknown_command"));
413  break;
414  }
415  }
416 
417  // end cmd subsets
418 
422 
431  function setDisplayMode($a_mode)
432  {
433  // security
434  if ($a_mode != "view" and $a_mode != "setup")
435  {
436  return false;
437  }
438 
439  $this->display_mode = $a_mode;
440  $_SESSION["display_mode"] = $this->display_mode;
441 
442  return true;
443  }
444 
448  function displayHeader()
449  {
450  $languages = $this->lng->getLanguages();
451 
452  $count = (int) round(count($languages) / 2);
453  $num = 1;
454 
455  foreach ($languages as $lang_key)
456  {
457  if ($num === $count)
458  {
459  $this->tpl->touchBlock("lng_new_row");
460  }
461 
462  $this->tpl->setCurrentBlock("languages");
463  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
464  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
465  $this->tpl->setVariable("LANG_ICON", $lang_key);
466  $this->tpl->setVariable("LANG_KEY", $lang_key);
467  $this->tpl->setVariable("BORDER", 0);
468  $this->tpl->setVariable("VSPACE", 0);
469  $this->tpl->parseCurrentBlock();
470 
471  $num++;
472  }
473 
474  if (count($languages) % 2)
475  {
476  $this->tpl->touchBlock("lng_empty_cell");
477  }
478 
479  if ($this->cmd != "logout" and $this->setup->isInstalled())
480  {
481  // add client link
482  if ($this->setup->isAdmin())
483  {
484  if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
485  {
486  $this->tpl->setCurrentBlock("add_client");
487  $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
488  $this->tpl->parseCurrentBlock();
489  }
490 
491  // client list link
492  $class = ($this->active_tab == "clientlist")
493  ? "ilSMActive"
494  : "ilSMInactive";
495  $this->tpl->setCurrentBlock("display_list");
496  $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
497  $this->tpl->setVariable("TAB_CLASS", $class);
498  $this->tpl->parseCurrentBlock();
499 
500  // edit paths link
501  $class = ($this->active_tab == "basicsettings")
502  ? "ilSMActive"
503  : "ilSMInactive";
504  $this->tpl->setCurrentBlock("edit_pathes");
505  $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
506  $this->tpl->setVariable("TAB_CLASS", $class);
507  $this->tpl->parseCurrentBlock();
508 
509  // preliminaries
510  $class = ($this->active_tab == "preliminaries")
511  ? "ilSMActive"
512  : "ilSMInactive";
513  $this->tpl->setCurrentBlock("preliminaries");
514  $this->tpl->setVariable("TXT_PRELIMINARIES",$this->lng->txt("preliminaries"));
515  $this->tpl->setVariable("TAB_CLASS", $class);
516  $this->tpl->parseCurrentBlock();
517 
518  // change password link
519  $class = ($this->active_tab == "password")
520  ? "ilSMActive"
521  : "ilSMInactive";
522  $this->tpl->setCurrentBlock("change_password");
523  $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
524  $this->tpl->setVariable("TAB_CLASS", $class);
525  $this->tpl->parseCurrentBlock();
526  }
527 
528  // logout link
529  if ($this->setup->isAuthenticated())
530  {
531  $this->tpl->setCurrentBlock("logout");
532  $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
533  $this->tpl->parseCurrentBlock();
534  }
535  }
536 
537  $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
538  $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
539  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
540  $this->tpl->setVariable("PAGETITLE","Setup");
541  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
542  $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
543  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","./css/setup.css");
544  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
545  $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
546  $this->tpl->setVariable("VERSION", $this->version);
547  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
548  $this->tpl->setVariable("LANG", $this->lang);
549  }
550 
554  function displayFooter()
555  {
556  // footer (not really)
557  if ($this->cmd != "logout")
558  {
559  if ($this->setup->ini_ilias_exists and $this->display_mode == "setup" and $this->setup->getClient()->getId() != "")
560  {
561  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
562  }
563  elseif ($this->setup->isAdmin())
564  {
565  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
566  }
567 
568  $this->displayNavButtons();
569  }
570 
571  $this->tpl->show();
572  }
573 
579  function displayNavButtons()
580  {
581  if (!$this->btn_prev_on and !$this->btn_next_on)
582  {
583  return false;
584  }
585 
586  $ntpl = new ilTemplate("tpl.navbuttons.html", true, true, "setup");
587  //$this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html", "setup");
588 
589  $ntpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
590 
591  if ($this->btn_prev_on)
592  {
593  $ntpl->setCurrentBlock("btn_back");
594  $ntpl->setVariable("TXT_PREV", $this->btn_prev_lng);
595  $ntpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
596  $ntpl->parseCurrentBlock();
597  }
598 
599  if ($this->btn_next_on)
600  {
601  $ntpl->setCurrentBlock("btn_forward");
602  $ntpl->setVariable("TXT_NEXT", $this->btn_next_lng);
603  $ntpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
604  $ntpl->parseCurrentBlock();
605  }
606 
607  $nav_html = $ntpl->get();
608  $this->tpl->setVariable("NAVBUTTONS", $nav_html);
609  if (!$this->no_second_nav)
610  {
611  $this->tpl->setVariable("NAVBUTTONS2", $nav_html);
612  }
613  return true;
614  }
615 
622  function SetButtonPrev($a_cmd = 0,$a_lng = 0)
623  {
624  $this->btn_prev_on = true;
625  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
626  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("prev");
627  }
628 
635  function SetButtonNext($a_cmd,$a_lng = 0)
636  {
637  $this->btn_next_on = true;
638  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
639  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next");
640  }
641 
645 
650  {
651  $this->checkDisplayMode();
652 
653  // disable/enable button
654  $btpl = new ilTemplate("tpl.buttons.html", true, true, "setup");
655  $btpl->setCurrentBlock("btn");
656  $btpl->setVariable("CMD", "changeaccess");
657  $access_button = ($this->setup->getClient()->status["access"]["status"]) ? "disable" : "enable";
658  $btpl->setVariable("TXT", $this->lng->txt($access_button));
659  $btpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
660  $btpl->parseCurrentBlock();
661  $this->tpl->setVariable("BUTTONS", $btpl->get());
662 
663  $this->initClientOverviewForm();
664  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
665 
666  $this->displayStatusPanel();
667  }
668 
672  public function initClientOverviewForm()
673  {
674  global $lng, $ilCtrl;
675 
676  $settings = $this->setup->getClient()->getAllSettings();
677 
678  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
679  $this->form = new ilPropertyFormGUI();
680 
681  $this->form->setTitle($lng->txt("client_info"));
682 
683  // installation name
684  $ne = new ilNonEditableValueGUI($lng->txt("inst_name"), "inst_name");
685  $ne->setValue(($this->setup->getClient()->getName())
686  ? $this->setup->getClient()->getName()
687  : "&lt;".$this->lng->txt("no_client_name")."&gt;");
688  $ne->setInfo($this->setup->getClient()->getDescription());
689  $this->form->addItem($ne);
690 
691  // client id
692  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "client_id");
693  $ne->setValue($this->setup->getClient()->getId());
694  $this->form->addItem($ne);
695 
696  // nic id
697  $ne = new ilNonEditableValueGUI($lng->txt("ilias_nic_id"), "nic_id");
698  $ne->setValue(($this->setup->getClient()->db_installed)
699  ? $settings["inst_id"]
700  : $txt_no_database);
701  $this->form->addItem($ne);
702 
703  // database version
704  $ne = new ilNonEditableValueGUI($lng->txt("db_version"), "db_vers");
705  $ne->setValue(($this->setup->getClient()->db_installed)
706  ? $settings["db_version"]
707  : $txt_no_database);
708  $this->form->addItem($ne);
709 
710  // access status
711  $ne = new ilNonEditableValueGUI($lng->txt("access_status"), "status");
712  //$access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->setup->getClient()->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
713  $access_status = ($this->setup->getClient()->status["access"]["status"]) ? "online" : "disabled";
714  $ne->setValue($this->lng->txt($access_status).$access_link);
715  $this->form->addItem($ne);
716 
717  // server information
718  $sh = new ilFormSectionHeaderGUI();
719  $sh->setTitle($this->lng->txt("server_info"));
720  $this->form->addItem($sh);
721 
722  // ilias version
723  $ne = new ilNonEditableValueGUI($lng->txt("ilias_version"), "il_vers");
724  $ne->setValue(ILIAS_VERSION);
725  $this->form->addItem($ne);
726 
727  // host
728  $ne = new ilNonEditableValueGUI($lng->txt("host"), "host");
729  $ne->setValue($_SERVER["SERVER_NAME"]);
730  $this->form->addItem($ne);
731 
732  // ip address and port
733  $ne = new ilNonEditableValueGUI($lng->txt("ip_address")." & ".
734  $lng->txt("port"));
735  $ne->setValue($_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"]);
736  $this->form->addItem($ne);
737 
738  // server software
739  $ne = new ilNonEditableValueGUI($lng->txt("server_software"), "server_softw");
740  $ne->setValue($_SERVER["SERVER_SOFTWARE"]);
741  $this->form->addItem($ne);
742 
743  // http path
744  $ne = new ilNonEditableValueGUI($lng->txt("http_path"), "http_path");
745  $ne->setValue(ILIAS_HTTP_PATH);
746  $this->form->addItem($ne);
747 
748  // absolute path
749  $ne = new ilNonEditableValueGUI($lng->txt("absolute_path"), "absolute_path");
751  $this->form->addItem($ne);
752 
753  // third party tools
754  $sh = new ilFormSectionHeaderGUI();
755  $sh->setTitle($this->lng->txt("3rd_party_software"));
756  $this->form->addItem($sh);
757 
758  $tools = array("convert", "zip", "unzip", "java", "htmldoc", "mkisofs");
759 
760  foreach ($tools as $tool)
761  {
762  // tool
763  $ne = new ilNonEditableValueGUI($lng->txt($tool."_path"), $tool."_path");
764  $p = $this->setup->ini->readVariable("tools", $tool);
765  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
766  $this->form->addItem($ne);
767  }
768 
769  // latex
770  $ne = new ilNonEditableValueGUI($lng->txt("url_to_latex"), "latex_url");
771  $p = $this->setup->ini->readVariable("tools", "latex"); // #13109
772  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
773  $this->form->addItem($ne);
774 
775  // virus scanner
776  $ne = new ilNonEditableValueGUI($lng->txt("virus_scanner"), "vscan");
777  $ne->setValue($this->setup->ini->readVariable("tools","vscantype"));
778  $this->form->addItem($ne);
779 
780  // scan command
781  $ne = new ilNonEditableValueGUI($lng->txt("scan_command"), "scan");
782  $p = $this->setup->ini->readVariable("tools","scancommand");
783  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
784  $this->form->addItem($ne);
785 
786  // clean command
787  $ne = new ilNonEditableValueGUI($lng->txt("clean_command"), "clean");
788  $p = $this->setup->ini->readVariable("tools","cleancommand");
789  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
790  $this->form->addItem($ne);
791 
792  $this->form->setFormAction("setup.php?cmd=gateway");
793  }
794 
798 
803  {
804  $OK = "<font color=\"green\"><strong>OK</strong></font>";
805  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
806 
807  $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html", "setup");
808 
809  $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
810  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
811  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
812  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
813  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
814  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
815  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
816 
817  $server_os = php_uname();
818  $server_web = $_SERVER["SERVER_SOFTWARE"];
819  $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
820 
821  if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
822  {
823  $env_comment = $this->lng->txt("env_ok");
824  }
825  else
826  {
827  $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
828  }
829 
830  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
831  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
832  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
833 
834  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
835  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
836 
837  $preliminaries = array("php", "root", "folder_create",
838  "cookies_enabled", "dom", "xsl", "gd", "memory");
839  foreach ($preliminaries as $preliminary)
840  {
841  $this->tpl->setCurrentBlock("preliminary");
842  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_".$preliminary));
843  if ($this->setup->preliminaries_result[$preliminary]["status"] == true)
844  {
845  $this->tpl->setVariable("STATUS_PRE", $OK);
846  }
847  else
848  {
849  $this->tpl->setVariable("STATUS_PRE", $FAILED);
850  }
851  $this->tpl->setVariable("COMMENT_PRE", $this->setup->preliminaries_result[$preliminary]["comment"]);
852  $this->tpl->parseCurrentBlock();
853  }
854 
855  // summary
856  if ($this->setup->preliminaries === true)
857  {
858  if ($this->setup->isInstalled())
859  {
860  $cmd = "mastersettings";
861  }
862  else
863  {
864  $cmd = "install";
865  }
866  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
867 //echo "-".$this->display_mode."-";
868  $this->setButtonNext($cmd,$btn_text);
869  }
870  else
871  {
872  $this->tpl->setCurrentBlock("premessage");
873  $this->tpl->setVariable("TXT_PRE_ERR", sprintf($this->lng->txt("pre_error"),
874  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"));
875  $this->tpl->parseCurrentBlock();
876  }
877  }
878 
882 
886  function displayMasterSetup($a_omit_init = false)
887  {
888  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
889  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
890  $this->tpl->setVariable("TXT_INFO",
891  $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
892 
893  $this->setButtonPrev("preliminaries");
894 
895  if ($this->setup->isInstalled())
896  {
897  $this->setButtonNext("list");
898  }
899 
900  if (!$a_omit_init)
901  {
902  $this->initBasicSettingsForm(true);
903  }
904  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
905  }
906 
910  function changeMasterSettings($a_omit_init = false)
911  {
912  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
913  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
914  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
915 
916  $this->btn_next_on = true;
917  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
918  $this->btn_next_cmd = "newclient";
919 
920  if (!$a_omit_init)
921  {
922  $this->initBasicSettingsForm();
923  $this->getBasicSettingsValues();
924  }
925  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
926  }
927 
931  public function initBasicSettingsForm($a_install = false)
932  {
933  global $lng, $ilCtrl;
934 
935  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
936  $this->form = new ilPropertyFormGUI();
937 
938  // webspace dir
939  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
940  if ($a_install)
941  {
942  $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
943  }
944  $cwd = ilUtil::isWindows()
945  ? str_replace("\\", "/", getcwd())
946  : getcwd();
947 
948  $ne->setValue($cwd."/data");
949  $this->form->addItem($ne);
950 
951  // data dir
952  if ($a_install)
953  {
954  $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
955  $ti->setInfo($lng->txt("data_directory_info"));
956  $ti->setRequired(true);
957  $this->form->addItem($ti);
958  }
959  else
960  {
961  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
962  $this->form->addItem($ne);
963  }
964 
965  $lvext = (ilUtil::isWindows())
966  ? "_win"
967  : "";
968 
969 
970  // logging
971  $sh = new ilFormSectionHeaderGUI();
972  $sh->setTitle($lng->txt("logging"));
973  $this->form->addItem($sh);
974 
975  // path to log file
976  $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
977  $ti->setInfo($lng->txt("log_path_comment".$lvext));
978  $this->form->addItem($ti);
979 
980  // disable logging
981  $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
982  $this->form->addItem($cb);
983 
984  // server settings
985  $sh = new ilFormSectionHeaderGUI();
986  $sh->setTitle($lng->txt("server_settings"));
987  $this->form->addItem($sh);
988 
989  // time zone
990  include_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
991  $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
992  $si->setOptions(array_merge(
993  array("" => "-- ".$lng->txt("please_select")." --"),
995  $si->setRequired(true);
996  $this->form->addItem($si);
997 
998  // required 3rd party tools
999  $sh = new ilFormSectionHeaderGUI();
1000  $sh->setTitle($lng->txt("3rd_party_software_req"));
1001  $this->form->addItem($sh);
1002 
1003  // convert path
1004  $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
1005  $ti->setInfo($lng->txt("convert_path_comment".$lvext));
1006  $ti->setRequired(true);
1007  $this->form->addItem($ti);
1008 
1009  // zip path
1010  $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
1011  $ti->setInfo($lng->txt("zip_path_comment".$lvext));
1012  $ti->setRequired(true);
1013  $this->form->addItem($ti);
1014 
1015  // unzip path
1016  $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
1017  $ti->setInfo($lng->txt("unzip_path_comment".$lvext));
1018  $ti->setRequired(true);
1019  $this->form->addItem($ti);
1020 
1021  // optional 3rd party tools
1022  $sh = new ilFormSectionHeaderGUI();
1023  $sh->setTitle($lng->txt("3rd_party_software_opt"));
1024  $this->form->addItem($sh);
1025 
1026  // java path
1027  $ti = new ilTextInputGUI($lng->txt("java_path"), "java_path");
1028  $ti->setInfo($lng->txt("java_path_comment".$lvext));
1029  $this->form->addItem($ti);
1030 
1031  // htmldoc path
1032  $ti = new ilTextInputGUI($lng->txt("htmldoc_path"), "htmldoc_path");
1033  $ti->setInfo($lng->txt("htmldoc_path_comment".$lvext));
1034  $this->form->addItem($ti);
1035 
1036  // mkisofs path
1037  $ti = new ilTextInputGUI($lng->txt("mkisofs_path"), "mkisofs_path");
1038  $ti->setInfo($lng->txt("mkisofs_path_comment"));
1039  $this->form->addItem($ti);
1040 
1041  // latex
1042  $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
1043  $ti->setInfo($lng->txt("latex_url_comment"));
1044  $this->form->addItem($ti);
1045 
1046  // virus scanner
1047  $options = array(
1048  "none" => $lng->txt("none"),
1049  "sophos" => $lng->txt("sophos"),
1050  "antivir" => $lng->txt("antivir"),
1051  "clamav" => $lng->txt("clamav")
1052  );
1053  $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
1054  $si->setOptions($options);
1055  $this->form->addItem($si);
1056 
1057  // scan command
1058  $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
1059  $this->form->addItem($ti);
1060 
1061  // clean command
1062  $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
1063  $this->form->addItem($ti);
1064 
1065  if ($a_install)
1066  {
1067  $sh = new ilFormSectionHeaderGUI();
1068  $sh->setTitle($lng->txt("master_password"));
1069  $this->form->addItem($sh);
1070 
1071  // password
1072  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1073  $pi->setRequired(true);
1074  $pi->setSkipSyntaxCheck(true);
1075  $pi->setInfo($lng->txt("password_info"));
1076  $this->form->addItem($pi);
1077  }
1078 
1079  if ($a_install)
1080  {
1081  $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
1082  }
1083  else
1084  {
1085  $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
1086  $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
1087  }
1088 
1089  $this->form->setTitle($lng->txt("data_directories"));
1090  $this->form->setFormAction("setup.php?cmd=gateway");
1091 
1092  if ($a_install)
1093  {
1094  $det = $this->determineTools();
1095  $this->form->setValuesByArray($det);
1096  }
1097 
1098  }
1099 
1103  public function getBasicSettingsValues()
1104  {
1105  $values = array();
1106 
1107  $values["webspace_dir"] = getcwd()."/data";
1108  $values["data_dir"] = $this->setup->ini->readVariable("clients","datadir");
1109  $values["convert_path"] = $this->setup->ini->readVariable("tools","convert");
1110  $values["zip_path"] = $this->setup->ini->readVariable("tools","zip");
1111  $values["unzip_path"] = $this->setup->ini->readVariable("tools","unzip");
1112  $values["java_path"] = $this->setup->ini->readVariable("tools","java");
1113  $values["htmldoc_path"] = $this->setup->ini->readVariable("tools","htmldoc");
1114  $values["mkisofs_path"] = $this->setup->ini->readVariable("tools","mkisofs");
1115  $values["latex_url"] = $this->setup->ini->readVariable("tools","latex");
1116  $values["fop_path"] = $this->setup->ini->readVariable("tools","fop");
1117  $values["vscanner_type"] = $this->setup->ini->readVariable("tools", "vscantype");
1118  $values["scan_command"] = $this->setup->ini->readVariable("tools", "scancommand");
1119  $values["clean_command"] = $this->setup->ini->readVariable("tools", "cleancommand");
1120  $values["log_path"] = $this->setup->ini->readVariable("log","path")."/".
1121  $this->setup->ini->readVariable("log","file");
1122  $values["chk_log_status"] = !$this->setup->ini->readVariable("log","enabled");
1123  $values["time_zone"] = $this->setup->ini->readVariable("server", "timezone");
1124 
1125  $this->form->setValuesByArray($values);
1126  }
1127 
1131  public function saveBasicSettings()
1132  {
1133  global $tpl, $lng, $ilCtrl;
1134 
1135  $this->initBasicSettingsForm(true);
1136 
1137  if ($this->form->checkInput())
1138  {
1139  // correct paths on windows
1140  if (ilUtil::isWindows())
1141  {
1142  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1143  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1144  foreach ($fs as $f)
1145  {
1146  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1147  }
1148  }
1149 
1150  $_POST["setup_pass"] = $_POST["password"];
1151  $_POST["setup_pass2"] = $_POST["password_retype"];
1152  if (!$this->setup->checkDataDirSetup($_POST))
1153  {
1154  $i = $this->form->getItemByPostVar("datadir_path");
1155  $i->setAlert($this->lng->txt($this->setup->getError()));
1156  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1157  }
1158  else if (!$this->setup->checkLogSetup($_POST))
1159  {
1160  $i = $this->form->getItemByPostVar("log_path");
1161  $i->setAlert($this->lng->txt($this->setup->getError()));
1162  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1163  }
1164  else if (!$this->setup->checkPasswordSetup($_POST))
1165  {
1166  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1167  }
1168  else if (!$this->setup->saveMasterSetup($_POST))
1169  {
1170  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1171  }
1172  else
1173  {
1174  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1175  ilUtil::redirect("setup.php?cmd=mastersettings");
1176  }
1177  }
1178 
1179  $this->form->setValuesByPost();
1180  $this->displayMasterSetup(true);
1181  }
1182 
1186  public function updateBasicSettings()
1187  {
1188  global $tpl, $lng, $ilCtrl;
1189 
1190  $this->initBasicSettingsForm();
1191 
1192  if ($this->form->checkInput())
1193  {
1194  if (ilUtil::isWindows())
1195  {
1196  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1197  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1198  foreach ($fs as $f)
1199  {
1200  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1201  }
1202  }
1203 
1204  if (!$this->setup->checkLogSetup($_POST))
1205  {
1206  $i = $this->form->getItemByPostVar("log_path");
1207  $i->setAlert($this->lng->txt($this->setup->getError()));
1208  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1209  }
1210  else if (!$this->setup->updateMasterSettings($_POST))
1211  {
1212  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1213  }
1214  else
1215  {
1216  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1217  ilUtil::redirect("setup.php?cmd=mastersettings");
1218  }
1219  }
1220 
1221  $this->form->setValuesByPost();
1222  $this->changeMasterSettings(true);
1223  }
1224 
1228 
1232  function loginClient()
1233  {
1234  session_destroy();
1235 
1236  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
1237  }
1238 
1242  function displayLogin($a_omit_minit = false, $a_omit_cinit = false)
1243  {
1244  global $lng;
1245 
1246  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
1247 
1248  if ($a_omit_minit)
1249  {
1250  $m_form = $this->form->getHTML();
1251  }
1252  if (!$a_omit_cinit)
1253  {
1254  $this->initClientLoginForm();
1255  }
1256  $cl_form = $this->form->getHTML();
1257  if (!$a_omit_minit)
1258  {
1259  $this->initMasterLoginForm();
1260  $m_form = $this->form->getHTML();
1261  }
1262  $this->tpl->setVariable("SETUP_CONTENT", $cl_form."<br>".$m_form);
1263  $this->tpl->setVariable("TXT_HEADER", $lng->txt("login"));
1264  }
1265 
1269  public function performMLogin()
1270  {
1271  $this->initMasterLoginForm();
1272  if ($this->form->checkInput())
1273  {
1274  $i = $this->form->getItemByPostVar("mpassword");
1275  if (!$this->setup->loginAsAdmin($_POST["mpassword"]))
1276  {
1277  $i->setAlert($this->lng->txt("login_invalid"));
1278  }
1279  else
1280  {
1281  // everything ok -> we are authenticated
1282  ilUtil::redirect("setup.php");
1283  }
1284  }
1285 
1286  // something wrong -> display login again
1287  $this->form->setValuesByPost();
1288  $this->displayLogin(true);
1289  }
1290 
1294  function performLogin()
1295  {
1296  $this->initClientLoginForm();
1297  if ($this->form->checkInput())
1298  {
1299  $i = $this->form->getItemByPostVar("password");
1300  if (!$this->setup->loginAsClient(
1301  array("client_id" => $_POST["client_id"],
1302  "username" => $_POST["username"], "password" => $_POST["password"])))
1303  {
1304  $i->setAlert($this->setup->getError());
1305  }
1306  else
1307  {
1308  // everything ok -> we are authenticated
1309  ilUtil::redirect("setup.php");
1310  }
1311  }
1312 
1313  // something wrong -> display login again
1314  $this->form->setValuesByPost();
1315  $this->displayLogin(false, true);
1316  }
1317 
1321  public function initClientLoginForm()
1322  {
1323  global $lng, $ilCtrl;
1324 
1325  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1326  $this->form = new ilPropertyFormGUI();
1327 
1328  // client id
1329  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1330  $ti->setMaxLength(32);
1331  $ti->setSize(20);
1332  $this->form->addItem($ti);
1333 
1334  // username
1335  $ti = new ilTextInputGUI($lng->txt("username"), "username");
1336  $ti->setSize(20);
1337  $this->form->addItem($ti);
1338 
1339  // password
1340  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1341  $pi->setSize(20);
1342  $pi->setRetype(false);
1343  $pi->setSkipSyntaxCheck(true);
1344  $this->form->addItem($pi);
1345 
1346  $this->form->addCommandButton("performLogin", $lng->txt("login"));
1347 
1348  $this->form->setTitle($lng->txt("client_login"));
1349  $this->form->setFormAction("setup.php?cmd=gateway");
1350  }
1351 
1355  public function initMasterLoginForm()
1356  {
1357  global $lng, $ilCtrl;
1358 
1359  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1360  $this->form = new ilPropertyFormGUI();
1361 
1362  // password
1363  $pi = new ilPasswordInputGUI($lng->txt("password"), "mpassword");
1364  $pi->setSize(20);
1365  $pi->setRetype(false);
1366  $pi->setSkipSyntaxCheck(true);
1367  $this->form->addItem($pi);
1368 
1369  $this->form->addCommandButton("performMLogin", $lng->txt("login"));
1370 
1371  $this->form->setTitle($lng->txt("admin_login"));
1372  $this->form->setFormAction("setup.php?cmd=gateway");
1373 
1374  }
1375 
1379 
1384  {
1385  $_SESSION["ClientId"] = "";
1386 
1387  $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html", "setup");
1388  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1389  ilUtil::sendInfo();
1390 
1391  // common
1392  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("list_clients"));
1393  $this->tpl->setVariable("TXT_LISTSTATUS",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1394  $this->tpl->setVariable("TXT_TOGGLELIST",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1395 
1396  include_once("./setup/classes/class.ilClientListTableGUI.php");
1397  $tab = new ilClientListTableGUI($this->setup);
1398  $this->tpl->setVariable("CLIENT_LIST", $tab->getHTML());
1399 
1400  // create new client button
1401  $this->btn_next_on = true;
1402  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
1403  $this->btn_next_cmd = "newclient";
1404  }
1405 
1410  {
1411  $_POST = $this->determineTools($_POST);
1412  $this->updateBasicSettings();
1413  }
1414 
1419  {
1420  $this->displayMasterSetup(true);
1421  }
1422 
1426  function determineTools($a_tools = "")
1427  {
1428  $cwd = ilUtil::isWindows()
1429  ? str_replace("\\", "/", getcwd())
1430  : getcwd();
1431  if (!ilUtil::isWindows())
1432  {
1433  $tools = array("convert" => "convert",
1434  "zip" => "zip", "unzip" => "unzip",
1435  "java" => "java", "htmldoc" => "htmldoc", "mkisofs" => "mkisofs");
1436  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin", "/usr/bin");
1437  }
1438  else
1439  {
1440  $tools = array("convert" => "convert.exe",
1441  "zip" => "zip.exe", "unzip" => "unzip.exe");
1442  $dirs = array($cwd."/Services/Windows/bin32/zip",
1443  $cwd."/Services/Windows/bin32/unzip",
1444  $cwd."/Services/Windows/bin32/convert");
1445  }
1446  foreach($tools as $k => $tool)
1447  {
1448  // try which command
1449  unset($ret);
1450  @exec("which ".$tool, $ret);
1451  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
1452  {
1453  $a_tools[$k."_path"] = $ret[0];
1454  continue;
1455  }
1456 
1457  // try common directories
1458  foreach($dirs as $dir)
1459  {
1460  if (@is_file($dir."/".$tool))
1461  {
1462  $a_tools[$k."_path"] = $dir."/".$tool;
1463  continue;
1464  }
1465  }
1466  }
1467  return $a_tools;
1468  }
1469 
1470 
1474 
1479  function selectDBType()
1480  {
1481  $this->checkDisplayMode("create_new_client");
1482 
1483 
1484 if (true)
1485 {
1486  $this->initDBSelectionForm();
1487  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1488 }
1489 else
1490 {
1491  // output
1492 
1493  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_select_db.html", "setup");
1494 
1495  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1496  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1497 
1498  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
1499  $this->tpl->setVariable("TXT_DB_SELECTION", $this->lng->txt("db_selection"));
1500 }
1501  if ($this->setup->getClient()->status["ini"]["status"])
1502  {
1503  $this->setButtonNext("db");
1504  }
1505 
1506  $this->checkPanelMode();
1507  }
1508 
1512  public function initDBSelectionForm()
1513  {
1514  global $lng, $ilCtrl;
1515 
1516  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1517  $this->form = new ilPropertyFormGUI();
1518 
1519  // db type
1520  $options = array(
1521  "mysql" => "MySQL 5.0.x or higher",
1522  "oracle" => "Oracle 10g or higher",
1523  );
1524  $si = new ilSelectInputGUI($lng->txt("db_type"), "db_type");
1525  $si->setOptions($options);
1526  $si->setInfo($lng->txt(""));
1527  $this->form->addItem($si);
1528 
1529  $this->form->addCommandButton("selectdbtype", $lng->txt("save"));
1530 
1531  $this->form->setTitle($lng->txt("db_selection"));
1532  $this->form->setFormAction("setup.php?cmd=gateway");
1533  }
1534 
1538 
1542  function displayIni($a_omit_form_init = false)
1543  {
1544  $this->checkDisplayMode("create_new_client");
1545 
1546  if ($_POST["db_type"] != "")
1547  {
1548  $_SESSION["db_type"] = $_POST["db_type"];
1549  }
1550  else
1551  {
1552  $_POST["db_type"] = $_SESSION["db_type"];
1553  }
1554 
1555  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1556  if (!$a_omit_form_init)
1557  {
1558  $this->initClientIniForm();
1559  $this->getClientIniValues();
1560  }
1561  $this->tpl->setVariable("SETUP_CONTENT",
1562  $this->form->getHTML());
1563 
1564  if ($this->setup->getClient()->status["ini"]["status"])
1565  {
1566  $this->setButtonNext("db");
1567  }
1568 
1569  $this->checkPanelMode();
1570  }
1571 
1575  public function initClientIniForm()
1576  {
1577  global $lng, $ilCtrl;
1578 
1579  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1580  $this->form = new ilPropertyFormGUI();
1581 
1582  // client id
1583  if ($this->setup->ini_client_exists)
1584  {
1585  $hi = new ilHiddenInputGUI("client_id");
1586  $hi->setValue($this->client_id);
1587  $this->form->addItem($hi);
1588 
1589  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "hh");
1590  $ne->setValue($this->client_id);
1591  $this->form->addItem($ne);
1592  }
1593  else
1594  {
1595  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1596  $ti->setMaxLength(32);
1597  $ti->setRequired(true);
1598  $this->form->addItem($ti);
1599  }
1600 
1601  // database connection
1602  $sh = new ilFormSectionHeaderGUI();
1603  $sh->setTitle($lng->txt("db_conn"));
1604  $this->form->addItem($sh);
1605 
1606  // db type
1607  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "dbt");
1608  $ne->setValue($lng->txt("db_".$_SESSION["db_type"]));
1609  $this->form->addItem($ne);
1610 
1611  // db host
1612  $ti = new ilTextInputGUI($lng->txt("db_host"), "db_host");
1613  $ti->setMaxLength(120);
1614  $ti->setRequired(true);
1615  $this->form->addItem($ti);
1616 
1617  // db name
1618  if ($_SESSION["db_type"] == "mysql")
1619  {
1620  $ti = new ilTextInputGUI($lng->txt("db_name"), "db_name");
1621  $ti->setRequired(true);
1622  }
1623  else
1624  {
1625  $ti = new ilTextInputGUI($lng->txt("db_service_name"), "db_name");
1626  }
1627  $ti->setMaxLength(40);
1628  $this->form->addItem($ti);
1629 
1630  // db user
1631  $ti = new ilTextInputGUI($lng->txt("db_user"), "db_user");
1632  $ti->setMaxLength(40);
1633  $ti->setRequired(true);
1634  $this->form->addItem($ti);
1635 
1636  // db port
1637  $ti = new ilTextInputGUI($lng->txt("db_port"), "db_port");
1638  $ti->setMaxLength(8);
1639  $this->form->addItem($ti);
1640 
1641  // db password
1642  $ti = new ilTextInputGUI($lng->txt("db_pass"), "db_pass");
1643  $ti->setMaxLength(40);
1644  $this->form->addItem($ti);
1645 
1646  $this->form->addCommandButton("saveClientIni", $lng->txt("save"));
1647 
1648  $this->form->setTitle($lng->txt("inst_identification"));
1649  $this->form->setFormAction("setup.php?cmd=gateway");
1650  }
1651 
1655  public function getClientIniValues()
1656  {
1657  $values = array();
1658 
1659  $values["db_host"] = $this->setup->getClient()->getDbHost();
1660  $values["db_user"] = $this->setup->getClient()->getDbUser();
1661  $values["db_port"] = $this->setup->getClient()->getDbPort();
1662  $values["db_pass"] = $this->setup->getClient()->getDbPass();
1663  $values["db_name"] = $this->setup->getClient()->getDbName();
1664  $values["client_id"] = $this->setup->getClient()->getId();
1665 
1666  $this->form->setValuesByArray($values);
1667  }
1668 
1672  public function saveClientIni()
1673  {
1674  global $tpl, $lng, $ilCtrl;
1675 
1676  $this->initClientIniForm();
1677  if ($this->form->checkInput())
1678  {
1679  if (strlen($_POST["client_id"]) != strlen(urlencode(($_POST["client_id"]))))
1680  {
1681  $i = $this->form->getItemByPostVar("client_id");
1682  $i->setAlert($this->lng->txt("ini_client_id_invalid"));
1683  ilUtil::sendFailure($this->lng->txt("ini_client_id_invalid"),true);
1684  }
1685  else if (strlen($_POST["client_id"]) < 4)
1686  {
1687  $i = $this->form->getItemByPostVar("client_id");
1688  $i->setAlert($this->lng->txt("ini_client_id_too_short"));
1689  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_short"),true);
1690  }
1691  else if (strlen($_POST["client_id"]) > 32)
1692  {
1693  $i = $this->form->getItemByPostVar("client_id");
1694  $i->setAlert($this->lng->txt("ini_client_id_too_long"));
1695  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_long"),true);
1696  }
1697  else if (!$this->setup->ini_client_exists && file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$_POST["client_id"]))
1698  {
1699  $i = $this->form->getItemByPostVar("client_id");
1700  $i->setAlert($this->lng->txt("ini_client_id_exists"));
1701  ilUtil::sendFailure($this->lng->txt("ini_client_id_exists"),true);
1702  }
1703  else
1704  {
1705 
1706  // save some old values
1707  $old_db_name = $this->setup->getClient()->getDbName();
1708  $old_db_type = $this->setup->getClient()->getDbType();
1709  $old_client_id = $this->setup->getClient()->getId();
1710 
1711  // create new client object if it does not exist
1712  if (!$this->setup->ini_client_exists)
1713  {
1714  $client_id = $_POST["client_id"];
1715  $this->setup->newClient($client_id);
1716  }
1717 
1718  // set client data
1719  $this->setup->getClient()->setId($_POST["client_id"]);
1720  $this->setup->getClient()->setDbHost($_POST["db_host"]);
1721  $this->setup->getClient()->setDbName($_POST["db_name"]);
1722  $this->setup->getClient()->setDbUser($_POST["db_user"]);
1723  $this->setup->getClient()->setDbPort($_POST["db_port"]);
1724  $this->setup->getClient()->setDbPass($_POST["db_pass"]);
1725  $this->setup->getClient()->setDbType($_SESSION["db_type"]);
1726  $this->setup->getClient()->setDSN();
1727 
1728  // try to connect to database
1729  if (!$this->setup->getClient()->checkDatabaseHost())
1730  {
1731  $i = $this->form->getItemByPostVar("db_host");
1732  $i->setAlert($this->lng->txt($this->setup->getClient()->getError()));
1733  ilUtil::sendFailure($this->setup->getClient()->getError(),true);
1734  }
1735  else
1736  {
1737  // check if db exists
1738  $db_installed = $this->setup->getClient()->checkDatabaseExists();
1739 
1740  if ($db_installed and (!$this->setup->ini_ilias_exists or ($this->setup->getClient()->getDbName() != $old_db_name)))
1741  {
1742  $_POST["db_name"] = $old_db_name;
1743  $message = ucfirst($this->lng->txt("database"))." \"".$this->setup->getClient()->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
1744  $i = $this->form->getItemByPostVar("db_name");
1745  $i->setAlert($message);
1746  ilUtil::sendFailure($message, true);
1747  }
1748  else
1749  {
1750  // all ok. create client.ini and save posted data
1751  if (!$this->setup->ini_client_exists)
1752  {
1753  if ($this->setup->saveNewClient())
1754  {
1755  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1756  $this->setup->getClient()->status["ini"]["status"] = true;
1757  $_SESSION["ClientId"] = $client_id;
1758  ilUtil::redirect("setup.php?cmd=displayIni&client_id=".$client_id);
1759  }
1760  else
1761  {
1762  $err = $this->setup->getError();
1763  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1764  $this->setup->getClient()->status["ini"]["status"] = false;
1765  $this->setup->getClient()->status["ini"]["comment"] = $err;
1766  }
1767  }
1768  else
1769  {
1770  if ($this->setup->getClient()->ini->write())
1771  {
1772  ilUtil::sendSuccess($this->lng->txt("settings_changed"));
1773  $this->setup->getClient()->status["ini"]["status"] = true;
1774  ilUtil::redirect("setup.php?cmd=displayIni");
1775  }
1776  else
1777  {
1778  $err = $this->setup->getClient()->ini->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  }
1784  }
1785  }
1786  }
1787  }
1788 
1789  $this->form->setValuesByPost();
1790  $this->displayIni(true);
1791  }
1792 
1798  function displayError($a_message)
1799  {
1800  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html", "setup");
1801 
1802  $this->tpl->setCurrentBlock("content");
1803  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1804  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1805  $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
1806  $this->tpl->parseCurrentBlock();
1807 
1808  $this->tpl->show();
1809  exit();
1810  }
1811 
1815  function displayLogout()
1816  {
1817  $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html", "setup");
1818 
1819  session_destroy();
1820 
1821  $this->logged_out = true;
1822  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));
1823  $this->tpl->setCurrentBlock("home_link");
1824  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
1825  $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
1826  $this->tpl->parseCurrentBlock();
1827  }
1828 
1833  {
1834  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1835 
1836  $steps = array();
1837  $steps = $this->setup->getStatus();
1838 
1839  // remove access step
1840  unset($steps["access"]);
1841 
1842  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1843  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1844  //$steps["sess"]["text"] = $this->lng->txt("setup_process_step_sess");
1845  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1846  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1847  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1848  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1849 
1850  $stpl = new ilTemplate("tpl.process_panel.html", true, true, "setup");
1851 
1852  $num = 1;
1853 
1854  foreach ($steps as $key => $val)
1855  {
1856  $stpl->setCurrentBlock("menu_row");
1857  $stpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
1858  $stpl->setVariable("TXT_ACTION",$val["text"]);
1859  $stpl->setVariable("IMG_ARROW", "spacer.gif");
1860 
1861  $num++;
1862 
1863  if ($this->cmd == $key and isset($this->cmd))
1864  {
1865  $stpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1866  $stpl->setVariable("IMG_ARROW", "arrow_right.png");
1867  }
1868 
1869  $status = ($val["status"]) ? $OK : "";
1870 
1871  $stpl->setVariable("TXT_STATUS",$status);
1872  $stpl->parseCurrentBlock();
1873  }
1874 
1875  $stpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
1876 
1877  $this->tpl->setVariable("PROCESS_MENU", $stpl->get());
1878  }
1879 
1884  {
1885  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1886 
1887  $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html", "setup");
1888 
1889  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1890  // display status
1891  if ($this->setup->getClient()->status)
1892  {
1893  foreach ($this->setup->getClient()->status as $key => $val)
1894  {
1895  $status = ($val["status"]) ? $OK : "&nbsp;";
1896  $this->tpl->setCurrentBlock("status_row");
1897  $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1898  $this->tpl->setVariable("TXT_STATUS",$status);
1899  $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1900  $this->tpl->parseCurrentBlock();
1901  }
1902  }
1903  }
1904 
1910  function checkDisplayMode($a_title = "")
1911  {
1912  switch ($this->display_mode)
1913  {
1914  case "view":
1915  $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html", "setup");
1916  // display tabs
1917  include "./setup/include/inc.client_tabs.php";
1918  $client_name = ($this->setup->getClient()->getName()) ? $this->setup->getClient()->getName() : $this->lng->txt("no_client_name");
1919  $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
1920  break;
1921 
1922  case "setup":
1923  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1924  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));
1925  break;
1926 
1927  default:
1928  $this->displayError($this->lng->txt("unknown_display_mode"));
1929  exit();
1930  break;
1931  }
1932  }
1933 
1937  function checkPanelMode()
1938  {
1939  switch ($this->display_mode)
1940  {
1941  case "view":
1942  $this->displayStatusPanel();
1943  break;
1944 
1945  case "setup":
1946  $this->displayProcessPanel();
1947  break;
1948  }
1949  }
1950 
1954  function displayStartup()
1955  {
1956  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1957 
1958  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
1959  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
1960 
1961  $this->displayProcessPanel();
1962 
1963  $this->setButtonNext("ini");
1964  }
1965 
1969 
1973  function displayDatabase()
1974  {
1975  global $ilErr,$ilDB,$ilLog;
1976 
1977  $this->checkDisplayMode("setup_database");
1978 
1979  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
1980 
1981  // database is intalled
1982  if ($this->setup->getClient()->db_installed)
1983  {
1984  $ilDB = $this->setup->getClient()->db;
1985  $this->lng->setDbHandler($ilDB);
1986  $dbupdate = new ilDBUpdate($ilDB);
1987  $db_status = $dbupdate->getDBVersionStatus();
1988  $hotfix_available = $dbupdate->hotfixAvailable();
1989  $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available);
1990  $this->getClientDbFormValues($dbupdate);
1991  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1992 
1993  if ($db_status)
1994  {
1995  $this->setButtonNext("lang");
1996  }
1997  }
1998  else // database is not installed
1999  {
2000  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db")."<br />".
2001  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>".
2002  "<p><b>".$this->lng->txt("info_text_db2")."</b></p><br/>");
2003 
2004  $this->initClientDbForm();
2005  $this->getClientDbFormValues();
2006  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2007  $this->setButtonPrev("ini");
2008  }
2009 
2010  $this->checkPanelMode();
2011  }
2012 
2016  public function initClientDbForm($a_install = true, $dbupdate = null, $db_status = false, $hotfix_available = false)
2017  {
2018  global $lng, $ilCtrl;
2019 
2020  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2021  $this->form = new ilPropertyFormGUI();
2022 
2023  // type
2024  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "db_type");
2025  $this->form->addItem($ne);
2026 
2027  // version
2028  if ($this->setup->getClient()->getDBType() == "mysql")
2029  {
2030  $ne = new ilNonEditableValueGUI($lng->txt("version"), "db_version");
2031  $ilDB = $this->setup->getClient()->db;
2032  $ne->setValue($ilDB->getDBVersion());
2033  $this->form->addItem($ne);
2034  }
2035 
2036  // host
2037  $ne = new ilNonEditableValueGUI($lng->txt("host"), "db_host");
2038  $this->form->addItem($ne);
2039 
2040  // name
2041  $ne = new ilNonEditableValueGUI($lng->txt("name"), "db_name");
2042  $this->form->addItem($ne);
2043 
2044  // user
2045  $ne = new ilNonEditableValueGUI($lng->txt("user"), "db_user");
2046  $this->form->addItem($ne);
2047 
2048  // port
2049  $ne = new ilNonEditableValueGUI($lng->txt("port"), "db_port");
2050  $this->form->addItem($ne);
2051 
2052  // creation / collation for mysql
2053  if ($this->setup->getClient()->getDBType() == "mysql" && $a_install)
2054  {
2055  // create database
2056  $cb = new ilCheckboxInputGUI($lng->txt("database_create"), "chk_db_create");
2057 
2058  // collation
2059  $collations = array
2060  (
2061  "utf8_unicode_ci",
2062  "utf8_general_ci",
2063  "utf8_czech_ci",
2064  "utf8_danish_ci",
2065  "utf8_estonian_ci",
2066  "utf8_icelandic_ci",
2067  "utf8_latvian_ci",
2068  "utf8_lithuanian_ci",
2069  "utf8_persian_ci",
2070  "utf8_polish_ci",
2071  "utf8_roman_ci",
2072  "utf8_romanian_ci",
2073  "utf8_slovak_ci",
2074  "utf8_slovenian_ci",
2075  "utf8_spanish2_ci",
2076  "utf8_spanish_ci",
2077  "utf8_swedish_ci",
2078  "utf8_turkish_ci"
2079  );
2080  foreach($collations as $collation)
2081  {
2082  $options[$collation] = $collation;
2083  }
2084  $si = new ilSelectInputGUI($lng->txt("collation"), "collation");
2085  $si->setOptions($options);
2086  $si->setInfo($this->lng->txt("info_text_db_collation2")." ".
2087  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
2088  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2089  $cb->addSubItem($si);
2090 
2091  $this->form->addItem($cb);
2092  }
2093 
2094  if ($a_install)
2095  {
2096  $this->form->addCommandButton("installDatabase", $lng->txt("database_install"));
2097  }
2098  else
2099  {
2100  $ilDB = $this->setup->getClient()->db;
2101  $this->lng->setDbHandler($ilDB);
2102  $dbupdate = new ilDBUpdate($ilDB);
2103 
2104  // database version
2105  $ne = new ilNonEditableValueGUI($lng->txt("database_version"), "curv");
2106  $ne->setValue($dbupdate->currentVersion);
2107  $this->form->addItem($ne);
2108 
2109  // file version
2110  $ne = new ilNonEditableValueGUI($lng->txt("file_version"), "filev");
2111  $ne->setValue($dbupdate->fileVersion);
2112  $this->form->addItem($ne);
2113 
2114  if (!$db_status = $dbupdate->getDBVersionStatus())
2115  {
2116  // next update step
2117  $options = array();
2118  for ($i = $dbupdate->currentVersion + 1; $i <= $dbupdate->fileVersion; $i++)
2119  {
2120  $options[$i] = $i;
2121  }
2122  if (count($options) > 1)
2123  {
2124  $si = new ilSelectInputGUI($lng->txt("next_update_break"), "update_break");
2125  $si->setOptions($options);
2126  $si->setInfo($lng->txt("next_update_break_info"));
2127  $this->form->addItem($si);
2128  }
2129 
2130  if ($dbupdate->getRunningStatus() > 0)
2131  {
2132  ilUtil::sendFailure($this->lng->txt("db_update_interrupted")."<br /><br />".
2133  $this->lng->txt("db_update_interrupted_avoid"));
2134  }
2135  else
2136  {
2137  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2138  }
2139  $this->form->addCommandButton("updateDatabase", $lng->txt("database_update"));
2140  }
2141  else if ($hotfix_available)
2142  {
2143  // hotfix current version
2144  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2145  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2146  $this->form->addItem($ne);
2147 
2148  // hotfix file version
2149  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2150  $ne->setValue($dbupdate->getHotfixFileVersion());
2151  $this->form->addItem($ne);
2152 
2153  $this->form->addCommandButton("applyHotfix", $lng->txt("apply_hotfixes"));
2154  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2155  }
2156  else
2157  {
2158  if ($dbupdate->getHotfixFileVersion() > 0)
2159  {
2160  // hotfix current version
2161  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2162  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2163  $this->form->addItem($ne);
2164 
2165  // hotfix file version
2166  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2167  $ne->setValue($dbupdate->getHotfixFileVersion());
2168  $this->form->addItem($ne);
2169  }
2170  ilUtil::sendSuccess($this->lng->txt("database_is_uptodate"));
2171  }
2172  }
2173 
2174  $this->form->setTitle($lng->txt("database"));
2175  $this->form->setFormAction("setup.php?cmd=gateway");
2176  }
2177 
2182  public function getClientDbFormValues($dbupdate = null)
2183  {
2184  global $lng;
2185 
2186  $values = array();
2187 
2188  $values["db_host"] = $this->setup->getClient()->getDbHost();
2189  $values["db_name"] = $this->setup->getClient()->getDbName();
2190  $values["db_user"] = $this->setup->getClient()->getDbUser();
2191  $values["db_port"] = $this->setup->getClient()->getDbPort();
2192  $values["db_type"] = $lng->txt("db_".$this->setup->getClient()->getDbType());
2193  if (is_object($dbupdate))
2194  {
2195  $values["update_break"] = $dbupdate->fileVersion;
2196  if (($dbupdate->fileVersion - $dbupdate->currentVersion) >= 200)
2197  {
2198  $values["update_break"] = $dbupdate->currentVersion + 200 -
2199  ($dbupdate->currentVersion % 100);
2200  }
2201  }
2202 
2203  $this->form->setValuesByArray($values);
2204  }
2205 
2209 
2216  function installDatabase()
2217  {
2218  if (!$this->setup->getClient()->db_exists)
2219  {
2220  if ($_POST["chk_db_create"])
2221  {
2222  if (!$this->setup->createDatabase($_POST["collation"]))
2223  {
2224  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2225  ilUtil::redirect("setup.php?cmd=displayDatabase");
2226  }
2227  }
2228  else
2229  {
2230  ilUtil::sendFailure($this->lng->txt("database_not_exists_create_first"), true);
2231  ilUtil::redirect("setup.php?cmd=displayDatabase");
2232  }
2233  }
2234  if (!$this->setup->installDatabase())
2235  {
2236  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2237  }
2238  else
2239  {
2240  ilUtil::sendSuccess($this->lng->txt("database_installed"), true);
2241  }
2242  ilUtil::redirect("setup.php?cmd=displayDatabase");
2243  }
2244 
2248 
2252  function updateDatabase()
2253  {
2254  global $ilCtrlStructureReader;
2255 
2256  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2257 
2258  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2259  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2260  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2261  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2262  include_once "./Services/Tree/classes/class.ilTree.php";
2263  include_once "./classes/class.ilSaxParser.php";
2264  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2265 
2266  // referencing db handler in language class
2267  $ilDB = $this->setup->getClient()->db;
2268  $this->lng->setDbHandler($ilDB);
2269 
2270  // run dbupdate
2271  $dbupdate = new ilDBUpdate($ilDB);
2272  $dbupdate->applyUpdate((int) $_POST["update_break"]);
2273 
2274  if ($dbupdate->updateMsg == "no_changes")
2275  {
2276  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2277  }
2278  else
2279  {
2280  $sep = "";
2281  foreach ($dbupdate->updateMsg as $row)
2282  {
2283  if ($row["msg"] == "update_applied")
2284  {
2285  $a_message.= $sep.$row["nr"];
2286  $sep = ", ";
2287  }
2288  else
2289  {
2290  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2291  }
2292  }
2293  if ($a_message != "")
2294  {
2295  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2296  }
2297  }
2298 
2299  ilUtil::sendInfo($a_message.$e_message, true);
2300  ilUtil::redirect("setup.php?cmd=displayDatabase");
2301  }
2302 
2306 
2310  function applyHotfix()
2311  {
2312  global $ilCtrlStructureReader;
2313 
2314  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2315 
2316  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2317  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2318  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2319  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2320  include_once "./Services/Tree/classes/class.ilTree.php";
2321  include_once "./classes/class.ilSaxParser.php";
2322  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2323 
2324  // referencing db handler in language class
2325  $ilDB = $this->setup->getClient()->db;
2326  $this->lng->setDbHandler($ilDB);
2327 
2328  // run dbupdate
2329  $dbupdate = new ilDBUpdate($ilDB);
2330  $dbupdate->applyHotfix();
2331 
2332  if ($dbupdate->updateMsg == "no_changes")
2333  {
2334  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2335  }
2336  else
2337  {
2338  $sep = "";
2339  foreach ($dbupdate->updateMsg as $row)
2340  {
2341  if ($row["msg"] == "update_applied")
2342  {
2343  $a_message.= $sep.$row["nr"];
2344  $sep = ", ";
2345  }
2346  else
2347  {
2348  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2349  }
2350  }
2351  if ($a_message != "")
2352  {
2353  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2354  }
2355  }
2356 
2357  ilUtil::sendInfo($a_message.$e_message, true);
2358  ilUtil::redirect("setup.php?cmd=displayDatabase");
2359  }
2360 
2364 
2368  function displaySessions()
2369  {
2370  require_once('Services/Authentication/classes/class.ilSessionControl.php');
2371 
2372  $this->checkDisplayMode("setup_sessions");
2373 
2374  if (!$this->setup->getClient()->db_installed)
2375  {
2376  // program should never come to this place
2377  $message = "No database found! Please install database first.";
2378  ilUtil::sendInfo($message);
2379  }
2380 
2381  $setting_fields = ilSessionControl::getSettingFields();
2382 
2383  $valid = true;
2384  $settings = array();
2385 
2386  foreach( $setting_fields as $field )
2387  {
2388  if( $field == 'session_allow_client_maintenance' )
2389  {
2390  if( isset($_POST[$field]) ) $_POST[$field] = '1';
2391  else $_POST[$field] = '0';
2392  }
2393 
2394  if( isset($_POST[$field]) && $_POST[$field] != '' )
2395  {
2396  $settings[$field] = $_POST[$field];
2397  }
2398  else
2399  {
2400  $valid = false;
2401  break;
2402  }
2403 
2404  }
2405 
2406  if($valid) $this->setup->setSessionSettings($settings);
2407 
2408  $settings = $this->setup->getSessionSettings();
2409 
2410  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2411  $form = new ilPropertyFormGUI();
2412 
2413  include_once 'Services/Authentication/classes/class.ilSession.php';
2414 
2415  // BEGIN SESSION SETTINGS
2416  // create session handling radio group
2417  $ssettings = new ilRadioGroupInputGUI($this->lng->txt('sess_mode'), 'session_handling_type');
2418  $ssettings->setValue($settings['session_handling_type'], ilSession::SESSION_HANDLING_FIXED);
2419 
2420  // first option, fixed session duration
2421  $fixed = new ilRadioOption($this->lng->txt('sess_fixed_duration'), ilSession::SESSION_HANDLING_FIXED);
2422 
2423  // add session handling to radio group
2424  $ssettings->addOption($fixed);
2425 
2426  // second option, session control
2427  $ldsh = new ilRadioOption($this->lng->txt('sess_load_dependent_session_handling'), ilSession::SESSION_HANDLING_LOAD_DEPENDENT);
2428 
2429  // this is the max count of active sessions
2430  // that are getting started simlutanously
2431  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
2432  $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
2433  $ti->setMaxLength(5);
2434  $ti->setSize(5);
2435  $ti->setValue($settings['session_max_count']);
2436  $ldsh->addSubItem($ti);
2437 
2438  // after this (min) idle time the session can be deleted,
2439  // if there are further requests for new sessions,
2440  // but max session count is reached yet
2441  $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
2442  $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
2443  $ti->setMaxLength(5);
2444  $ti->setSize(5);
2445  $ti->setValue($settings['session_min_idle']);
2446  $ldsh->addSubItem($ti);
2447 
2448  // after this (max) idle timeout the session expires
2449  // and become invalid, so it is not considered anymore
2450  // when calculating current count of active sessions
2451  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
2452  $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
2453  $ti->setMaxLength(5);
2454  $ti->setSize(5);
2455  $ti->setValue($settings['session_max_idle']);
2456  $ldsh->addSubItem($ti);
2457 
2458  // this is the max duration that can elapse between the first and the secnd
2459  // request to the system before the session is immidietly deleted
2460  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
2461  $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
2462  $ti->setMaxLength(5);
2463  $ti->setSize(5);
2464  $ti->setValue($settings['session_max_idle_after_first_request']);
2465  $ldsh->addSubItem($ti);
2466 
2467  // add session control to radio group
2468  $ssettings->addOption($ldsh);
2469 
2470  $form->addItem($ssettings);
2471 
2472  // controls the ability t maintenance the following
2473  // settings in client administration
2474  $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
2475  $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
2476  $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
2477  $form->addItem($chkb);
2478  // END SESSION SETTINGS
2479 
2480  // save and cancel commands
2481  $form->addCommandButton("sess", $this->lng->txt('save'));
2482 
2483  $form->setTitle($this->lng->txt("sess_sessions"));
2484  $form->setFormAction('setup.php?client_id='.$this->client_id.'&cmd=sess');
2485 
2486  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt('sess_sessions'))));
2487  $this->tpl->setVariable("TXT_INFO", '');
2488  $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
2489 
2490  /*$this->setButtonPrev("db");
2491 
2492  if($this->setup->checkClientSessionSettings($this->client,true))
2493  {
2494  $this->setButtonNext("lang");
2495  }*/
2496 
2497  $this->checkPanelMode();
2498  }
2499 
2503 
2507  function displayLanguages()
2508  {
2509  $this->checkDisplayMode("setup_languages");
2510 
2511  if (!$this->setup->getClient()->db_installed)
2512  {
2513  // program should never come to this place
2514  $message = "No database found! Please install database first.";
2515  ilUtil::sendFailure($message);
2516  }
2517 
2518  include_once("./setup/classes/class.ilSetupLanguageTableGUI.php");
2519  $tab = new ilSetupLanguageTableGUI($this->setup->getClient());
2520  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2521 
2522  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2523  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2524 
2525  $installed_langs = $this->lng->getInstalledLanguages();
2526  $lang_count = count($installed_langs);
2527  if ($lang_count > 0)
2528  {
2529  $this->setup->getClient()->status["lang"]["status"] = true;
2530  $this->setup->getClient()->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2531  }
2532  else
2533  {
2534  $this->setup->getClient()->status["lang"]["status"] = false;
2535  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2536  }
2537 
2538  $this->setButtonPrev("lang");
2539 
2540  if ($lang_count > 0)
2541  {
2542  $this->setButtonNext("contact");
2543  }
2544 
2545  $this->checkPanelMode();
2546  }
2547 
2554  function saveLanguages()
2555  {
2556  if (empty($_POST["form"]["lang_id"]))
2557  {
2558  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
2559  ilUtil::redirect("setup.php?cmd=lang");
2560  }
2561 
2562  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2563  {
2564  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
2565  ilUtil::redirect("setup.php?cmd=lang");
2566  }
2567 
2568  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2569 
2570  if (is_array($result))
2571  {
2572  $count = count($result);
2573  $txt = "tet";
2574 
2575  foreach ($result as $key => $lang_key)
2576  {
2577  $list .= $this->lng->txt("lang_".$lang_key);
2578 
2579  if ($count > $key + 1)
2580  {
2581  $list .= ", ";
2582  }
2583  }
2584  }
2585 
2586  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
2587  $message = $this->lng->txt("languages_installed");
2588 
2589  if ($result !== true)
2590  {
2591  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2592  }
2593  ilUtil::sendInfo($message, true);
2594  ilUtil::redirect("setup.php?cmd=lang");
2595  }
2596 
2600 
2604  function displayContactData($a_omit_init = false)
2605  {
2606  $this->checkDisplayMode("setup_contact_data");
2607  $settings = $this->setup->getClient()->getAllSettings();
2608 
2609  if (!$a_omit_init)
2610  {
2611  $this->initContactDataForm();
2612  $this->getContactValues();
2613  }
2614  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2615  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2616  $this->setButtonPrev("lang");
2617 
2618  $check = $this->setup->checkClientContact($this->setup->client);
2619 
2620  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
2621  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
2622 
2623  if ($check["status"])
2624  {
2625  $this->setButtonNext("nic");
2626  }
2627 
2628  $this->checkPanelMode();
2629  }
2630 
2636  public function initContactDataForm()
2637  {
2638  global $lng, $ilCtrl;
2639 
2640  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2641  $this->form = new ilPropertyFormGUI();
2642 
2643  // name
2644  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
2645  $ti->setMaxLength(64);
2646  $ti->setSize(30);
2647  $ti->setRequired(true);
2648  $this->form->addItem($ti);
2649 
2650  // description
2651  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
2652  $ti->setMaxLength(64);
2653  $ti->setSize(30);
2654  $this->form->addItem($ti);
2655 
2656  // institution
2657  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
2658  $ti->setMaxLength(64);
2659  $ti->setSize(30);
2660  $this->form->addItem($ti);
2661 
2662  // contact data
2663  $sh = new ilFormSectionHeaderGUI();
2664  $sh->setTitle($lng->txt("contact_data"));
2665  $this->form->addItem($sh);
2666 
2667  // first name
2668  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
2669  $ti->setMaxLength(64);
2670  $ti->setSize(30);
2671  $ti->setRequired(true);
2672  $this->form->addItem($ti);
2673 
2674  // last name
2675  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
2676  $ti->setMaxLength(64);
2677  $ti->setSize(30);
2678  $ti->setRequired(true);
2679  $this->form->addItem($ti);
2680 
2681  $fs = array (
2682  "title" => array("max" => 64, "size" => 30),
2683  "position" => array("max" => 64, "size" => 30),
2684  "institution" => array("max" => 200, "size" => 30),
2685  "street" => array("max" => 64, "size" => 30),
2686  "zipcode" => array("max" => 10, "size" => 5),
2687  "city" => array("max" => 64, "size" => 30),
2688  "country" => array("max" => 64, "size" => 30),
2689  "phone" => array("max" => 64, "size" => 30)
2690  );
2691  foreach ($fs as $f => $op)
2692  {
2693  // field
2694  $ti = new ilTextInputGUI($lng->txt($f), "admin_".$f);
2695  $ti->setMaxLength($op["max"]);
2696  $ti->setSize($op["size"]);
2697  $ti->setInfo($lng->txt(""));
2698  $this->form->addItem($ti);
2699  }
2700 
2701  // email
2702  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
2703  $ti->setRequired(true);
2704  $this->form->addItem($ti);
2705 
2706  $this->form->addCommandButton("saveContact", $lng->txt("save"));
2707 
2708  $this->form->setTitle($lng->txt("client_data"));
2709  $this->form->setFormAction("setup.php?cmd=gateway");
2710  }
2711 
2715  public function getContactValues()
2716  {
2717 
2718  $settings = $this->setup->getClient()->getAllSettings();
2719 
2720  $values = $settings;
2721 
2722  $values["inst_name"] = ($this->setup->getClient()->getName())
2723  ? $this->setup->getClient()->getName()
2724  : $this->setup->getClient()->getId();
2725  $values["inst_info"] = $this->setup->getClient()->getDescription();
2726 
2727  $this->form->setValuesByArray($values);
2728  }
2729 
2733  public function saveContact()
2734  {
2735  global $tpl, $lng, $ilCtrl;
2736 
2737  $this->initContactDataForm();
2738  if ($this->form->checkInput())
2739  {
2740  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
2741  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
2742  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
2743  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
2744  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
2745  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
2746  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
2747  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
2748  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
2749  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
2750  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
2751  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
2752  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
2753 
2754  // update client.ini
2755  $this->setup->getClient()->setName($_POST["inst_name"]);
2756  $this->setup->getClient()->setDescription($_POST["inst_info"]);
2757  $this->setup->getClient()->ini->write();
2758 
2759  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2760  ilUtil::redirect("setup.php?cmd=displayContactData");
2761  }
2762 
2763  $this->form->setValuesByPost();
2764  $this->displayContactData(true);
2765  }
2766 
2770 
2774  function displayNIC($a_omit_init = false)
2775  {
2776  $this->checkDisplayMode("nic_registration");
2777  $settings = $this->setup->getClient()->getAllSettings();
2778  $nic_key = $this->setup->getClient()->getNICkey();
2779 
2780  // reload settings
2781  $settings = $this->setup->getClient()->getAllSettings();
2782 //var_dump($settings);
2783  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
2784  {
2785  $this->no_second_nav = true;
2786  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
2787  }
2788  else
2789  {
2790  // reload settings
2791  $settings = $this->setup->getClient()->getAllSettings();
2792 
2793  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
2794  if (!$a_omit_init)
2795  {
2796  $this->initRegistrationForm();
2797  $this->getRegistrationValues();
2798  }
2799  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2800 
2801  if (isset($settings["nic_enabled"]))
2802  {
2803  $this->setup->getClient()->status["nic"]["status"] = true;
2804  }
2805 
2806  }
2807 
2808  $this->setButtonPrev("contact");
2809 
2810  if ($this->setup->getClient()->status["nic"]["status"])
2811  {
2812  $this->setButtonNext("finish","finish");
2813  }
2814 
2815  $this->checkPanelMode();
2816  }
2817 
2823  public function initRegistrationForm($a_mode = "edit")
2824  {
2825  global $lng, $ilCtrl;
2826 
2827  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2828  $this->form = new ilPropertyFormGUI();
2829 
2830  // registration type
2831  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
2832  $radg->setValue(1);
2833  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
2834  $radg->addOption($op1);
2835  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
2836  $radg->addOption($op1);
2837  $this->form->addItem($radg);
2838 
2839  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
2840  $this->form->setFormAction("setup.php?cmd=gateway");
2841  }
2842 
2846  public function getRegistrationValues()
2847  {
2848  $settings = $this->setup->getClient()->getAllSettings();
2849  $nic_key = $this->setup->getClient()->getNICkey();
2850 
2851 
2852  $values = array();
2853 
2854  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
2855  {
2856  $values["register"] = 1;
2857  }
2858  /*elseif ($settings["nic_enabled"] == "2")
2859  {
2860  $this->tpl->setVariable("EMAIL",$checked);
2861  }*/
2862  else
2863  {
2864  $values["register"] = 0;
2865  }
2866 
2867  $this->form->setValuesByArray($values);
2868  }
2869 
2873  public function saveRegistration()
2874  {
2875  global $tpl, $lng, $ilCtrl;
2876 
2877  $this->initRegistrationForm();
2878  if ($this->form->checkInput())
2879  {
2880  // check register option
2881  if ($_POST["register"] == 1)
2882  {
2883  // update nic
2884  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
2885 //var_dump($this->setup->getClient()->nic_status);
2886  // online registration failed
2887  if (empty($this->setup->getClient()->nic_status[2]))
2888  {
2889  $this->setup->getClient()->setSetting("nic_enabled","-1");
2890  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
2891  ilUtil::redirect("setup.php?cmd=displayNIC");
2892  }
2893  else
2894  {
2895  $this->setup->getClient()->setSetting("inst_id",$this->setup->getClient()->nic_status[2]);
2896  $this->setup->getClient()->setSetting("nic_enabled","1");
2897  $this->setup->getClient()->status["nic"]["status"] = true;
2898  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
2899  ilUtil::redirect("setup.php?cmd=displayNIC");
2900  }
2901  }
2902  /*elseif ($_POST["form"]["register"] == 2)
2903  {
2904  $nic_by_email = (int) $_POST["form"]["nic_id"];
2905 
2906  $checksum = md5($nic_key.$nic_by_email);
2907 
2908  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
2909  {
2910  $message = $this->lng->txt("nic_reg_enter_correct_id");
2911  }
2912  else
2913  {
2914  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
2915  $this->setup->getClient()->setSetting("nic_enabled","1");
2916  $message = $this->lng->txt("nic_reg_enabled");
2917  }
2918  }*/
2919  else
2920  {
2921  $this->setup->getClient()->setSetting("inst_id","0");
2922  $this->setup->getClient()->setSetting("nic_enabled","0");
2923  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
2924  ilUtil::redirect("setup.php?cmd=displayNIC");
2925  }
2926  }
2927 
2928  $this->form->setValuesByPost();
2929  $this->displayNIC(true);
2930  }
2931 
2935 
2939  function displayTools()
2940  {
2941  $this->checkDisplayMode();
2942 
2943  // output
2944  ilUtil::sendInfo();
2945 
2946  // use property forms and add the settings type switch
2947  $ctrl_structure_form = $this->initControlStructureForm();
2948  $settings_type_form = $this->initSettingsTypeForm();
2949 
2950  $this->tpl->setVariable("SETUP_CONTENT",
2951  $ctrl_structure_form->getHTML() . "<br />" .
2952  $settings_type_form->getHTML());
2953 
2954  /* ---- obsolete -----
2955  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html", "setup");
2956  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2957  $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
2958  $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
2959  $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
2960 
2961  $ilDB = $this->setup->getClient()->db;
2962  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
2963  $crec = $ilDB->fetchAssoc($cset);
2964 
2965  if ($crec["cnt"] == 0)
2966  {
2967  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2968  $this->lng->txt("ctrl_missing_desc"));
2969  }
2970  else
2971  {
2972  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2973  $this->lng->txt("ctrl_structure_desc"));
2974  }
2975 
2976  $this->tpl->parseCurrentBlock();
2977  ------- obsolete ------*/
2978 
2979  //$this->checkPanelMode();
2980  }
2981 
2988  {
2989  include_once ("Services/Form/classes/class.ilPropertyFormGUI.php");
2990  $form = new ilPropertyFormGUI();
2991 
2992  $form->setId("control_structure");
2993  $form->setTitle($this->lng->txt("ctrl_structure"));
2994  $form->setFormAction("setup.php?cmd=gateway");
2995 
2996  $ilDB = $this->setup->getClient()->db;
2997  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
2998  $crec = $ilDB->fetchAssoc($cset);
2999 
3000  $item = new ilCustomInputGUI($this->lng->txt("ctrl_structure_reload"));
3001  if ($crec["cnt"] == 0)
3002  {
3003  $item->setInfo($this->lng->txt("ctrl_missing_desc"));
3004  }
3005  else
3006  {
3007  $item->setInfo($this->lng->txt("ctrl_structure_desc"));
3008  }
3009  $form->addItem($item);
3010 
3011  $form->addCommandButton("reloadStructure", $this->lng->txt("reload"));
3012  return $form;
3013  }
3014 
3015 
3020  {
3021  global $ilCtrlStructureReader;
3022 
3023  if (!$this->setup->getClient()->db_installed)
3024  {
3025  ilUtil::sendInfo($this->lng->txt("no_db"), true);
3026  $this->displayTools();
3027  return;
3028  }
3029 
3030  // referencing does not work in dbupdate-script
3031  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
3032 // BEGIN WebDAV
3033  // read module and service information into db
3034  require_once "./setup/classes/class.ilModuleReader.php";
3035  require_once "./setup/classes/class.ilServiceReader.php";
3036  require_once "./setup/classes/class.ilCtrlStructureReader.php";
3037 
3038  require_once "./Services/Component/classes/class.ilModule.php";
3039  require_once "./Services/Component/classes/class.ilService.php";
3040  $modules = ilModule::getAvailableCoreModules();
3042 
3044  foreach($modules as $module)
3045  {
3046  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
3047  $module["subdir"], "Modules");
3048  $mr->getModules();
3049  unset($mr);
3050  }
3051 
3053  foreach($services as $service)
3054  {
3055  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
3056  $service["subdir"], "Services");
3057  $sr->getServices();
3058  unset($sr);
3059  }
3060 // END WebDAV
3061 
3062  $ilCtrlStructureReader->readStructure(true);
3063  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
3064  $this->displayTools();
3065  }
3066 
3073  {
3074  include_once("./Services/Administration/classes/class.ilSetting.php");
3075  $type = ilSetting::_getValueType();
3076 
3077  include_once ("Services/Form/classes/class.ilPropertyFormGUI.php");
3078  $form = new ilPropertyFormGUI();
3079 
3080  $form->setId("settings_type");
3081  $form->setTitle($this->lng->txt("settings_type"));
3082  $form->setFormAction("setup.php?cmd=gateway");
3083 
3084  $item = new ilNonEditableValueGUI($this->lng->txt('settings_type_current'));
3085  $item->setValue(strtoupper($type));
3086 
3087  if ($type == "clob")
3088  {
3089  $item->setInfo($this->lng->txt('settings_info_clob'));
3090  $form->addCommandButton("showLongerSettings", $this->lng->txt("settings_show_longer"));
3091  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_text"));
3092  }
3093  else
3094  {
3095  $item->setInfo($this->lng->txt('settings_info_text'));
3096  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_clob"));
3097  }
3098  $form->addItem($item);
3099 
3100  if (is_array($this->longer_settings))
3101  {
3102  $item = new ilCustomInputGUI($this->lng->txt('settings_longer_values'));
3103 
3104  if (count($this->longer_settings))
3105  {
3106  foreach ($this->longer_settings as $row)
3107  {
3108  $subitem = new ilCustomInputGUI(sprintf($this->lng->txt('settings_key_info'), $row['module'], $row['keyword']));
3109  $subitem->setInfo($row['value']);
3110  $item->addSubItem($subitem);
3111  }
3112  }
3113  else
3114  {
3115  $item->setHTML($this->lng->txt('settings_no_longer_values'));
3116  }
3117  $form->addItem($item);
3118  }
3119 
3120  return $form;
3121  }
3122 
3123 
3128  {
3129  include_once("./Services/Administration/classes/class.ilSetting.php");
3130  $old_type = ilSetting::_getValueType();
3131 
3132  if ($old_type == "clob")
3133  {
3134  $longer_settings = ilSetting::_getLongerSettings();
3135  if (count($longer_settings))
3136  {
3137  $this->longer_settings = $longer_settings;
3138  ilUtil::sendFailure($this->lng->txt("settings_too_long"));
3139  }
3140  else
3141  {
3143  }
3144  }
3145  else
3146  {
3148  }
3149 
3150  if ($changed)
3151  {
3152  ilUtil::sendInfo($this->lng->txt("settings_type_changed"));
3153  }
3154 
3155  $this->displayTools();
3156  }
3157 
3158 
3164  {
3165  include_once("./Services/Administration/classes/class.ilSetting.php");
3166  $this->longer_settings = ilSetting::_getLongerSettings();
3167  $this->displayTools();
3168  }
3169 
3174  {
3175  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
3176 
3177  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
3178 
3179  // formular sent
3180  if ($_POST["form"])
3181  {
3182  $pass_old = $this->setup->getPassword();
3183 
3184  if (empty($_POST["form"]["pass_old"]))
3185  {
3186  $message = $this->lng->txt("password_enter_old");
3187  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3188  }
3189 
3190  if (md5($_POST["form"]["pass_old"]) != $pass_old)
3191  {
3192  $message = $this->lng->txt("password_old_wrong");
3193  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3194  }
3195 
3196  if (empty($_POST["form"]["pass"]))
3197  {
3198  $message = $this->lng->txt("password_empty");
3199  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3200  }
3201 
3202  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
3203  {
3204  $message = $this->lng->txt("password_not_match");
3205  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3206  }
3207 
3208  if (md5($_POST["form"]["pass"]) == $pass_old)
3209  {
3210  $message = $this->lng->txt("password_same");
3211  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3212  }
3213 
3214  if (!$this->setup->setPassword($_POST["form"]["pass"]))
3215  {
3216  $message = $this->lng->txt("save_error");
3217  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3218  }
3219 
3220  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
3221  ilUtil::redirect("setup.php");
3222  }
3223 
3224  // output
3225  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html", "setup");
3226 
3227  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
3228 
3229  // pass form
3230  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3231  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
3232  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
3233  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
3234  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
3235  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
3236  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3237  }
3238 
3243  {
3244  $this->checkDisplayMode("finish_setup");
3245  $this->no_second_nav = true;
3246 //echo "<b>1</b>";
3247  if ($this->validateSetup())
3248  {
3249  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
3250  "<p>".$this->lng->txt("user").": <b>root</b><br />".
3251  $this->lng->txt("password").": <b>homer</b></p>";
3252  $this->setButtonNext("login_new","login");
3253 //echo "<b>2</b>";
3254  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
3255  // the setup_ok fails (with MDB2 and a larger
3256  // client list), alex 17.1.2008
3257  $this->setup->getClient()->setSetting("setup_ok",1);
3258 //$this->setup->getClient()->setSetting("zzz", "Z");
3259 //echo "<b>3</b>";
3260  $this->setup->getClient()->status["finish"]["status"] = true;
3261 //echo "<b>4</b>";
3262  }
3263  else
3264  {
3265  $txt_info = $this->lng->txt("info_text_finish2");
3266  }
3267 
3268 //echo "<b>5</b>";
3269  // output
3270  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html", "setup");
3271  $this->tpl->setVariable("TXT_INFO",$txt_info);
3272 
3273  $this->setButtonPrev("nic");
3274 //echo "<b>6</b>";
3275  $this->checkPanelMode();
3276 //echo "<b>7</b>";
3277  }
3278 
3283  {
3284  $this->checkDisplayMode();
3285 
3286  // formular sent
3287  if ($_POST["form"]["delete"])
3288  {
3289  $ini = true;
3290  $db = false;
3291  $files = false;
3292 
3293  /* disabled
3294  switch ($_POST["form"]["delete"])
3295  {
3296  case 1:
3297  $ini = true;
3298  break;
3299 
3300  case 2:
3301  $ini = true;
3302  $db = true;
3303  break;
3304 
3305  case 3:
3306  $ini = true;
3307  $db = true;
3308  $files = true;
3309  break;
3310  }
3311  */
3312 
3313  $msg = $this->setup->getClient()->delete($ini,$db,$files);
3314 
3315  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
3316  ilUtil::redirect("setup.php");
3317  }
3318 
3319  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3320 
3321  // output
3322  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html", "setup");
3323 
3324  // delete panel
3325  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3326  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3327  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3328  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3329 
3330  $this->checkPanelMode();
3331  }
3332 
3338  function changeAccessMode($a_back)
3339  {
3340  if ($this->setup->getClient()->status["finish"]["status"])
3341  {
3342  $val = ($this->setup->getClient()->ini->readVariable("client","access")) ? "0" : true;
3343  $this->setup->getClient()->ini->setVariable("client","access",$val);
3344  $this->setup->getClient()->ini->write();
3345  $message = "client_access_mode_changed";
3346  }
3347  else
3348  {
3349  $message = "client_setup_not_finished";
3350  }
3351 
3352  ilUtil::sendInfo($this->lng->txt($message),true);
3353 
3354  ilUtil::redirect("setup.php?cmd=".$a_back);
3355  }
3356 
3361  {
3362  if ($_POST["form"])
3363  {
3364  $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections);
3365 
3366  if (!$client->init())
3367  {
3368  $this->setup->raiseError($this->lng->txt("no_valid_client_id"),$this->setup->error_obj->MESSAGE);
3369  }
3370 
3371  $status = $this->setup->getStatus($client);
3372 
3373  if ($status["finish"]["status"])
3374  {
3375  $this->setup->ini->setVariable("clients","default",$client->getId());
3376  $this->setup->ini->write();
3377  $message = "default_client_changed";
3378  }
3379  else
3380  {
3381  $message = "client_setup_not_finished";
3382  }
3383  }
3384 
3385  ilUtil::sendInfo($this->lng->txt($message),true);
3386 
3387  ilUtil::redirect("setup.php");
3388  }
3389 
3394  function validateSetup()
3395  {
3396  foreach ($this->setup->getClient()->status as $key => $val)
3397  {
3398  if ($key != "finish" and $key != "access")
3399  {
3400  if ($val["status"] != true)
3401  {
3402  return false;
3403  }
3404  }
3405  }
3406 
3407 //$this->setup->getClient()->setSetting("zzz", "V");
3408  $clientlist = new ilClientList($this->setup->db_connections);
3409 //$this->setup->getClient()->setSetting("zzz", "W");
3410  $list = $clientlist->getClients();
3411 //$this->setup->getClient()->setSetting("zzz", "X");
3412  if (count($list) == 1)
3413  {
3414  $this->setup->ini->setVariable("clients","default",$this->setup->getClient()->getId());
3415  $this->setup->ini->write();
3416 
3417  $this->setup->getClient()->ini->setVariable("client","access",1);
3418  $this->setup->getClient()->ini->write();
3419  }
3420 //$this->setup->getClient()->setSetting("zzz", "Y");
3421  return true;
3422  }
3423 
3428  {
3429  if (!$this->setup->getClient()->status["db"]["status"])
3430  {
3431  $this->cmd = "db";
3432  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3433  $this->displayDatabase();
3434  }
3435  elseif (!$this->setup->getClient()->status["lang"]["status"])
3436  {
3437  $this->cmd = "lang";
3438  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3439  $this->displayLanguages();
3440  }
3441  elseif (!$this->setup->getClient()->status["contact"]["status"])
3442  {
3443  $this->cmd = "contact";
3444  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3445  $this->displayContactData();
3446  }
3447  elseif (!$this->setup->getClient()->status["nic"]["status"])
3448  {
3449  $this->cmd = "nic";
3450  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3451  $this->displayNIC();
3452  }
3453  elseif (!$this->setup->getClient()->status["finish"]["status"])
3454  {
3455  $this->cmd = "finish";
3456  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3457  $this->displayFinishSetup();
3458  }
3459  else
3460  {
3461  return false;
3462  }
3463  }
3464 
3468  function toggleClientList()
3469  {
3470  if ($this->setup->ini->readVariable("clients","list"))
3471  {
3472  $this->setup->ini->setVariable("clients","list","0");
3473  $this->setup->ini->write();
3474  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
3475  }
3476  else
3477  {
3478  $this->setup->ini->setVariable("clients","list","1");
3479  $this->setup->ini->write();
3480  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
3481  }
3482 
3483  ilUtil::redirect("setup.php");
3484  }
3485 
3486 } // END class.ilSetupGUI
3487 ?>