ILIAS  Release_4_0_x_branch Revision 61816
 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: 36109 $';
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 "lang":
310  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->setup->error === true)
311  {
313  }
314  else
315  {
316  $this->displayLanguages();
317  }
318  break;
319 
320  case "contact":
321  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "contact")
322  {
324  }
325  else
326  {
327  $this->displayContactData();
328  }
329  break;
330 
331  case "nic":
332  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "nic")
333  {
335  }
336  else
337  {
338  $this->displayNIC();
339  }
340  break;
341 
342  case "finish":
343  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "finish")
344  {
346  }
347  else
348  {
349  $this->displayFinishSetup();
350  }
351  break;
352 
353  case "changeaccess":
354  $this->changeAccessMode($_GET["back"]);
355  break;
356 
357  case "logout":
358  $this->displayLogout();
359  break;
360 
361  case "login":
362  session_destroy();
363  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
364  break;
365 
366  case "login_new":
367  if ($this->setup->getClient()->ini->readVariable("client","access") != "1")
368  {
369  $this->setup->getClient()->ini->setVariable("client","access","1");
370  $this->setup->getClient()->ini->write();
371  }
372 
373  session_destroy();
374  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
375  break;
376 
377  case "tools":
378  $this->displayTools();
379  break;
380 
381  case "reloadStructure":
382  $this->reloadControlStructure();
383  break;
384 
385  case "saveClientIni":
386  case "installDatabase":
387  case "displayDatabase":
388  case "updateDatabase":
389  case "saveLanguages":
390  case "saveContact":
391  case "displayContactData":
392  case "displayNIC":
393  case "saveRegistration":
394  case "applyHotfix":
395  $this->$cmd();
396  break;
397 
398  default:
399  $this->displayError($this->lng->txt("unknown_command"));
400  break;
401  }
402  }
403 
404  // end cmd subsets
405 
409 
418  function setDisplayMode($a_mode)
419  {
420  // security
421  if ($a_mode != "view" and $a_mode != "setup")
422  {
423  return false;
424  }
425 
426  $this->display_mode = $a_mode;
427  $_SESSION["display_mode"] = $this->display_mode;
428 
429  return true;
430  }
431 
435  function displayHeader()
436  {
437  $languages = $this->lng->getLanguages();
438 
439  $count = (int) round(count($languages) / 2);
440  $num = 1;
441 
442  foreach ($languages as $lang_key)
443  {
444  if ($num === $count)
445  {
446  $this->tpl->touchBlock("lng_new_row");
447  }
448 
449  $this->tpl->setCurrentBlock("languages");
450  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
451  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
452  $this->tpl->setVariable("LANG_ICON", $lang_key);
453  $this->tpl->setVariable("LANG_KEY", $lang_key);
454  $this->tpl->setVariable("BORDER", 0);
455  $this->tpl->setVariable("VSPACE", 0);
456  $this->tpl->parseCurrentBlock();
457 
458  $num++;
459  }
460 
461  if (count($languages) % 2)
462  {
463  $this->tpl->touchBlock("lng_empty_cell");
464  }
465 
466  if ($this->cmd != "logout" and $this->setup->isInstalled())
467  {
468  // add client link
469  if ($this->setup->isAdmin())
470  {
471  if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
472  {
473  $this->tpl->setCurrentBlock("add_client");
474  $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
475  $this->tpl->parseCurrentBlock();
476  }
477 
478  // client list link
479  $class = ($this->active_tab == "clientlist")
480  ? "ilSMActive"
481  : "ilSMInactive";
482  $this->tpl->setCurrentBlock("display_list");
483  $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
484  $this->tpl->setVariable("TAB_CLASS", $class);
485  $this->tpl->parseCurrentBlock();
486 
487  // edit paths link
488  $class = ($this->active_tab == "basicsettings")
489  ? "ilSMActive"
490  : "ilSMInactive";
491  $this->tpl->setCurrentBlock("edit_pathes");
492  $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
493  $this->tpl->setVariable("TAB_CLASS", $class);
494  $this->tpl->parseCurrentBlock();
495 
496  // preliminaries
497  $class = ($this->active_tab == "preliminaries")
498  ? "ilSMActive"
499  : "ilSMInactive";
500  $this->tpl->setCurrentBlock("preliminaries");
501  $this->tpl->setVariable("TXT_PRELIMINARIES",$this->lng->txt("preliminaries"));
502  $this->tpl->setVariable("TAB_CLASS", $class);
503  $this->tpl->parseCurrentBlock();
504 
505  // change password link
506  $class = ($this->active_tab == "password")
507  ? "ilSMActive"
508  : "ilSMInactive";
509  $this->tpl->setCurrentBlock("change_password");
510  $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
511  $this->tpl->setVariable("TAB_CLASS", $class);
512  $this->tpl->parseCurrentBlock();
513  }
514 
515  // logout link
516  if ($this->setup->isAuthenticated())
517  {
518  $this->tpl->setCurrentBlock("logout");
519  $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
520  $this->tpl->parseCurrentBlock();
521  }
522  }
523 
524  $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
525  $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
526  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
527  $this->tpl->setVariable("PAGETITLE","Setup");
528  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
529  $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
530  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","./css/setup.css");
531  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
532  $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
533  $this->tpl->setVariable("VERSION", $this->version);
534  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
535  $this->tpl->setVariable("LANG", $this->lang);
536  }
537 
541  function displayFooter()
542  {
543  // footer (not really)
544  if ($this->cmd != "logout")
545  {
546  if ($this->setup->ini_ilias_exists and $this->display_mode == "setup" and $this->setup->getClient()->getId() != "")
547  {
548  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
549  }
550  elseif ($this->setup->isAdmin())
551  {
552  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
553  }
554 
555  $this->displayNavButtons();
556  }
557 
558  $this->tpl->show();
559  }
560 
566  function displayNavButtons()
567  {
568  if (!$this->btn_prev_on and !$this->btn_next_on)
569  {
570  return false;
571  }
572 
573  $ntpl = new ilTemplate("tpl.navbuttons.html", true, true, "setup");
574  //$this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html", "setup");
575 
576  $ntpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
577 
578  if ($this->btn_prev_on)
579  {
580  $ntpl->setCurrentBlock("btn_back");
581  $ntpl->setVariable("TXT_PREV", $this->btn_prev_lng);
582  $ntpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
583  $ntpl->parseCurrentBlock();
584  }
585 
586  if ($this->btn_next_on)
587  {
588  $ntpl->setCurrentBlock("btn_forward");
589  $ntpl->setVariable("TXT_NEXT", $this->btn_next_lng);
590  $ntpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
591  $ntpl->parseCurrentBlock();
592  }
593 
594  $nav_html = $ntpl->get();
595  $this->tpl->setVariable("NAVBUTTONS", $nav_html);
596  if (!$this->no_second_nav)
597  {
598  $this->tpl->setVariable("NAVBUTTONS2", $nav_html);
599  }
600  return true;
601  }
602 
609  function SetButtonPrev($a_cmd = 0,$a_lng = 0)
610  {
611  $this->btn_prev_on = true;
612  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
613  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("prev");
614  }
615 
622  function SetButtonNext($a_cmd,$a_lng = 0)
623  {
624  $this->btn_next_on = true;
625  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
626  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next");
627  }
628 
632 
637  {
638  $this->checkDisplayMode();
639 
640  // disable/enable button
641  $btpl = new ilTemplate("tpl.buttons.html", true, true, "setup");
642  $btpl->setCurrentBlock("btn");
643  $btpl->setVariable("CMD", "changeaccess");
644  $access_button = ($this->setup->getClient()->status["access"]["status"]) ? "disable" : "enable";
645  $btpl->setVariable("TXT", $this->lng->txt($access_button));
646  $btpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
647  $btpl->parseCurrentBlock();
648  $this->tpl->setVariable("BUTTONS", $btpl->get());
649 
650  $this->initClientOverviewForm();
651  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
652 
653  $this->displayStatusPanel();
654  }
655 
659  public function initClientOverviewForm()
660  {
661  global $lng, $ilCtrl;
662 
663  $settings = $this->setup->getClient()->getAllSettings();
664 
665  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
666  $this->form = new ilPropertyFormGUI();
667 
668  $this->form->setTitle($lng->txt("client_info"));
669 
670  // installation name
671  $ne = new ilNonEditableValueGUI($lng->txt("inst_name"), "inst_name");
672  $ne->setValue(($this->setup->getClient()->getName())
673  ? $this->setup->getClient()->getName()
674  : "&lt;".$this->lng->txt("no_client_name")."&gt;");
675  $ne->setInfo($this->setup->getClient()->getDescription());
676  $this->form->addItem($ne);
677 
678  // client id
679  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "client_id");
680  $ne->setValue($this->setup->getClient()->getId());
681  $this->form->addItem($ne);
682 
683  // nic id
684  $ne = new ilNonEditableValueGUI($lng->txt("ilias_nic_id"), "nic_id");
685  $ne->setValue(($this->setup->getClient()->db_installed)
686  ? $settings["inst_id"]
687  : $txt_no_database);
688  $this->form->addItem($ne);
689 
690  // database version
691  $ne = new ilNonEditableValueGUI($lng->txt("db_version"), "db_vers");
692  $ne->setValue(($this->setup->getClient()->db_installed)
693  ? $settings["db_version"]
694  : $txt_no_database);
695  $this->form->addItem($ne);
696 
697  // access status
698  $ne = new ilNonEditableValueGUI($lng->txt("access_status"), "status");
699  //$access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->setup->getClient()->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
700  $access_status = ($this->setup->getClient()->status["access"]["status"]) ? "online" : "disabled";
701  $ne->setValue($this->lng->txt($access_status).$access_link);
702  $this->form->addItem($ne);
703 
704  // server information
705  $sh = new ilFormSectionHeaderGUI();
706  $sh->setTitle($this->lng->txt("server_info"));
707  $this->form->addItem($sh);
708 
709  // ilias version
710  $ne = new ilNonEditableValueGUI($lng->txt("ilias_version"), "il_vers");
711  $ne->setValue(ILIAS_VERSION);
712  $this->form->addItem($ne);
713 
714  // host
715  $ne = new ilNonEditableValueGUI($lng->txt("host"), "host");
716  $ne->setValue($_SERVER["SERVER_NAME"]);
717  $this->form->addItem($ne);
718 
719  // ip address and port
720  $ne = new ilNonEditableValueGUI($lng->txt("ip_address")." & ".
721  $lng->txt("port"));
722  $ne->setValue($_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"]);
723  $this->form->addItem($ne);
724 
725  // server software
726  $ne = new ilNonEditableValueGUI($lng->txt("server_software"), "server_softw");
727  $ne->setValue($_SERVER["SERVER_SOFTWARE"]);
728  $this->form->addItem($ne);
729 
730  // http path
731  $ne = new ilNonEditableValueGUI($lng->txt("http_path"), "http_path");
732  $ne->setValue(ILIAS_HTTP_PATH);
733  $this->form->addItem($ne);
734 
735  // absolute path
736  $ne = new ilNonEditableValueGUI($lng->txt("absolute_path"), "absolute_path");
738  $this->form->addItem($ne);
739 
740  // third party tools
741  $sh = new ilFormSectionHeaderGUI();
742  $sh->setTitle($this->lng->txt("3rd_party_software"));
743  $this->form->addItem($sh);
744 
745  $tools = array("convert", "zip", "unzip", "java", "htmldoc", "mkisofs");
746 
747  foreach ($tools as $tool)
748  {
749  // tool
750  $ne = new ilNonEditableValueGUI($lng->txt($tool."_path"), $tool."_path");
751  $p = $this->setup->ini->readVariable("tools", $tool);
752  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
753  $this->form->addItem($ne);
754  }
755 
756  // latex
757  $ne = new ilNonEditableValueGUI($lng->txt("url_to_latex"), "latex_url");
758  $p = $this->setup->ini->readVariable("tools", "latex_url");
759  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
760  $this->form->addItem($ne);
761 
762  // virus scanner
763  $ne = new ilNonEditableValueGUI($lng->txt("virus_scanner"), "vscan");
764  $ne->setValue($this->setup->ini->readVariable("tools","vscantype"));
765  $this->form->addItem($ne);
766 
767  // scan command
768  $ne = new ilNonEditableValueGUI($lng->txt("scan_command"), "scan");
769  $p = $this->setup->ini->readVariable("tools","scancommand");
770  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
771  $this->form->addItem($ne);
772 
773  // clean command
774  $ne = new ilNonEditableValueGUI($lng->txt("clean_command"), "clean");
775  $p = $this->setup->ini->readVariable("tools","cleancommand");
776  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
777  $this->form->addItem($ne);
778 
779  $this->form->setFormAction("setup.php?cmd=gateway");
780  }
781 
785 
790  {
791  $OK = "<font color=\"green\"><strong>OK</strong></font>";
792  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
793 
794  $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html", "setup");
795 
796  $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
797  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
798  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
799  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
800  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
801  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
802  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
803 
804  $server_os = php_uname();
805  $server_web = $_SERVER["SERVER_SOFTWARE"];
806  $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
807 
808  if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
809  {
810  $env_comment = $this->lng->txt("env_ok");
811  }
812  else
813  {
814  $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
815  }
816 
817  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
818  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
819  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
820 
821  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
822  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
823 
824  $preliminaries = array("php", "root", "folder_create",
825  "cookies_enabled", "dom", "xsl", "gd", "memory");
826  foreach ($preliminaries as $preliminary)
827  {
828  $this->tpl->setCurrentBlock("preliminary");
829  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_".$preliminary));
830  if ($this->setup->preliminaries_result[$preliminary]["status"] == true)
831  {
832  $this->tpl->setVariable("STATUS_PRE", $OK);
833  }
834  else
835  {
836  $this->tpl->setVariable("STATUS_PRE", $FAILED);
837  }
838  $this->tpl->setVariable("COMMENT_PRE", $this->setup->preliminaries_result[$preliminary]["comment"]);
839  $this->tpl->parseCurrentBlock();
840  }
841 
842  // summary
843  if ($this->setup->preliminaries === true)
844  {
845  if ($this->setup->isInstalled())
846  {
847  $cmd = "mastersettings";
848  }
849  else
850  {
851  $cmd = "install";
852  }
853  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
854 //echo "-".$this->display_mode."-";
855  $this->setButtonNext($cmd,$btn_text);
856  }
857  else
858  {
859  $this->tpl->setCurrentBlock("premessage");
860  $this->tpl->setVariable("TXT_PRE_ERR", sprintf($this->lng->txt("pre_error"),
861  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"));
862  $this->tpl->parseCurrentBlock();
863  }
864  }
865 
869 
873  function displayMasterSetup($a_omit_init = false)
874  {
875  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
876  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
877  $this->tpl->setVariable("TXT_INFO",
878  $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
879 
880  $this->setButtonPrev("preliminaries");
881 
882  if ($this->setup->isInstalled())
883  {
884  $this->setButtonNext("list");
885  }
886 
887  if (!$a_omit_init)
888  {
889  $this->initBasicSettingsForm(true);
890  }
891  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
892  }
893 
897  function changeMasterSettings($a_omit_init = false)
898  {
899  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
900  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
901  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
902 
903  $this->btn_next_on = true;
904  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
905  $this->btn_next_cmd = "newclient";
906 
907  if (!$a_omit_init)
908  {
909  $this->initBasicSettingsForm();
910  $this->getBasicSettingsValues();
911  }
912  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
913  }
914 
918  public function initBasicSettingsForm($a_install = false)
919  {
920  global $lng, $ilCtrl;
921 
922  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
923  $this->form = new ilPropertyFormGUI();
924 
925  // webspace dir
926  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
927  if ($a_install)
928  {
929  $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
930  }
931  $cwd = ilUtil::isWindows()
932  ? str_replace("\\", "/", getcwd())
933  : getcwd();
934 
935  $ne->setValue($cwd."/data");
936  $this->form->addItem($ne);
937 
938  // data dir
939  if ($a_install)
940  {
941  $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
942  $ti->setInfo($lng->txt("data_directory_info"));
943  $ti->setRequired(true);
944  $this->form->addItem($ti);
945  }
946  else
947  {
948  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
949  $this->form->addItem($ne);
950  }
951 
952  $lvext = (ilUtil::isWindows())
953  ? "_win"
954  : "";
955 
956 
957  // logging
958  $sh = new ilFormSectionHeaderGUI();
959  $sh->setTitle($lng->txt("logging"));
960  $this->form->addItem($sh);
961 
962  // path to log file
963  $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
964  $ti->setInfo($lng->txt("log_path_comment".$lvext));
965  $this->form->addItem($ti);
966 
967  // disable logging
968  $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
969  $this->form->addItem($cb);
970 
971  // server settings
972  $sh = new ilFormSectionHeaderGUI();
973  $sh->setTitle($lng->txt("server_settings"));
974  $this->form->addItem($sh);
975 
976  // time zone
977  include_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
978  $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
979  $si->setOptions(array_merge(
980  array("" => "-- ".$lng->txt("please_select")." --"),
982  $si->setRequired(true);
983  $this->form->addItem($si);
984 
985  // required 3rd party tools
986  $sh = new ilFormSectionHeaderGUI();
987  $sh->setTitle($lng->txt("3rd_party_software_req"));
988  $this->form->addItem($sh);
989 
990  // convert path
991  $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
992  $ti->setInfo($lng->txt("convert_path_comment".$lvext));
993  $ti->setRequired(true);
994  $this->form->addItem($ti);
995 
996  // zip path
997  $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
998  $ti->setInfo($lng->txt("zip_path_comment".$lvext));
999  $ti->setRequired(true);
1000  $this->form->addItem($ti);
1001 
1002  // unzip path
1003  $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
1004  $ti->setInfo($lng->txt("unzip_path_comment".$lvext));
1005  $ti->setRequired(true);
1006  $this->form->addItem($ti);
1007 
1008  // optional 3rd party tools
1009  $sh = new ilFormSectionHeaderGUI();
1010  $sh->setTitle($lng->txt("3rd_party_software_opt"));
1011  $this->form->addItem($sh);
1012 
1013  // java path
1014  $ti = new ilTextInputGUI($lng->txt("java_path"), "java_path");
1015  $ti->setInfo($lng->txt("java_path_comment".$lvext));
1016  $this->form->addItem($ti);
1017 
1018  // htmldoc path
1019  $ti = new ilTextInputGUI($lng->txt("htmldoc_path"), "htmldoc_path");
1020  $ti->setInfo($lng->txt("htmldoc_path_comment".$lvext));
1021  $this->form->addItem($ti);
1022 
1023  // mkisofs path
1024  $ti = new ilTextInputGUI($lng->txt("mkisofs_path"), "mkisofs_path");
1025  $ti->setInfo($lng->txt("mkisofs_path_comment"));
1026  $this->form->addItem($ti);
1027 
1028  // latex
1029  $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
1030  $ti->setInfo($lng->txt("latex_url_comment"));
1031  $this->form->addItem($ti);
1032 
1033  // virus scanner
1034  $options = array(
1035  "none" => $lng->txt("none"),
1036  "sophos" => $lng->txt("sophos"),
1037  "antivir" => $lng->txt("antivir"),
1038  "clamav" => $lng->txt("clamav")
1039  );
1040  $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
1041  $si->setOptions($options);
1042  $this->form->addItem($si);
1043 
1044  // scan command
1045  $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
1046  $this->form->addItem($ti);
1047 
1048  // clean command
1049  $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
1050  $this->form->addItem($ti);
1051 
1052  if ($a_install)
1053  {
1054  $sh = new ilFormSectionHeaderGUI();
1055  $sh->setTitle($lng->txt("master_password"));
1056  $this->form->addItem($sh);
1057 
1058  // password
1059  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1060  $pi->setRequired(true);
1061  $pi->setSkipSyntaxCheck(true);
1062  $pi->setInfo($lng->txt("password_info"));
1063  $this->form->addItem($pi);
1064  }
1065 
1066  if ($a_install)
1067  {
1068  $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
1069  }
1070  else
1071  {
1072  $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
1073  $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
1074  }
1075 
1076  $this->form->setTitle($lng->txt("data_directories"));
1077  $this->form->setFormAction("setup.php?cmd=gateway");
1078 
1079  if ($a_install)
1080  {
1081  $det = $this->determineTools();
1082  $this->form->setValuesByArray($det);
1083  }
1084 
1085  }
1086 
1090  public function getBasicSettingsValues()
1091  {
1092  $values = array();
1093 
1094  $values["webspace_dir"] = getcwd()."/data";
1095  $values["data_dir"] = $this->setup->ini->readVariable("clients","datadir");
1096  $values["convert_path"] = $this->setup->ini->readVariable("tools","convert");
1097  $values["zip_path"] = $this->setup->ini->readVariable("tools","zip");
1098  $values["unzip_path"] = $this->setup->ini->readVariable("tools","unzip");
1099  $values["java_path"] = $this->setup->ini->readVariable("tools","java");
1100  $values["htmldoc_path"] = $this->setup->ini->readVariable("tools","htmldoc");
1101  $values["mkisofs_path"] = $this->setup->ini->readVariable("tools","mkisofs");
1102  $values["latex_url"] = $this->setup->ini->readVariable("tools","latex");
1103  $values["fop_path"] = $this->setup->ini->readVariable("tools","fop");
1104  $values["vscanner_type"] = $this->setup->ini->readVariable("tools", "vscantype");
1105  $values["scan_command"] = $this->setup->ini->readVariable("tools", "scancommand");
1106  $values["clean_command"] = $this->setup->ini->readVariable("tools", "cleancommand");
1107  $values["log_path"] = $this->setup->ini->readVariable("log","path")."/".
1108  $this->setup->ini->readVariable("log","file");
1109  $values["chk_log_status"] = !$this->setup->ini->readVariable("log","enabled");
1110  $values["time_zone"] = $this->setup->ini->readVariable("server", "timezone");
1111 
1112  $this->form->setValuesByArray($values);
1113  }
1114 
1118  public function saveBasicSettings()
1119  {
1120  global $tpl, $lng, $ilCtrl;
1121 
1122  $this->initBasicSettingsForm(true);
1123 
1124  if ($this->form->checkInput())
1125  {
1126  // correct paths on windows
1127  if (ilUtil::isWindows())
1128  {
1129  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1130  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1131  foreach ($fs as $f)
1132  {
1133  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1134  }
1135  }
1136 
1137  $_POST["setup_pass"] = $_POST["password"];
1138  $_POST["setup_pass2"] = $_POST["password_retype"];
1139  if (!$this->setup->checkDataDirSetup($_POST))
1140  {
1141  $i = $this->form->getItemByPostVar("datadir_path");
1142  $i->setAlert($this->lng->txt($this->setup->getError()));
1143  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1144  }
1145  else if (!$this->setup->checkLogSetup($_POST))
1146  {
1147  $i = $this->form->getItemByPostVar("log_path");
1148  $i->setAlert($this->lng->txt($this->setup->getError()));
1149  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1150  }
1151  else if (!$this->setup->checkPasswordSetup($_POST))
1152  {
1153  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1154  }
1155  else if (!$this->setup->saveMasterSetup($_POST))
1156  {
1157  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1158  }
1159  else
1160  {
1161  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1162  ilUtil::redirect("setup.php?cmd=mastersettings");
1163  }
1164  }
1165 
1166  $this->form->setValuesByPost();
1167  $this->displayMasterSetup(true);
1168  }
1169 
1173  public function updateBasicSettings()
1174  {
1175  global $tpl, $lng, $ilCtrl;
1176 
1177  $this->initBasicSettingsForm();
1178 
1179  if ($this->form->checkInput())
1180  {
1181  if (ilUtil::isWindows())
1182  {
1183  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1184  "unzip_path", "java_path", "htmldoc_path", "mkisofs_path");
1185  foreach ($fs as $f)
1186  {
1187  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1188  }
1189  }
1190 
1191  if (!$this->setup->checkLogSetup($_POST))
1192  {
1193  $i = $this->form->getItemByPostVar("log_path");
1194  $i->setAlert($this->lng->txt($this->setup->getError()));
1195  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1196  }
1197  else if (!$this->setup->updateMasterSettings($_POST))
1198  {
1199  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1200  }
1201  else
1202  {
1203  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1204  ilUtil::redirect("setup.php?cmd=mastersettings");
1205  }
1206  }
1207 
1208  $this->form->setValuesByPost();
1209  $this->changeMasterSettings(true);
1210  }
1211 
1215 
1219  function loginClient()
1220  {
1221  session_destroy();
1222 
1223  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
1224  }
1225 
1229  function displayLogin($a_omit_minit = false, $a_omit_cinit = false)
1230  {
1231  global $lng;
1232 
1233  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
1234 
1235  if ($a_omit_minit)
1236  {
1237  $m_form = $this->form->getHTML();
1238  }
1239  if (!$a_omit_cinit)
1240  {
1241  $this->initClientLoginForm();
1242  }
1243  $cl_form = $this->form->getHTML();
1244  if (!$a_omit_minit)
1245  {
1246  $this->initMasterLoginForm();
1247  $m_form = $this->form->getHTML();
1248  }
1249  $this->tpl->setVariable("SETUP_CONTENT", $cl_form."<br>".$m_form);
1250  $this->tpl->setVariable("TXT_HEADER", $lng->txt("login"));
1251  }
1252 
1256  public function performMLogin()
1257  {
1258  $this->initMasterLoginForm();
1259  if ($this->form->checkInput())
1260  {
1261  $i = $this->form->getItemByPostVar("mpassword");
1262  if (!$this->setup->loginAsAdmin($_POST["mpassword"]))
1263  {
1264  $i->setAlert($this->lng->txt("login_invalid"));
1265  }
1266  else
1267  {
1268  // everything ok -> we are authenticated
1269  ilUtil::redirect("setup.php");
1270  }
1271  }
1272 
1273  // something wrong -> display login again
1274  $this->form->setValuesByPost();
1275  $this->displayLogin(true);
1276  }
1277 
1281  function performLogin()
1282  {
1283  $this->initClientLoginForm();
1284  if ($this->form->checkInput())
1285  {
1286  $i = $this->form->getItemByPostVar("password");
1287  if (!$this->setup->loginAsClient(
1288  array("client_id" => $_POST["client_id"],
1289  "username" => $_POST["username"], "password" => $_POST["password"])))
1290  {
1291  $i->setAlert($this->setup->getError());
1292  }
1293  else
1294  {
1295  // everything ok -> we are authenticated
1296  ilUtil::redirect("setup.php");
1297  }
1298  }
1299 
1300  // something wrong -> display login again
1301  $this->form->setValuesByPost();
1302  $this->displayLogin(false, true);
1303  }
1304 
1308  public function initClientLoginForm()
1309  {
1310  global $lng, $ilCtrl;
1311 
1312  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1313  $this->form = new ilPropertyFormGUI();
1314 
1315  // client id
1316  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1317  $ti->setMaxLength(32);
1318  $ti->setSize(20);
1319  $this->form->addItem($ti);
1320 
1321  // username
1322  $ti = new ilTextInputGUI($lng->txt("username"), "username");
1323  $ti->setSize(20);
1324  $this->form->addItem($ti);
1325 
1326  // password
1327  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1328  $pi->setSize(20);
1329  $pi->setRetype(false);
1330  $pi->setSkipSyntaxCheck(true);
1331  $this->form->addItem($pi);
1332 
1333  $this->form->addCommandButton("performLogin", $lng->txt("login"));
1334 
1335  $this->form->setTitle($lng->txt("client_login"));
1336  $this->form->setFormAction("setup.php?cmd=gateway");
1337  }
1338 
1342  public function initMasterLoginForm()
1343  {
1344  global $lng, $ilCtrl;
1345 
1346  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1347  $this->form = new ilPropertyFormGUI();
1348 
1349  // password
1350  $pi = new ilPasswordInputGUI($lng->txt("password"), "mpassword");
1351  $pi->setSize(20);
1352  $pi->setRetype(false);
1353  $pi->setSkipSyntaxCheck(true);
1354  $this->form->addItem($pi);
1355 
1356  $this->form->addCommandButton("performMLogin", $lng->txt("login"));
1357 
1358  $this->form->setTitle($lng->txt("admin_login"));
1359  $this->form->setFormAction("setup.php?cmd=gateway");
1360 
1361  }
1362 
1366 
1371  {
1372  $_SESSION["ClientId"] = "";
1373 
1374  $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html", "setup");
1375  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1376  ilUtil::sendInfo();
1377 
1378  // common
1379  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("list_clients"));
1380  $this->tpl->setVariable("TXT_LISTSTATUS",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1381  $this->tpl->setVariable("TXT_TOGGLELIST",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1382 
1383  include_once("./setup/classes/class.ilClientListTableGUI.php");
1384  $tab = new ilClientListTableGUI($this->setup);
1385  $this->tpl->setVariable("CLIENT_LIST", $tab->getHTML());
1386 
1387  // create new client button
1388  $this->btn_next_on = true;
1389  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
1390  $this->btn_next_cmd = "newclient";
1391  }
1392 
1397  {
1398  $_POST = $this->determineTools($_POST);
1399  $this->updateBasicSettings();
1400  }
1401 
1406  {
1407  $this->displayMasterSetup(true);
1408  }
1409 
1413  function determineTools($a_tools = "")
1414  {
1415  $cwd = ilUtil::isWindows()
1416  ? str_replace("\\", "/", getcwd())
1417  : getcwd();
1418  if (!ilUtil::isWindows())
1419  {
1420  $tools = array("convert" => "convert",
1421  "zip" => "zip", "unzip" => "unzip",
1422  "java" => "java", "htmldoc" => "htmldoc", "mkisofs" => "mkisofs");
1423  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin", "/usr/bin");
1424  }
1425  else
1426  {
1427  $tools = array("convert" => "convert.exe",
1428  "zip" => "zip.exe", "unzip" => "unzip.exe");
1429  $dirs = array($cwd."/Services/Windows/bin32/zip",
1430  $cwd."/Services/Windows/bin32/unzip",
1431  $cwd."/Services/Windows/bin32/convert");
1432  }
1433  foreach($tools as $k => $tool)
1434  {
1435  // try which command
1436  unset($ret);
1437  @exec("which ".$tool, $ret);
1438  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
1439  {
1440  $a_tools[$k."_path"] = $ret[0];
1441  continue;
1442  }
1443 
1444  // try common directories
1445  foreach($dirs as $dir)
1446  {
1447  if (@is_file($dir."/".$tool))
1448  {
1449  $a_tools[$k."_path"] = $dir."/".$tool;
1450  continue;
1451  }
1452  }
1453  }
1454  return $a_tools;
1455  }
1456 
1457 
1461 
1466  function selectDBType()
1467  {
1468  $this->checkDisplayMode("create_new_client");
1469 
1470 
1471 if (true)
1472 {
1473  $this->initDBSelectionForm();
1474  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1475 }
1476 else
1477 {
1478  // output
1479 
1480  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_select_db.html", "setup");
1481 
1482  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1483  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1484 
1485  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
1486  $this->tpl->setVariable("TXT_DB_SELECTION", $this->lng->txt("db_selection"));
1487 }
1488  if ($this->setup->getClient()->status["ini"]["status"])
1489  {
1490  $this->setButtonNext("db");
1491  }
1492 
1493  $this->checkPanelMode();
1494  }
1495 
1499  public function initDBSelectionForm()
1500  {
1501  global $lng, $ilCtrl;
1502 
1503  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1504  $this->form = new ilPropertyFormGUI();
1505 
1506  // db type
1507  $options = array(
1508  "mysql" => "MySQL 5.0.x or higher",
1509  "oracle" => "Oracle 10g or higher",
1510  );
1511  $si = new ilSelectInputGUI($lng->txt("db_type"), "db_type");
1512  $si->setOptions($options);
1513  $si->setInfo($lng->txt(""));
1514  $this->form->addItem($si);
1515 
1516  $this->form->addCommandButton("selectdbtype", $lng->txt("save"));
1517 
1518  $this->form->setTitle($lng->txt("db_selection"));
1519  $this->form->setFormAction("setup.php?cmd=gateway");
1520  }
1521 
1525 
1529  function displayIni($a_omit_form_init = false)
1530  {
1531  $this->checkDisplayMode("create_new_client");
1532 
1533  if ($_POST["db_type"] != "")
1534  {
1535  $_SESSION["db_type"] = $_POST["db_type"];
1536  }
1537  else
1538  {
1539  $_POST["db_type"] = $_SESSION["db_type"];
1540  }
1541 
1542  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1543  if (!$a_omit_form_init)
1544  {
1545  $this->initClientIniForm();
1546  $this->getClientIniValues();
1547  }
1548  $this->tpl->setVariable("SETUP_CONTENT",
1549  $this->form->getHTML());
1550 
1551  if ($this->setup->getClient()->status["ini"]["status"])
1552  {
1553  $this->setButtonNext("db");
1554  }
1555 
1556  $this->checkPanelMode();
1557  }
1558 
1562  public function initClientIniForm()
1563  {
1564  global $lng, $ilCtrl;
1565 
1566  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1567  $this->form = new ilPropertyFormGUI();
1568 
1569  // client id
1570  if ($this->setup->ini_client_exists)
1571  {
1572  $hi = new ilHiddenInputGUI("client_id");
1573  $hi->setValue($this->client_id);
1574  $this->form->addItem($hi);
1575 
1576  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "hh");
1577  $ne->setValue($this->client_id);
1578  $this->form->addItem($ne);
1579  }
1580  else
1581  {
1582  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1583  $ti->setMaxLength(32);
1584  $ti->setRequired(true);
1585  $this->form->addItem($ti);
1586  }
1587 
1588  // database connection
1589  $sh = new ilFormSectionHeaderGUI();
1590  $sh->setTitle($lng->txt("db_conn"));
1591  $this->form->addItem($sh);
1592 
1593  // db type
1594  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "dbt");
1595  $ne->setValue($lng->txt("db_".$_SESSION["db_type"]));
1596  $this->form->addItem($ne);
1597 
1598  // db host
1599  $ti = new ilTextInputGUI($lng->txt("db_host"), "db_host");
1600  $ti->setMaxLength(120);
1601  $ti->setRequired(true);
1602  $this->form->addItem($ti);
1603 
1604  // db name
1605  if ($_SESSION["db_type"] == "mysql")
1606  {
1607  $ti = new ilTextInputGUI($lng->txt("db_name"), "db_name");
1608  $ti->setRequired(true);
1609  }
1610  else
1611  {
1612  $ti = new ilTextInputGUI($lng->txt("db_service_name"), "db_name");
1613  }
1614  $ti->setMaxLength(40);
1615  $this->form->addItem($ti);
1616 
1617  // db user
1618  $ti = new ilTextInputGUI($lng->txt("db_user"), "db_user");
1619  $ti->setMaxLength(40);
1620  $ti->setRequired(true);
1621  $this->form->addItem($ti);
1622 
1623  // db port
1624  $ti = new ilTextInputGUI($lng->txt("db_port"), "db_port");
1625  $ti->setMaxLength(8);
1626  $this->form->addItem($ti);
1627 
1628  // db password
1629  $ti = new ilTextInputGUI($lng->txt("db_pass"), "db_pass");
1630  $ti->setMaxLength(40);
1631  $this->form->addItem($ti);
1632 
1633  $this->form->addCommandButton("saveClientIni", $lng->txt("save"));
1634 
1635  $this->form->setTitle($lng->txt("inst_identification"));
1636  $this->form->setFormAction("setup.php?cmd=gateway");
1637  }
1638 
1642  public function getClientIniValues()
1643  {
1644  $values = array();
1645 
1646  $values["db_host"] = $this->setup->getClient()->getDbHost();
1647  $values["db_user"] = $this->setup->getClient()->getDbUser();
1648  $values["db_port"] = $this->setup->getClient()->getDbPort();
1649  $values["db_pass"] = $this->setup->getClient()->getDbPass();
1650  $values["db_name"] = $this->setup->getClient()->getDbName();
1651  $values["client_id"] = $this->setup->getClient()->getId();
1652 
1653  $this->form->setValuesByArray($values);
1654  }
1655 
1659  public function saveClientIni()
1660  {
1661  global $tpl, $lng, $ilCtrl;
1662 
1663  $this->initClientIniForm();
1664  if ($this->form->checkInput())
1665  {
1666  if (strlen($_POST["client_id"]) != strlen(urlencode(($_POST["client_id"]))))
1667  {
1668  $i = $this->form->getItemByPostVar("client_id");
1669  $i->setAlert($this->lng->txt("ini_client_id_invalid"));
1670  ilUtil::sendFailure($this->lng->txt("ini_client_id_invalid"),true);
1671  }
1672  else if (strlen($_POST["client_id"]) < 4)
1673  {
1674  $i = $this->form->getItemByPostVar("client_id");
1675  $i->setAlert($this->lng->txt("ini_client_id_too_short"));
1676  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_short"),true);
1677  }
1678  else if (strlen($_POST["client_id"]) > 32)
1679  {
1680  $i = $this->form->getItemByPostVar("client_id");
1681  $i->setAlert($this->lng->txt("ini_client_id_too_long"));
1682  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_long"),true);
1683  }
1684  else if (!$this->setup->ini_client_exists && file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$_POST["client_id"]))
1685  {
1686  $i = $this->form->getItemByPostVar("client_id");
1687  $i->setAlert($this->lng->txt("ini_client_id_exists"));
1688  ilUtil::sendFailure($this->lng->txt("ini_client_id_exists"),true);
1689  }
1690  else
1691  {
1692 
1693  // save some old values
1694  $old_db_name = $this->setup->getClient()->getDbName();
1695  $old_db_type = $this->setup->getClient()->getDbType();
1696  $old_client_id = $this->setup->getClient()->getId();
1697 
1698  // create new client object if it does not exist
1699  if (!$this->setup->ini_client_exists)
1700  {
1701  $client_id = $_POST["client_id"];
1702  $this->setup->newClient($client_id);
1703  }
1704 
1705  // set client data
1706  $this->setup->getClient()->setId($_POST["client_id"]);
1707  $this->setup->getClient()->setDbHost($_POST["db_host"]);
1708  $this->setup->getClient()->setDbName($_POST["db_name"]);
1709  $this->setup->getClient()->setDbUser($_POST["db_user"]);
1710  $this->setup->getClient()->setDbPort($_POST["db_port"]);
1711  $this->setup->getClient()->setDbPass($_POST["db_pass"]);
1712  $this->setup->getClient()->setDbType($_SESSION["db_type"]);
1713  $this->setup->getClient()->setDSN();
1714 
1715  // try to connect to database
1716  if (!$this->setup->getClient()->checkDatabaseHost())
1717  {
1718  $i = $this->form->getItemByPostVar("db_host");
1719  $i->setAlert($this->lng->txt($this->setup->getClient()->getError()));
1720  ilUtil::sendFailure($this->setup->getClient()->getError(),true);
1721  }
1722  else
1723  {
1724  // check if db exists
1725  $db_installed = $this->setup->getClient()->checkDatabaseExists();
1726 
1727  if ($db_installed and (!$this->setup->ini_ilias_exists or ($this->setup->getClient()->getDbName() != $old_db_name)))
1728  {
1729  $_POST["db_name"] = $old_db_name;
1730  $message = ucfirst($this->lng->txt("database"))." \"".$this->setup->getClient()->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
1731  $i = $this->form->getItemByPostVar("db_name");
1732  $i->setAlert($message);
1733  ilUtil::sendFailure($message, true);
1734  }
1735  else
1736  {
1737  // all ok. create client.ini and save posted data
1738  if (!$this->setup->ini_client_exists)
1739  {
1740  if ($this->setup->saveNewClient())
1741  {
1742  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1743  $this->setup->getClient()->status["ini"]["status"] = true;
1744  $_SESSION["ClientId"] = $client_id;
1745  ilUtil::redirect("setup.php?cmd=displayIni&client_id=".$client_id);
1746  }
1747  else
1748  {
1749  $err = $this->setup->getError();
1750  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1751  $this->setup->getClient()->status["ini"]["status"] = false;
1752  $this->setup->getClient()->status["ini"]["comment"] = $err;
1753  }
1754  }
1755  else
1756  {
1757  if ($this->setup->getClient()->ini->write())
1758  {
1759  ilUtil::sendSuccess($this->lng->txt("settings_changed"));
1760  $this->setup->getClient()->status["ini"]["status"] = true;
1761  ilUtil::redirect("setup.php?cmd=displayIni");
1762  }
1763  else
1764  {
1765  $err = $this->setup->getClient()->ini->getError();
1766  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1767  $this->setup->getClient()->status["ini"]["status"] = false;
1768  $this->setup->getClient()->status["ini"]["comment"] = $err;
1769  }
1770  }
1771  }
1772  }
1773  }
1774  }
1775 
1776  $this->form->setValuesByPost();
1777  $this->displayIni(true);
1778  }
1779 
1785  function displayError($a_message)
1786  {
1787  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html", "setup");
1788 
1789  $this->tpl->setCurrentBlock("content");
1790  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1791  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1792  $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
1793  $this->tpl->parseCurrentBlock();
1794 
1795  $this->tpl->show();
1796  exit();
1797  }
1798 
1802  function displayLogout()
1803  {
1804  $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html", "setup");
1805 
1806  session_destroy();
1807 
1808  $this->logged_out = true;
1809  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));
1810  $this->tpl->setCurrentBlock("home_link");
1811  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
1812  $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
1813  $this->tpl->parseCurrentBlock();
1814  }
1815 
1820  {
1821  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1822 
1823  $steps = array();
1824  $steps = $this->setup->getStatus();
1825 
1826  // remove access step
1827  unset($steps["access"]);
1828 
1829  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1830  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1831  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1832  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1833  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1834  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1835 
1836  $stpl = new ilTemplate("tpl.process_panel.html", true, true, "setup");
1837 
1838  $num = 1;
1839 
1840  foreach ($steps as $key => $val)
1841  {
1842  $stpl->setCurrentBlock("menu_row");
1843  $stpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
1844  $stpl->setVariable("TXT_ACTION",$val["text"]);
1845  $stpl->setVariable("IMG_ARROW", "spacer.gif");
1846 
1847  $num++;
1848 
1849  if ($this->cmd == $key and isset($this->cmd))
1850  {
1851  $stpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1852  $stpl->setVariable("IMG_ARROW", "arrow_right.png");
1853  }
1854 
1855  $status = ($val["status"]) ? $OK : "";
1856 
1857  $stpl->setVariable("TXT_STATUS",$status);
1858  $stpl->parseCurrentBlock();
1859  }
1860 
1861  $stpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
1862 
1863  $this->tpl->setVariable("PROCESS_MENU", $stpl->get());
1864  }
1865 
1870  {
1871  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1872 
1873  $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html", "setup");
1874 
1875  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1876  // display status
1877  if ($this->setup->getClient()->status)
1878  {
1879  foreach ($this->setup->getClient()->status as $key => $val)
1880  {
1881  $status = ($val["status"]) ? $OK : "&nbsp;";
1882  $this->tpl->setCurrentBlock("status_row");
1883  $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1884  $this->tpl->setVariable("TXT_STATUS",$status);
1885  $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1886  $this->tpl->parseCurrentBlock();
1887  }
1888  }
1889  }
1890 
1896  function checkDisplayMode($a_title = "")
1897  {
1898  switch ($this->display_mode)
1899  {
1900  case "view":
1901  $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html", "setup");
1902  // display tabs
1903  include "./setup/include/inc.client_tabs.php";
1904  $client_name = ($this->setup->getClient()->getName()) ? $this->setup->getClient()->getName() : $this->lng->txt("no_client_name");
1905  $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
1906  break;
1907 
1908  case "setup":
1909  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1910  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));
1911  break;
1912 
1913  default:
1914  $this->displayError($this->lng->txt("unknown_display_mode"));
1915  exit();
1916  break;
1917  }
1918  }
1919 
1923  function checkPanelMode()
1924  {
1925  switch ($this->display_mode)
1926  {
1927  case "view":
1928  $this->displayStatusPanel();
1929  break;
1930 
1931  case "setup":
1932  $this->displayProcessPanel();
1933  break;
1934  }
1935  }
1936 
1940  function displayStartup()
1941  {
1942  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1943 
1944  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
1945  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
1946 
1947  $this->displayProcessPanel();
1948 
1949  $this->setButtonNext("ini");
1950  }
1951 
1955 
1959  function displayDatabase()
1960  {
1961  global $ilErr,$ilDB,$ilLog;
1962 
1963  $this->checkDisplayMode("setup_database");
1964 
1965  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
1966 
1967  // database is intalled
1968  if ($this->setup->getClient()->db_installed)
1969  {
1970  $ilDB = $this->setup->getClient()->db;
1971  $this->lng->setDbHandler($ilDB);
1972  $dbupdate = new ilDBUpdate($ilDB);
1973  $db_status = $dbupdate->getDBVersionStatus();
1974  $hotfix_available = $dbupdate->hotfixAvailable();
1975  $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available);
1976  $this->getClientDbFormValues($dbupdate);
1977  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1978 
1979  if ($db_status)
1980  {
1981  $this->setButtonNext("lang");
1982  }
1983  }
1984  else // database is not installed
1985  {
1986  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db")."<br />".
1987  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>".
1988  "<p><b>".$this->lng->txt("info_text_db2")."</b></p><br/>");
1989 
1990  $this->initClientDbForm();
1991  $this->getClientDbFormValues();
1992  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1993  $this->setButtonPrev("ini");
1994  }
1995 
1996  $this->checkPanelMode();
1997  }
1998 
2002  public function initClientDbForm($a_install = true, $dbupdate = null, $db_status = false, $hotfix_available = false)
2003  {
2004  global $lng, $ilCtrl;
2005 
2006  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2007  $this->form = new ilPropertyFormGUI();
2008 
2009  // type
2010  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "db_type");
2011  $this->form->addItem($ne);
2012 
2013  // version
2014  if ($this->setup->getClient()->getDBType() == "mysql")
2015  {
2016  $ne = new ilNonEditableValueGUI($lng->txt("version"), "db_version");
2017  $ilDB = $this->setup->getClient()->db;
2018  $ne->setValue($ilDB->getDBVersion());
2019  $this->form->addItem($ne);
2020  }
2021 
2022  // host
2023  $ne = new ilNonEditableValueGUI($lng->txt("host"), "db_host");
2024  $this->form->addItem($ne);
2025 
2026  // name
2027  $ne = new ilNonEditableValueGUI($lng->txt("name"), "db_name");
2028  $this->form->addItem($ne);
2029 
2030  // user
2031  $ne = new ilNonEditableValueGUI($lng->txt("user"), "db_user");
2032  $this->form->addItem($ne);
2033 
2034  // port
2035  $ne = new ilNonEditableValueGUI($lng->txt("port"), "db_port");
2036  $this->form->addItem($ne);
2037 
2038  // creation / collation for mysql
2039  if ($this->setup->getClient()->getDBType() == "mysql" && $a_install)
2040  {
2041  // create database
2042  $cb = new ilCheckboxInputGUI($lng->txt("database_create"), "chk_db_create");
2043 
2044  // collation
2045  $collations = array
2046  (
2047  "utf8_unicode_ci",
2048  "utf8_general_ci",
2049  "utf8_czech_ci",
2050  "utf8_danish_ci",
2051  "utf8_estonian_ci",
2052  "utf8_icelandic_ci",
2053  "utf8_latvian_ci",
2054  "utf8_lithuanian_ci",
2055  "utf8_persian_ci",
2056  "utf8_polish_ci",
2057  "utf8_roman_ci",
2058  "utf8_romanian_ci",
2059  "utf8_slovak_ci",
2060  "utf8_slovenian_ci",
2061  "utf8_spanish2_ci",
2062  "utf8_spanish_ci",
2063  "utf8_swedish_ci",
2064  "utf8_turkish_ci"
2065  );
2066  foreach($collations as $collation)
2067  {
2068  $options[$collation] = $collation;
2069  }
2070  $si = new ilSelectInputGUI($lng->txt("collation"), "collation");
2071  $si->setOptions($options);
2072  $si->setInfo($this->lng->txt("info_text_db_collation2")." ".
2073  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
2074  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2075  $cb->addSubItem($si);
2076 
2077  $this->form->addItem($cb);
2078  }
2079 
2080  if ($a_install)
2081  {
2082  $this->form->addCommandButton("installDatabase", $lng->txt("database_install"));
2083  }
2084  else
2085  {
2086  $ilDB = $this->setup->getClient()->db;
2087  $this->lng->setDbHandler($ilDB);
2088  $dbupdate = new ilDBUpdate($ilDB);
2089 
2090  // database version
2091  $ne = new ilNonEditableValueGUI($lng->txt("database_version"), "curv");
2092  $ne->setValue($dbupdate->currentVersion);
2093  $this->form->addItem($ne);
2094 
2095  // file version
2096  $ne = new ilNonEditableValueGUI($lng->txt("file_version"), "filev");
2097  $ne->setValue($dbupdate->fileVersion);
2098  $this->form->addItem($ne);
2099 
2100  if (!$db_status = $dbupdate->getDBVersionStatus())
2101  {
2102  // next update step
2103  $options = array();
2104  for ($i = $dbupdate->currentVersion + 1; $i <= $dbupdate->fileVersion; $i++)
2105  {
2106  $options[$i] = $i;
2107  }
2108  if (count($options) > 1)
2109  {
2110  $si = new ilSelectInputGUI($lng->txt("next_update_break"), "update_break");
2111  $si->setOptions($options);
2112  $si->setInfo($lng->txt("next_update_break_info"));
2113  $this->form->addItem($si);
2114  }
2115 
2116  if ($dbupdate->getRunningStatus() > 0)
2117  {
2118  ilUtil::sendFailure($this->lng->txt("db_update_interrupted")."<br /><br />".
2119  $this->lng->txt("db_update_interrupted_avoid"));
2120  }
2121  else
2122  {
2123  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2124  }
2125  $this->form->addCommandButton("updateDatabase", $lng->txt("database_update"));
2126  }
2127  else if ($hotfix_available)
2128  {
2129  // hotfix current version
2130  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2131  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2132  $this->form->addItem($ne);
2133 
2134  // hotfix file version
2135  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2136  $ne->setValue($dbupdate->getHotfixFileVersion());
2137  $this->form->addItem($ne);
2138 
2139  $this->form->addCommandButton("applyHotfix", $lng->txt("apply_hotfixes"));
2140  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2141  }
2142  else
2143  {
2144  if ($dbupdate->getHotfixFileVersion() > 0)
2145  {
2146  // hotfix current version
2147  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2148  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2149  $this->form->addItem($ne);
2150 
2151  // hotfix file version
2152  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2153  $ne->setValue($dbupdate->getHotfixFileVersion());
2154  $this->form->addItem($ne);
2155  }
2156  ilUtil::sendSuccess($this->lng->txt("database_is_uptodate"));
2157  }
2158  }
2159 
2160  $this->form->setTitle($lng->txt("database"));
2161  $this->form->setFormAction("setup.php?cmd=gateway");
2162  }
2163 
2168  public function getClientDbFormValues($dbupdate = null)
2169  {
2170  global $lng;
2171 
2172  $values = array();
2173 
2174  $values["db_host"] = $this->setup->getClient()->getDbHost();
2175  $values["db_name"] = $this->setup->getClient()->getDbName();
2176  $values["db_user"] = $this->setup->getClient()->getDbUser();
2177  $values["db_port"] = $this->setup->getClient()->getDbPort();
2178  $values["db_type"] = $lng->txt("db_".$this->setup->getClient()->getDbType());
2179  if (is_object($dbupdate))
2180  {
2181  $values["update_break"] = $dbupdate->fileVersion;
2182  if (($dbupdate->fileVersion - $dbupdate->currentVersion) >= 200)
2183  {
2184  $values["update_break"] = $dbupdate->currentVersion + 200 -
2185  ($dbupdate->currentVersion % 100);
2186  }
2187  }
2188 
2189  $this->form->setValuesByArray($values);
2190  }
2191 
2195 
2202  function installDatabase()
2203  {
2204  if (!$this->setup->getClient()->db_exists)
2205  {
2206  if ($_POST["chk_db_create"])
2207  {
2208  if (!$this->setup->createDatabase($_POST["collation"]))
2209  {
2210  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2211  ilUtil::redirect("setup.php?cmd=displayDatabase");
2212  }
2213  }
2214  else
2215  {
2216  ilUtil::sendFailure($this->lng->txt("database_not_exists_create_first"), true);
2217  ilUtil::redirect("setup.php?cmd=displayDatabase");
2218  }
2219  }
2220  if (!$this->setup->installDatabase())
2221  {
2222  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2223  }
2224  else
2225  {
2226  ilUtil::sendSuccess($this->lng->txt("database_installed"), true);
2227  }
2228  ilUtil::redirect("setup.php?cmd=displayDatabase");
2229  }
2230 
2234 
2238  function updateDatabase()
2239  {
2240  global $ilCtrlStructureReader;
2241 
2242  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2243 
2244  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2245  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2246  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2247  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2248  include_once "./Services/Tree/classes/class.ilTree.php";
2249  include_once "./classes/class.ilSaxParser.php";
2250  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2251 
2252  // referencing db handler in language class
2253  $ilDB = $this->setup->getClient()->db;
2254  $this->lng->setDbHandler($ilDB);
2255 
2256  // run dbupdate
2257  $dbupdate = new ilDBUpdate($ilDB);
2258  $dbupdate->applyUpdate((int) $_POST["update_break"]);
2259 
2260  if ($dbupdate->updateMsg == "no_changes")
2261  {
2262  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2263  }
2264  else
2265  {
2266  $sep = "";
2267  foreach ($dbupdate->updateMsg as $row)
2268  {
2269  if ($row["msg"] == "update_applied")
2270  {
2271  $a_message.= $sep.$row["nr"];
2272  $sep = ", ";
2273  }
2274  else
2275  {
2276  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2277  }
2278  }
2279  if ($a_message != "")
2280  {
2281  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2282  }
2283  }
2284 
2285  ilUtil::sendInfo($a_message.$e_message, true);
2286  ilUtil::redirect("setup.php?cmd=displayDatabase");
2287  }
2288 
2292 
2296  function applyHotfix()
2297  {
2298  global $ilCtrlStructureReader;
2299 
2300  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2301 
2302  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2303  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2304  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2305  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2306  include_once "./Services/Tree/classes/class.ilTree.php";
2307  include_once "./classes/class.ilSaxParser.php";
2308  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2309 
2310  // referencing db handler in language class
2311  $ilDB = $this->setup->getClient()->db;
2312  $this->lng->setDbHandler($ilDB);
2313 
2314  // run dbupdate
2315  $dbupdate = new ilDBUpdate($ilDB);
2316  $dbupdate->applyHotfix();
2317 
2318  if ($dbupdate->updateMsg == "no_changes")
2319  {
2320  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2321  }
2322  else
2323  {
2324  $sep = "";
2325  foreach ($dbupdate->updateMsg as $row)
2326  {
2327  if ($row["msg"] == "update_applied")
2328  {
2329  $a_message.= $sep.$row["nr"];
2330  $sep = ", ";
2331  }
2332  else
2333  {
2334  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2335  }
2336  }
2337  if ($a_message != "")
2338  {
2339  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2340  }
2341  }
2342 
2343  ilUtil::sendInfo($a_message.$e_message, true);
2344  ilUtil::redirect("setup.php?cmd=displayDatabase");
2345  }
2346 
2350 
2354  function displayLanguages()
2355  {
2356  $this->checkDisplayMode("setup_languages");
2357 
2358  if (!$this->setup->getClient()->db_installed)
2359  {
2360  // program should never come to this place
2361  $message = "No database found! Please install database first.";
2362  ilUtil::sendFailure($message);
2363  }
2364 
2365  include_once("./setup/classes/class.ilSetupLanguageTableGUI.php");
2366  $tab = new ilSetupLanguageTableGUI($this->setup->getClient());
2367  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2368 
2369  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2370  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2371 
2372  $installed_langs = $this->lng->getInstalledLanguages();
2373  $lang_count = count($installed_langs);
2374  if ($lang_count > 0)
2375  {
2376  $this->setup->getClient()->status["lang"]["status"] = true;
2377  $this->setup->getClient()->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2378  }
2379  else
2380  {
2381  $this->setup->getClient()->status["lang"]["status"] = false;
2382  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2383  }
2384 
2385  $this->setButtonPrev("db");
2386 
2387  if ($lang_count > 0)
2388  {
2389  $this->setButtonNext("contact");
2390  }
2391 
2392  $this->checkPanelMode();
2393  }
2394 
2401  function saveLanguages()
2402  {
2403  if (empty($_POST["form"]["lang_id"]))
2404  {
2405  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
2406  ilUtil::redirect("setup.php?cmd=lang");
2407  }
2408 
2409  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2410  {
2411  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
2412  ilUtil::redirect("setup.php?cmd=lang");
2413  }
2414 
2415  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2416 
2417  if (is_array($result))
2418  {
2419  $count = count($result);
2420  $txt = "tet";
2421 
2422  foreach ($result as $key => $lang_key)
2423  {
2424  $list .= $this->lng->txt("lang_".$lang_key);
2425 
2426  if ($count > $key + 1)
2427  {
2428  $list .= ", ";
2429  }
2430  }
2431  }
2432 
2433  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
2434  $message = $this->lng->txt("languages_installed");
2435 
2436  if ($result !== true)
2437  {
2438  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2439  }
2440  ilUtil::sendInfo($message, true);
2441  ilUtil::redirect("setup.php?cmd=lang");
2442  }
2443 
2447 
2451  function displayContactData($a_omit_init = false)
2452  {
2453  $this->checkDisplayMode("setup_contact_data");
2454  $settings = $this->setup->getClient()->getAllSettings();
2455 
2456  if (!$a_omit_init)
2457  {
2458  $this->initContactDataForm();
2459  $this->getContactValues();
2460  }
2461  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2462  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2463  $this->setButtonPrev("lang");
2464 
2465  $check = $this->setup->checkClientContact($this->setup->client);
2466 
2467  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
2468  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
2469 
2470  if ($check["status"])
2471  {
2472  $this->setButtonNext("nic");
2473  }
2474 
2475  $this->checkPanelMode();
2476  }
2477 
2483  public function initContactDataForm()
2484  {
2485  global $lng, $ilCtrl;
2486 
2487  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2488  $this->form = new ilPropertyFormGUI();
2489 
2490  // name
2491  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
2492  $ti->setMaxLength(64);
2493  $ti->setSize(30);
2494  $ti->setRequired(true);
2495  $this->form->addItem($ti);
2496 
2497  // description
2498  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
2499  $ti->setMaxLength(64);
2500  $ti->setSize(30);
2501  $this->form->addItem($ti);
2502 
2503  // institution
2504  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
2505  $ti->setMaxLength(64);
2506  $ti->setSize(30);
2507  $this->form->addItem($ti);
2508 
2509  // contact data
2510  $sh = new ilFormSectionHeaderGUI();
2511  $sh->setTitle($lng->txt("contact_data"));
2512  $this->form->addItem($sh);
2513 
2514  // first name
2515  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
2516  $ti->setMaxLength(64);
2517  $ti->setSize(30);
2518  $ti->setRequired(true);
2519  $this->form->addItem($ti);
2520 
2521  // last name
2522  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
2523  $ti->setMaxLength(64);
2524  $ti->setSize(30);
2525  $ti->setRequired(true);
2526  $this->form->addItem($ti);
2527 
2528  $fs = array (
2529  "title" => array("max" => 64, "size" => 30),
2530  "position" => array("max" => 64, "size" => 30),
2531  "institution" => array("max" => 200, "size" => 30),
2532  "street" => array("max" => 64, "size" => 30),
2533  "zipcode" => array("max" => 10, "size" => 5),
2534  "city" => array("max" => 64, "size" => 30),
2535  "country" => array("max" => 64, "size" => 30),
2536  "phone" => array("max" => 64, "size" => 30)
2537  );
2538  foreach ($fs as $f => $op)
2539  {
2540  // field
2541  $ti = new ilTextInputGUI($lng->txt($f), "admin_".$f);
2542  $ti->setMaxLength($op["max"]);
2543  $ti->setSize($op["size"]);
2544  $ti->setInfo($lng->txt(""));
2545  $this->form->addItem($ti);
2546  }
2547 
2548  // email
2549  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
2550  $ti->setRequired(true);
2551  $this->form->addItem($ti);
2552 
2553  $this->form->addCommandButton("saveContact", $lng->txt("save"));
2554 
2555  $this->form->setTitle($lng->txt("client_data"));
2556  $this->form->setFormAction("setup.php?cmd=gateway");
2557  }
2558 
2562  public function getContactValues()
2563  {
2564 
2565  $settings = $this->setup->getClient()->getAllSettings();
2566 
2567  $values = $settings;
2568 
2569  $values["inst_name"] = ($this->setup->getClient()->getName())
2570  ? $this->setup->getClient()->getName()
2571  : $this->setup->getClient()->getId();
2572  $values["inst_info"] = $this->setup->getClient()->getDescription();
2573 
2574  $this->form->setValuesByArray($values);
2575  }
2576 
2580  public function saveContact()
2581  {
2582  global $tpl, $lng, $ilCtrl;
2583 
2584  $this->initContactDataForm();
2585  if ($this->form->checkInput())
2586  {
2587  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
2588  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
2589  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
2590  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
2591  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
2592  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
2593  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
2594  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
2595  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
2596  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
2597  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
2598  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
2599  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
2600 
2601  // update client.ini
2602  $this->setup->getClient()->setName($_POST["inst_name"]);
2603  $this->setup->getClient()->setDescription($_POST["inst_info"]);
2604  $this->setup->getClient()->ini->write();
2605 
2606  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
2607  ilUtil::redirect("setup.php?cmd=displayContactData");
2608  }
2609 
2610  $this->form->setValuesByPost();
2611  $this->displayContactData(true);
2612  }
2613 
2617 
2621  function displayNIC($a_omit_init = false)
2622  {
2623  $this->checkDisplayMode("nic_registration");
2624  $settings = $this->setup->getClient()->getAllSettings();
2625  $nic_key = $this->setup->getClient()->getNICkey();
2626 
2627  // reload settings
2628  $settings = $this->setup->getClient()->getAllSettings();
2629 //var_dump($settings);
2630  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
2631  {
2632  $this->no_second_nav = true;
2633  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
2634  }
2635  else
2636  {
2637  // reload settings
2638  $settings = $this->setup->getClient()->getAllSettings();
2639 
2640  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
2641  if (!$a_omit_init)
2642  {
2643  $this->initRegistrationForm();
2644  $this->getRegistrationValues();
2645  }
2646  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2647 
2648  if (isset($settings["nic_enabled"]))
2649  {
2650  $this->setup->getClient()->status["nic"]["status"] = true;
2651  }
2652 
2653  }
2654 
2655  $this->setButtonPrev("contact");
2656 
2657  if ($this->setup->getClient()->status["nic"]["status"])
2658  {
2659  $this->setButtonNext("finish","finish");
2660  }
2661 
2662  $this->checkPanelMode();
2663  }
2664 
2670  public function initRegistrationForm($a_mode = "edit")
2671  {
2672  global $lng, $ilCtrl;
2673 
2674  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2675  $this->form = new ilPropertyFormGUI();
2676 
2677  // registration type
2678  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
2679  $radg->setValue(1);
2680  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
2681  $radg->addOption($op1);
2682  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
2683  $radg->addOption($op1);
2684  $this->form->addItem($radg);
2685 
2686  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
2687  $this->form->setFormAction("setup.php?cmd=gateway");
2688  }
2689 
2693  public function getRegistrationValues()
2694  {
2695  $settings = $this->setup->getClient()->getAllSettings();
2696  $nic_key = $this->setup->getClient()->getNICkey();
2697 
2698 
2699  $values = array();
2700 
2701  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
2702  {
2703  $values["register"] = 1;
2704  }
2705  /*elseif ($settings["nic_enabled"] == "2")
2706  {
2707  $this->tpl->setVariable("EMAIL",$checked);
2708  }*/
2709  else
2710  {
2711  $values["register"] = 0;
2712  }
2713 
2714  $this->form->setValuesByArray($values);
2715  }
2716 
2720  public function saveRegistration()
2721  {
2722  global $tpl, $lng, $ilCtrl;
2723 
2724  $this->initRegistrationForm();
2725  if ($this->form->checkInput())
2726  {
2727  // check register option
2728  if ($_POST["register"] == 1)
2729  {
2730  // update nic
2731  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
2732 //var_dump($this->setup->getClient()->nic_status);
2733  // online registration failed
2734  if (empty($this->setup->getClient()->nic_status[2]))
2735  {
2736  $this->setup->getClient()->setSetting("nic_enabled","-1");
2737  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
2738  ilUtil::redirect("setup.php?cmd=displayNIC");
2739  }
2740  else
2741  {
2742  $this->setup->getClient()->setSetting("inst_id",$this->setup->getClient()->nic_status[2]);
2743  $this->setup->getClient()->setSetting("nic_enabled","1");
2744  $this->setup->getClient()->status["nic"]["status"] = true;
2745  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
2746  ilUtil::redirect("setup.php?cmd=displayNIC");
2747  }
2748  }
2749  /*elseif ($_POST["form"]["register"] == 2)
2750  {
2751  $nic_by_email = (int) $_POST["form"]["nic_id"];
2752 
2753  $checksum = md5($nic_key.$nic_by_email);
2754 
2755  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
2756  {
2757  $message = $this->lng->txt("nic_reg_enter_correct_id");
2758  }
2759  else
2760  {
2761  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
2762  $this->setup->getClient()->setSetting("nic_enabled","1");
2763  $message = $this->lng->txt("nic_reg_enabled");
2764  }
2765  }*/
2766  else
2767  {
2768  $this->setup->getClient()->setSetting("inst_id","0");
2769  $this->setup->getClient()->setSetting("nic_enabled","0");
2770  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
2771  ilUtil::redirect("setup.php?cmd=displayNIC");
2772  }
2773  }
2774 
2775  $this->form->setValuesByPost();
2776  $this->displayNIC(true);
2777  }
2778 
2782 
2786  function displayTools()
2787  {
2788  $this->checkDisplayMode();
2789 
2790  // output
2791  ilUtil::sendInfo();
2792  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html", "setup");
2793  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2794  $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
2795  $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
2796  $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
2797 
2798  $ilDB = $this->setup->getClient()->db;
2799  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
2800  $crec = $ilDB->fetchAssoc($cset);
2801 
2802  if ($crec["cnt"] == 0)
2803  {
2804  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2805  $this->lng->txt("ctrl_missing_desc"));
2806  }
2807  else
2808  {
2809  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2810  $this->lng->txt("ctrl_structure_desc"));
2811  }
2812 
2813  $this->tpl->parseCurrentBlock();
2814 
2815  //$this->checkPanelMode();
2816  }
2817 
2822  {
2823  global $ilCtrlStructureReader;
2824 
2825  if (!$this->setup->getClient()->db_installed)
2826  {
2827  ilUtil::sendInfo($this->lng->txt("no_db"), true);
2828  $this->displayTools();
2829  return;
2830  }
2831 
2832  // referencing does not work in dbupdate-script
2833  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
2834 // BEGIN WebDAV
2835  // read module and service information into db
2836  require_once "./setup/classes/class.ilModuleReader.php";
2837  require_once "./setup/classes/class.ilServiceReader.php";
2838  require_once "./setup/classes/class.ilCtrlStructureReader.php";
2839 
2840  require_once "./Services/Component/classes/class.ilModule.php";
2841  require_once "./Services/Component/classes/class.ilService.php";
2842  $modules = ilModule::getAvailableCoreModules();
2844 
2846  foreach($modules as $module)
2847  {
2848  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
2849  $module["subdir"], "Modules");
2850  $mr->getModules();
2851  unset($mr);
2852  }
2853 
2855  foreach($services as $service)
2856  {
2857  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
2858  $service["subdir"], "Services");
2859  $sr->getServices();
2860  unset($sr);
2861  }
2862 // END WebDAV
2863 
2864  $ilCtrlStructureReader->readStructure(true);
2865  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
2866  $this->displayTools();
2867  }
2868 
2869 
2870 
2875  {
2876  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
2877 
2878  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
2879 
2880  // formular sent
2881  if ($_POST["form"])
2882  {
2883  $pass_old = $this->setup->getPassword();
2884 
2885  if (empty($_POST["form"]["pass_old"]))
2886  {
2887  $message = $this->lng->txt("password_enter_old");
2888  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2889  }
2890 
2891  if (md5($_POST["form"]["pass_old"]) != $pass_old)
2892  {
2893  $message = $this->lng->txt("password_old_wrong");
2894  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2895  }
2896 
2897  if (empty($_POST["form"]["pass"]))
2898  {
2899  $message = $this->lng->txt("password_empty");
2900  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2901  }
2902 
2903  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
2904  {
2905  $message = $this->lng->txt("password_not_match");
2906  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2907  }
2908 
2909  if (md5($_POST["form"]["pass"]) == $pass_old)
2910  {
2911  $message = $this->lng->txt("password_same");
2912  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2913  }
2914 
2915  if (!$this->setup->setPassword($_POST["form"]["pass"]))
2916  {
2917  $message = $this->lng->txt("save_error");
2918  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
2919  }
2920 
2921  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
2922  ilUtil::redirect("setup.php");
2923  }
2924 
2925  // output
2926  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html", "setup");
2927 
2928  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
2929 
2930  // pass form
2931  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2932  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
2933  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
2934  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
2935  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
2936  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
2937  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2938  }
2939 
2944  {
2945  $this->checkDisplayMode("finish_setup");
2946  $this->no_second_nav = true;
2947 //echo "<b>1</b>";
2948  if ($this->validateSetup())
2949  {
2950  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
2951  "<p>".$this->lng->txt("user").": <b>root</b><br />".
2952  $this->lng->txt("password").": <b>homer</b></p>";
2953  $this->setButtonNext("login_new","login");
2954 //echo "<b>2</b>";
2955  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
2956  // the setup_ok fails (with MDB2 and a larger
2957  // client list), alex 17.1.2008
2958  $this->setup->getClient()->setSetting("setup_ok",1);
2959 //$this->setup->getClient()->setSetting("zzz", "Z");
2960 //echo "<b>3</b>";
2961  $this->setup->getClient()->status["finish"]["status"] = true;
2962 //echo "<b>4</b>";
2963  }
2964  else
2965  {
2966  $txt_info = $this->lng->txt("info_text_finish2");
2967  }
2968 
2969 //echo "<b>5</b>";
2970  // output
2971  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html", "setup");
2972  $this->tpl->setVariable("TXT_INFO",$txt_info);
2973 
2974  $this->setButtonPrev("nic");
2975 //echo "<b>6</b>";
2976  $this->checkPanelMode();
2977 //echo "<b>7</b>";
2978  }
2979 
2984  {
2985  $this->checkDisplayMode();
2986 
2987  // formular sent
2988  if ($_POST["form"]["delete"])
2989  {
2990  $ini = true;
2991  $db = false;
2992  $files = false;
2993 
2994  /* disabled
2995  switch ($_POST["form"]["delete"])
2996  {
2997  case 1:
2998  $ini = true;
2999  break;
3000 
3001  case 2:
3002  $ini = true;
3003  $db = true;
3004  break;
3005 
3006  case 3:
3007  $ini = true;
3008  $db = true;
3009  $files = true;
3010  break;
3011  }
3012  */
3013 
3014  $msg = $this->setup->getClient()->delete($ini,$db,$files);
3015 
3016  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
3017  ilUtil::redirect("setup.php");
3018  }
3019 
3020  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3021 
3022  // output
3023  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html", "setup");
3024 
3025  // delete panel
3026  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3027  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3028  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3029  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3030 
3031  $this->checkPanelMode();
3032  }
3033 
3039  function changeAccessMode($a_back)
3040  {
3041  if ($this->setup->getClient()->status["finish"]["status"])
3042  {
3043  $val = ($this->setup->getClient()->ini->readVariable("client","access")) ? "0" : true;
3044  $this->setup->getClient()->ini->setVariable("client","access",$val);
3045  $this->setup->getClient()->ini->write();
3046  $message = "client_access_mode_changed";
3047  }
3048  else
3049  {
3050  $message = "client_setup_not_finished";
3051  }
3052 
3053  ilUtil::sendInfo($this->lng->txt($message),true);
3054 
3055  ilUtil::redirect("setup.php?cmd=".$a_back);
3056  }
3057 
3062  {
3063  if ($_POST["form"])
3064  {
3065  $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections);
3066 
3067  if (!$client->init())
3068  {
3069  $this->setup->raiseError($this->lng->txt("no_valid_client_id"),$this->setup->error_obj->MESSAGE);
3070  }
3071 
3072  $status = $this->setup->getStatus($client);
3073 
3074  if ($status["finish"]["status"])
3075  {
3076  $this->setup->ini->setVariable("clients","default",$client->getId());
3077  $this->setup->ini->write();
3078  $message = "default_client_changed";
3079  }
3080  else
3081  {
3082  $message = "client_setup_not_finished";
3083  }
3084  }
3085 
3086  ilUtil::sendInfo($this->lng->txt($message),true);
3087 
3088  ilUtil::redirect("setup.php");
3089  }
3090 
3095  function validateSetup()
3096  {
3097  foreach ($this->setup->getClient()->status as $key => $val)
3098  {
3099  if ($key != "finish" and $key != "access")
3100  {
3101  if ($val["status"] != true)
3102  {
3103  return false;
3104  }
3105  }
3106  }
3107 
3108 //$this->setup->getClient()->setSetting("zzz", "V");
3109  $clientlist = new ilClientList($this->setup->db_connections);
3110 //$this->setup->getClient()->setSetting("zzz", "W");
3111  $list = $clientlist->getClients();
3112 //$this->setup->getClient()->setSetting("zzz", "X");
3113  if (count($list) == 1)
3114  {
3115  $this->setup->ini->setVariable("clients","default",$this->setup->getClient()->getId());
3116  $this->setup->ini->write();
3117 
3118  $this->setup->getClient()->ini->setVariable("client","access",1);
3119  $this->setup->getClient()->ini->write();
3120  }
3121 //$this->setup->getClient()->setSetting("zzz", "Y");
3122  return true;
3123  }
3124 
3129  {
3130  if (!$this->setup->getClient()->status["db"]["status"])
3131  {
3132  $this->cmd = "db";
3133  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3134  $this->displayDatabase();
3135  }
3136  elseif (!$this->setup->getClient()->status["lang"]["status"])
3137  {
3138  $this->cmd = "lang";
3139  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3140  $this->displayLanguages();
3141  }
3142  elseif (!$this->setup->getClient()->status["contact"]["status"])
3143  {
3144  $this->cmd = "contact";
3145  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3146  $this->displayContactData();
3147  }
3148  elseif (!$this->setup->getClient()->status["nic"]["status"])
3149  {
3150  $this->cmd = "nic";
3151  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3152  $this->displayNIC();
3153  }
3154  elseif (!$this->setup->getClient()->status["finish"]["status"])
3155  {
3156  $this->cmd = "finish";
3157  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3158  $this->displayFinishSetup();
3159  }
3160  else
3161  {
3162  return false;
3163  }
3164  }
3165 
3169  function toggleClientList()
3170  {
3171  if ($this->setup->ini->readVariable("clients","list"))
3172  {
3173  $this->setup->ini->setVariable("clients","list","0");
3174  $this->setup->ini->write();
3175  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
3176  }
3177  else
3178  {
3179  $this->setup->ini->setVariable("clients","list","1");
3180  $this->setup->ini->write();
3181  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
3182  }
3183 
3184  ilUtil::redirect("setup.php");
3185  }
3186 
3187 } // END class.ilSetupGUI
3188 ?>