ILIAS  eassessment Revision 61809
 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: 31725 $';
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  $this->$cmd();
407  break;
408 
409  default:
410  $this->displayError($this->lng->txt("unknown_command"));
411  break;
412  }
413  }
414 
415  // end cmd subsets
416 
420 
429  function setDisplayMode($a_mode)
430  {
431  // security
432  if ($a_mode != "view" and $a_mode != "setup")
433  {
434  return false;
435  }
436 
437  $this->display_mode = $a_mode;
438  $_SESSION["display_mode"] = $this->display_mode;
439 
440  return true;
441  }
442 
446  function displayHeader()
447  {
448  $languages = $this->lng->getLanguages();
449 
450  $count = (int) round(count($languages) / 2);
451  $num = 1;
452 
453  foreach ($languages as $lang_key)
454  {
455  if ($num === $count)
456  {
457  $this->tpl->touchBlock("lng_new_row");
458  }
459 
460  $this->tpl->setCurrentBlock("languages");
461  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
462  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
463  $this->tpl->setVariable("LANG_ICON", $lang_key);
464  $this->tpl->setVariable("LANG_KEY", $lang_key);
465  $this->tpl->setVariable("BORDER", 0);
466  $this->tpl->setVariable("VSPACE", 0);
467  $this->tpl->parseCurrentBlock();
468 
469  $num++;
470  }
471 
472  if (count($languages) % 2)
473  {
474  $this->tpl->touchBlock("lng_empty_cell");
475  }
476 
477  if ($this->cmd != "logout" and $this->setup->isInstalled())
478  {
479  // add client link
480  if ($this->setup->isAdmin())
481  {
482  if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
483  {
484  $this->tpl->setCurrentBlock("add_client");
485  $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
486  $this->tpl->parseCurrentBlock();
487  }
488 
489  // client list link
490  $class = ($this->active_tab == "clientlist")
491  ? "ilSMActive"
492  : "ilSMInactive";
493  $this->tpl->setCurrentBlock("display_list");
494  $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
495  $this->tpl->setVariable("TAB_CLASS", $class);
496  $this->tpl->parseCurrentBlock();
497 
498  // edit paths link
499  $class = ($this->active_tab == "basicsettings")
500  ? "ilSMActive"
501  : "ilSMInactive";
502  $this->tpl->setCurrentBlock("edit_pathes");
503  $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
504  $this->tpl->setVariable("TAB_CLASS", $class);
505  $this->tpl->parseCurrentBlock();
506 
507  // preliminaries
508  $class = ($this->active_tab == "preliminaries")
509  ? "ilSMActive"
510  : "ilSMInactive";
511  $this->tpl->setCurrentBlock("preliminaries");
512  $this->tpl->setVariable("TXT_PRELIMINARIES",$this->lng->txt("preliminaries"));
513  $this->tpl->setVariable("TAB_CLASS", $class);
514  $this->tpl->parseCurrentBlock();
515 
516  // change password link
517  $class = ($this->active_tab == "password")
518  ? "ilSMActive"
519  : "ilSMInactive";
520  $this->tpl->setCurrentBlock("change_password");
521  $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
522  $this->tpl->setVariable("TAB_CLASS", $class);
523  $this->tpl->parseCurrentBlock();
524  }
525 
526  // logout link
527  if ($this->setup->isAuthenticated())
528  {
529  $this->tpl->setCurrentBlock("logout");
530  $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
531  $this->tpl->parseCurrentBlock();
532  }
533  }
534 
535  $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
536  $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
537  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
538  $this->tpl->setVariable("PAGETITLE","Setup");
539  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
540  $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
541  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","./css/setup.css");
542  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
543  $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
544  $this->tpl->setVariable("VERSION", $this->version);
545  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
546  $this->tpl->setVariable("LANG", $this->lang);
547  }
548 
552  function displayFooter()
553  {
554  // footer (not really)
555  if ($this->cmd != "logout")
556  {
557  if ($this->setup->ini_ilias_exists and $this->display_mode == "setup" and $this->setup->getClient()->getId() != "")
558  {
559  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
560  }
561  elseif ($this->setup->isAdmin())
562  {
563  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
564  }
565 
566  $this->displayNavButtons();
567  }
568 
569  $this->tpl->show();
570  }
571 
577  function displayNavButtons()
578  {
579  if (!$this->btn_prev_on and !$this->btn_next_on)
580  {
581  return false;
582  }
583 
584  $ntpl = new ilTemplate("tpl.navbuttons.html", true, true, "setup");
585  //$this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html", "setup");
586 
587  $ntpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
588 
589  if ($this->btn_prev_on)
590  {
591  $ntpl->setCurrentBlock("btn_back");
592  $ntpl->setVariable("TXT_PREV", $this->btn_prev_lng);
593  $ntpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
594  $ntpl->parseCurrentBlock();
595  }
596 
597  if ($this->btn_next_on)
598  {
599  $ntpl->setCurrentBlock("btn_forward");
600  $ntpl->setVariable("TXT_NEXT", $this->btn_next_lng);
601  $ntpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
602  $ntpl->parseCurrentBlock();
603  }
604 
605  $nav_html = $ntpl->get();
606  $this->tpl->setVariable("NAVBUTTONS", $nav_html);
607  if (!$this->no_second_nav)
608  {
609  $this->tpl->setVariable("NAVBUTTONS2", $nav_html);
610  }
611  return true;
612  }
613 
620  function SetButtonPrev($a_cmd = 0,$a_lng = 0)
621  {
622  $this->btn_prev_on = true;
623  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
624  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("prev");
625  }
626 
633  function SetButtonNext($a_cmd,$a_lng = 0)
634  {
635  $this->btn_next_on = true;
636  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
637  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next");
638  }
639 
643 
648  {
649  $this->checkDisplayMode();
650 
651  // disable/enable button
652  $btpl = new ilTemplate("tpl.buttons.html", true, true, "setup");
653  $btpl->setCurrentBlock("btn");
654  $btpl->setVariable("CMD", "changeaccess");
655  $access_button = ($this->setup->getClient()->status["access"]["status"]) ? "disable" : "enable";
656  $btpl->setVariable("TXT", $this->lng->txt($access_button));
657  $btpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
658  $btpl->parseCurrentBlock();
659  $this->tpl->setVariable("BUTTONS", $btpl->get());
660 
661  $this->initClientOverviewForm();
662  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
663 
664  $this->displayStatusPanel();
665  }
666 
670  public function initClientOverviewForm()
671  {
672  global $lng, $ilCtrl;
673 
674  $settings = $this->setup->getClient()->getAllSettings();
675 
676  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
677  $this->form = new ilPropertyFormGUI();
678 
679  $this->form->setTitle($lng->txt("client_info"));
680 
681  // installation name
682  $ne = new ilNonEditableValueGUI($lng->txt("inst_name"), "inst_name");
683  $ne->setValue(($this->setup->getClient()->getName())
684  ? $this->setup->getClient()->getName()
685  : "&lt;".$this->lng->txt("no_client_name")."&gt;");
686  $ne->setInfo($this->setup->getClient()->getDescription());
687  $this->form->addItem($ne);
688 
689  // client id
690  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "client_id");
691  $ne->setValue($this->setup->getClient()->getId());
692  $this->form->addItem($ne);
693 
694  // nic id
695  $ne = new ilNonEditableValueGUI($lng->txt("ilias_nic_id"), "nic_id");
696  $ne->setValue(($this->setup->getClient()->db_installed)
697  ? $settings["inst_id"]
698  : $txt_no_database);
699  $this->form->addItem($ne);
700 
701  // database version
702  $ne = new ilNonEditableValueGUI($lng->txt("db_version"), "db_vers");
703  $ne->setValue(($this->setup->getClient()->db_installed)
704  ? $settings["db_version"]
705  : $txt_no_database);
706  $this->form->addItem($ne);
707 
708  // access status
709  $ne = new ilNonEditableValueGUI($lng->txt("access_status"), "status");
710  //$access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->setup->getClient()->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
711  $access_status = ($this->setup->getClient()->status["access"]["status"]) ? "online" : "disabled";
712  $ne->setValue($this->lng->txt($access_status).$access_link);
713  $this->form->addItem($ne);
714 
715  // server information
716  $sh = new ilFormSectionHeaderGUI();
717  $sh->setTitle($this->lng->txt("server_info"));
718  $this->form->addItem($sh);
719 
720  // ilias version
721  $ne = new ilNonEditableValueGUI($lng->txt("ilias_version"), "il_vers");
722  $ne->setValue(ILIAS_VERSION);
723  $this->form->addItem($ne);
724 
725  // host
726  $ne = new ilNonEditableValueGUI($lng->txt("host"), "host");
727  $ne->setValue($_SERVER["SERVER_NAME"]);
728  $this->form->addItem($ne);
729 
730  // ip address and port
731  $ne = new ilNonEditableValueGUI($lng->txt("ip_address")." & ".
732  $lng->txt("port"));
733  $ne->setValue($_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"]);
734  $this->form->addItem($ne);
735 
736  // server software
737  $ne = new ilNonEditableValueGUI($lng->txt("server_software"), "server_softw");
738  $ne->setValue($_SERVER["SERVER_SOFTWARE"]);
739  $this->form->addItem($ne);
740 
741  // http path
742  $ne = new ilNonEditableValueGUI($lng->txt("http_path"), "http_path");
743  $ne->setValue(ILIAS_HTTP_PATH);
744  $this->form->addItem($ne);
745 
746  // absolute path
747  $ne = new ilNonEditableValueGUI($lng->txt("absolute_path"), "absolute_path");
749  $this->form->addItem($ne);
750 
751  // third party tools
752  $sh = new ilFormSectionHeaderGUI();
753  $sh->setTitle($this->lng->txt("3rd_party_software"));
754  $this->form->addItem($sh);
755 
756  $tools = array("convert", "zip", "unzip", "java", "htmldoc", "mkisofs");
757 
758  foreach ($tools as $tool)
759  {
760  // tool
761  $ne = new ilNonEditableValueGUI($lng->txt($tool."_path"), $tool."_path");
762  $p = $this->setup->ini->readVariable("tools", $tool);
763  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
764  $this->form->addItem($ne);
765  }
766 
767  // latex
768  $ne = new ilNonEditableValueGUI($lng->txt("url_to_latex"), "latex_url");
769  $p = $this->setup->ini->readVariable("tools", "latex_url");
770  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
771  $this->form->addItem($ne);
772 
773  // virus scanner
774  $ne = new ilNonEditableValueGUI($lng->txt("virus_scanner"), "vscan");
775  $ne->setValue($this->setup->ini->readVariable("tools","vscantype"));
776  $this->form->addItem($ne);
777 
778  // scan command
779  $ne = new ilNonEditableValueGUI($lng->txt("scan_command"), "scan");
780  $p = $this->setup->ini->readVariable("tools","scancommand");
781  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
782  $this->form->addItem($ne);
783 
784  // clean command
785  $ne = new ilNonEditableValueGUI($lng->txt("clean_command"), "clean");
786  $p = $this->setup->ini->readVariable("tools","cleancommand");
787  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
788  $this->form->addItem($ne);
789 
790  $this->form->setFormAction("setup.php?cmd=gateway");
791  }
792 
796 
801  {
802  $OK = "<font color=\"green\"><strong>OK</strong></font>";
803  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
804 
805  $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html", "setup");
806 
807  $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
808  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
809  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
810  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
811  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
812  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
813  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
814 
815  $server_os = php_uname();
816  $server_web = $_SERVER["SERVER_SOFTWARE"];
817  $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
818 
819  if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
820  {
821  $env_comment = $this->lng->txt("env_ok");
822  }
823  else
824  {
825  $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
826  }
827 
828  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
829  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
830  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
831 
832  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
833  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
834 
835  $preliminaries = array("php", "root", "folder_create",
836  "cookies_enabled", "dom", "xsl", "gd", "memory");
837  foreach ($preliminaries as $preliminary)
838  {
839  $this->tpl->setCurrentBlock("preliminary");
840  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_".$preliminary));
841  if ($this->setup->preliminaries_result[$preliminary]["status"] == true)
842  {
843  $this->tpl->setVariable("STATUS_PRE", $OK);
844  }
845  else
846  {
847  $this->tpl->setVariable("STATUS_PRE", $FAILED);
848  }
849  $this->tpl->setVariable("COMMENT_PRE", $this->setup->preliminaries_result[$preliminary]["comment"]);
850  $this->tpl->parseCurrentBlock();
851  }
852 
853  // summary
854  if ($this->setup->preliminaries === true)
855  {
856  if ($this->setup->isInstalled())
857  {
858  $cmd = "mastersettings";
859  }
860  else
861  {
862  $cmd = "install";
863  }
864  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
865 //echo "-".$this->display_mode."-";
866  $this->setButtonNext($cmd,$btn_text);
867  }
868  else
869  {
870  $this->tpl->setCurrentBlock("premessage");
871  $this->tpl->setVariable("TXT_PRE_ERR", sprintf($this->lng->txt("pre_error"),
872  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"));
873  $this->tpl->parseCurrentBlock();
874  }
875  }
876 
880 
884  function displayMasterSetup($a_omit_init = false)
885  {
886  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
887  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
888  $this->tpl->setVariable("TXT_INFO",
889  $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
890 
891  $this->setButtonPrev("preliminaries");
892 
893  if ($this->setup->isInstalled())
894  {
895  $this->setButtonNext("list");
896  }
897 
898  if (!$a_omit_init)
899  {
900  $this->initBasicSettingsForm(true);
901  }
902  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
903  }
904 
908  function changeMasterSettings($a_omit_init = false)
909  {
910  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
911  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
912  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
913 
914  $this->btn_next_on = true;
915  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
916  $this->btn_next_cmd = "newclient";
917 
918  if (!$a_omit_init)
919  {
920  $this->initBasicSettingsForm();
921  $this->getBasicSettingsValues();
922  }
923  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
924  }
925 
929  public function initBasicSettingsForm($a_install = false)
930  {
931  global $lng, $ilCtrl;
932 
933  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
934  $this->form = new ilPropertyFormGUI();
935 
936  // webspace dir
937  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
938  if ($a_install)
939  {
940  $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
941  }
942  $cwd = ilUtil::isWindows()
943  ? str_replace("\\", "/", getcwd())
944  : getcwd();
945 
946  $ne->setValue($cwd."/data");
947  $this->form->addItem($ne);
948 
949  // data dir
950  if ($a_install)
951  {
952  $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
953  $ti->setInfo($lng->txt("data_directory_info"));
954  $ti->setRequired(true);
955  $this->form->addItem($ti);
956  }
957  else
958  {
959  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
960  $this->form->addItem($ne);
961  }
962 
963  $lvext = (ilUtil::isWindows())
964  ? "_win"
965  : "";
966 
967 
968  // logging
969  $sh = new ilFormSectionHeaderGUI();
970  $sh->setTitle($lng->txt("logging"));
971  $this->form->addItem($sh);
972 
973  // path to log file
974  $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
975  $ti->setInfo($lng->txt("log_path_comment".$lvext));
976  $this->form->addItem($ti);
977 
978  // disable logging
979  $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
980  $this->form->addItem($cb);
981 
982  // server settings
983  $sh = new ilFormSectionHeaderGUI();
984  $sh->setTitle($lng->txt("server_settings"));
985  $this->form->addItem($sh);
986 
987  // time zone
988  include_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
989  $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
990  $si->setOptions(array_merge(
991  array("" => "-- ".$lng->txt("please_select")." --"),
993  $si->setRequired(true);
994  $this->form->addItem($si);
995 
996  // required 3rd party tools
997  $sh = new ilFormSectionHeaderGUI();
998  $sh->setTitle($lng->txt("3rd_party_software_req"));
999  $this->form->addItem($sh);
1000 
1001  // convert path
1002  $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
1003  $ti->setInfo($lng->txt("convert_path_comment".$lvext));
1004  $ti->setRequired(true);
1005  $this->form->addItem($ti);
1006 
1007  // zip path
1008  $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
1009  $ti->setInfo($lng->txt("zip_path_comment".$lvext));
1010  $ti->setRequired(true);
1011  $this->form->addItem($ti);
1012 
1013  // unzip path
1014  $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
1015  $ti->setInfo($lng->txt("unzip_path_comment".$lvext));
1016  $ti->setRequired(true);
1017  $this->form->addItem($ti);
1018 
1019  // optional 3rd party tools
1020  $sh = new ilFormSectionHeaderGUI();
1021  $sh->setTitle($lng->txt("3rd_party_software_opt"));
1022  $this->form->addItem($sh);
1023 
1024  // java path
1025  $ti = new ilTextInputGUI($lng->txt("java_path"), "java_path");
1026  $ti->setInfo($lng->txt("java_path_comment".$lvext));
1027  $this->form->addItem($ti);
1028 
1029  // htmldoc path
1030  $ti = new ilTextInputGUI($lng->txt("htmldoc_path"), "htmldoc_path");
1031  $ti->setInfo($lng->txt("htmldoc_path_comment".$lvext));
1032  $this->form->addItem($ti);
1033 
1034  // mkisofs path
1035  $ti = new ilTextInputGUI($lng->txt("mkisofs_path"), "mkisofs_path");
1036  $ti->setInfo($lng->txt("mkisofs_path_comment"));
1037  $this->form->addItem($ti);
1038 
1039  // latex
1040  $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
1041  $ti->setInfo($lng->txt("latex_url_comment"));
1042  $this->form->addItem($ti);
1043 
1044  // virus scanner
1045  $options = array(
1046  "none" => $lng->txt("none"),
1047  "sophos" => $lng->txt("sophos"),
1048  "antivir" => $lng->txt("antivir"),
1049  "clamav" => $lng->txt("clamav")
1050  );
1051  $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
1052  $si->setOptions($options);
1053  $this->form->addItem($si);
1054 
1055  // scan command
1056  $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
1057  $this->form->addItem($ti);
1058 
1059  // clean command
1060  $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
1061  $this->form->addItem($ti);
1062 
1063  if ($a_install)
1064  {
1065  $sh = new ilFormSectionHeaderGUI();
1066  $sh->setTitle($lng->txt("master_password"));
1067  $this->form->addItem($sh);
1068 
1069  // password
1070  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1071  $pi->setRequired(true);
1072  $pi->setSkipSyntaxCheck(true);
1073  $pi->setInfo($lng->txt("password_info"));
1074  $this->form->addItem($pi);
1075  }
1076 
1077  if ($a_install)
1078  {
1079  $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
1080  }
1081  else
1082  {
1083  $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
1084  $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
1085  }
1086 
1087  $this->form->setTitle($lng->txt("data_directories"));
1088  $this->form->setFormAction("setup.php?cmd=gateway");
1089 
1090  if ($a_install)
1091  {
1092  $det = $this->determineTools();
1093  $this->form->setValuesByArray($det);
1094  }
1095 
1096  }
1097 
1101  public function getBasicSettingsValues()
1102  {
1103  $values = array();
1104 
1105  $values["webspace_dir"] = getcwd()."/data";
1106  $values["data_dir"] = $this->setup->ini->readVariable("clients","datadir");
1107  $values["convert_path"] = $this->setup->ini->readVariable("tools","convert");
1108  $values["zip_path"] = $this->setup->ini->readVariable("tools","zip");
1109  $values["unzip_path"] = $this->setup->ini->readVariable("tools","unzip");
1110  $values["java_path"] = $this->setup->ini->readVariable("tools","java");
1111  $values["htmldoc_path"] = $this->setup->ini->readVariable("tools","htmldoc");
1112  $values["mkisofs_path"] = $this->setup->ini->readVariable("tools","mkisofs");
1113  $values["latex_url"] = $this->setup->ini->readVariable("tools","latex");
1114  $values["fop_path"] = $this->setup->ini->readVariable("tools","fop");
1115  $values["vscanner_type"] = $this->setup->ini->readVariable("tools", "vscantype");
1116  $values["scan_command"] = $this->setup->ini->readVariable("tools", "scancommand");
1117  $values["clean_command"] = $this->setup->ini->readVariable("tools", "cleancommand");
1118  $values["log_path"] = $this->setup->ini->readVariable("log","path")."/".
1119  $this->setup->ini->readVariable("log","file");
1120  $values["chk_log_status"] = !$this->setup->ini->readVariable("log","enabled");
1121  $values["time_zone"] = $this->setup->ini->readVariable("server", "timezone");
1122 
1123  $this->form->setValuesByArray($values);
1124  }
1125 
1129  public function saveBasicSettings()
1130  {
1131  global $tpl, $lng, $ilCtrl;
1132 
1133  $this->initBasicSettingsForm(true);
1134 
1135  if ($this->form->checkInput())
1136  {
1137  // correct paths on windows
1138  if (ilUtil::isWindows())
1139  {
1140  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1141  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1142  foreach ($fs as $f)
1143  {
1144  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1145  }
1146  }
1147 
1148  $_POST["setup_pass"] = $_POST["password"];
1149  $_POST["setup_pass2"] = $_POST["password_retype"];
1150  if (!$this->setup->checkDataDirSetup($_POST))
1151  {
1152  $i = $this->form->getItemByPostVar("datadir_path");
1153  $i->setAlert($this->lng->txt($this->setup->getError()));
1154  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1155  }
1156  else if (!$this->setup->checkLogSetup($_POST))
1157  {
1158  $i = $this->form->getItemByPostVar("log_path");
1159  $i->setAlert($this->lng->txt($this->setup->getError()));
1160  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1161  }
1162  else if (!$this->setup->checkPasswordSetup($_POST))
1163  {
1164  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1165  }
1166  else if (!$this->setup->saveMasterSetup($_POST))
1167  {
1168  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1169  }
1170  else
1171  {
1172  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1173  ilUtil::redirect("setup.php?cmd=mastersettings");
1174  }
1175  }
1176 
1177  $this->form->setValuesByPost();
1178  $this->displayMasterSetup(true);
1179  }
1180 
1184  public function updateBasicSettings()
1185  {
1186  global $tpl, $lng, $ilCtrl;
1187 
1188  $this->initBasicSettingsForm();
1189 
1190  if ($this->form->checkInput())
1191  {
1192  if (ilUtil::isWindows())
1193  {
1194  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1195  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1196  foreach ($fs as $f)
1197  {
1198  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1199  }
1200  }
1201 
1202  if (!$this->setup->checkLogSetup($_POST))
1203  {
1204  $i = $this->form->getItemByPostVar("log_path");
1205  $i->setAlert($this->lng->txt($this->setup->getError()));
1206  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1207  }
1208  else if (!$this->setup->updateMasterSettings($_POST))
1209  {
1210  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1211  }
1212  else
1213  {
1214  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1215  ilUtil::redirect("setup.php?cmd=mastersettings");
1216  }
1217  }
1218 
1219  $this->form->setValuesByPost();
1220  $this->changeMasterSettings(true);
1221  }
1222 
1226 
1230  function loginClient()
1231  {
1232  session_destroy();
1233 
1234  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
1235  }
1236 
1240  function displayLogin($a_omit_minit = false, $a_omit_cinit = false)
1241  {
1242  global $lng;
1243 
1244  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
1245 
1246  if ($a_omit_minit)
1247  {
1248  $m_form = $this->form->getHTML();
1249  }
1250  if (!$a_omit_cinit)
1251  {
1252  $this->initClientLoginForm();
1253  }
1254  $cl_form = $this->form->getHTML();
1255  if (!$a_omit_minit)
1256  {
1257  $this->initMasterLoginForm();
1258  $m_form = $this->form->getHTML();
1259  }
1260  $this->tpl->setVariable("SETUP_CONTENT", $cl_form."<br>".$m_form);
1261  $this->tpl->setVariable("TXT_HEADER", $lng->txt("login"));
1262  }
1263 
1267  public function performMLogin()
1268  {
1269  $this->initMasterLoginForm();
1270  if ($this->form->checkInput())
1271  {
1272  $i = $this->form->getItemByPostVar("mpassword");
1273  if (!$this->setup->loginAsAdmin($_POST["mpassword"]))
1274  {
1275  $i->setAlert($this->lng->txt("login_invalid"));
1276  }
1277  else
1278  {
1279  // everything ok -> we are authenticated
1280  ilUtil::redirect("setup.php");
1281  }
1282  }
1283 
1284  // something wrong -> display login again
1285  $this->form->setValuesByPost();
1286  $this->displayLogin(true);
1287  }
1288 
1292  function performLogin()
1293  {
1294  $this->initClientLoginForm();
1295  if ($this->form->checkInput())
1296  {
1297  $i = $this->form->getItemByPostVar("password");
1298  if (!$this->setup->loginAsClient(
1299  array("client_id" => $_POST["client_id"],
1300  "username" => $_POST["username"], "password" => $_POST["password"])))
1301  {
1302  $i->setAlert($this->setup->getError());
1303  }
1304  else
1305  {
1306  // everything ok -> we are authenticated
1307  ilUtil::redirect("setup.php");
1308  }
1309  }
1310 
1311  // something wrong -> display login again
1312  $this->form->setValuesByPost();
1313  $this->displayLogin(false, true);
1314  }
1315 
1319  public function initClientLoginForm()
1320  {
1321  global $lng, $ilCtrl;
1322 
1323  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1324  $this->form = new ilPropertyFormGUI();
1325 
1326  // client id
1327  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1328  $ti->setMaxLength(32);
1329  $ti->setSize(20);
1330  $this->form->addItem($ti);
1331 
1332  // username
1333  $ti = new ilTextInputGUI($lng->txt("username"), "username");
1334  $ti->setSize(20);
1335  $this->form->addItem($ti);
1336 
1337  // password
1338  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1339  $pi->setSize(20);
1340  $pi->setRetype(false);
1341  $pi->setSkipSyntaxCheck(true);
1342  $this->form->addItem($pi);
1343 
1344  $this->form->addCommandButton("performLogin", $lng->txt("login"));
1345 
1346  $this->form->setTitle($lng->txt("client_login"));
1347  $this->form->setFormAction("setup.php?cmd=gateway");
1348  }
1349 
1353  public function initMasterLoginForm()
1354  {
1355  global $lng, $ilCtrl;
1356 
1357  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1358  $this->form = new ilPropertyFormGUI();
1359 
1360  // password
1361  $pi = new ilPasswordInputGUI($lng->txt("password"), "mpassword");
1362  $pi->setSize(20);
1363  $pi->setRetype(false);
1364  $pi->setSkipSyntaxCheck(true);
1365  $this->form->addItem($pi);
1366 
1367  $this->form->addCommandButton("performMLogin", $lng->txt("login"));
1368 
1369  $this->form->setTitle($lng->txt("admin_login"));
1370  $this->form->setFormAction("setup.php?cmd=gateway");
1371 
1372  }
1373 
1377 
1382  {
1383  $_SESSION["ClientId"] = "";
1384 
1385  $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html", "setup");
1386  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1387  ilUtil::sendInfo();
1388 
1389  // common
1390  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("list_clients"));
1391  $this->tpl->setVariable("TXT_LISTSTATUS",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1392  $this->tpl->setVariable("TXT_TOGGLELIST",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1393 
1394  include_once("./setup/classes/class.ilClientListTableGUI.php");
1395  $tab = new ilClientListTableGUI($this->setup);
1396  $this->tpl->setVariable("CLIENT_LIST", $tab->getHTML());
1397 
1398  // create new client button
1399  $this->btn_next_on = true;
1400  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
1401  $this->btn_next_cmd = "newclient";
1402  }
1403 
1408  {
1409  $_POST = $this->determineTools($_POST);
1410  $this->updateBasicSettings();
1411  }
1412 
1417  {
1418  $this->displayMasterSetup(true);
1419  }
1420 
1424  function determineTools($a_tools = "")
1425  {
1426  $cwd = ilUtil::isWindows()
1427  ? str_replace("\\", "/", getcwd())
1428  : getcwd();
1429  if (!ilUtil::isWindows())
1430  {
1431  $tools = array("convert" => "convert",
1432  "zip" => "zip", "unzip" => "unzip",
1433  "java" => "java", "htmldoc" => "htmldoc", "mkisofs" => "mkisofs");
1434  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin", "/usr/bin");
1435  }
1436  else
1437  {
1438  $tools = array("convert" => "convert.exe",
1439  "zip" => "zip.exe", "unzip" => "unzip.exe");
1440  $dirs = array($cwd."/Services/Windows/bin32/zip",
1441  $cwd."/Services/Windows/bin32/unzip",
1442  $cwd."/Services/Windows/bin32/convert");
1443  }
1444  foreach($tools as $k => $tool)
1445  {
1446  // try which command
1447  unset($ret);
1448  @exec("which ".$tool, $ret);
1449  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
1450  {
1451  $a_tools[$k."_path"] = $ret[0];
1452  continue;
1453  }
1454 
1455  // try common directories
1456  foreach($dirs as $dir)
1457  {
1458  if (@is_file($dir."/".$tool))
1459  {
1460  $a_tools[$k."_path"] = $dir."/".$tool;
1461  continue;
1462  }
1463  }
1464  }
1465  return $a_tools;
1466  }
1467 
1468 
1472 
1477  function selectDBType()
1478  {
1479  $this->checkDisplayMode("create_new_client");
1480 
1481 
1482 if (true)
1483 {
1484  $this->initDBSelectionForm();
1485  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1486 }
1487 else
1488 {
1489  // output
1490 
1491  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_select_db.html", "setup");
1492 
1493  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1494  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1495 
1496  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
1497  $this->tpl->setVariable("TXT_DB_SELECTION", $this->lng->txt("db_selection"));
1498 }
1499  if ($this->setup->getClient()->status["ini"]["status"])
1500  {
1501  $this->setButtonNext("db");
1502  }
1503 
1504  $this->checkPanelMode();
1505  }
1506 
1510  public function initDBSelectionForm()
1511  {
1512  global $lng, $ilCtrl;
1513 
1514  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1515  $this->form = new ilPropertyFormGUI();
1516 
1517  // db type
1518  $options = array(
1519  "mysql" => "MySQL 5.0.x or higher",
1520  "oracle" => "Oracle 10g or higher",
1521  );
1522  $si = new ilSelectInputGUI($lng->txt("db_type"), "db_type");
1523  $si->setOptions($options);
1524  $si->setInfo($lng->txt(""));
1525  $this->form->addItem($si);
1526 
1527  $this->form->addCommandButton("selectdbtype", $lng->txt("save"));
1528 
1529  $this->form->setTitle($lng->txt("db_selection"));
1530  $this->form->setFormAction("setup.php?cmd=gateway");
1531  }
1532 
1536 
1540  function displayIni($a_omit_form_init = false)
1541  {
1542  $this->checkDisplayMode("create_new_client");
1543 
1544  if ($_POST["db_type"] != "")
1545  {
1546  $_SESSION["db_type"] = $_POST["db_type"];
1547  }
1548  else
1549  {
1550  $_POST["db_type"] = $_SESSION["db_type"];
1551  }
1552 
1553  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1554  if (!$a_omit_form_init)
1555  {
1556  $this->initClientIniForm();
1557  $this->getClientIniValues();
1558  }
1559  $this->tpl->setVariable("SETUP_CONTENT",
1560  $this->form->getHTML());
1561 
1562  if ($this->setup->getClient()->status["ini"]["status"])
1563  {
1564  $this->setButtonNext("db");
1565  }
1566 
1567  $this->checkPanelMode();
1568  }
1569 
1573  public function initClientIniForm()
1574  {
1575  global $lng, $ilCtrl;
1576 
1577  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1578  $this->form = new ilPropertyFormGUI();
1579 
1580  // client id
1581  if ($this->setup->ini_client_exists)
1582  {
1583  $hi = new ilHiddenInputGUI("client_id");
1584  $hi->setValue($this->client_id);
1585  $this->form->addItem($hi);
1586 
1587  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "hh");
1588  $ne->setValue($this->client_id);
1589  $this->form->addItem($ne);
1590  }
1591  else
1592  {
1593  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1594  $ti->setMaxLength(32);
1595  $ti->setRequired(true);
1596  $this->form->addItem($ti);
1597  }
1598 
1599  // database connection
1600  $sh = new ilFormSectionHeaderGUI();
1601  $sh->setTitle($lng->txt("db_conn"));
1602  $this->form->addItem($sh);
1603 
1604  // db type
1605  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "dbt");
1606  $ne->setValue($lng->txt("db_".$_SESSION["db_type"]));
1607  $this->form->addItem($ne);
1608 
1609  // db host
1610  $ti = new ilTextInputGUI($lng->txt("db_host"), "db_host");
1611  $ti->setMaxLength(120);
1612  $ti->setRequired(true);
1613  $this->form->addItem($ti);
1614 
1615  // db name
1616  if ($_SESSION["db_type"] == "mysql")
1617  {
1618  $ti = new ilTextInputGUI($lng->txt("db_name"), "db_name");
1619  $ti->setRequired(true);
1620  }
1621  else
1622  {
1623  $ti = new ilTextInputGUI($lng->txt("db_service_name"), "db_name");
1624  }
1625  $ti->setMaxLength(40);
1626  $this->form->addItem($ti);
1627 
1628  // db user
1629  $ti = new ilTextInputGUI($lng->txt("db_user"), "db_user");
1630  $ti->setMaxLength(40);
1631  $ti->setRequired(true);
1632  $this->form->addItem($ti);
1633 
1634  // db port
1635  $ti = new ilTextInputGUI($lng->txt("db_port"), "db_port");
1636  $ti->setMaxLength(8);
1637  $this->form->addItem($ti);
1638 
1639  // db password
1640  $ti = new ilTextInputGUI($lng->txt("db_pass"), "db_pass");
1641  $ti->setMaxLength(40);
1642  $this->form->addItem($ti);
1643 
1644  $this->form->addCommandButton("saveClientIni", $lng->txt("save"));
1645 
1646  $this->form->setTitle($lng->txt("inst_identification"));
1647  $this->form->setFormAction("setup.php?cmd=gateway");
1648  }
1649 
1653  public function getClientIniValues()
1654  {
1655  $values = array();
1656 
1657  $values["db_host"] = $this->setup->getClient()->getDbHost();
1658  $values["db_user"] = $this->setup->getClient()->getDbUser();
1659  $values["db_port"] = $this->setup->getClient()->getDbPort();
1660  $values["db_pass"] = $this->setup->getClient()->getDbPass();
1661  $values["db_name"] = $this->setup->getClient()->getDbName();
1662  $values["client_id"] = $this->setup->getClient()->getId();
1663 
1664  $this->form->setValuesByArray($values);
1665  }
1666 
1670  public function saveClientIni()
1671  {
1672  global $tpl, $lng, $ilCtrl;
1673 
1674  $this->initClientIniForm();
1675  if ($this->form->checkInput())
1676  {
1677  if (strlen($_POST["client_id"]) != strlen(urlencode(($_POST["client_id"]))))
1678  {
1679  $i = $this->form->getItemByPostVar("client_id");
1680  $i->setAlert($this->lng->txt("ini_client_id_invalid"));
1681  ilUtil::sendFailure($this->lng->txt("ini_client_id_invalid"),true);
1682  }
1683  else if (strlen($_POST["client_id"]) < 4)
1684  {
1685  $i = $this->form->getItemByPostVar("client_id");
1686  $i->setAlert($this->lng->txt("ini_client_id_too_short"));
1687  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_short"),true);
1688  }
1689  else if (strlen($_POST["client_id"]) > 32)
1690  {
1691  $i = $this->form->getItemByPostVar("client_id");
1692  $i->setAlert($this->lng->txt("ini_client_id_too_long"));
1693  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_long"),true);
1694  }
1695  else if (!$this->setup->ini_client_exists && file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$_POST["client_id"]))
1696  {
1697  $i = $this->form->getItemByPostVar("client_id");
1698  $i->setAlert($this->lng->txt("ini_client_id_exists"));
1699  ilUtil::sendFailure($this->lng->txt("ini_client_id_exists"),true);
1700  }
1701  else
1702  {
1703 
1704  // save some old values
1705  $old_db_name = $this->setup->getClient()->getDbName();
1706  $old_db_type = $this->setup->getClient()->getDbType();
1707  $old_client_id = $this->setup->getClient()->getId();
1708 
1709  // create new client object if it does not exist
1710  if (!$this->setup->ini_client_exists)
1711  {
1712  $client_id = $_POST["client_id"];
1713  $this->setup->newClient($client_id);
1714  }
1715 
1716  // set client data
1717  $this->setup->getClient()->setId($_POST["client_id"]);
1718  $this->setup->getClient()->setDbHost($_POST["db_host"]);
1719  $this->setup->getClient()->setDbName($_POST["db_name"]);
1720  $this->setup->getClient()->setDbUser($_POST["db_user"]);
1721  $this->setup->getClient()->setDbPort($_POST["db_port"]);
1722  $this->setup->getClient()->setDbPass($_POST["db_pass"]);
1723  $this->setup->getClient()->setDbType($_SESSION["db_type"]);
1724  $this->setup->getClient()->setDSN();
1725 
1726  // try to connect to database
1727  if (!$this->setup->getClient()->checkDatabaseHost())
1728  {
1729  $i = $this->form->getItemByPostVar("db_host");
1730  $i->setAlert($this->lng->txt($this->setup->getClient()->getError()));
1731  ilUtil::sendFailure($this->setup->getClient()->getError(),true);
1732  }
1733  else
1734  {
1735  // check if db exists
1736  $db_installed = $this->setup->getClient()->checkDatabaseExists();
1737 
1738  if ($db_installed and (!$this->setup->ini_ilias_exists or ($this->setup->getClient()->getDbName() != $old_db_name)))
1739  {
1740  $_POST["db_name"] = $old_db_name;
1741  $message = ucfirst($this->lng->txt("database"))." \"".$this->setup->getClient()->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
1742  $i = $this->form->getItemByPostVar("db_name");
1743  $i->setAlert($message);
1744  ilUtil::sendFailure($message, true);
1745  }
1746  else
1747  {
1748  // all ok. create client.ini and save posted data
1749  if (!$this->setup->ini_client_exists)
1750  {
1751  if ($this->setup->saveNewClient())
1752  {
1753  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1754  $this->setup->getClient()->status["ini"]["status"] = true;
1755  $_SESSION["ClientId"] = $client_id;
1756  ilUtil::redirect("setup.php?cmd=displayIni&client_id=".$client_id);
1757  }
1758  else
1759  {
1760  $err = $this->setup->getError();
1761  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1762  $this->setup->getClient()->status["ini"]["status"] = false;
1763  $this->setup->getClient()->status["ini"]["comment"] = $err;
1764  }
1765  }
1766  else
1767  {
1768  if ($this->setup->getClient()->ini->write())
1769  {
1770  ilUtil::sendSuccess($this->lng->txt("settings_changed"));
1771  $this->setup->getClient()->status["ini"]["status"] = true;
1772  ilUtil::redirect("setup.php?cmd=displayIni");
1773  }
1774  else
1775  {
1776  $err = $this->setup->getClient()->ini->getError();
1777  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1778  $this->setup->getClient()->status["ini"]["status"] = false;
1779  $this->setup->getClient()->status["ini"]["comment"] = $err;
1780  }
1781  }
1782  }
1783  }
1784  }
1785  }
1786 
1787  $this->form->setValuesByPost();
1788  $this->displayIni(true);
1789  }
1790 
1796  function displayError($a_message)
1797  {
1798  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html", "setup");
1799 
1800  $this->tpl->setCurrentBlock("content");
1801  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1802  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1803  $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
1804  $this->tpl->parseCurrentBlock();
1805 
1806  $this->tpl->show();
1807  exit();
1808  }
1809 
1813  function displayLogout()
1814  {
1815  $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html", "setup");
1816 
1817  session_destroy();
1818 
1819  $this->logged_out = true;
1820  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));
1821  $this->tpl->setCurrentBlock("home_link");
1822  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
1823  $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
1824  $this->tpl->parseCurrentBlock();
1825  }
1826 
1831  {
1832  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1833 
1834  $steps = array();
1835  $steps = $this->setup->getStatus();
1836 
1837  // remove access step
1838  unset($steps["access"]);
1839 
1840  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1841  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1842  //$steps["sess"]["text"] = $this->lng->txt("setup_process_step_sess");
1843  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1844  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1845  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1846  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1847 
1848  $stpl = new ilTemplate("tpl.process_panel.html", true, true, "setup");
1849 
1850  $num = 1;
1851 
1852  foreach ($steps as $key => $val)
1853  {
1854  $stpl->setCurrentBlock("menu_row");
1855  $stpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
1856  $stpl->setVariable("TXT_ACTION",$val["text"]);
1857  $stpl->setVariable("IMG_ARROW", "spacer.gif");
1858 
1859  $num++;
1860 
1861  if ($this->cmd == $key and isset($this->cmd))
1862  {
1863  $stpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1864  $stpl->setVariable("IMG_ARROW", "arrow_right.png");
1865  }
1866 
1867  $status = ($val["status"]) ? $OK : "";
1868 
1869  $stpl->setVariable("TXT_STATUS",$status);
1870  $stpl->parseCurrentBlock();
1871  }
1872 
1873  $stpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
1874 
1875  $this->tpl->setVariable("PROCESS_MENU", $stpl->get());
1876  }
1877 
1882  {
1883  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1884 
1885  $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html", "setup");
1886 
1887  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1888  // display status
1889  if ($this->setup->getClient()->status)
1890  {
1891  foreach ($this->setup->getClient()->status as $key => $val)
1892  {
1893  $status = ($val["status"]) ? $OK : "&nbsp;";
1894  $this->tpl->setCurrentBlock("status_row");
1895  $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1896  $this->tpl->setVariable("TXT_STATUS",$status);
1897  $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1898  $this->tpl->parseCurrentBlock();
1899  }
1900  }
1901  }
1902 
1908  function checkDisplayMode($a_title = "")
1909  {
1910  switch ($this->display_mode)
1911  {
1912  case "view":
1913  $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html", "setup");
1914  // display tabs
1915  include "./setup/include/inc.client_tabs.php";
1916  $client_name = ($this->setup->getClient()->getName()) ? $this->setup->getClient()->getName() : $this->lng->txt("no_client_name");
1917  $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
1918  break;
1919 
1920  case "setup":
1921  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1922  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));
1923  break;
1924 
1925  default:
1926  $this->displayError($this->lng->txt("unknown_display_mode"));
1927  exit();
1928  break;
1929  }
1930  }
1931 
1935  function checkPanelMode()
1936  {
1937  switch ($this->display_mode)
1938  {
1939  case "view":
1940  $this->displayStatusPanel();
1941  break;
1942 
1943  case "setup":
1944  $this->displayProcessPanel();
1945  break;
1946  }
1947  }
1948 
1952  function displayStartup()
1953  {
1954  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1955 
1956  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
1957  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
1958 
1959  $this->displayProcessPanel();
1960 
1961  $this->setButtonNext("ini");
1962  }
1963 
1967 
1971  function displayDatabase()
1972  {
1973  global $ilErr,$ilDB,$ilLog;
1974 
1975  include_once "./Services/Database/classes/class.ilDBUpdateEA.php";
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 ilDBUpdateEA($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 ilDBUpdateEA($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->getHotfixCurrentVersionAsString());
2146  $this->form->addItem($ne);
2147 
2148  // hotfix file version
2149  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2150  $ne->setValue($dbupdate->getHotfixFileVersionAsString());
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 (strlen($dbupdate->getHotfixFileVersionAsString()))
2159  {
2160  // hotfix current version
2161  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2162  $ne->setValue($dbupdate->getHotfixCurrentVersionAsString());
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.ilDBUpdateEA.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.ilDBUpdateEA.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 ilDBUpdateEA($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  // controls the ability t maintenance the following
2414  // settings in client administration
2415  $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
2416  $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
2417  $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
2418  $form->addItem($chkb);
2419 
2420  // this is the max count of active sessions
2421  // that are getting started simlutanously
2422  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
2423  $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
2424  $ti->setMaxLength(5);
2425  $ti->setSize(5);
2426  $ti->setValue($settings['session_max_count']);
2427  $form->addItem($ti);
2428 
2429  // after this (min) idle time the session can be deleted,
2430  // if there are further requests for new sessions,
2431  // but max session count is reached yet
2432  $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
2433  $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
2434  $ti->setMaxLength(5);
2435  $ti->setSize(5);
2436  $ti->setValue($settings['session_min_idle']);
2437  $form->addItem($ti);
2438 
2439  // after this (max) idle timeout the session expires
2440  // and become invalid, so it is not considered anymore
2441  // when calculating current count of active sessions
2442  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
2443  $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
2444  $ti->setMaxLength(5);
2445  $ti->setSize(5);
2446  $ti->setValue($settings['session_max_idle']);
2447  $form->addItem($ti);
2448 
2449  // this is the max duration that can elapse between the first and the secnd
2450  // request to the system before the session is immidietly deleted
2451  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
2452  $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
2453  $ti->setMaxLength(5);
2454  $ti->setSize(5);
2455  $ti->setValue($settings['session_max_idle_after_first_request']);
2456  $form->addItem($ti);
2457 
2458  // save and cancel commands
2459  $form->addCommandButton("sess", $this->lng->txt('save'));
2460 
2461  $form->setTitle($this->lng->txt("sess_sessions"));
2462  $form->setFormAction('setup.php?client_id='.$this->client_id.'&cmd=sess');
2463 
2464  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt('sess_sessions'))));
2465  $this->tpl->setVariable("TXT_INFO", '');
2466  $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
2467 
2468  /*$this->setButtonPrev("db");
2469 
2470  if($this->setup->checkClientSessionSettings($this->client,true))
2471  {
2472  $this->setButtonNext("lang");
2473  }*/
2474 
2475  $this->checkPanelMode();
2476  }
2477 
2481 
2485  function displayLanguages()
2486  {
2487  $this->checkDisplayMode("setup_languages");
2488 
2489  if (!$this->setup->getClient()->db_installed)
2490  {
2491  // program should never come to this place
2492  $message = "No database found! Please install database first.";
2493  ilUtil::sendFailure($message);
2494  }
2495 
2496  include_once("./setup/classes/class.ilSetupLanguagesTableGUI.php");
2497  $tab = new ilSetupLanguagesTableGUI($this->setup->getClient());
2498  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2499 
2500  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2501  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2502 
2503  $installed_langs = $this->lng->getInstalledLanguages();
2504  $lang_count = count($installed_langs);
2505  if ($lang_count > 0)
2506  {
2507  $this->setup->getClient()->status["lang"]["status"] = true;
2508  $this->setup->getClient()->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2509  }
2510  else
2511  {
2512  $this->setup->getClient()->status["lang"]["status"] = false;
2513  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2514  }
2515 
2516  $this->setButtonPrev("lang");
2517 
2518  if ($lang_count > 0)
2519  {
2520  $this->setButtonNext("contact");
2521  }
2522 
2523  $this->checkPanelMode();
2524  }
2525 
2532  function saveLanguages()
2533  {
2534  if (empty($_POST["form"]["lang_id"]))
2535  {
2536  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
2537  ilUtil::redirect("setup.php?cmd=lang");
2538  }
2539 
2540  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2541  {
2542  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
2543  ilUtil::redirect("setup.php?cmd=lang");
2544  }
2545 
2546  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2547 
2548  if (is_array($result))
2549  {
2550  $count = count($result);
2551  $txt = "tet";
2552 
2553  foreach ($result as $key => $lang_key)
2554  {
2555  $list .= $this->lng->txt("lang_".$lang_key);
2556 
2557  if ($count > $key + 1)
2558  {
2559  $list .= ", ";
2560  }
2561  }
2562  }
2563 
2564  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
2565  $message = $this->lng->txt("languages_installed");
2566 
2567  if ($result !== true)
2568  {
2569  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2570  }
2571  ilUtil::sendInfo($message, true);
2572  ilUtil::redirect("setup.php?cmd=lang");
2573  }
2574 
2578 
2582  function displayContactData($a_omit_init = false)
2583  {
2584  $this->checkDisplayMode("setup_contact_data");
2585  $settings = $this->setup->getClient()->getAllSettings();
2586 
2587  if (!$a_omit_init)
2588  {
2589  $this->initContactDataForm();
2590  $this->getContactValues();
2591  }
2592  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2593  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2594  $this->setButtonPrev("lang");
2595 
2596  $check = $this->setup->checkClientContact($this->setup->client);
2597 
2598  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
2599  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
2600 
2601  if ($check["status"])
2602  {
2603  $this->setButtonNext("nic");
2604  }
2605 
2606  $this->checkPanelMode();
2607  }
2608 
2614  public function initContactDataForm()
2615  {
2616  global $lng, $ilCtrl;
2617 
2618  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2619  $this->form = new ilPropertyFormGUI();
2620 
2621  // name
2622  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
2623  $ti->setMaxLength(64);
2624  $ti->setSize(30);
2625  $ti->setRequired(true);
2626  $this->form->addItem($ti);
2627 
2628  // description
2629  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
2630  $ti->setMaxLength(64);
2631  $ti->setSize(30);
2632  $this->form->addItem($ti);
2633 
2634  // institution
2635  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
2636  $ti->setMaxLength(64);
2637  $ti->setSize(30);
2638  $this->form->addItem($ti);
2639 
2640  // contact data
2641  $sh = new ilFormSectionHeaderGUI();
2642  $sh->setTitle($lng->txt("contact_data"));
2643  $this->form->addItem($sh);
2644 
2645  // first name
2646  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
2647  $ti->setMaxLength(64);
2648  $ti->setSize(30);
2649  $ti->setRequired(true);
2650  $this->form->addItem($ti);
2651 
2652  // last name
2653  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
2654  $ti->setMaxLength(64);
2655  $ti->setSize(30);
2656  $ti->setRequired(true);
2657  $this->form->addItem($ti);
2658 
2659  $fs = array (
2660  "title" => array("max" => 64, "size" => 30),
2661  "position" => array("max" => 64, "size" => 30),
2662  "institution" => array("max" => 200, "size" => 30),
2663  "street" => array("max" => 64, "size" => 30),
2664  "zipcode" => array("max" => 10, "size" => 5),
2665  "city" => array("max" => 64, "size" => 30),
2666  "country" => array("max" => 64, "size" => 30),
2667  "phone" => array("max" => 64, "size" => 30)
2668  );
2669  foreach ($fs as $f => $op)
2670  {
2671  // field
2672  $ti = new ilTextInputGUI($lng->txt($f), "admin_".$f);
2673  $ti->setMaxLength($op["max"]);
2674  $ti->setSize($op["size"]);
2675  $ti->setInfo($lng->txt(""));
2676  $this->form->addItem($ti);
2677  }
2678 
2679  // email
2680  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
2681  $ti->setRequired(true);
2682  $this->form->addItem($ti);
2683 
2684  $this->form->addCommandButton("saveContact", $lng->txt("save"));
2685 
2686  $this->form->setTitle($lng->txt("client_data"));
2687  $this->form->setFormAction("setup.php?cmd=gateway");
2688  }
2689 
2693  public function getContactValues()
2694  {
2695 
2696  $settings = $this->setup->getClient()->getAllSettings();
2697 
2698  $values = $settings;
2699 
2700  $values["inst_name"] = ($this->setup->getClient()->getName())
2701  ? $this->setup->getClient()->getName()
2702  : $this->setup->getClient()->getId();
2703  $values["inst_info"] = $this->setup->getClient()->getDescription();
2704 
2705  $this->form->setValuesByArray($values);
2706  }
2707 
2711  public function saveContact()
2712  {
2713  global $tpl, $lng, $ilCtrl;
2714 
2715  $this->initContactDataForm();
2716  if ($this->form->checkInput())
2717  {
2718  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
2719  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
2720  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
2721  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
2722  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
2723  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
2724  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
2725  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
2726  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
2727  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
2728  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
2729  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
2730  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
2731 
2732  // update client.ini
2733  $this->setup->getClient()->setName($_POST["inst_name"]);
2734  $this->setup->getClient()->setDescription($_POST["inst_info"]);
2735  $this->setup->getClient()->ini->write();
2736 
2737  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2738  ilUtil::redirect("setup.php?cmd=displayContactData");
2739  }
2740 
2741  $this->form->setValuesByPost();
2742  $this->displayContactData(true);
2743  }
2744 
2748 
2752  function displayNIC($a_omit_init = false)
2753  {
2754  $this->checkDisplayMode("nic_registration");
2755  $settings = $this->setup->getClient()->getAllSettings();
2756  $nic_key = $this->setup->getClient()->getNICkey();
2757 
2758  // reload settings
2759  $settings = $this->setup->getClient()->getAllSettings();
2760 //var_dump($settings);
2761  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
2762  {
2763  $this->no_second_nav = true;
2764  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
2765  }
2766  else
2767  {
2768  // reload settings
2769  $settings = $this->setup->getClient()->getAllSettings();
2770 
2771  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
2772  if (!$a_omit_init)
2773  {
2774  $this->initRegistrationForm();
2775  $this->getRegistrationValues();
2776  }
2777  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2778 
2779  if (isset($settings["nic_enabled"]))
2780  {
2781  $this->setup->getClient()->status["nic"]["status"] = true;
2782  }
2783 
2784  }
2785 
2786  $this->setButtonPrev("contact");
2787 
2788  if ($this->setup->getClient()->status["nic"]["status"])
2789  {
2790  $this->setButtonNext("finish","finish");
2791  }
2792 
2793  $this->checkPanelMode();
2794  }
2795 
2801  public function initRegistrationForm($a_mode = "edit")
2802  {
2803  global $lng, $ilCtrl;
2804 
2805  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2806  $this->form = new ilPropertyFormGUI();
2807 
2808  // registration type
2809  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
2810  $radg->setValue(1);
2811  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
2812  $radg->addOption($op1);
2813  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
2814  $radg->addOption($op1);
2815  $this->form->addItem($radg);
2816 
2817  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
2818  $this->form->setFormAction("setup.php?cmd=gateway");
2819  }
2820 
2824  public function getRegistrationValues()
2825  {
2826  $settings = $this->setup->getClient()->getAllSettings();
2827  $nic_key = $this->setup->getClient()->getNICkey();
2828 
2829 
2830  $values = array();
2831 
2832  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
2833  {
2834  $values["register"] = 1;
2835  }
2836  /*elseif ($settings["nic_enabled"] == "2")
2837  {
2838  $this->tpl->setVariable("EMAIL",$checked);
2839  }*/
2840  else
2841  {
2842  $values["register"] = 0;
2843  }
2844 
2845  $this->form->setValuesByArray($values);
2846  }
2847 
2851  public function saveRegistration()
2852  {
2853  global $tpl, $lng, $ilCtrl;
2854 
2855  $this->initRegistrationForm();
2856  if ($this->form->checkInput())
2857  {
2858  // check register option
2859  if ($_POST["register"] == 1)
2860  {
2861  // update nic
2862  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
2863 //var_dump($this->setup->getClient()->nic_status);
2864  // online registration failed
2865  if (empty($this->setup->getClient()->nic_status[2]))
2866  {
2867  $this->setup->getClient()->setSetting("nic_enabled","-1");
2868  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
2869  ilUtil::redirect("setup.php?cmd=displayNIC");
2870  }
2871  else
2872  {
2873  $this->setup->getClient()->setSetting("inst_id",$this->setup->getClient()->nic_status[2]);
2874  $this->setup->getClient()->setSetting("nic_enabled","1");
2875  $this->setup->getClient()->status["nic"]["status"] = true;
2876  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
2877  ilUtil::redirect("setup.php?cmd=displayNIC");
2878  }
2879  }
2880  /*elseif ($_POST["form"]["register"] == 2)
2881  {
2882  $nic_by_email = (int) $_POST["form"]["nic_id"];
2883 
2884  $checksum = md5($nic_key.$nic_by_email);
2885 
2886  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
2887  {
2888  $message = $this->lng->txt("nic_reg_enter_correct_id");
2889  }
2890  else
2891  {
2892  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
2893  $this->setup->getClient()->setSetting("nic_enabled","1");
2894  $message = $this->lng->txt("nic_reg_enabled");
2895  }
2896  }*/
2897  else
2898  {
2899  $this->setup->getClient()->setSetting("inst_id","0");
2900  $this->setup->getClient()->setSetting("nic_enabled","0");
2901  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
2902  ilUtil::redirect("setup.php?cmd=displayNIC");
2903  }
2904  }
2905 
2906  $this->form->setValuesByPost();
2907  $this->displayNIC(true);
2908  }
2909 
2913 
2917  function displayTools()
2918  {
2919  $this->checkDisplayMode();
2920 
2921  // output
2922  ilUtil::sendInfo();
2923  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html", "setup");
2924  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2925  $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
2926  $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
2927  $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
2928 
2929  $ilDB = $this->setup->getClient()->db;
2930  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
2931  $crec = $ilDB->fetchAssoc($cset);
2932 
2933  if ($crec["cnt"] == 0)
2934  {
2935  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2936  $this->lng->txt("ctrl_missing_desc"));
2937  }
2938  else
2939  {
2940  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2941  $this->lng->txt("ctrl_structure_desc"));
2942  }
2943 
2944  $this->tpl->parseCurrentBlock();
2945 
2946  //$this->checkPanelMode();
2947  }
2948 
2953  {
2954  global $ilCtrlStructureReader;
2955 
2956  if (!$this->setup->getClient()->db_installed)
2957  {
2958  ilUtil::sendInfo($this->lng->txt("no_db"), true);
2959  $this->displayTools();
2960  return;
2961  }
2962 
2963  // referencing does not work in dbupdate-script
2964  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
2965 // BEGIN WebDAV
2966  // read module and service information into db
2967  require_once "./setup/classes/class.ilModuleReader.php";
2968  require_once "./setup/classes/class.ilServiceReader.php";
2969  require_once "./setup/classes/class.ilCtrlStructureReader.php";
2970 
2971  require_once "./Services/Component/classes/class.ilModule.php";
2972  require_once "./Services/Component/classes/class.ilService.php";
2973  $modules = ilModule::getAvailableCoreModules();
2975 
2977  foreach($modules as $module)
2978  {
2979  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
2980  $module["subdir"], "Modules");
2981  $mr->getModules();
2982  unset($mr);
2983  }
2984 
2986  foreach($services as $service)
2987  {
2988  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
2989  $service["subdir"], "Services");
2990  $sr->getServices();
2991  unset($sr);
2992  }
2993 // END WebDAV
2994 
2995  $ilCtrlStructureReader->readStructure(true);
2996  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
2997  $this->displayTools();
2998  }
2999 
3000 
3001 
3006  {
3007  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
3008 
3009  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
3010 
3011  // formular sent
3012  if ($_POST["form"])
3013  {
3014  $pass_old = $this->setup->getPassword();
3015 
3016  if (empty($_POST["form"]["pass_old"]))
3017  {
3018  $message = $this->lng->txt("password_enter_old");
3019  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3020  }
3021 
3022  if (md5($_POST["form"]["pass_old"]) != $pass_old)
3023  {
3024  $message = $this->lng->txt("password_old_wrong");
3025  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3026  }
3027 
3028  if (empty($_POST["form"]["pass"]))
3029  {
3030  $message = $this->lng->txt("password_empty");
3031  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3032  }
3033 
3034  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
3035  {
3036  $message = $this->lng->txt("password_not_match");
3037  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3038  }
3039 
3040  if (md5($_POST["form"]["pass"]) == $pass_old)
3041  {
3042  $message = $this->lng->txt("password_same");
3043  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3044  }
3045 
3046  if (!$this->setup->setPassword($_POST["form"]["pass"]))
3047  {
3048  $message = $this->lng->txt("save_error");
3049  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3050  }
3051 
3052  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
3053  ilUtil::redirect("setup.php");
3054  }
3055 
3056  // output
3057  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html", "setup");
3058 
3059  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
3060 
3061  // pass form
3062  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3063  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
3064  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
3065  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
3066  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
3067  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
3068  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3069  }
3070 
3075  {
3076  $this->checkDisplayMode("finish_setup");
3077  $this->no_second_nav = true;
3078 //echo "<b>1</b>";
3079  if ($this->validateSetup())
3080  {
3081  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
3082  "<p>".$this->lng->txt("user").": <b>root</b><br />".
3083  $this->lng->txt("password").": <b>homer</b></p>";
3084  $this->setButtonNext("login_new","login");
3085 //echo "<b>2</b>";
3086  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
3087  // the setup_ok fails (with MDB2 and a larger
3088  // client list), alex 17.1.2008
3089  $this->setup->getClient()->setSetting("setup_ok",1);
3090 //$this->setup->getClient()->setSetting("zzz", "Z");
3091 //echo "<b>3</b>";
3092  $this->setup->getClient()->status["finish"]["status"] = true;
3093 //echo "<b>4</b>";
3094  }
3095  else
3096  {
3097  $txt_info = $this->lng->txt("info_text_finish2");
3098  }
3099 
3100 //echo "<b>5</b>";
3101  // output
3102  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html", "setup");
3103  $this->tpl->setVariable("TXT_INFO",$txt_info);
3104 
3105  $this->setButtonPrev("nic");
3106 //echo "<b>6</b>";
3107  $this->checkPanelMode();
3108 //echo "<b>7</b>";
3109  }
3110 
3115  {
3116  $this->checkDisplayMode();
3117 
3118  // formular sent
3119  if ($_POST["form"]["delete"])
3120  {
3121  $ini = true;
3122  $db = false;
3123  $files = false;
3124 
3125  /* disabled
3126  switch ($_POST["form"]["delete"])
3127  {
3128  case 1:
3129  $ini = true;
3130  break;
3131 
3132  case 2:
3133  $ini = true;
3134  $db = true;
3135  break;
3136 
3137  case 3:
3138  $ini = true;
3139  $db = true;
3140  $files = true;
3141  break;
3142  }
3143  */
3144 
3145  $msg = $this->setup->getClient()->delete($ini,$db,$files);
3146 
3147  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
3148  ilUtil::redirect("setup.php");
3149  }
3150 
3151  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3152 
3153  // output
3154  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html", "setup");
3155 
3156  // delete panel
3157  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3158  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3159  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3160  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3161 
3162  $this->checkPanelMode();
3163  }
3164 
3170  function changeAccessMode($a_back)
3171  {
3172  if ($this->setup->getClient()->status["finish"]["status"])
3173  {
3174  $val = ($this->setup->getClient()->ini->readVariable("client","access")) ? "0" : true;
3175  $this->setup->getClient()->ini->setVariable("client","access",$val);
3176  $this->setup->getClient()->ini->write();
3177  $message = "client_access_mode_changed";
3178  }
3179  else
3180  {
3181  $message = "client_setup_not_finished";
3182  }
3183 
3184  ilUtil::sendInfo($this->lng->txt($message),true);
3185 
3186  ilUtil::redirect("setup.php?cmd=".$a_back);
3187  }
3188 
3193  {
3194  if ($_POST["form"])
3195  {
3196  $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections);
3197 
3198  if (!$client->init())
3199  {
3200  $this->setup->raiseError($this->lng->txt("no_valid_client_id"),$this->setup->error_obj->MESSAGE);
3201  }
3202 
3203  $status = $this->setup->getStatus($client);
3204 
3205  if ($status["finish"]["status"])
3206  {
3207  $this->setup->ini->setVariable("clients","default",$client->getId());
3208  $this->setup->ini->write();
3209  $message = "default_client_changed";
3210  }
3211  else
3212  {
3213  $message = "client_setup_not_finished";
3214  }
3215  }
3216 
3217  ilUtil::sendInfo($this->lng->txt($message),true);
3218 
3219  ilUtil::redirect("setup.php");
3220  }
3221 
3226  function validateSetup()
3227  {
3228  foreach ($this->setup->getClient()->status as $key => $val)
3229  {
3230  if ($key != "finish" and $key != "access")
3231  {
3232  if ($val["status"] != true)
3233  {
3234  return false;
3235  }
3236  }
3237  }
3238 
3239 //$this->setup->getClient()->setSetting("zzz", "V");
3240  $clientlist = new ilClientList($this->setup->db_connections);
3241 //$this->setup->getClient()->setSetting("zzz", "W");
3242  $list = $clientlist->getClients();
3243 //$this->setup->getClient()->setSetting("zzz", "X");
3244  if (count($list) == 1)
3245  {
3246  $this->setup->ini->setVariable("clients","default",$this->setup->getClient()->getId());
3247  $this->setup->ini->write();
3248 
3249  $this->setup->getClient()->ini->setVariable("client","access",1);
3250  $this->setup->getClient()->ini->write();
3251  }
3252 //$this->setup->getClient()->setSetting("zzz", "Y");
3253  return true;
3254  }
3255 
3260  {
3261  if (!$this->setup->getClient()->status["db"]["status"])
3262  {
3263  $this->cmd = "db";
3264  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3265  $this->displayDatabase();
3266  }
3267  elseif (!$this->setup->getClient()->status["lang"]["status"])
3268  {
3269  $this->cmd = "lang";
3270  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3271  $this->displayLanguages();
3272  }
3273  elseif (!$this->setup->getClient()->status["contact"]["status"])
3274  {
3275  $this->cmd = "contact";
3276  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3277  $this->displayContactData();
3278  }
3279  elseif (!$this->setup->getClient()->status["nic"]["status"])
3280  {
3281  $this->cmd = "nic";
3282  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3283  $this->displayNIC();
3284  }
3285  elseif (!$this->setup->getClient()->status["finish"]["status"])
3286  {
3287  $this->cmd = "finish";
3288  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3289  $this->displayFinishSetup();
3290  }
3291  else
3292  {
3293  return false;
3294  }
3295  }
3296 
3300  function toggleClientList()
3301  {
3302  if ($this->setup->ini->readVariable("clients","list"))
3303  {
3304  $this->setup->ini->setVariable("clients","list","0");
3305  $this->setup->ini->write();
3306  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
3307  }
3308  else
3309  {
3310  $this->setup->ini->setVariable("clients","list","1");
3311  $this->setup->ini->write();
3312  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
3313  }
3314 
3315  ilUtil::redirect("setup.php");
3316  }
3317 
3318 } // END class.ilSetupGUI
3319 ?>