ILIAS  Release_4_1_x_branch Revision 61804
 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: 36110 $';
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  $this->checkDisplayMode("setup_database");
1976 
1977  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
1978 
1979  // database is intalled
1980  if ($this->setup->getClient()->db_installed)
1981  {
1982  $ilDB = $this->setup->getClient()->db;
1983  $this->lng->setDbHandler($ilDB);
1984  $dbupdate = new ilDBUpdate($ilDB);
1985  $db_status = $dbupdate->getDBVersionStatus();
1986  $hotfix_available = $dbupdate->hotfixAvailable();
1987  $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available);
1988  $this->getClientDbFormValues($dbupdate);
1989  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1990 
1991  if ($db_status)
1992  {
1993  $this->setButtonNext("lang");
1994  }
1995  }
1996  else // database is not installed
1997  {
1998  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db")."<br />".
1999  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>".
2000  "<p><b>".$this->lng->txt("info_text_db2")."</b></p><br/>");
2001 
2002  $this->initClientDbForm();
2003  $this->getClientDbFormValues();
2004  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2005  $this->setButtonPrev("ini");
2006  }
2007 
2008  $this->checkPanelMode();
2009  }
2010 
2014  public function initClientDbForm($a_install = true, $dbupdate = null, $db_status = false, $hotfix_available = false)
2015  {
2016  global $lng, $ilCtrl;
2017 
2018  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2019  $this->form = new ilPropertyFormGUI();
2020 
2021  // type
2022  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "db_type");
2023  $this->form->addItem($ne);
2024 
2025  // version
2026  if ($this->setup->getClient()->getDBType() == "mysql")
2027  {
2028  $ne = new ilNonEditableValueGUI($lng->txt("version"), "db_version");
2029  $ilDB = $this->setup->getClient()->db;
2030  $ne->setValue($ilDB->getDBVersion());
2031  $this->form->addItem($ne);
2032  }
2033 
2034  // host
2035  $ne = new ilNonEditableValueGUI($lng->txt("host"), "db_host");
2036  $this->form->addItem($ne);
2037 
2038  // name
2039  $ne = new ilNonEditableValueGUI($lng->txt("name"), "db_name");
2040  $this->form->addItem($ne);
2041 
2042  // user
2043  $ne = new ilNonEditableValueGUI($lng->txt("user"), "db_user");
2044  $this->form->addItem($ne);
2045 
2046  // port
2047  $ne = new ilNonEditableValueGUI($lng->txt("port"), "db_port");
2048  $this->form->addItem($ne);
2049 
2050  // creation / collation for mysql
2051  if ($this->setup->getClient()->getDBType() == "mysql" && $a_install)
2052  {
2053  // create database
2054  $cb = new ilCheckboxInputGUI($lng->txt("database_create"), "chk_db_create");
2055 
2056  // collation
2057  $collations = array
2058  (
2059  "utf8_unicode_ci",
2060  "utf8_general_ci",
2061  "utf8_czech_ci",
2062  "utf8_danish_ci",
2063  "utf8_estonian_ci",
2064  "utf8_icelandic_ci",
2065  "utf8_latvian_ci",
2066  "utf8_lithuanian_ci",
2067  "utf8_persian_ci",
2068  "utf8_polish_ci",
2069  "utf8_roman_ci",
2070  "utf8_romanian_ci",
2071  "utf8_slovak_ci",
2072  "utf8_slovenian_ci",
2073  "utf8_spanish2_ci",
2074  "utf8_spanish_ci",
2075  "utf8_swedish_ci",
2076  "utf8_turkish_ci"
2077  );
2078  foreach($collations as $collation)
2079  {
2080  $options[$collation] = $collation;
2081  }
2082  $si = new ilSelectInputGUI($lng->txt("collation"), "collation");
2083  $si->setOptions($options);
2084  $si->setInfo($this->lng->txt("info_text_db_collation2")." ".
2085  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
2086  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2087  $cb->addSubItem($si);
2088 
2089  $this->form->addItem($cb);
2090  }
2091 
2092  if ($a_install)
2093  {
2094  $this->form->addCommandButton("installDatabase", $lng->txt("database_install"));
2095  }
2096  else
2097  {
2098  $ilDB = $this->setup->getClient()->db;
2099  $this->lng->setDbHandler($ilDB);
2100  $dbupdate = new ilDBUpdate($ilDB);
2101 
2102  // database version
2103  $ne = new ilNonEditableValueGUI($lng->txt("database_version"), "curv");
2104  $ne->setValue($dbupdate->currentVersion);
2105  $this->form->addItem($ne);
2106 
2107  // file version
2108  $ne = new ilNonEditableValueGUI($lng->txt("file_version"), "filev");
2109  $ne->setValue($dbupdate->fileVersion);
2110  $this->form->addItem($ne);
2111 
2112  if (!$db_status = $dbupdate->getDBVersionStatus())
2113  {
2114  // next update step
2115  $options = array();
2116  for ($i = $dbupdate->currentVersion + 1; $i <= $dbupdate->fileVersion; $i++)
2117  {
2118  $options[$i] = $i;
2119  }
2120  if (count($options) > 1)
2121  {
2122  $si = new ilSelectInputGUI($lng->txt("next_update_break"), "update_break");
2123  $si->setOptions($options);
2124  $si->setInfo($lng->txt("next_update_break_info"));
2125  $this->form->addItem($si);
2126  }
2127 
2128  if ($dbupdate->getRunningStatus() > 0)
2129  {
2130  ilUtil::sendFailure($this->lng->txt("db_update_interrupted")."<br /><br />".
2131  $this->lng->txt("db_update_interrupted_avoid"));
2132  }
2133  else
2134  {
2135  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2136  }
2137  $this->form->addCommandButton("updateDatabase", $lng->txt("database_update"));
2138  }
2139  else if ($hotfix_available)
2140  {
2141  // hotfix current version
2142  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2143  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2144  $this->form->addItem($ne);
2145 
2146  // hotfix file version
2147  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2148  $ne->setValue($dbupdate->getHotfixFileVersion());
2149  $this->form->addItem($ne);
2150 
2151  $this->form->addCommandButton("applyHotfix", $lng->txt("apply_hotfixes"));
2152  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2153  }
2154  else
2155  {
2156  if ($dbupdate->getHotfixFileVersion() > 0)
2157  {
2158  // hotfix current version
2159  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2160  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2161  $this->form->addItem($ne);
2162 
2163  // hotfix file version
2164  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2165  $ne->setValue($dbupdate->getHotfixFileVersion());
2166  $this->form->addItem($ne);
2167  }
2168  ilUtil::sendSuccess($this->lng->txt("database_is_uptodate"));
2169  }
2170  }
2171 
2172  $this->form->setTitle($lng->txt("database"));
2173  $this->form->setFormAction("setup.php?cmd=gateway");
2174  }
2175 
2180  public function getClientDbFormValues($dbupdate = null)
2181  {
2182  global $lng;
2183 
2184  $values = array();
2185 
2186  $values["db_host"] = $this->setup->getClient()->getDbHost();
2187  $values["db_name"] = $this->setup->getClient()->getDbName();
2188  $values["db_user"] = $this->setup->getClient()->getDbUser();
2189  $values["db_port"] = $this->setup->getClient()->getDbPort();
2190  $values["db_type"] = $lng->txt("db_".$this->setup->getClient()->getDbType());
2191  if (is_object($dbupdate))
2192  {
2193  $values["update_break"] = $dbupdate->fileVersion;
2194  if (($dbupdate->fileVersion - $dbupdate->currentVersion) >= 200)
2195  {
2196  $values["update_break"] = $dbupdate->currentVersion + 200 -
2197  ($dbupdate->currentVersion % 100);
2198  }
2199  }
2200 
2201  $this->form->setValuesByArray($values);
2202  }
2203 
2207 
2214  function installDatabase()
2215  {
2216  if (!$this->setup->getClient()->db_exists)
2217  {
2218  if ($_POST["chk_db_create"])
2219  {
2220  if (!$this->setup->createDatabase($_POST["collation"]))
2221  {
2222  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2223  ilUtil::redirect("setup.php?cmd=displayDatabase");
2224  }
2225  }
2226  else
2227  {
2228  ilUtil::sendFailure($this->lng->txt("database_not_exists_create_first"), true);
2229  ilUtil::redirect("setup.php?cmd=displayDatabase");
2230  }
2231  }
2232  if (!$this->setup->installDatabase())
2233  {
2234  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2235  }
2236  else
2237  {
2238  ilUtil::sendSuccess($this->lng->txt("database_installed"), true);
2239  }
2240  ilUtil::redirect("setup.php?cmd=displayDatabase");
2241  }
2242 
2246 
2250  function updateDatabase()
2251  {
2252  global $ilCtrlStructureReader;
2253 
2254  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2255 
2256  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2257  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2258  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2259  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2260  include_once "./Services/Tree/classes/class.ilTree.php";
2261  include_once "./classes/class.ilSaxParser.php";
2262  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2263 
2264  // referencing db handler in language class
2265  $ilDB = $this->setup->getClient()->db;
2266  $this->lng->setDbHandler($ilDB);
2267 
2268  // run dbupdate
2269  $dbupdate = new ilDBUpdate($ilDB);
2270  $dbupdate->applyUpdate((int) $_POST["update_break"]);
2271 
2272  if ($dbupdate->updateMsg == "no_changes")
2273  {
2274  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2275  }
2276  else
2277  {
2278  $sep = "";
2279  foreach ($dbupdate->updateMsg as $row)
2280  {
2281  if ($row["msg"] == "update_applied")
2282  {
2283  $a_message.= $sep.$row["nr"];
2284  $sep = ", ";
2285  }
2286  else
2287  {
2288  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2289  }
2290  }
2291  if ($a_message != "")
2292  {
2293  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2294  }
2295  }
2296 
2297  ilUtil::sendInfo($a_message.$e_message, true);
2298  ilUtil::redirect("setup.php?cmd=displayDatabase");
2299  }
2300 
2304 
2308  function applyHotfix()
2309  {
2310  global $ilCtrlStructureReader;
2311 
2312  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2313 
2314  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2315  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2316  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2317  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2318  include_once "./Services/Tree/classes/class.ilTree.php";
2319  include_once "./classes/class.ilSaxParser.php";
2320  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2321 
2322  // referencing db handler in language class
2323  $ilDB = $this->setup->getClient()->db;
2324  $this->lng->setDbHandler($ilDB);
2325 
2326  // run dbupdate
2327  $dbupdate = new ilDBUpdate($ilDB);
2328  $dbupdate->applyHotfix();
2329 
2330  if ($dbupdate->updateMsg == "no_changes")
2331  {
2332  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2333  }
2334  else
2335  {
2336  $sep = "";
2337  foreach ($dbupdate->updateMsg as $row)
2338  {
2339  if ($row["msg"] == "update_applied")
2340  {
2341  $a_message.= $sep.$row["nr"];
2342  $sep = ", ";
2343  }
2344  else
2345  {
2346  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2347  }
2348  }
2349  if ($a_message != "")
2350  {
2351  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2352  }
2353  }
2354 
2355  ilUtil::sendInfo($a_message.$e_message, true);
2356  ilUtil::redirect("setup.php?cmd=displayDatabase");
2357  }
2358 
2362 
2366  function displaySessions()
2367  {
2368  require_once('Services/Authentication/classes/class.ilSessionControl.php');
2369 
2370  $this->checkDisplayMode("setup_sessions");
2371 
2372  if (!$this->setup->getClient()->db_installed)
2373  {
2374  // program should never come to this place
2375  $message = "No database found! Please install database first.";
2376  ilUtil::sendInfo($message);
2377  }
2378 
2379  $setting_fields = ilSessionControl::getSettingFields();
2380 
2381  $valid = true;
2382  $settings = array();
2383 
2384  foreach( $setting_fields as $field )
2385  {
2386  if( $field == 'session_allow_client_maintenance' )
2387  {
2388  if( isset($_POST[$field]) ) $_POST[$field] = '1';
2389  else $_POST[$field] = '0';
2390  }
2391 
2392  if( isset($_POST[$field]) && $_POST[$field] != '' )
2393  {
2394  $settings[$field] = $_POST[$field];
2395  }
2396  else
2397  {
2398  $valid = false;
2399  break;
2400  }
2401 
2402  }
2403 
2404  if($valid) $this->setup->setSessionSettings($settings);
2405 
2406  $settings = $this->setup->getSessionSettings();
2407 
2408  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2409  $form = new ilPropertyFormGUI();
2410 
2411  // controls the ability t maintenance the following
2412  // settings in client administration
2413  $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
2414  $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
2415  $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
2416  $form->addItem($chkb);
2417 
2418  // this is the max count of active sessions
2419  // that are getting started simlutanously
2420  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
2421  $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
2422  $ti->setMaxLength(5);
2423  $ti->setSize(5);
2424  $ti->setValue($settings['session_max_count']);
2425  $form->addItem($ti);
2426 
2427  // after this (min) idle time the session can be deleted,
2428  // if there are further requests for new sessions,
2429  // but max session count is reached yet
2430  $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
2431  $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
2432  $ti->setMaxLength(5);
2433  $ti->setSize(5);
2434  $ti->setValue($settings['session_min_idle']);
2435  $form->addItem($ti);
2436 
2437  // after this (max) idle timeout the session expires
2438  // and become invalid, so it is not considered anymore
2439  // when calculating current count of active sessions
2440  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
2441  $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
2442  $ti->setMaxLength(5);
2443  $ti->setSize(5);
2444  $ti->setValue($settings['session_max_idle']);
2445  $form->addItem($ti);
2446 
2447  // this is the max duration that can elapse between the first and the secnd
2448  // request to the system before the session is immidietly deleted
2449  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
2450  $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
2451  $ti->setMaxLength(5);
2452  $ti->setSize(5);
2453  $ti->setValue($settings['session_max_idle_after_first_request']);
2454  $form->addItem($ti);
2455 
2456  // save and cancel commands
2457  $form->addCommandButton("sess", $this->lng->txt('save'));
2458 
2459  $form->setTitle($this->lng->txt("sess_sessions"));
2460  $form->setFormAction('setup.php?client_id='.$this->client_id.'&cmd=sess');
2461 
2462  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt('sess_sessions'))));
2463  $this->tpl->setVariable("TXT_INFO", '');
2464  $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
2465 
2466  /*$this->setButtonPrev("db");
2467 
2468  if($this->setup->checkClientSessionSettings($this->client,true))
2469  {
2470  $this->setButtonNext("lang");
2471  }*/
2472 
2473  $this->checkPanelMode();
2474  }
2475 
2479 
2483  function displayLanguages()
2484  {
2485  $this->checkDisplayMode("setup_languages");
2486 
2487  if (!$this->setup->getClient()->db_installed)
2488  {
2489  // program should never come to this place
2490  $message = "No database found! Please install database first.";
2491  ilUtil::sendFailure($message);
2492  }
2493 
2494  include_once("./setup/classes/class.ilSetupLanguageTableGUI.php");
2495  $tab = new ilSetupLanguageTableGUI($this->setup->getClient());
2496  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2497 
2498  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2499  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2500 
2501  $installed_langs = $this->lng->getInstalledLanguages();
2502  $lang_count = count($installed_langs);
2503  if ($lang_count > 0)
2504  {
2505  $this->setup->getClient()->status["lang"]["status"] = true;
2506  $this->setup->getClient()->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2507  }
2508  else
2509  {
2510  $this->setup->getClient()->status["lang"]["status"] = false;
2511  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2512  }
2513 
2514  $this->setButtonPrev("lang");
2515 
2516  if ($lang_count > 0)
2517  {
2518  $this->setButtonNext("contact");
2519  }
2520 
2521  $this->checkPanelMode();
2522  }
2523 
2530  function saveLanguages()
2531  {
2532  if (empty($_POST["form"]["lang_id"]))
2533  {
2534  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
2535  ilUtil::redirect("setup.php?cmd=lang");
2536  }
2537 
2538  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2539  {
2540  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
2541  ilUtil::redirect("setup.php?cmd=lang");
2542  }
2543 
2544  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2545 
2546  if (is_array($result))
2547  {
2548  $count = count($result);
2549  $txt = "tet";
2550 
2551  foreach ($result as $key => $lang_key)
2552  {
2553  $list .= $this->lng->txt("lang_".$lang_key);
2554 
2555  if ($count > $key + 1)
2556  {
2557  $list .= ", ";
2558  }
2559  }
2560  }
2561 
2562  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
2563  $message = $this->lng->txt("languages_installed");
2564 
2565  if ($result !== true)
2566  {
2567  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2568  }
2569  ilUtil::sendInfo($message, true);
2570  ilUtil::redirect("setup.php?cmd=lang");
2571  }
2572 
2576 
2580  function displayContactData($a_omit_init = false)
2581  {
2582  $this->checkDisplayMode("setup_contact_data");
2583  $settings = $this->setup->getClient()->getAllSettings();
2584 
2585  if (!$a_omit_init)
2586  {
2587  $this->initContactDataForm();
2588  $this->getContactValues();
2589  }
2590  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2591  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2592  $this->setButtonPrev("lang");
2593 
2594  $check = $this->setup->checkClientContact($this->setup->client);
2595 
2596  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
2597  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
2598 
2599  if ($check["status"])
2600  {
2601  $this->setButtonNext("nic");
2602  }
2603 
2604  $this->checkPanelMode();
2605  }
2606 
2612  public function initContactDataForm()
2613  {
2614  global $lng, $ilCtrl;
2615 
2616  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2617  $this->form = new ilPropertyFormGUI();
2618 
2619  // name
2620  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
2621  $ti->setMaxLength(64);
2622  $ti->setSize(30);
2623  $ti->setRequired(true);
2624  $this->form->addItem($ti);
2625 
2626  // description
2627  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
2628  $ti->setMaxLength(64);
2629  $ti->setSize(30);
2630  $this->form->addItem($ti);
2631 
2632  // institution
2633  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
2634  $ti->setMaxLength(64);
2635  $ti->setSize(30);
2636  $this->form->addItem($ti);
2637 
2638  // contact data
2639  $sh = new ilFormSectionHeaderGUI();
2640  $sh->setTitle($lng->txt("contact_data"));
2641  $this->form->addItem($sh);
2642 
2643  // first name
2644  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
2645  $ti->setMaxLength(64);
2646  $ti->setSize(30);
2647  $ti->setRequired(true);
2648  $this->form->addItem($ti);
2649 
2650  // last name
2651  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
2652  $ti->setMaxLength(64);
2653  $ti->setSize(30);
2654  $ti->setRequired(true);
2655  $this->form->addItem($ti);
2656 
2657  $fs = array (
2658  "title" => array("max" => 64, "size" => 30),
2659  "position" => array("max" => 64, "size" => 30),
2660  "institution" => array("max" => 200, "size" => 30),
2661  "street" => array("max" => 64, "size" => 30),
2662  "zipcode" => array("max" => 10, "size" => 5),
2663  "city" => array("max" => 64, "size" => 30),
2664  "country" => array("max" => 64, "size" => 30),
2665  "phone" => array("max" => 64, "size" => 30)
2666  );
2667  foreach ($fs as $f => $op)
2668  {
2669  // field
2670  $ti = new ilTextInputGUI($lng->txt($f), "admin_".$f);
2671  $ti->setMaxLength($op["max"]);
2672  $ti->setSize($op["size"]);
2673  $ti->setInfo($lng->txt(""));
2674  $this->form->addItem($ti);
2675  }
2676 
2677  // email
2678  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
2679  $ti->setRequired(true);
2680  $this->form->addItem($ti);
2681 
2682  $this->form->addCommandButton("saveContact", $lng->txt("save"));
2683 
2684  $this->form->setTitle($lng->txt("client_data"));
2685  $this->form->setFormAction("setup.php?cmd=gateway");
2686  }
2687 
2691  public function getContactValues()
2692  {
2693 
2694  $settings = $this->setup->getClient()->getAllSettings();
2695 
2696  $values = $settings;
2697 
2698  $values["inst_name"] = ($this->setup->getClient()->getName())
2699  ? $this->setup->getClient()->getName()
2700  : $this->setup->getClient()->getId();
2701  $values["inst_info"] = $this->setup->getClient()->getDescription();
2702 
2703  $this->form->setValuesByArray($values);
2704  }
2705 
2709  public function saveContact()
2710  {
2711  global $tpl, $lng, $ilCtrl;
2712 
2713  $this->initContactDataForm();
2714  if ($this->form->checkInput())
2715  {
2716  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
2717  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
2718  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
2719  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
2720  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
2721  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
2722  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
2723  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
2724  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
2725  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
2726  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
2727  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
2728  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
2729 
2730  // update client.ini
2731  $this->setup->getClient()->setName($_POST["inst_name"]);
2732  $this->setup->getClient()->setDescription($_POST["inst_info"]);
2733  $this->setup->getClient()->ini->write();
2734 
2735  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2736  ilUtil::redirect("setup.php?cmd=displayContactData");
2737  }
2738 
2739  $this->form->setValuesByPost();
2740  $this->displayContactData(true);
2741  }
2742 
2746 
2750  function displayNIC($a_omit_init = false)
2751  {
2752  $this->checkDisplayMode("nic_registration");
2753  $settings = $this->setup->getClient()->getAllSettings();
2754  $nic_key = $this->setup->getClient()->getNICkey();
2755 
2756  // reload settings
2757  $settings = $this->setup->getClient()->getAllSettings();
2758 //var_dump($settings);
2759  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
2760  {
2761  $this->no_second_nav = true;
2762  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
2763  }
2764  else
2765  {
2766  // reload settings
2767  $settings = $this->setup->getClient()->getAllSettings();
2768 
2769  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
2770  if (!$a_omit_init)
2771  {
2772  $this->initRegistrationForm();
2773  $this->getRegistrationValues();
2774  }
2775  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2776 
2777  if (isset($settings["nic_enabled"]))
2778  {
2779  $this->setup->getClient()->status["nic"]["status"] = true;
2780  }
2781 
2782  }
2783 
2784  $this->setButtonPrev("contact");
2785 
2786  if ($this->setup->getClient()->status["nic"]["status"])
2787  {
2788  $this->setButtonNext("finish","finish");
2789  }
2790 
2791  $this->checkPanelMode();
2792  }
2793 
2799  public function initRegistrationForm($a_mode = "edit")
2800  {
2801  global $lng, $ilCtrl;
2802 
2803  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2804  $this->form = new ilPropertyFormGUI();
2805 
2806  // registration type
2807  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
2808  $radg->setValue(1);
2809  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
2810  $radg->addOption($op1);
2811  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
2812  $radg->addOption($op1);
2813  $this->form->addItem($radg);
2814 
2815  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
2816  $this->form->setFormAction("setup.php?cmd=gateway");
2817  }
2818 
2822  public function getRegistrationValues()
2823  {
2824  $settings = $this->setup->getClient()->getAllSettings();
2825  $nic_key = $this->setup->getClient()->getNICkey();
2826 
2827 
2828  $values = array();
2829 
2830  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
2831  {
2832  $values["register"] = 1;
2833  }
2834  /*elseif ($settings["nic_enabled"] == "2")
2835  {
2836  $this->tpl->setVariable("EMAIL",$checked);
2837  }*/
2838  else
2839  {
2840  $values["register"] = 0;
2841  }
2842 
2843  $this->form->setValuesByArray($values);
2844  }
2845 
2849  public function saveRegistration()
2850  {
2851  global $tpl, $lng, $ilCtrl;
2852 
2853  $this->initRegistrationForm();
2854  if ($this->form->checkInput())
2855  {
2856  // check register option
2857  if ($_POST["register"] == 1)
2858  {
2859  // update nic
2860  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
2861 //var_dump($this->setup->getClient()->nic_status);
2862  // online registration failed
2863  if (empty($this->setup->getClient()->nic_status[2]))
2864  {
2865  $this->setup->getClient()->setSetting("nic_enabled","-1");
2866  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
2867  ilUtil::redirect("setup.php?cmd=displayNIC");
2868  }
2869  else
2870  {
2871  $this->setup->getClient()->setSetting("inst_id",$this->setup->getClient()->nic_status[2]);
2872  $this->setup->getClient()->setSetting("nic_enabled","1");
2873  $this->setup->getClient()->status["nic"]["status"] = true;
2874  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
2875  ilUtil::redirect("setup.php?cmd=displayNIC");
2876  }
2877  }
2878  /*elseif ($_POST["form"]["register"] == 2)
2879  {
2880  $nic_by_email = (int) $_POST["form"]["nic_id"];
2881 
2882  $checksum = md5($nic_key.$nic_by_email);
2883 
2884  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
2885  {
2886  $message = $this->lng->txt("nic_reg_enter_correct_id");
2887  }
2888  else
2889  {
2890  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
2891  $this->setup->getClient()->setSetting("nic_enabled","1");
2892  $message = $this->lng->txt("nic_reg_enabled");
2893  }
2894  }*/
2895  else
2896  {
2897  $this->setup->getClient()->setSetting("inst_id","0");
2898  $this->setup->getClient()->setSetting("nic_enabled","0");
2899  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
2900  ilUtil::redirect("setup.php?cmd=displayNIC");
2901  }
2902  }
2903 
2904  $this->form->setValuesByPost();
2905  $this->displayNIC(true);
2906  }
2907 
2911 
2915  function displayTools()
2916  {
2917  $this->checkDisplayMode();
2918 
2919  // output
2920  ilUtil::sendInfo();
2921  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html", "setup");
2922  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2923  $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
2924  $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
2925  $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
2926 
2927  $ilDB = $this->setup->getClient()->db;
2928  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
2929  $crec = $ilDB->fetchAssoc($cset);
2930 
2931  if ($crec["cnt"] == 0)
2932  {
2933  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2934  $this->lng->txt("ctrl_missing_desc"));
2935  }
2936  else
2937  {
2938  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2939  $this->lng->txt("ctrl_structure_desc"));
2940  }
2941 
2942  $this->tpl->parseCurrentBlock();
2943 
2944  //$this->checkPanelMode();
2945  }
2946 
2951  {
2952  global $ilCtrlStructureReader;
2953 
2954  if (!$this->setup->getClient()->db_installed)
2955  {
2956  ilUtil::sendInfo($this->lng->txt("no_db"), true);
2957  $this->displayTools();
2958  return;
2959  }
2960 
2961  // referencing does not work in dbupdate-script
2962  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
2963 // BEGIN WebDAV
2964  // read module and service information into db
2965  require_once "./setup/classes/class.ilModuleReader.php";
2966  require_once "./setup/classes/class.ilServiceReader.php";
2967  require_once "./setup/classes/class.ilCtrlStructureReader.php";
2968 
2969  require_once "./Services/Component/classes/class.ilModule.php";
2970  require_once "./Services/Component/classes/class.ilService.php";
2971  $modules = ilModule::getAvailableCoreModules();
2973 
2975  foreach($modules as $module)
2976  {
2977  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
2978  $module["subdir"], "Modules");
2979  $mr->getModules();
2980  unset($mr);
2981  }
2982 
2984  foreach($services as $service)
2985  {
2986  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
2987  $service["subdir"], "Services");
2988  $sr->getServices();
2989  unset($sr);
2990  }
2991 // END WebDAV
2992 
2993  $ilCtrlStructureReader->readStructure(true);
2994  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
2995  $this->displayTools();
2996  }
2997 
2998 
2999 
3004  {
3005  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
3006 
3007  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
3008 
3009  // formular sent
3010  if ($_POST["form"])
3011  {
3012  $pass_old = $this->setup->getPassword();
3013 
3014  if (empty($_POST["form"]["pass_old"]))
3015  {
3016  $message = $this->lng->txt("password_enter_old");
3017  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3018  }
3019 
3020  if (md5($_POST["form"]["pass_old"]) != $pass_old)
3021  {
3022  $message = $this->lng->txt("password_old_wrong");
3023  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3024  }
3025 
3026  if (empty($_POST["form"]["pass"]))
3027  {
3028  $message = $this->lng->txt("password_empty");
3029  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3030  }
3031 
3032  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
3033  {
3034  $message = $this->lng->txt("password_not_match");
3035  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3036  }
3037 
3038  if (md5($_POST["form"]["pass"]) == $pass_old)
3039  {
3040  $message = $this->lng->txt("password_same");
3041  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3042  }
3043 
3044  if (!$this->setup->setPassword($_POST["form"]["pass"]))
3045  {
3046  $message = $this->lng->txt("save_error");
3047  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3048  }
3049 
3050  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
3051  ilUtil::redirect("setup.php");
3052  }
3053 
3054  // output
3055  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html", "setup");
3056 
3057  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
3058 
3059  // pass form
3060  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3061  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
3062  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
3063  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
3064  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
3065  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
3066  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3067  }
3068 
3073  {
3074  $this->checkDisplayMode("finish_setup");
3075  $this->no_second_nav = true;
3076 //echo "<b>1</b>";
3077  if ($this->validateSetup())
3078  {
3079  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
3080  "<p>".$this->lng->txt("user").": <b>root</b><br />".
3081  $this->lng->txt("password").": <b>homer</b></p>";
3082  $this->setButtonNext("login_new","login");
3083 //echo "<b>2</b>";
3084  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
3085  // the setup_ok fails (with MDB2 and a larger
3086  // client list), alex 17.1.2008
3087  $this->setup->getClient()->setSetting("setup_ok",1);
3088 //$this->setup->getClient()->setSetting("zzz", "Z");
3089 //echo "<b>3</b>";
3090  $this->setup->getClient()->status["finish"]["status"] = true;
3091 //echo "<b>4</b>";
3092  }
3093  else
3094  {
3095  $txt_info = $this->lng->txt("info_text_finish2");
3096  }
3097 
3098 //echo "<b>5</b>";
3099  // output
3100  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html", "setup");
3101  $this->tpl->setVariable("TXT_INFO",$txt_info);
3102 
3103  $this->setButtonPrev("nic");
3104 //echo "<b>6</b>";
3105  $this->checkPanelMode();
3106 //echo "<b>7</b>";
3107  }
3108 
3113  {
3114  $this->checkDisplayMode();
3115 
3116  // formular sent
3117  if ($_POST["form"]["delete"])
3118  {
3119  $ini = true;
3120  $db = false;
3121  $files = false;
3122 
3123  /* disabled
3124  switch ($_POST["form"]["delete"])
3125  {
3126  case 1:
3127  $ini = true;
3128  break;
3129 
3130  case 2:
3131  $ini = true;
3132  $db = true;
3133  break;
3134 
3135  case 3:
3136  $ini = true;
3137  $db = true;
3138  $files = true;
3139  break;
3140  }
3141  */
3142 
3143  $msg = $this->setup->getClient()->delete($ini,$db,$files);
3144 
3145  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
3146  ilUtil::redirect("setup.php");
3147  }
3148 
3149  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3150 
3151  // output
3152  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html", "setup");
3153 
3154  // delete panel
3155  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3156  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3157  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3158  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3159 
3160  $this->checkPanelMode();
3161  }
3162 
3168  function changeAccessMode($a_back)
3169  {
3170  if ($this->setup->getClient()->status["finish"]["status"])
3171  {
3172  $val = ($this->setup->getClient()->ini->readVariable("client","access")) ? "0" : true;
3173  $this->setup->getClient()->ini->setVariable("client","access",$val);
3174  $this->setup->getClient()->ini->write();
3175  $message = "client_access_mode_changed";
3176  }
3177  else
3178  {
3179  $message = "client_setup_not_finished";
3180  }
3181 
3182  ilUtil::sendInfo($this->lng->txt($message),true);
3183 
3184  ilUtil::redirect("setup.php?cmd=".$a_back);
3185  }
3186 
3191  {
3192  if ($_POST["form"])
3193  {
3194  $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections);
3195 
3196  if (!$client->init())
3197  {
3198  $this->setup->raiseError($this->lng->txt("no_valid_client_id"),$this->setup->error_obj->MESSAGE);
3199  }
3200 
3201  $status = $this->setup->getStatus($client);
3202 
3203  if ($status["finish"]["status"])
3204  {
3205  $this->setup->ini->setVariable("clients","default",$client->getId());
3206  $this->setup->ini->write();
3207  $message = "default_client_changed";
3208  }
3209  else
3210  {
3211  $message = "client_setup_not_finished";
3212  }
3213  }
3214 
3215  ilUtil::sendInfo($this->lng->txt($message),true);
3216 
3217  ilUtil::redirect("setup.php");
3218  }
3219 
3224  function validateSetup()
3225  {
3226  foreach ($this->setup->getClient()->status as $key => $val)
3227  {
3228  if ($key != "finish" and $key != "access")
3229  {
3230  if ($val["status"] != true)
3231  {
3232  return false;
3233  }
3234  }
3235  }
3236 
3237 //$this->setup->getClient()->setSetting("zzz", "V");
3238  $clientlist = new ilClientList($this->setup->db_connections);
3239 //$this->setup->getClient()->setSetting("zzz", "W");
3240  $list = $clientlist->getClients();
3241 //$this->setup->getClient()->setSetting("zzz", "X");
3242  if (count($list) == 1)
3243  {
3244  $this->setup->ini->setVariable("clients","default",$this->setup->getClient()->getId());
3245  $this->setup->ini->write();
3246 
3247  $this->setup->getClient()->ini->setVariable("client","access",1);
3248  $this->setup->getClient()->ini->write();
3249  }
3250 //$this->setup->getClient()->setSetting("zzz", "Y");
3251  return true;
3252  }
3253 
3258  {
3259  if (!$this->setup->getClient()->status["db"]["status"])
3260  {
3261  $this->cmd = "db";
3262  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3263  $this->displayDatabase();
3264  }
3265  elseif (!$this->setup->getClient()->status["lang"]["status"])
3266  {
3267  $this->cmd = "lang";
3268  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3269  $this->displayLanguages();
3270  }
3271  elseif (!$this->setup->getClient()->status["contact"]["status"])
3272  {
3273  $this->cmd = "contact";
3274  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3275  $this->displayContactData();
3276  }
3277  elseif (!$this->setup->getClient()->status["nic"]["status"])
3278  {
3279  $this->cmd = "nic";
3280  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3281  $this->displayNIC();
3282  }
3283  elseif (!$this->setup->getClient()->status["finish"]["status"])
3284  {
3285  $this->cmd = "finish";
3286  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3287  $this->displayFinishSetup();
3288  }
3289  else
3290  {
3291  return false;
3292  }
3293  }
3294 
3298  function toggleClientList()
3299  {
3300  if ($this->setup->ini->readVariable("clients","list"))
3301  {
3302  $this->setup->ini->setVariable("clients","list","0");
3303  $this->setup->ini->write();
3304  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
3305  }
3306  else
3307  {
3308  $this->setup->ini->setVariable("clients","list","1");
3309  $this->setup->ini->write();
3310  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
3311  }
3312 
3313  ilUtil::redirect("setup.php");
3314  }
3315 
3316 } // END class.ilSetupGUI
3317 ?>