ILIAS  Release_4_4_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  // note: this is currently only used for subtabs, alex 8.1.2012
47  include_once("./Services/UIComponent/Tabs/classes/class.ilTabsGUI.php");
48  $this->tabs = new ilTabsGUI();
49  $this->tabs->setSetupMode(true);
50 
51  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
52  iljQueryUtil::initjQuery($this->tpl);
53  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
55 
56  // CVS - REVISION - DO NOT MODIFY
57  $this->revision = '$Revision: 49592 $';
58  $this->version = "2 ".substr(substr($this->revision,1),0,-2);
59  $this->lang = $this->lng->lang_key;
60 
61  // init setup
62  $this->setup = new ilSetup($_SESSION["auth"],$_SESSION["access_mode"]);
63 
64  // init client object if exists
65  $client_id = ($_GET["client_id"]) ? $_GET["client_id"] : $_SESSION["ClientId"];
66  if ($_POST["client_id"] != "")
67  {
68  $client_id = $_POST["client_id"];
69  }
70 
71 /*if ($_POST["client_id"] == "")
72 {
73 echo "<br>+".$_GET["client_id"];
74 echo "<br>+".$_POST["client_id"];
75 echo "<br>+".$_SESSION["ClientId"];
76 echo "<br>+".$client_id;
77 }*/
78  // for security
79  if (!$this->setup->isAdmin() and $client_id != $_SESSION["ClientId"])
80  {
81  $client_id = $_SESSION["ClientId"];
82  }
83 
84  $this->client_id = $client_id;
85 
86  $this->setup->ini_client_exists = $this->setup->newClient($client_id);
87  if (is_object($this->setup->getClient()))
88  {
89  $this->setup->getClient()->status = $this->setup->getStatus($client_id);
90  }
91 
92  // determine command
93  if (($this->cmd = $_GET["cmd"]) == "gateway")
94  {
95  // surpress warning if POST is not set
96  @$this->cmd = key($_POST["cmd"]);
97  }
98 
99  // determine display mode here
100  // TODO: depending on previous setting (session)
101  // 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)
102  if ($this->setup->isAuthenticated() and !$this->setup->getClient()->status["finish"]["status"] and $this->cmd != "clientlist" and $this->cmd != "")
103  {
104  $this->setDisplayMode("setup");
105  }
106  else
107  {
108  $this->setDisplayMode($_SESSION["display_mode"]);
109  }
110 
111  // output starts here
112 
113 
114  // main cmd handling
115  if (!$this->setup->isAuthenticated() or !$this->setup->isInstalled())
116  {
117  // check for first time installation or migrate an old one first
118  if (!$this->setup->isInstalled() or !($this->setup->ini->readVariable("clients","path")))
119  {
120  $this->cmdInstall();
121  }
122  else
123  {
124  if ($this->cmd == "performLogin" || $this->cmd == "performMLogin")
125  {
126  $cmd = $this->cmd;
127  $this->$cmd();
128  }
129  else
130  {
131  $this->displayLogin();
132  }
133  }
134  }
135  else
136  {
137  if ($this->setup->isAdmin())
138  {
139  $this->cmdAdmin();
140  }
141  else
142  {
143  $this->cmdClient();
144  }
145  }
146 
147  // display header
148  $this->displayHeader();
149 
150  if (DEBUG)
151  {
152  echo "cmd: ".$this->cmd." | access: ".$this->setup->access_mode." | display: ".$this->display_mode;
153  var_dump($this->setup->getClient()->status);
154  }
155 
156  // display footer
157  $this->displayFooter();
158 
159  // end output
160 
161  } // end constructor
162 
163  // cmd subsets
164 
168  function cmdInstall()
169  {
170  $cmd = $this->cmd;
171  switch ($this->cmd)
172  {
173  case NULL:
174  case "preliminaries":
175  $this->setup->checkPreliminaries();
176  $this->displayPreliminaries();
177  break;
178 
179  case "install":
180  $this->displayMasterSetup();
181  break;
182 
183  case "determineToolsPathInstall":
184  $this->determineToolsPathInstall();
185  break;
186 
187  case "saveBasicSettings":
188  $this->$cmd();
189  break;
190 
191  default:
192  $this->displayError($this->lng->txt("unknown_command"));
193  break;
194  }
195  }
196 
200  function cmdAdmin()
201  {
202  $cmd = $this->cmd;
203 
204  switch ($this->cmd)
205  {
206  case NULL:
207  case "clientlist":
208  $this->setDisplayMode("view");
209  $this->displayClientList();
210  $this->active_tab = "clientlist";
211  break;
212 
213  case "changepassword":
214  $this->setDisplayMode("view");
215  $this->changeMasterPassword();
216  $this->active_tab = "password";
217  break;
218 
219  case "mastersettings":
220  $this->setDisplayMode("view");
221  $this->changeMasterSettings();
222  $this->active_tab = "basicsettings";
223  break;
224 
225  case "determineToolsPath":
226  $this->setDisplayMode("view");
227  $this->determineToolsPath();
228  break;
229 
230  case "changedefault":
231  $this->changeDefaultClient();
232  break;
233 
234  case "newclient":
235  $this->cmd = "selectdb";
236  $this->setDisplayMode("setup");
237  $this->setup->ini_client_exists = $this->setup->newClient();
238  $this->selectDBType();
239  break;
240 
241  case "selectdbtype":
242  case "displayIni":
243  $this->cmd = "ini";
244  $this->setDisplayMode("setup");
245  //$this->setup->ini_client_exists = $this->setup->newClient($this->client_id);
246  $this->displayIni();
247  break;
248 
249  case "startup":
250  $this->setDisplayMode("setup");
251  $this->setup->ini_client_exists = $this->setup->newClient();
252  $this->displayStartup();
253  break;
254 
255  case "delete":
256  $this->setDisplayMode("view");
257  $this->displayDeleteConfirmation();
258  break;
259 
260  case "togglelist":
261  $this->setDisplayMode("view");
262  $this->toggleClientList();
263  break;
264 
265  case "preliminaries":
266  $this->setup->checkPreliminaries();
267  $this->displayPreliminaries();
268  $this->active_tab = "preliminaries";
269  break;
270 
271  case "updateBasicSettings":
272  case "performLogin":
273  case "performMLogin":
274  $this->$cmd();
275  break;
276 
277  default:
278  $this->cmdClient();
279  break;
280  }
281  }
282 
286  function cmdClient()
287  {
288  $cmd = $this->cmd;
289  switch ($this->cmd)
290  {
291  case NULL:
292  case "view":
293  if ($this->setup->getClient()->db_installed)
294  {
295  $this->setDisplayMode("view");
296  $this->displayClientOverview();
297  }
298  else
299  {
300  $this->cmd = "db";
301  $this->displayDatabase();
302  }
303  break;
304 
305  case "ini":
306  // only allow access to ini if db does not exist yet
307  //if ($this->setup->getClient()->db_installed)
308  //{
309  // $this->cmd = "db";
310  // $this->displayDatabase();
311  //}
312  //else
313  //{
314  $this->displayIni();
315  //}
316  break;
317 
318  case "db":
319  $this->displayDatabase();
320  break;
321 
322  case "dbslave":
323  $this->displayDatabaseSlave();
324  break;
325 
326  case "sess":
327  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "sess" and $this->setup->error === true)
328  {
330  }
331  else
332  {
333  $this->displaySessions();
334  }
335  break;
336 
337  case "lang":
338  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->setup->error === true)
339  {
341  }
342  else
343  {
344  $this->displayLanguages();
345  }
346  break;
347 
348  case "contact":
349  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "contact")
350  {
352  }
353  else
354  {
355  $this->displayContactData();
356  }
357  break;
358 
359  case "proxy":
360  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "proxy")
361  {
363  }
364  else
365  {
366  $this->displayProxy();
367  }
368  break;
369 
370  case "nic":
371  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "nic")
372  {
374  }
375  else
376  {
377  $this->displayNIC();
378  }
379  break;
380 
381  case "finish":
382  if (!isset($_GET["lang"]) and !$this->setup->getClient()->status["finish"]["status"] and $_GET["cmd"] == "finish")
383  {
385  }
386  else
387  {
388  $this->displayFinishSetup();
389  }
390  break;
391 
392  case "changeaccess":
393  $this->changeAccessMode($_GET["back"]);
394  break;
395 
396  case "logout":
397  $this->displayLogout();
398  break;
399 
400  case "login":
401  session_destroy();
402  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
403  break;
404 
405  case "login_new":
406  if ($this->setup->getClient()->ini->readVariable("client","access") != "1")
407  {
408  $this->setup->getClient()->ini->setVariable("client","access","1");
409  $this->setup->getClient()->ini->write();
410  }
411 
412  session_destroy();
413  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
414  break;
415 
416  case "tools":
417  $this->displayTools();
418  break;
419 
420  case "reloadStructure":
421  $this->reloadControlStructure();
422  break;
423 
424  case 'switchTree':
425  $this->switchTree();
426  break;
427 
428  case "saveClientIni":
429  case "installDatabase":
430  case "displayDatabase":
431  case "updateDatabase":
432  case "showUpdateSteps":
433  case "saveLanguages":
434  case "saveContact":
435  case "displayContactData":
436  case "displayNIC":
437  case "saveRegistration":
438  case "applyHotfix":
439  case "showHotfixSteps":
440  case "applyCustomUpdates":
441  case "changeSettingsType":
442  case "showLongerSettings":
443  case "cloneSelectSource":
444  case "cloneSaveSource":
445  case "saveProxy":
446  case "saveDbSlave":
447  $this->$cmd();
448  break;
449 
450  default:
451  $this->displayError($this->lng->txt("unknown_command"));
452  break;
453  }
454  }
455 
456  // end cmd subsets
457 
461 
470  function setDisplayMode($a_mode)
471  {
472  // security
473  if ($a_mode != "view" and $a_mode != "setup")
474  {
475  return false;
476  }
477 
478  $this->display_mode = $a_mode;
479  $_SESSION["display_mode"] = $this->display_mode;
480 
481  return true;
482  }
483 
487  function displayHeader()
488  {
489  $languages = $this->lng->getLanguages();
490 
491  $count = (int) round(count($languages) / 2);
492  $num = 1;
493 
494  foreach ($languages as $lang_key)
495  {
496  if ($num === $count)
497  {
498  $this->tpl->touchBlock("lng_new_row");
499  }
500 
501  $this->tpl->setCurrentBlock("languages");
502  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
503  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
504  $this->tpl->setVariable("LANG_ICON", $lang_key);
505  $this->tpl->setVariable("LANG_KEY", $lang_key);
506  $this->tpl->setVariable("BORDER", 0);
507  $this->tpl->setVariable("VSPACE", 0);
508  $this->tpl->parseCurrentBlock();
509 
510  $num++;
511  }
512 
513  if (count($languages) % 2)
514  {
515  $this->tpl->touchBlock("lng_empty_cell");
516  }
517 
518  if ($this->cmd != "logout" and $this->setup->isInstalled())
519  {
520  // add client link
521  if ($this->setup->isAdmin())
522  {
523  if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
524  {
525  $this->tpl->setCurrentBlock("add_client");
526  $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
527  $this->tpl->parseCurrentBlock();
528  }
529 
530  // client list link
531  $class = ($this->active_tab == "clientlist")
532  ? "ilSMActive"
533  : "ilSMInactive";
534  $this->tpl->setCurrentBlock("display_list");
535  $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
536  $this->tpl->setVariable("TAB_CLASS", $class);
537  $this->tpl->parseCurrentBlock();
538 
539  // edit paths link
540  $class = ($this->active_tab == "basicsettings")
541  ? "ilSMActive"
542  : "ilSMInactive";
543  $this->tpl->setCurrentBlock("edit_pathes");
544  $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
545  $this->tpl->setVariable("TAB_CLASS", $class);
546  $this->tpl->parseCurrentBlock();
547 
548  // preliminaries
549  $class = ($this->active_tab == "preliminaries")
550  ? "ilSMActive"
551  : "ilSMInactive";
552  $this->tpl->setCurrentBlock("preliminaries");
553  $this->tpl->setVariable("TXT_PRELIMINARIES",$this->lng->txt("preliminaries"));
554  $this->tpl->setVariable("TAB_CLASS", $class);
555  $this->tpl->parseCurrentBlock();
556 
557  // change password link
558  $class = ($this->active_tab == "password")
559  ? "ilSMActive"
560  : "ilSMInactive";
561  $this->tpl->setCurrentBlock("change_password");
562  $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
563  $this->tpl->setVariable("TAB_CLASS", $class);
564  $this->tpl->parseCurrentBlock();
565  }
566 
567  // logout link
568  if ($this->setup->isAuthenticated())
569  {
570  $this->tpl->setCurrentBlock("logout");
571  $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
572  $this->tpl->parseCurrentBlock();
573  }
574  }
575 
576  $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
577  $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
578  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
579  $this->tpl->setVariable("PAGETITLE","Setup");
580  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
581  $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
582  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","./css/setup.css");
583  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
584  $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
585  $this->tpl->setVariable("VERSION", $this->version);
586  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
587  $this->tpl->setVariable("LANG", $this->lang);
588  }
589 
593  function displayFooter()
594  {
595  // footer (not really)
596  if ($this->cmd != "logout")
597  {
598  if ($this->setup->ini_ilias_exists and $this->display_mode == "setup" and $this->setup->getClient()->getId() != "")
599  {
600  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
601  }
602  elseif ($this->setup->isAdmin())
603  {
604  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
605  }
606 
607  $this->displayNavButtons();
608  }
609 
610  $this->tpl->show();
611  }
612 
618  function displayNavButtons()
619  {
620  if (!$this->btn_prev_on and !$this->btn_next_on)
621  {
622  return false;
623  }
624 
625  $ntpl = new ilTemplate("tpl.navbuttons.html", true, true, "setup");
626  //$this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html", "setup");
627 
628  $ntpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
629 
630  if ($this->btn_prev_on)
631  {
632  $ntpl->setCurrentBlock("btn_back");
633  $ntpl->setVariable("TXT_PREV", $this->btn_prev_lng);
634  $ntpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
635  $ntpl->parseCurrentBlock();
636  }
637 
638  if ($this->btn_next_on)
639  {
640  $ntpl->setCurrentBlock("btn_forward");
641  $ntpl->setVariable("TXT_NEXT", $this->btn_next_lng);
642  $ntpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
643  $ntpl->parseCurrentBlock();
644  }
645 
646  $nav_html = $ntpl->get();
647  $this->tpl->setVariable("NAVBUTTONS", $nav_html);
648  if (!$this->no_second_nav)
649  {
650  $this->tpl->setVariable("NAVBUTTONS2", $nav_html);
651  }
652  return true;
653  }
654 
661  function SetButtonPrev($a_cmd = 0,$a_lng = 0)
662  {
663  $this->btn_prev_on = true;
664  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
665  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("prev");
666  }
667 
674  function SetButtonNext($a_cmd,$a_lng = 0)
675  {
676  $this->btn_next_on = true;
677  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
678  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next");
679  }
680 
684 
689  {
690  $this->checkDisplayMode();
691 
692  // disable/enable button
693  $btpl = new ilTemplate("tpl.buttons.html", true, true, "setup");
694  $btpl->setCurrentBlock("btn");
695  $btpl->setVariable("CMD", "changeaccess");
696  $access_button = ($this->setup->getClient()->status["access"]["status"]) ? "disable" : "enable";
697  $btpl->setVariable("TXT", $this->lng->txt($access_button));
698  $btpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
699  $btpl->parseCurrentBlock();
700  $this->tpl->setVariable("BUTTONS", $btpl->get());
701 
702  $this->initClientOverviewForm();
703  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
704 
705  $this->displayStatusPanel();
706  }
707 
711  public function initClientOverviewForm()
712  {
713  global $lng, $ilCtrl;
714 
715  $settings = $this->setup->getClient()->getAllSettings();
716 
717  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
718  $this->form = new ilPropertyFormGUI();
719 
720  $this->form->setTitle($lng->txt("client_info"));
721 
722  // installation name
723  $ne = new ilNonEditableValueGUI($lng->txt("inst_name"), "inst_name");
724  $ne->setValue(($this->setup->getClient()->getName())
725  ? $this->setup->getClient()->getName()
726  : "&lt;".$this->lng->txt("no_client_name")."&gt;");
727  $ne->setInfo($this->setup->getClient()->getDescription());
728  $this->form->addItem($ne);
729 
730  // client id
731  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "client_id");
732  $ne->setValue($this->setup->getClient()->getId());
733  $this->form->addItem($ne);
734 
735  // nic id
736  $ne = new ilNonEditableValueGUI($lng->txt("ilias_nic_id"), "nic_id");
737  $ne->setValue(($this->setup->getClient()->db_installed)
738  ? $settings["inst_id"]
739  : $txt_no_database);
740  $this->form->addItem($ne);
741 
742  // database version
743  $ne = new ilNonEditableValueGUI($lng->txt("db_version"), "db_vers");
744  $ne->setValue(($this->setup->getClient()->db_installed)
745  ? $settings["db_version"]
746  : $txt_no_database);
747  $this->form->addItem($ne);
748 
749  // access status
750  $ne = new ilNonEditableValueGUI($lng->txt("access_status"), "status");
751  //$access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->setup->getClient()->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
752  $access_status = ($this->setup->getClient()->status["access"]["status"]) ? "online" : "disabled";
753  $ne->setValue($this->lng->txt($access_status).$access_link);
754  $this->form->addItem($ne);
755 
756  // server information
757  $sh = new ilFormSectionHeaderGUI();
758  $sh->setTitle($this->lng->txt("server_info"));
759  $this->form->addItem($sh);
760 
761  // ilias version
762  $ne = new ilNonEditableValueGUI($lng->txt("ilias_version"), "il_vers");
763  $ne->setValue(ILIAS_VERSION);
764  $this->form->addItem($ne);
765 
766  // host
767  $ne = new ilNonEditableValueGUI($lng->txt("host"), "host");
768  $ne->setValue($_SERVER["SERVER_NAME"]);
769  $this->form->addItem($ne);
770 
771  // ip address and port
772  $ne = new ilNonEditableValueGUI($lng->txt("ip_address")." & ".
773  $lng->txt("port"));
774  $ne->setValue($_SERVER["SERVER_ADDR"].":".$_SERVER["SERVER_PORT"]);
775  $this->form->addItem($ne);
776 
777  // server software
778  $ne = new ilNonEditableValueGUI($lng->txt("server_software"), "server_softw");
779  $ne->setValue($_SERVER["SERVER_SOFTWARE"]);
780  $this->form->addItem($ne);
781 
782  // http path
783  $ne = new ilNonEditableValueGUI($lng->txt("http_path"), "http_path");
784  $ne->setValue(ILIAS_HTTP_PATH);
785  $this->form->addItem($ne);
786 
787  // absolute path
788  $ne = new ilNonEditableValueGUI($lng->txt("absolute_path"), "absolute_path");
790  $this->form->addItem($ne);
791 
792  // third party tools
793  $sh = new ilFormSectionHeaderGUI();
794  $sh->setTitle($this->lng->txt("3rd_party_software"));
795  $this->form->addItem($sh);
796 
797  $tools = array("convert", "zip", "unzip", "ghostscript", "java", "htmldoc", "ffmpeg");
798 
799  foreach ($tools as $tool)
800  {
801  // tool
802  $ne = new ilNonEditableValueGUI($lng->txt($tool."_path"), $tool."_path");
803  $p = $this->setup->ini->readVariable("tools", $tool);
804  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
805  $this->form->addItem($ne);
806  }
807 
808  // latex
809  $ne = new ilNonEditableValueGUI($lng->txt("url_to_latex"), "latex_url");
810  $p = $this->setup->ini->readVariable("tools", "latex"); // #13109
811  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
812  $this->form->addItem($ne);
813 
814  // virus scanner
815  $ne = new ilNonEditableValueGUI($lng->txt("virus_scanner"), "vscan");
816  $ne->setValue($this->setup->ini->readVariable("tools","vscantype"));
817  $this->form->addItem($ne);
818 
819  // scan command
820  $ne = new ilNonEditableValueGUI($lng->txt("scan_command"), "scan");
821  $p = $this->setup->ini->readVariable("tools","scancommand");
822  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
823  $this->form->addItem($ne);
824 
825  // clean command
826  $ne = new ilNonEditableValueGUI($lng->txt("clean_command"), "clean");
827  $p = $this->setup->ini->readVariable("tools","cleancommand");
828  $ne->setValue($p ? $p : $this->lng->txt("not_configured"));
829  $this->form->addItem($ne);
830 
831  $this->form->setFormAction("setup.php?cmd=gateway");
832  }
833 
837 
842  {
843  $OK = "<font color=\"green\"><strong>OK</strong></font>";
844  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
845 
846  $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html", "setup");
847 
848  $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
849  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
850  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
851  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
852  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
853  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
854  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
855 
856  $server_os = php_uname();
857  $server_web = $_SERVER["SERVER_SOFTWARE"];
858  $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
859 
860  if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
861  {
862  $env_comment = $this->lng->txt("env_ok");
863  }
864  else
865  {
866  $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
867  }
868 
869  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
870  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
871  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
872 
873  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
874  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
875 
876  $preliminaries = array("php", "root", "folder_create",
877  "cookies_enabled", "dom", "xsl", "gd", "memory");
878  foreach ($preliminaries as $preliminary)
879  {
880  $this->tpl->setCurrentBlock("preliminary");
881  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_".$preliminary));
882  if ($this->setup->preliminaries_result[$preliminary]["status"] == true)
883  {
884  $this->tpl->setVariable("STATUS_PRE", $OK);
885  }
886  else
887  {
888  $this->tpl->setVariable("STATUS_PRE", $FAILED);
889  }
890  $this->tpl->setVariable("COMMENT_PRE", $this->setup->preliminaries_result[$preliminary]["comment"]);
891  $this->tpl->parseCurrentBlock();
892  }
893 
894  // summary
895  if ($this->setup->preliminaries === true)
896  {
897  if ($this->setup->isInstalled())
898  {
899  $cmd = "mastersettings";
900  }
901  else
902  {
903  $cmd = "install";
904  }
905  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
906 //echo "-".$this->display_mode."-";
907  $this->setButtonNext($cmd,$btn_text);
908  }
909  else
910  {
911  $this->tpl->setCurrentBlock("premessage");
912  $this->tpl->setVariable("TXT_PRE_ERR", sprintf($this->lng->txt("pre_error"),
913  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"));
914  $this->tpl->parseCurrentBlock();
915  }
916  }
917 
921 
925  function displayMasterSetup($a_omit_init = false)
926  {
927  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
928  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
929  $this->tpl->setVariable("TXT_INFO",
930  $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
931 
932  $this->setButtonPrev("preliminaries");
933 
934  if ($this->setup->isInstalled())
935  {
936  $this->setButtonNext("list");
937  }
938 
939  if (!$a_omit_init)
940  {
941  $this->initBasicSettingsForm(true);
942  }
943  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
944  }
945 
949  function changeMasterSettings($a_omit_init = false)
950  {
951  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
952  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
953  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
954 
955  $this->btn_next_on = true;
956  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
957  $this->btn_next_cmd = "newclient";
958 
959  if (!$a_omit_init)
960  {
961  $this->initBasicSettingsForm();
962  $this->getBasicSettingsValues();
963  }
964  $this->tpl->setVariable("SETUP_CONTENT", "<br>".$this->form->getHTML()."<br>");
965  }
966 
970  public function initBasicSettingsForm($a_install = false)
971  {
972  global $lng, $ilCtrl;
973 
974  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
975  $this->form = new ilPropertyFormGUI();
976 
977  // webspace dir
978  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_in_ws"), "webspace_dir");
979  if ($a_install)
980  {
981  $ne->setInfo($this->lng->txt("data_directory_in_ws_info"));
982  }
983  $cwd = ilUtil::isWindows()
984  ? str_replace("\\", "/", getcwd())
985  : getcwd();
986 
987  $ne->setValue($cwd."/data");
988  $this->form->addItem($ne);
989 
990  // data dir
991  if ($a_install)
992  {
993  $ti = new ilTextInputGUI($lng->txt("data_directory_outside_ws"), "datadir_path");
994  $ti->setInfo($lng->txt("data_directory_info"));
995  $ti->setRequired(true);
996  $this->form->addItem($ti);
997  }
998  else
999  {
1000  $ne = new ilNonEditableValueGUI($lng->txt("data_directory_outside_ws"), "data_dir");
1001  $this->form->addItem($ne);
1002  }
1003 
1004  $lvext = (ilUtil::isWindows())
1005  ? "_win"
1006  : "";
1007 
1008 
1009  // logging
1010  $sh = new ilFormSectionHeaderGUI();
1011  $sh->setTitle($lng->txt("logging"));
1012  $this->form->addItem($sh);
1013 
1014  // path to log file
1015  $ti = new ilTextInputGUI($lng->txt("log_path"), "log_path");
1016  $ti->setInfo($lng->txt("log_path_comment".$lvext));
1017  $this->form->addItem($ti);
1018 
1019  // disable logging
1020  $cb = new ilCheckboxInputGUI($lng->txt("disable_logging"), "chk_log_status");
1021  $this->form->addItem($cb);
1022 
1023  // server settings
1024  $sh = new ilFormSectionHeaderGUI();
1025  $sh->setTitle($lng->txt("server_settings"));
1026  $this->form->addItem($sh);
1027 
1028  // time zone
1029  include_once("./Services/Calendar/classes/class.ilCalendarUtil.php");
1030  $si = new ilSelectInputGUI($lng->txt("time_zone"), "time_zone");
1031  $si->setOptions(array_merge(
1032  array("" => "-- ".$lng->txt("please_select")." --"),
1034  $si->setRequired(true);
1035  $this->form->addItem($si);
1036 
1037  // required 3rd party tools
1038  $sh = new ilFormSectionHeaderGUI();
1039  $sh->setTitle($lng->txt("3rd_party_software_req"));
1040  $this->form->addItem($sh);
1041 
1042  // convert path
1043  $ti = new ilTextInputGUI($lng->txt("convert_path"), "convert_path");
1044  $ti->setInfo($lng->txt("convert_path_comment".$lvext));
1045  $ti->setRequired(true);
1046  $this->form->addItem($ti);
1047 
1048  // zip path
1049  $ti = new ilTextInputGUI($lng->txt("zip_path"), "zip_path");
1050  $ti->setInfo($lng->txt("zip_path_comment".$lvext));
1051  $ti->setRequired(true);
1052  $this->form->addItem($ti);
1053 
1054  // unzip path
1055  $ti = new ilTextInputGUI($lng->txt("unzip_path"), "unzip_path");
1056  $ti->setInfo($lng->txt("unzip_path_comment".$lvext));
1057  $ti->setRequired(true);
1058  $this->form->addItem($ti);
1059 
1060  // optional 3rd party tools
1061  $sh = new ilFormSectionHeaderGUI();
1062  $sh->setTitle($lng->txt("3rd_party_software_opt"));
1063  $this->form->addItem($sh);
1064 
1065  // ghostscript path
1066  $ti = new ilTextInputGUI($lng->txt("ghostscript_path"), "ghostscript_path");
1067  $ti->setInfo($lng->txt("ghostscript_path_comment".$lvext));
1068  $this->form->addItem($ti);
1069 
1070  // java path
1071  $ti = new ilTextInputGUI($lng->txt("java_path"), "java_path");
1072  $ti->setInfo($lng->txt("java_path_comment".$lvext));
1073  $this->form->addItem($ti);
1074 
1075  // htmldoc path
1076  $ti = new ilTextInputGUI($lng->txt("htmldoc_path"), "htmldoc_path");
1077  $ti->setInfo($lng->txt("htmldoc_path_comment".$lvext));
1078  $this->form->addItem($ti);
1079 
1080  // ffmpeg path
1081  $ti = new ilTextInputGUI($lng->txt("ffmpeg_path"), "ffmpeg_path");
1082  $ti->setInfo($lng->txt("ffmpeg_path_comment"));
1083  $this->form->addItem($ti);
1084 
1085  // latex
1086  $ti = new ilTextInputGUI($lng->txt("url_to_latex"), "latex_url");
1087  $ti->setInfo($lng->txt("latex_url_comment"));
1088  $this->form->addItem($ti);
1089 
1090  // virus scanner
1091  $options = array(
1092  "none" => $lng->txt("none"),
1093  "sophos" => $lng->txt("sophos"),
1094  "antivir" => $lng->txt("antivir"),
1095  "clamav" => $lng->txt("clamav")
1096  );
1097  $si = new ilSelectInputGUI($lng->txt("virus_scanner"), "vscanner_type");
1098  $si->setOptions($options);
1099  $this->form->addItem($si);
1100 
1101  // scan command
1102  $ti = new ilTextInputGUI($lng->txt("scan_command"), "scan_command");
1103  $this->form->addItem($ti);
1104 
1105  // clean command
1106  $ti = new ilTextInputGUI($lng->txt("clean_command"), "clean_command");
1107  $this->form->addItem($ti);
1108 
1109  if ($a_install)
1110  {
1111  $sh = new ilFormSectionHeaderGUI();
1112  $sh->setTitle($lng->txt("master_password"));
1113  $this->form->addItem($sh);
1114 
1115  // password
1116  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1117  $pi->setRequired(true);
1118  $pi->setSkipSyntaxCheck(true);
1119  $pi->setInfo($lng->txt("password_info"));
1120  $this->form->addItem($pi);
1121  }
1122 
1123  if ($a_install)
1124  {
1125  $this->form->addCommandButton("saveBasicSettings", $lng->txt("save"));
1126  }
1127  else
1128  {
1129  $this->form->addCommandButton("updateBasicSettings", $lng->txt("save"));
1130  $this->form->addCommandButton("determineToolsPath", $lng->txt("determine_tools_paths"));
1131  }
1132 
1133  $this->form->setTitle($lng->txt("data_directories"));
1134  $this->form->setFormAction("setup.php?cmd=gateway");
1135 
1136  if ($a_install)
1137  {
1138  $det = $this->determineTools();
1139  $this->form->setValuesByArray($det);
1140  }
1141 
1142  }
1143 
1147  public function getBasicSettingsValues()
1148  {
1149  $values = array();
1150 
1151  $values["webspace_dir"] = getcwd()."/data";
1152  $values["data_dir"] = $this->setup->ini->readVariable("clients","datadir");
1153  $values["convert_path"] = $this->setup->ini->readVariable("tools","convert");
1154  $values["zip_path"] = $this->setup->ini->readVariable("tools","zip");
1155  $values["unzip_path"] = $this->setup->ini->readVariable("tools","unzip");
1156  $values["ghostscript_path"] = $this->setup->ini->readVariable("tools","ghostscript");
1157  $values["java_path"] = $this->setup->ini->readVariable("tools","java");
1158  $values["htmldoc_path"] = $this->setup->ini->readVariable("tools","htmldoc");
1159  //$values["mkisofs_path"] = $this->setup->ini->readVariable("tools","mkisofs");
1160  $values["ffmpeg_path"] = $this->setup->ini->readVariable("tools","ffmpeg");
1161  $values["latex_url"] = $this->setup->ini->readVariable("tools","latex");
1162  $values["fop_path"] = $this->setup->ini->readVariable("tools","fop");
1163  $values["vscanner_type"] = $this->setup->ini->readVariable("tools", "vscantype");
1164  $values["scan_command"] = $this->setup->ini->readVariable("tools", "scancommand");
1165  $values["clean_command"] = $this->setup->ini->readVariable("tools", "cleancommand");
1166  $values["log_path"] = $this->setup->ini->readVariable("log","path")."/".
1167  $this->setup->ini->readVariable("log","file");
1168  $values["chk_log_status"] = !$this->setup->ini->readVariable("log","enabled");
1169  $values["time_zone"] = $this->setup->ini->readVariable("server", "timezone");
1170 
1171  $this->form->setValuesByArray($values);
1172  }
1173 
1177  public function saveBasicSettings()
1178  {
1179  global $tpl, $lng, $ilCtrl;
1180 
1181  $this->initBasicSettingsForm(true);
1182 
1183  if ($this->form->checkInput())
1184  {
1185  // correct paths on windows
1186  if (ilUtil::isWindows())
1187  {
1188  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1189  "unzip_path", "ghostscript_path", "java_path", "htmldoc_path", "ffmpeg_path");
1190  foreach ($fs as $f)
1191  {
1192  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1193  }
1194  }
1195 
1196  $_POST["setup_pass"] = $_POST["password"];
1197  $_POST["setup_pass2"] = $_POST["password_retype"];
1198  if (!$this->setup->checkDataDirSetup($_POST))
1199  {
1200  $i = $this->form->getItemByPostVar("datadir_path");
1201  $i->setAlert($this->lng->txt($this->setup->getError()));
1202  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1203  }
1204  else if (!$this->setup->checkLogSetup($_POST))
1205  {
1206  $i = $this->form->getItemByPostVar("log_path");
1207  $i->setAlert($this->lng->txt($this->setup->getError()));
1208  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1209  }
1210  else if (!$this->setup->checkPasswordSetup($_POST))
1211  {
1212  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1213  }
1214  else if (!$this->setup->saveMasterSetup($_POST))
1215  {
1216  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1217  }
1218  else
1219  {
1220  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1221  ilUtil::redirect("setup.php?cmd=mastersettings");
1222  }
1223  }
1224 
1225  $this->form->setValuesByPost();
1226  $this->displayMasterSetup(true);
1227  }
1228 
1232  public function updateBasicSettings()
1233  {
1234  global $tpl, $lng, $ilCtrl;
1235 
1236  $this->initBasicSettingsForm();
1237 
1238  if ($this->form->checkInput())
1239  {
1240  if (ilUtil::isWindows())
1241  {
1242  $fs = array("datadir_path", "log_path", "convert_path", "zip_path",
1243  "unzip_path", "ghostscript_path", "java_path", "htmldoc_path", "ffmpeg_path");
1244  foreach ($fs as $f)
1245  {
1246  $_POST[$f] = str_replace("\\", "/", $_POST[$f]);
1247  }
1248  }
1249 
1250  if (!$this->setup->checkLogSetup($_POST))
1251  {
1252  $i = $this->form->getItemByPostVar("log_path");
1253  $i->setAlert($this->lng->txt($this->setup->getError()));
1254  ilUtil::sendFailure($this->lng->txt("form_input_not_valid"),true);
1255  }
1256  else if (!$this->setup->updateMasterSettings($_POST))
1257  {
1258  ilUtil::sendFailure($this->lng->txt($this->setup->getError()),true);
1259  }
1260  else
1261  {
1262  ilUtil::sendSuccess($this->lng->txt("settings_saved"),true);
1263  ilUtil::redirect("setup.php?cmd=mastersettings");
1264  }
1265  }
1266 
1267  $this->form->setValuesByPost();
1268  $this->changeMasterSettings(true);
1269  }
1270 
1274 
1278  function loginClient()
1279  {
1280  session_destroy();
1281 
1282  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->setup->getClient()->getId());
1283  }
1284 
1288  function displayLogin($a_omit_minit = false, $a_omit_cinit = false)
1289  {
1290  global $lng;
1291 
1292  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
1293 
1294  if ($a_omit_minit)
1295  {
1296  $m_form = $this->form->getHTML();
1297  }
1298  if (!$a_omit_cinit)
1299  {
1300  $this->initClientLoginForm();
1301  }
1302  $cl_form = $this->form->getHTML();
1303  if (!$a_omit_minit)
1304  {
1305  $this->initMasterLoginForm();
1306  $m_form = $this->form->getHTML();
1307  }
1308  $this->tpl->setVariable("SETUP_CONTENT", $cl_form."<br>".$m_form);
1309  $this->tpl->setVariable("TXT_HEADER", $lng->txt("login"));
1310  }
1311 
1315  public function performMLogin()
1316  {
1317  $this->initMasterLoginForm();
1318  if ($this->form->checkInput())
1319  {
1320  $i = $this->form->getItemByPostVar("mpassword");
1321  if (!$this->setup->loginAsAdmin($_POST["mpassword"]))
1322  {
1323  $i->setAlert($this->lng->txt("login_invalid"));
1324  }
1325  else
1326  {
1327  // everything ok -> we are authenticated
1328  ilUtil::redirect("setup.php");
1329  }
1330  }
1331 
1332  // something wrong -> display login again
1333  $this->form->setValuesByPost();
1334  $this->displayLogin(true);
1335  }
1336 
1340  function performLogin()
1341  {
1342  $this->initClientLoginForm();
1343  if ($this->form->checkInput())
1344  {
1345  $i = $this->form->getItemByPostVar("password");
1346  if (!$this->setup->loginAsClient(
1347  array("client_id" => $_POST["client_id"],
1348  "username" => $_POST["username"], "password" => $_POST["password"])))
1349  {
1350  $i->setAlert($this->setup->getError());
1351  }
1352  else
1353  {
1354  // everything ok -> we are authenticated
1355  ilUtil::redirect("setup.php");
1356  }
1357  }
1358 
1359  // something wrong -> display login again
1360  $this->form->setValuesByPost();
1361  $this->displayLogin(false, true);
1362  }
1363 
1367  public function initClientLoginForm()
1368  {
1369  global $lng, $ilCtrl;
1370 
1371  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1372  $this->form = new ilPropertyFormGUI();
1373 
1374  // client id
1375  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1376  $ti->setMaxLength(32);
1377  $ti->setSize(20);
1378  $this->form->addItem($ti);
1379 
1380  // username
1381  $ti = new ilTextInputGUI($lng->txt("username"), "username");
1382  $ti->setSize(20);
1383  $this->form->addItem($ti);
1384 
1385  // password
1386  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
1387  $pi->setSize(20);
1388  $pi->setRetype(false);
1389  $pi->setSkipSyntaxCheck(true);
1390  $this->form->addItem($pi);
1391 
1392  $this->form->addCommandButton("performLogin", $lng->txt("login"));
1393 
1394  $this->form->setTitle($lng->txt("client_login"));
1395  $this->form->setFormAction("setup.php?cmd=gateway");
1396  }
1397 
1401  public function initMasterLoginForm()
1402  {
1403  global $lng, $ilCtrl;
1404 
1405  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1406  $this->form = new ilPropertyFormGUI();
1407 
1408  // password
1409  $pi = new ilPasswordInputGUI($lng->txt("password"), "mpassword");
1410  $pi->setSize(20);
1411  $pi->setRetype(false);
1412  $pi->setSkipSyntaxCheck(true);
1413  $this->form->addItem($pi);
1414 
1415  $this->form->addCommandButton("performMLogin", $lng->txt("login"));
1416 
1417  $this->form->setTitle($lng->txt("admin_login"));
1418  $this->form->setFormAction("setup.php?cmd=gateway");
1419 
1420  }
1421 
1425 
1430  {
1431  $_SESSION["ClientId"] = "";
1432 
1433  $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html", "setup");
1434  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1435  ilUtil::sendInfo();
1436 
1437  // common
1438  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("list_clients"));
1439  $this->tpl->setVariable("TXT_LISTSTATUS",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1440  $this->tpl->setVariable("TXT_TOGGLELIST",($this->setup->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1441 
1442  include_once("./setup/classes/class.ilClientListTableGUI.php");
1443  $tab = new ilClientListTableGUI($this->setup);
1444  $this->tpl->setVariable("CLIENT_LIST", $tab->getHTML());
1445 
1446  // create new client button
1447  $this->btn_next_on = true;
1448  $this->btn_next_lng = $this->lng->txt("create_new_client")."...";
1449  $this->btn_next_cmd = "newclient";
1450  }
1451 
1456  {
1457  $_POST = $this->determineTools($_POST);
1458  $this->updateBasicSettings();
1459  }
1460 
1465  {
1466  $this->displayMasterSetup(true);
1467  }
1468 
1472  function determineTools($a_tools = "")
1473  {
1474  $cwd = ilUtil::isWindows()
1475  ? str_replace("\\", "/", getcwd())
1476  : getcwd();
1477  if (!ilUtil::isWindows())
1478  {
1479  $tools = array("convert" => "convert",
1480  "zip" => "zip", "unzip" => "unzip", "ghostscript" => "gs",
1481  "java" => "java", "htmldoc" => "htmldoc", "ffmpeg" => "ffmpeg");
1482  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin", "/usr/bin");
1483  }
1484  else
1485  {
1486  $tools = array("convert" => "convert.exe",
1487  "zip" => "zip.exe", "unzip" => "unzip.exe");
1488  $dirs = array($cwd."/Services/Windows/bin32/zip",
1489  $cwd."/Services/Windows/bin32/unzip",
1490  $cwd."/Services/Windows/bin32/convert");
1491  }
1492  foreach($tools as $k => $tool)
1493  {
1494  // try which command
1495  unset($ret);
1496  @exec("which ".$tool, $ret);
1497  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
1498  {
1499  $a_tools[$k."_path"] = $ret[0];
1500  continue;
1501  }
1502 
1503  // try common directories
1504  foreach($dirs as $dir)
1505  {
1506  if (@is_file($dir."/".$tool))
1507  {
1508  $a_tools[$k."_path"] = $dir."/".$tool;
1509  continue;
1510  }
1511  }
1512  }
1513  return $a_tools;
1514  }
1515 
1516 
1520 
1525  function selectDBType()
1526  {
1527  $this->checkDisplayMode("create_new_client");
1528 
1529 
1530 if (true)
1531 {
1532  $this->initDBSelectionForm();
1533  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
1534 }
1535 else
1536 {
1537  // output
1538 
1539  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_select_db.html", "setup");
1540 
1541  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1542  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1543 
1544  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
1545  $this->tpl->setVariable("TXT_DB_SELECTION", $this->lng->txt("db_selection"));
1546 }
1547  if ($this->setup->getClient()->status["ini"]["status"])
1548  {
1549  $this->setButtonNext("db");
1550  }
1551 
1552  $this->checkPanelMode();
1553  }
1554 
1558  public function initDBSelectionForm()
1559  {
1560  global $lng, $ilCtrl;
1561 
1562  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1563  $this->form = new ilPropertyFormGUI();
1564 
1565  // db type
1566  $options = array(
1567  "mysql" => "MySQL 5.0.x or higher (MyISAM engine)",
1568  "innodb" => "MySQL 5.0.x or higher (InnoDB engine)",
1569  "oracle" => "Oracle 10g or higher",
1570  "postgres" => "Postgres (experimental)"
1571  );
1572  $si = new ilSelectInputGUI($lng->txt("db_type"), "db_type");
1573  $si->setOptions($options);
1574  $si->setInfo($lng->txt(""));
1575  $this->form->addItem($si);
1576 
1577  $this->form->addCommandButton("selectdbtype", $lng->txt("save"));
1578 
1579  $this->form->setTitle($lng->txt("db_selection"));
1580  $this->form->setFormAction("setup.php?cmd=gateway");
1581  }
1582 
1586 
1590  function displayIni($a_omit_form_init = false)
1591  {
1592  $this->checkDisplayMode("create_new_client");
1593 
1594  if ($_POST["db_type"] != "")
1595  {
1596  $_SESSION["db_type"] = $_POST["db_type"];
1597  }
1598  else
1599  {
1600  $_POST["db_type"] = $_SESSION["db_type"];
1601  }
1602 
1603  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1604  if (!$a_omit_form_init)
1605  {
1606  $this->initClientIniForm();
1607  $this->getClientIniValues();
1608  }
1609  $this->tpl->setVariable("SETUP_CONTENT",
1610  $this->form->getHTML());
1611 
1612  if ($this->setup->getClient()->status["ini"]["status"])
1613  {
1614  $this->setButtonNext("db");
1615  }
1616 
1617  $this->checkPanelMode();
1618  }
1619 
1623  public function initClientIniForm()
1624  {
1625  global $lng, $ilCtrl;
1626 
1627  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
1628  $this->form = new ilPropertyFormGUI();
1629 
1630  // client id
1631  if ($this->setup->ini_client_exists)
1632  {
1633  $hi = new ilHiddenInputGUI("client_id");
1634  $hi->setValue($this->client_id);
1635  $this->form->addItem($hi);
1636 
1637  $ne = new ilNonEditableValueGUI($lng->txt("client_id"), "hh");
1638  $ne->setValue($this->client_id);
1639  $this->form->addItem($ne);
1640  }
1641  else
1642  {
1643  $ti = new ilTextInputGUI($lng->txt("client_id"), "client_id");
1644  $ti->setMaxLength(32);
1645  $ti->setRequired(true);
1646  $this->form->addItem($ti);
1647  }
1648 
1649  // database connection
1650  $sh = new ilFormSectionHeaderGUI();
1651  $sh->setTitle($lng->txt("db_conn"));
1652  $this->form->addItem($sh);
1653 
1654  // db type
1655  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "dbt");
1656  $ne->setValue($lng->txt("db_".$_SESSION["db_type"]));
1657  $this->form->addItem($ne);
1658 
1659  // db host
1660  $ti = new ilTextInputGUI($lng->txt("db_host"), "db_host");
1661  $ti->setMaxLength(120);
1662  $ti->setRequired(true);
1663  $this->form->addItem($ti);
1664 
1665  // db name
1666  if (in_array($_SESSION["db_type"], array("mysql", "postgres", "innodb")))
1667  {
1668  $ti = new ilTextInputGUI($lng->txt("db_name"), "db_name");
1669  $ti->setRequired(true);
1670  }
1671  else
1672  {
1673  $ti = new ilTextInputGUI($lng->txt("db_service_name"), "db_name");
1674  }
1675  $ti->setMaxLength(40);
1676  $this->form->addItem($ti);
1677 
1678  // db user
1679  $ti = new ilTextInputGUI($lng->txt("db_user"), "db_user");
1680  $ti->setMaxLength(40);
1681  $ti->setRequired(true);
1682  $this->form->addItem($ti);
1683 
1684  // db port
1685  $ti = new ilTextInputGUI($lng->txt("db_port"), "db_port");
1686  $ti->setMaxLength(8);
1687  $this->form->addItem($ti);
1688 
1689  // db password
1690  $ti = new ilTextInputGUI($lng->txt("db_pass"), "db_pass");
1691  $ti->setMaxLength(40);
1692  $this->form->addItem($ti);
1693 
1694  $this->form->addCommandButton("saveClientIni", $lng->txt("save"));
1695 
1696  $this->form->setTitle($lng->txt("inst_identification"));
1697  $this->form->setFormAction("setup.php?cmd=gateway");
1698  }
1699 
1703  public function getClientIniValues()
1704  {
1705  $values = array();
1706 
1707  $values["db_host"] = $this->setup->getClient()->getDbHost();
1708  $values["db_user"] = $this->setup->getClient()->getDbUser();
1709  $values["db_port"] = $this->setup->getClient()->getDbPort();
1710  $values["db_pass"] = $this->setup->getClient()->getDbPass();
1711  $values["db_name"] = $this->setup->getClient()->getDbName();
1712  $values["client_id"] = $this->setup->getClient()->getId();
1713 
1714  $this->form->setValuesByArray($values);
1715  }
1716 
1720  public function saveClientIni()
1721  {
1722  global $tpl, $lng, $ilCtrl;
1723 
1724  $this->initClientIniForm();
1725  if ($this->form->checkInput())
1726  {
1727  if (strlen($_POST["client_id"]) != strlen(urlencode(($_POST["client_id"])))
1728  || is_int(strpos($_POST["client_id"], "_")))
1729  {
1730  $i = $this->form->getItemByPostVar("client_id");
1731  $i->setAlert($this->lng->txt("ini_client_id_invalid"));
1732  ilUtil::sendFailure($this->lng->txt("ini_client_id_invalid"),true);
1733  }
1734  else if (strlen($_POST["client_id"]) < 4)
1735  {
1736  $i = $this->form->getItemByPostVar("client_id");
1737  $i->setAlert($this->lng->txt("ini_client_id_too_short"));
1738  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_short"),true);
1739  }
1740  else if (strlen($_POST["client_id"]) > 32)
1741  {
1742  $i = $this->form->getItemByPostVar("client_id");
1743  $i->setAlert($this->lng->txt("ini_client_id_too_long"));
1744  ilUtil::sendFailure($this->lng->txt("ini_client_id_too_long"),true);
1745  }
1746  else if (!$this->setup->ini_client_exists && file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$_POST["client_id"]))
1747  {
1748  $i = $this->form->getItemByPostVar("client_id");
1749  $i->setAlert($this->lng->txt("ini_client_id_exists"));
1750  ilUtil::sendFailure($this->lng->txt("ini_client_id_exists"),true);
1751  }
1752  else
1753  {
1754 
1755  // save some old values
1756  $old_db_name = $this->setup->getClient()->getDbName();
1757  $old_db_type = $this->setup->getClient()->getDbType();
1758  $old_client_id = $this->setup->getClient()->getId();
1759 
1760  // create new client object if it does not exist
1761  if (!$this->setup->ini_client_exists)
1762  {
1763  $client_id = $_POST["client_id"];
1764  $this->setup->newClient($client_id);
1765  }
1766 
1767  // set client data
1768  $this->setup->getClient()->setId($_POST["client_id"]);
1769  $this->setup->getClient()->setDbHost($_POST["db_host"]);
1770  $this->setup->getClient()->setDbName($_POST["db_name"]);
1771  $this->setup->getClient()->setDbUser($_POST["db_user"]);
1772  $this->setup->getClient()->setDbPort($_POST["db_port"]);
1773  $this->setup->getClient()->setDbPass($_POST["db_pass"]);
1774  $this->setup->getClient()->setDbType($_SESSION["db_type"]);
1775  $this->setup->getClient()->setDSN();
1776 
1777  // try to connect to database
1778  if (!$this->setup->getClient()->checkDatabaseHost())
1779  {
1780  $i = $this->form->getItemByPostVar("db_host");
1781  $i->setAlert($this->lng->txt($this->setup->getClient()->getError()));
1782  ilUtil::sendFailure($this->setup->getClient()->getError(),true);
1783  }
1784  else
1785  {
1786  // check if db exists
1787  $db_installed = $this->setup->getClient()->checkDatabaseExists();
1788 
1789  if ($db_installed and (!$this->setup->ini_ilias_exists or ($this->setup->getClient()->getDbName() != $old_db_name)))
1790  {
1791  $_POST["db_name"] = $old_db_name;
1792  $message = ucfirst($this->lng->txt("database"))." \"".$this->setup->getClient()->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
1793  $i = $this->form->getItemByPostVar("db_name");
1794  $i->setAlert($message);
1795  ilUtil::sendFailure($message, true);
1796  }
1797  else
1798  {
1799  // all ok. create client.ini and save posted data
1800  if (!$this->setup->ini_client_exists)
1801  {
1802  if ($this->setup->saveNewClient())
1803  {
1804  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
1805  $this->setup->getClient()->status["ini"]["status"] = true;
1806  $_SESSION["ClientId"] = $client_id;
1807  ilUtil::redirect("setup.php?cmd=displayIni&client_id=".$client_id);
1808  }
1809  else
1810  {
1811  $err = $this->setup->getError();
1812  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1813  $this->setup->getClient()->status["ini"]["status"] = false;
1814  $this->setup->getClient()->status["ini"]["comment"] = $err;
1815  }
1816  }
1817  else
1818  {
1819  if ($this->setup->getClient()->ini->write())
1820  {
1821  ilUtil::sendSuccess($this->lng->txt("settings_changed"));
1822  $this->setup->getClient()->status["ini"]["status"] = true;
1823  ilUtil::redirect("setup.php?cmd=displayIni");
1824  }
1825  else
1826  {
1827  $err = $this->setup->getClient()->ini->getError();
1828  ilUtil::sendFailure($this->lng->txt("save_error").": ".$err, true);
1829  $this->setup->getClient()->status["ini"]["status"] = false;
1830  $this->setup->getClient()->status["ini"]["comment"] = $err;
1831  }
1832  }
1833  }
1834  }
1835  }
1836  }
1837 
1838  $this->form->setValuesByPost();
1839  $this->displayIni(true);
1840  }
1841 
1847  function displayError($a_message)
1848  {
1849  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html", "setup");
1850 
1851  $this->tpl->setCurrentBlock("content");
1852  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1853  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1854  $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
1855  $this->tpl->parseCurrentBlock();
1856 
1857  $this->tpl->show();
1858  exit();
1859  }
1860 
1864  function displayLogout()
1865  {
1866  $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html", "setup");
1867 
1868  session_destroy();
1869 
1870  $this->logged_out = true;
1871  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));
1872  $this->tpl->setCurrentBlock("home_link");
1873  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
1874  $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
1875  $this->tpl->parseCurrentBlock();
1876  }
1877 
1882  {
1883  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1884 
1885  $steps = array();
1886  $steps = $this->setup->getStatus();
1887 
1888  // remove access step
1889  unset($steps["access"]);
1890 
1891  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1892  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1893  //$steps["sess"]["text"] = $this->lng->txt("setup_process_step_sess");
1894  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1895  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1896  $steps["proxy"]["text"] = $this->lng->txt("setup_process_step_proxy");
1897  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1898  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1899 
1900  $stpl = new ilTemplate("tpl.process_panel.html", true, true, "setup");
1901 
1902  $num = 1;
1903 
1904  foreach ($steps as $key => $val)
1905  {
1906  $stpl->setCurrentBlock("menu_row");
1907  $stpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
1908  $stpl->setVariable("TXT_ACTION",$val["text"]);
1909  $stpl->setVariable("IMG_ARROW", "spacer.png");
1910 
1911  $num++;
1912 
1913  if ($this->cmd == $key and isset($this->cmd))
1914  {
1915  $stpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1916  $stpl->setVariable("IMG_ARROW", "arrow_right.png");
1917  }
1918 
1919  $status = ($val["status"]) ? $OK : "";
1920 
1921  $stpl->setVariable("TXT_STATUS",$status);
1922  $stpl->parseCurrentBlock();
1923  }
1924 
1925  $stpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
1926 
1927  $this->tpl->setVariable("PROCESS_MENU", $stpl->get());
1928  }
1929 
1934  {
1935  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1936 
1937  $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html", "setup");
1938 
1939  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1940  // display status
1941  if ($this->setup->getClient()->status)
1942  {
1943  foreach ($this->setup->getClient()->status as $key => $val)
1944  {
1945  $status = ($val["status"]) ? $OK : "&nbsp;";
1946  $this->tpl->setCurrentBlock("status_row");
1947  $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1948  $this->tpl->setVariable("TXT_STATUS",$status);
1949 
1950 
1951  $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1952  $this->tpl->parseCurrentBlock();
1953  }
1954  }
1955  }
1956 
1962  function checkDisplayMode($a_title = "")
1963  {
1964  switch ($this->display_mode)
1965  {
1966  case "view":
1967  $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html", "setup");
1968  // display tabs
1969  include "./setup/include/inc.client_tabs.php";
1970  $client_name = ($this->setup->getClient()->getName()) ? $this->setup->getClient()->getName() : $this->lng->txt("no_client_name");
1971  $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->setup->getClient()->getId().")");
1972  break;
1973 
1974  case "setup":
1975  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
1976  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));
1977  break;
1978 
1979  default:
1980  $this->displayError($this->lng->txt("unknown_display_mode"));
1981  exit();
1982  break;
1983  }
1984  }
1985 
1992  function displaySubTabs()
1993  {
1994  $sub_tab_html = $this->tabs->getSubTabHTML();
1995  if ($sub_tab_html != "")
1996  {
1997  $this->tpl->setVariable("SUBTABS", $sub_tab_html);
1998  }
1999 
2000  }
2001 
2002 
2006  function checkPanelMode()
2007  {
2008  switch ($this->display_mode)
2009  {
2010  case "view":
2011  $this->displayStatusPanel();
2012  break;
2013 
2014  case "setup":
2015  $this->displayProcessPanel();
2016  break;
2017  }
2018  }
2019 
2023  function displayStartup()
2024  {
2025  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html", "setup");
2026 
2027  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
2028  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
2029 
2030  $this->displayProcessPanel();
2031 
2032  $this->setButtonNext("ini");
2033  }
2034 
2038 
2042  function displayDatabase()
2043  {
2044  global $ilErr,$ilDB,$ilLog;
2045 
2046  $this->checkDisplayMode("setup_database");
2047 
2048  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
2049 
2050  // database is intalled
2051  if ($this->setup->getClient()->db_installed)
2052  {
2053  $this->setDbSubTabs("db");
2054 
2055  $ilDB = $this->setup->getClient()->db;
2056  $this->lng->setDbHandler($ilDB);
2057  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2058  $dbupdate = new ilDBUpdate($ilDB);
2059  $db_status = $dbupdate->getDBVersionStatus();
2060  $hotfix_available = $dbupdate->hotfixAvailable();
2061  $custom_updates_available = $dbupdate->customUpdatesAvailable();
2062  $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available, $custom_updates_available);
2063  $this->getClientDbFormValues($dbupdate);
2064  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2065 
2066  if ($db_status)
2067  {
2068  $this->setButtonNext("lang");
2069  }
2070  }
2071  else // database is not installed
2072  {
2073  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db")."<br />".
2074  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>".
2075  "<p><b>".$this->lng->txt("info_text_db2")."</b></p><br/>");
2076 
2077  $this->initClientDbForm();
2078  $this->getClientDbFormValues();
2079  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2080  $this->setButtonPrev("ini");
2081  }
2082 
2083  $this->checkPanelMode();
2084 
2085  $this->displaySubTabs();
2086  }
2087 
2091  function displayDatabaseSlave($a_from_save = false)
2092  {
2093  global $ilErr,$ilDB,$ilLog;
2094 
2095  $this->checkDisplayMode("setup_database");
2096 
2097  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
2098 
2099  // database is intalled
2100  if (!$this->setup->getClient()->db_installed)
2101  {
2102  return;
2103  }
2104 
2105  $this->setDbSubTabs("repl");
2106 
2107  if (!$a_from_save)
2108  {
2109  $ilDB = $this->setup->getClient()->db;
2110  $this->lng->setDbHandler($ilDB);
2111  }
2112 
2113  ilUtil::sendInfo($this->lng->txt("mysql_replication_info_alpha"));
2114 
2115  if (!$a_from_save)
2116  {
2117  $this->initDbSlaveForm();
2118  }
2119 
2120  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2121 
2122  $this->checkPanelMode();
2123 
2124  $this->displaySubTabs();
2125  }
2126 
2130  public function initDbSlaveForm()
2131  {
2132  global $lng, $ilCtrl, $ilDB;
2133 
2134  $client = $this->setup->getClient();
2135 
2136  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2137  $this->form = new ilPropertyFormGUI();
2138 
2139  // db type
2140  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "slave_type");
2141  $ne->setValue($lng->txt("db_".$ilDB->getDbType()));
2142  $this->form->addItem($ne);
2143 
2144  // activate slave
2145  $act = new ilCheckboxInputGUI($this->lng->txt("db_active"), "slave_active");
2146  $act->setChecked($client->getDbSlaveActive());
2147  $this->form->addItem($act);
2148 
2149  // slave host
2150  $ti = new ilTextInputGUI($lng->txt("db_host"), "slave_host");
2151  $ti->setValue($client->getDbSlaveHost());
2152  $ti->setMaxLength(120);
2153  $ti->setRequired(true);
2154  $act->addSubItem($ti);
2155 
2156  // slave name
2157  $ti = new ilTextInputGUI($lng->txt("db_name"), "slave_name");
2158  $ti->setValue($client->getDbSlaveName());
2159  $ti->setRequired(true);
2160  $ti->setMaxLength(40);
2161  $act->addSubItem($ti);
2162 
2163  // slave user
2164  $ti = new ilTextInputGUI($lng->txt("db_user"), "slave_user");
2165  $ti->setValue($client->getDbSlaveUser());
2166  $ti->setMaxLength(40);
2167  $ti->setRequired(true);
2168  $act->addSubItem($ti);
2169 
2170  // slave port
2171  $ti = new ilTextInputGUI($lng->txt("db_port"), "slave_port");
2172  $ti->setValue($client->getDbSlavePort());
2173  $ti->setMaxLength(8);
2174  $act->addSubItem($ti);
2175 
2176  // set password
2177  $set_pw = new ilCheckboxInputGUI($this->lng->txt("db_set_password"), "set_slave_password");
2178  $act->addSubItem($set_pw);
2179 
2180  // slave password
2181  $ti = new ilTextInputGUI($lng->txt("db_pass"), "slave_pass");
2182  $ti->setMaxLength(40);
2183  $set_pw->addSubItem($ti);
2184 
2185  $this->form->addCommandButton("saveDbSlave", $lng->txt("save"));
2186 
2187  $this->form->setTitle($lng->txt("db_slave_settings"));
2188  $this->form->setFormAction("setup.php?cmd=gateway");
2189  }
2190 
2194  public function saveDbSlave()
2195  {
2196  global $tpl, $lng, $ilCtrl, $ilDB;
2197 
2198  $client = $this->setup->getClient();
2199 
2200  $ilDB = $this->setup->getClient()->db;
2201  $this->lng->setDbHandler($ilDB);
2202 
2203  $this->initDbSlaveForm();
2204  if ($this->form->checkInput())
2205  {
2206  $client->setDbSlaveActive($this->form->getInput("slave_active"));
2207  if ($this->form->getInput("slave_active"))
2208  {
2209  $client->setDbSlaveHost($this->form->getInput("slave_host"));
2210  $client->setDbSlaveUser($this->form->getInput("slave_user"));
2211  $client->setDbSlavePort($this->form->getInput("slave_port"));
2212  $client->setDbSlaveName($this->form->getInput("slave_name"));
2213  if ($this->form->getInput("set_slave_password"))
2214  {
2215  $client->setDbSlavePass($this->form->getInput("slave_pass"));
2216  }
2217  }
2218  $client->writeIni();
2219 
2220  ilUtil::sendSuccess($lng->txt("saved_successfully"), true);
2221  ilUtil::redirect("setup.php?cmd=dbslave");
2222  }
2223  else
2224  {
2225  $this->form->setValuesByPost();
2226  $this->displayDatabaseSlave(true);
2227  }
2228  }
2229 
2230 
2237  function setDbSubtabs($a_subtab_id = "db")
2238  {
2239  global $ilDB;
2240 
2241  if ($ilDB->getDbType() == "mysql")
2242  {
2243  $this->tabs->addSubTab("db", $this->lng->txt("db_master"), "setup.php?client_id=".$this->client_id."&cmd=db");
2244  $this->tabs->addSubTab("repl", $this->lng->txt("db_slave"), "setup.php?client_id=".$this->client_id."&cmd=dbslave");
2245  }
2246 
2247  $this->tabs->activateSubTab($a_subtab_id);
2248  }
2249 
2250 
2251 
2255  public function initClientDbForm($a_install = true, $dbupdate = null, $db_status = false, $hotfix_available = false, $custom_updates_available = false)
2256  {
2257  global $lng, $ilCtrl;
2258 
2259  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2260  $this->form = new ilPropertyFormGUI();
2261 
2262  // type
2263  $ne = new ilNonEditableValueGUI($lng->txt("db_type"), "db_type");
2264  $this->form->addItem($ne);
2265 
2266  // version
2267  if ($this->setup->getClient()->getDBType() == "mysql" ||
2268  $this->setup->getClient()->getDBType() == "innodb")
2269  {
2270  $ne = new ilNonEditableValueGUI($lng->txt("version"), "db_version");
2271  $ilDB = $this->setup->getClient()->db;
2272  $ne->setValue($ilDB->getDBVersion());
2273  $this->form->addItem($ne);
2274  }
2275 
2276  // host
2277  $ne = new ilNonEditableValueGUI($lng->txt("host"), "db_host");
2278  $this->form->addItem($ne);
2279 
2280  // name
2281  $ne = new ilNonEditableValueGUI($lng->txt("name"), "db_name");
2282  $this->form->addItem($ne);
2283 
2284  // user
2285  $ne = new ilNonEditableValueGUI($lng->txt("user"), "db_user");
2286  $this->form->addItem($ne);
2287 
2288  // port
2289  $ne = new ilNonEditableValueGUI($lng->txt("port"), "db_port");
2290  $this->form->addItem($ne);
2291 
2292  // creation / collation for mysql
2293  if (($this->setup->getClient()->getDBType() == "mysql" ||
2294  $this->setup->getClient()->getDBType() == "innodb") && $a_install)
2295  {
2296  // create database
2297  $cb = new ilCheckboxInputGUI($lng->txt("database_create"), "chk_db_create");
2298 
2299  // collation
2300  $collations = array
2301  (
2302  "utf8_unicode_ci",
2303  "utf8_general_ci",
2304  "utf8_czech_ci",
2305  "utf8_danish_ci",
2306  "utf8_estonian_ci",
2307  "utf8_icelandic_ci",
2308  "utf8_latvian_ci",
2309  "utf8_lithuanian_ci",
2310  "utf8_persian_ci",
2311  "utf8_polish_ci",
2312  "utf8_roman_ci",
2313  "utf8_romanian_ci",
2314  "utf8_slovak_ci",
2315  "utf8_slovenian_ci",
2316  "utf8_spanish2_ci",
2317  "utf8_spanish_ci",
2318  "utf8_swedish_ci",
2319  "utf8_turkish_ci"
2320  );
2321  foreach($collations as $collation)
2322  {
2323  $options[$collation] = $collation;
2324  }
2325  $si = new ilSelectInputGUI($lng->txt("collation"), "collation");
2326  $si->setOptions($options);
2327  $si->setInfo($this->lng->txt("info_text_db_collation2")." ".
2328  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
2329  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2330  $cb->addSubItem($si);
2331 
2332  $this->form->addItem($cb);
2333  }
2334 
2335  if ($a_install)
2336  {
2337  $this->form->addCommandButton("installDatabase", $lng->txt("database_install"));
2338  }
2339  else
2340  {
2341  $ilDB = $this->setup->getClient()->db;
2342  $this->lng->setDbHandler($ilDB);
2343  $dbupdate = new ilDBUpdate($ilDB);
2344 
2345  // database version
2346  $ne = new ilNonEditableValueGUI($lng->txt("database_version"), "curv");
2347  $ne->setValue($dbupdate->currentVersion);
2348  $this->form->addItem($ne);
2349 
2350  // file version
2351  $ne = new ilNonEditableValueGUI($lng->txt("file_version"), "filev");
2352  $ne->setValue($dbupdate->fileVersion);
2353  $this->form->addItem($ne);
2354 
2355  if (!$db_status = $dbupdate->getDBVersionStatus())
2356  {
2357  // next update step
2358  $options = array();
2359  for ($i = $dbupdate->currentVersion + 1; $i <= $dbupdate->fileVersion; $i++)
2360  {
2361  $options[$i] = $i;
2362  }
2363  if (count($options) > 1)
2364  {
2365  $si = new ilSelectInputGUI($lng->txt("next_update_break"), "update_break");
2366  $si->setOptions($options);
2367  $si->setInfo($lng->txt("next_update_break_info"));
2368  $this->form->addItem($si);
2369  }
2370 
2371  if ($dbupdate->getRunningStatus() > 0)
2372  {
2373  ilUtil::sendFailure($this->lng->txt("db_update_interrupted")."<br /><br />".
2374  $this->lng->txt("db_update_interrupted_avoid"));
2375  }
2376  else
2377  {
2378  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2379  }
2380  $this->form->addCommandButton("updateDatabase", $lng->txt("database_update"));
2381  $this->form->addCommandButton("showUpdateSteps", $lng->txt("show_update_steps"));
2382  }
2383  else if ($hotfix_available)
2384  {
2385  // hotfix current version
2386  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2387  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2388  $this->form->addItem($ne);
2389 
2390  // hotfix file version
2391  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2392  $ne->setValue($dbupdate->getHotfixFileVersion());
2393  $this->form->addItem($ne);
2394 
2395  $this->form->addCommandButton("applyHotfix", $lng->txt("apply_hotfixes"));
2396  $this->form->addCommandButton("showHotfixSteps", $lng->txt("show_update_steps"));
2397  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2398  }
2399  elseif($custom_updates_available)
2400  {
2401  // custom updates current version
2402  $ne = new ilNonEditableValueGUI($lng->txt("applied_custom_updates"), "curcu");
2403  $ne->setValue($dbupdate->getCustomUpdatesCurrentVersion());
2404  $this->form->addItem($ne);
2405 
2406  // custom updates file version
2407  $ne = new ilNonEditableValueGUI($lng->txt("available_custom_updates"), "filecu");
2408  $ne->setValue($dbupdate->getCustomUpdatesFileVersion());
2409  $this->form->addItem($ne);
2410 
2411  $this->form->addCommandButton("applyCustomUpdates", $lng->txt("apply_custom_updates"));
2412  ilUtil::sendInfo($this->lng->txt("database_needs_update"));
2413  }
2414  else
2415  {
2416  if ($dbupdate->getHotfixFileVersion() > 0)
2417  {
2418  // hotfix current version
2419  $ne = new ilNonEditableValueGUI($lng->txt("applied_hotfixes"), "curhf");
2420  $ne->setValue($dbupdate->getHotfixCurrentVersion());
2421  $this->form->addItem($ne);
2422 
2423  // hotfix file version
2424  $ne = new ilNonEditableValueGUI($lng->txt("available_hotfixes"), "filehf");
2425  $ne->setValue($dbupdate->getHotfixFileVersion());
2426  $this->form->addItem($ne);
2427  }
2428  if ($dbupdate->getCustomUpdatesFileVersion() > 0)
2429  {
2430  // custom updates current version
2431  $ne = new ilNonEditableValueGUI($lng->txt("applied_custom_updates"), "curcu");
2432  $ne->setValue($dbupdate->getCustomUpdatesCurrentVersion());
2433  $this->form->addItem($ne);
2434 
2435  // custom updates file version
2436  $ne = new ilNonEditableValueGUI($lng->txt("available_custom_updates"), "filecu");
2437  $ne->setValue($dbupdate->getCustomUpdatesFileVersion());
2438  $this->form->addItem($ne);
2439  }
2440  ilUtil::sendSuccess($this->lng->txt("database_is_uptodate"));
2441  }
2442  }
2443 
2444  $this->form->setTitle($lng->txt("database"));
2445  $this->form->setFormAction("setup.php?cmd=gateway");
2446  }
2447 
2452  public function getClientDbFormValues($dbupdate = null)
2453  {
2454  global $lng;
2455 
2456  $values = array();
2457 
2458  $values["db_host"] = $this->setup->getClient()->getDbHost();
2459  $values["db_name"] = $this->setup->getClient()->getDbName();
2460  $values["db_user"] = $this->setup->getClient()->getDbUser();
2461  $values["db_port"] = $this->setup->getClient()->getDbPort();
2462  $values["db_type"] = $lng->txt("db_".$this->setup->getClient()->getDbType());
2463  if (is_object($dbupdate))
2464  {
2465  $values["update_break"] = $dbupdate->fileVersion;
2466  if (($dbupdate->fileVersion - $dbupdate->currentVersion) >= 200)
2467  {
2468  $values["update_break"] = $dbupdate->currentVersion + 200 -
2469  ($dbupdate->currentVersion % 100);
2470  }
2471  }
2472 
2473  $this->form->setValuesByArray($values);
2474  }
2475 
2479 
2486  function installDatabase()
2487  {
2488  if (!$this->setup->getClient()->db_exists)
2489  {
2490  if ($_POST["chk_db_create"])
2491  {
2492  if (!$this->setup->createDatabase($_POST["collation"]))
2493  {
2494  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2495  ilUtil::redirect("setup.php?cmd=displayDatabase");
2496  }
2497  }
2498  else
2499  {
2500  ilUtil::sendFailure($this->lng->txt("database_not_exists_create_first"), true);
2501  ilUtil::redirect("setup.php?cmd=displayDatabase");
2502  }
2503  }
2504  if (!$this->setup->installDatabase())
2505  {
2506  ilUtil::sendFailure($this->lng->txt($this->setup->getError()), true);
2507  }
2508  else
2509  {
2510  ilUtil::sendSuccess($this->lng->txt("database_installed"), true);
2511  }
2512  ilUtil::redirect("setup.php?cmd=displayDatabase");
2513  }
2514 
2518 
2522  function updateDatabase()
2523  {
2524  global $ilCtrlStructureReader;
2525 
2526  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2527 
2528  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2529  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2530  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2531  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2532  include_once "./Services/Tree/classes/class.ilTree.php";
2533  include_once "./Services/Xml/classes/class.ilSaxParser.php";
2534  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2535 
2536  // #9019: init timezone
2537  $tz = $this->setup->ini->readVariable("server","timezone");
2538  if ($tz != "")
2539  {
2540  if (function_exists('date_default_timezone_set'))
2541  {
2542  date_default_timezone_set($tz);
2543  }
2544  define ("IL_TIMEZONE", $tz);
2545  }
2546 
2547  // referencing db handler in language class
2548  $ilDB = $this->setup->getClient()->db;
2549  $this->lng->setDbHandler($ilDB);
2550 
2551  // run dbupdate
2552  $dbupdate = new ilDBUpdate($ilDB);
2553  $dbupdate->applyUpdate((int) $_POST["update_break"]);
2554 
2555  if ($dbupdate->updateMsg == "no_changes")
2556  {
2557  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2558  }
2559  else
2560  {
2561  $sep = "";
2562  foreach ($dbupdate->updateMsg as $row)
2563  {
2564  if ($row["msg"] == "update_applied")
2565  {
2566  $a_message.= $sep.$row["nr"];
2567  $sep = ", ";
2568  }
2569  else
2570  {
2571  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2572  }
2573  }
2574  if ($a_message != "")
2575  {
2576  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2577  }
2578  }
2579 
2580  ilUtil::sendInfo($a_message.$e_message, true);
2581  ilUtil::redirect("setup.php?cmd=displayDatabase");
2582  }
2583 
2587 
2594  function showHotfixSteps()
2595  {
2596  $this->showUpdateSteps(true);
2597  }
2598 
2599 
2603  function showUpdateSteps($a_hotfix = false)
2604  {
2605  global $ilCtrlStructureReader;
2606 
2607  $this->checkDisplayMode("setup_database");
2608 
2609  //$this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html", "setup");
2610 
2611  // database is intalled
2612  if ($this->setup->getClient()->db_installed)
2613  {
2614  $ilDB = $this->setup->getClient()->db;
2615  $this->lng->setDbHandler($ilDB);
2616  $dbupdate = new ilDBUpdate($ilDB);
2617  $db_status = $dbupdate->getDBVersionStatus();
2618  $hotfix_available = $dbupdate->hotfixAvailable();
2619  $custom_updates_available = $dbupdate->customUpdatesAvailable();
2620 // $this->initClientDbForm(false, $dbupdate, $db_status, $hotfix_available, $custom_updates_available);
2621 // $this->getClientDbFormValues($dbupdate);
2622 
2623  $ntpl = new ilTemplate("tpl.setup_steps.html", true, true, "setup");
2624  if ($a_hotfix)
2625  {
2626  $ntpl->setVariable("CONTENT", $dbupdate->getHotfixSteps());
2627  }
2628  else
2629  {
2630  $ntpl->setVariable("CONTENT", $dbupdate->getUpdateSteps($_POST["update_break"]));
2631  }
2632  $ntpl->setVariable("BACK", $this->lng->txt("back"));
2633  $ntpl->setVariable("HREF_BACK", "./setup.php?client_id=&cmd=db");
2634  $this->tpl->setVariable("SETUP_CONTENT", $ntpl->get());
2635  }
2636  }
2637 
2638 
2642 
2646  function applyHotfix()
2647  {
2648  global $ilCtrlStructureReader;
2649 
2650  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
2651 
2652  include_once "./Services/Database/classes/class.ilDBUpdate.php";
2653  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
2654  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
2655  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
2656  include_once "./Services/Tree/classes/class.ilTree.php";
2657  include_once "./Services/Xml/classes/class.ilSaxParser.php";
2658  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
2659 
2660  // referencing db handler in language class
2661  $ilDB = $this->setup->getClient()->db;
2662  $this->lng->setDbHandler($ilDB);
2663 
2664  // run dbupdate
2665  $dbupdate = new ilDBUpdate($ilDB);
2666  $dbupdate->applyHotfix();
2667 
2668  if ($dbupdate->updateMsg == "no_changes")
2669  {
2670  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
2671  }
2672  else
2673  {
2674  $sep = "";
2675  foreach ($dbupdate->updateMsg as $row)
2676  {
2677  if ($row["msg"] == "update_applied")
2678  {
2679  $a_message.= $sep.$row["nr"];
2680  $sep = ", ";
2681  }
2682  else
2683  {
2684  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
2685  }
2686  }
2687  if ($a_message != "")
2688  {
2689  $a_message = $this->lng->txt("update_applied").": ".$a_message;
2690  }
2691  }
2692 
2693  ilUtil::sendInfo($a_message.$e_message, true);
2694  ilUtil::redirect("setup.php?cmd=displayDatabase");
2695  }
2696 
2700 
2704  function displaySessions()
2705  {
2706  require_once('Services/Authentication/classes/class.ilSessionControl.php');
2707 
2708  $this->checkDisplayMode("setup_sessions");
2709 
2710  if (!$this->setup->getClient()->db_installed)
2711  {
2712  // program should never come to this place
2713  $message = "No database found! Please install database first.";
2714  ilUtil::sendInfo($message);
2715  }
2716 
2717  $setting_fields = ilSessionControl::getSettingFields();
2718 
2719  $valid = true;
2720  $settings = array();
2721 
2722  foreach( $setting_fields as $field )
2723  {
2724  if( $field == 'session_allow_client_maintenance' )
2725  {
2726  if( isset($_POST[$field]) ) $_POST[$field] = '1';
2727  else $_POST[$field] = '0';
2728  }
2729 
2730  if( isset($_POST[$field]) && $_POST[$field] != '' )
2731  {
2732  $settings[$field] = $_POST[$field];
2733  }
2734  else
2735  {
2736  $valid = false;
2737  break;
2738  }
2739 
2740  }
2741 
2742  if($valid) $this->setup->setSessionSettings($settings);
2743 
2744  $settings = $this->setup->getSessionSettings();
2745 
2746  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2747  $form = new ilPropertyFormGUI();
2748 
2749  include_once 'Services/Authentication/classes/class.ilSession.php';
2750 
2751  // BEGIN SESSION SETTINGS
2752  // create session handling radio group
2753  $ssettings = new ilRadioGroupInputGUI($this->lng->txt('sess_mode'), 'session_handling_type');
2754  $ssettings->setValue($settings['session_handling_type'], ilSession::SESSION_HANDLING_FIXED);
2755 
2756  // first option, fixed session duration
2757  $fixed = new ilRadioOption($this->lng->txt('sess_fixed_duration'), ilSession::SESSION_HANDLING_FIXED);
2758 
2759  // add session handling to radio group
2760  $ssettings->addOption($fixed);
2761 
2762  // second option, session control
2763  $ldsh = new ilRadioOption($this->lng->txt('sess_load_dependent_session_handling'), ilSession::SESSION_HANDLING_LOAD_DEPENDENT);
2764 
2765  // this is the max count of active sessions
2766  // that are getting started simlutanously
2767  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_count'), "session_max_count");
2768  $ti->setInfo($this->lng->txt('sess_max_session_count_info'));
2769  $ti->setMaxLength(5);
2770  $ti->setSize(5);
2771  $ti->setValue($settings['session_max_count']);
2772  $ldsh->addSubItem($ti);
2773 
2774  // after this (min) idle time the session can be deleted,
2775  // if there are further requests for new sessions,
2776  // but max session count is reached yet
2777  $ti = new ilTextInputGUI($this->lng->txt('sess_min_session_idle'), "session_min_idle");
2778  $ti->setInfo($this->lng->txt('sess_min_session_idle_info'));
2779  $ti->setMaxLength(5);
2780  $ti->setSize(5);
2781  $ti->setValue($settings['session_min_idle']);
2782  $ldsh->addSubItem($ti);
2783 
2784  // after this (max) idle timeout the session expires
2785  // and become invalid, so it is not considered anymore
2786  // when calculating current count of active sessions
2787  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle'), "session_max_idle");
2788  $ti->setInfo($this->lng->txt('sess_max_session_idle_info'));
2789  $ti->setMaxLength(5);
2790  $ti->setSize(5);
2791  $ti->setValue($settings['session_max_idle']);
2792  $ldsh->addSubItem($ti);
2793 
2794  // this is the max duration that can elapse between the first and the secnd
2795  // request to the system before the session is immidietly deleted
2796  $ti = new ilTextInputGUI($this->lng->txt('sess_max_session_idle_after_first_request'), "session_max_idle_after_first_request");
2797  $ti->setInfo($this->lng->txt('sess_max_session_idle_after_first_request_info'));
2798  $ti->setMaxLength(5);
2799  $ti->setSize(5);
2800  $ti->setValue($settings['session_max_idle_after_first_request']);
2801  $ldsh->addSubItem($ti);
2802 
2803  // add session control to radio group
2804  $ssettings->addOption($ldsh);
2805 
2806  $form->addItem($ssettings);
2807 
2808  // controls the ability t maintenance the following
2809  // settings in client administration
2810  $chkb = new ilCheckboxInputGUI($this->lng->txt('sess_allow_client_maintenance'), "session_allow_client_maintenance");
2811  $chkb->setInfo($this->lng->txt('sess_allow_client_maintenance_info'));
2812  $chkb->setChecked($settings['session_allow_client_maintenance'] ? true : false);
2813  $form->addItem($chkb);
2814  // END SESSION SETTINGS
2815 
2816  // save and cancel commands
2817  $form->addCommandButton("sess", $this->lng->txt('save'));
2818 
2819  $form->setTitle($this->lng->txt("sess_sessions"));
2820  $form->setFormAction('setup.php?client_id='.$this->client_id.'&cmd=sess');
2821 
2822  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt('sess_sessions'))));
2823  $this->tpl->setVariable("TXT_INFO", '');
2824  $this->tpl->setVariable("SETUP_CONTENT", $form->getHTML());
2825 
2826  /*$this->setButtonPrev("db");
2827 
2828  if($this->setup->checkClientSessionSettings($this->client,true))
2829  {
2830  $this->setButtonNext("lang");
2831  }*/
2832 
2833  $this->checkPanelMode();
2834  }
2835 
2839 
2843  function displayLanguages()
2844  {
2845  $this->checkDisplayMode("setup_languages");
2846 
2847  if (!$this->setup->getClient()->db_installed)
2848  {
2849  // program should never come to this place
2850  $message = "No database found! Please install database first.";
2851  ilUtil::sendFailure($message);
2852  }
2853 
2854  include_once("./setup/classes/class.ilSetupLanguageTableGUI.php");
2855  $tab = new ilSetupLanguageTableGUI($this->setup->getClient());
2856  $this->tpl->setVariable("SETUP_CONTENT", $tab->getHTML());
2857 
2858  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2859  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2860 
2861  $installed_langs = $this->lng->getInstalledLanguages();
2862  $lang_count = count($installed_langs);
2863  if ($lang_count > 0)
2864  {
2865  $this->setup->getClient()->status["lang"]["status"] = true;
2866  $this->setup->getClient()->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2867  }
2868  else
2869  {
2870  $this->setup->getClient()->status["lang"]["status"] = false;
2871  $this->setup->getClient()->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2872  }
2873 
2874  $this->setButtonPrev("lang");
2875 
2876  if ($lang_count > 0)
2877  {
2878  $this->setButtonNext("contact");
2879  }
2880 
2881  $this->checkPanelMode();
2882  }
2883 
2890  function saveLanguages()
2891  {
2892  if (empty($_POST["form"]["lang_id"]))
2893  {
2894  ilUtil::sendFailure($this->lng->txt("lang_min_one_language"), true);
2895  ilUtil::redirect("setup.php?cmd=lang");
2896  }
2897 
2898  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2899  {
2900  ilUtil::sendFailure($this->lng->txt("lang_not_installed_default"), true);
2901  ilUtil::redirect("setup.php?cmd=lang");
2902  }
2903 
2904  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2905 
2906  if (is_array($result))
2907  {
2908  $count = count($result);
2909  $txt = "tet";
2910 
2911  foreach ($result as $key => $lang_key)
2912  {
2913  $list .= $this->lng->txt("lang_".$lang_key);
2914 
2915  if ($count > $key + 1)
2916  {
2917  $list .= ", ";
2918  }
2919  }
2920  }
2921 
2922  $this->setup->getClient()->setDefaultLanguage($_POST["form"]["lang_default"]);
2923  $message = $this->lng->txt("languages_installed");
2924 
2925  if ($result !== true)
2926  {
2927  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2928  }
2929  ilUtil::sendInfo($message, true);
2930  ilUtil::redirect("setup.php?cmd=lang");
2931  }
2932 
2936 
2940  function displayContactData($a_omit_init = false)
2941  {
2942  $this->checkDisplayMode("setup_contact_data");
2943  $settings = $this->setup->getClient()->getAllSettings();
2944 
2945  if (!$a_omit_init)
2946  {
2947  $this->initContactDataForm();
2948  $this->getContactValues();
2949  }
2950  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
2951  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2952  $this->setButtonPrev("lang");
2953 
2954  $check = $this->setup->checkClientContact($this->setup->client);
2955 
2956  $this->setup->getClient()->status["contact"]["status"] = $check["status"];
2957  $this->setup->getClient()->status["contact"]["comment"] = $check["comment"];
2958 
2959  if ($check["status"])
2960  {
2961  $this->setButtonNext("proxy");
2962  }
2963 
2964  $this->checkPanelMode();
2965  }
2966 
2972  public function initContactDataForm()
2973  {
2974  global $lng, $ilCtrl;
2975 
2976  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2977  $this->form = new ilPropertyFormGUI();
2978 
2979  // name
2980  $ti = new ilTextInputGUI($lng->txt("name"), "inst_name");
2981  $ti->setMaxLength(64);
2982  $ti->setSize(30);
2983  $ti->setRequired(true);
2984  $this->form->addItem($ti);
2985 
2986  // description
2987  $ti = new ilTextInputGUI($lng->txt("client_info"), "inst_info");
2988  $ti->setMaxLength(64);
2989  $ti->setSize(30);
2990  $this->form->addItem($ti);
2991 
2992  // institution
2993  $ti = new ilTextInputGUI($lng->txt("client_institution"), "inst_institution");
2994  $ti->setMaxLength(64);
2995  $ti->setSize(30);
2996  $this->form->addItem($ti);
2997 
2998  // contact data
2999  $sh = new ilFormSectionHeaderGUI();
3000  $sh->setTitle($lng->txt("contact_data"));
3001  $this->form->addItem($sh);
3002 
3003  // first name
3004  $ti = new ilTextInputGUI($lng->txt("firstname"), "admin_firstname");
3005  $ti->setMaxLength(64);
3006  $ti->setSize(30);
3007  $ti->setRequired(true);
3008  $this->form->addItem($ti);
3009 
3010  // last name
3011  $ti = new ilTextInputGUI($lng->txt("lastname"), "admin_lastname");
3012  $ti->setMaxLength(64);
3013  $ti->setSize(30);
3014  $ti->setRequired(true);
3015  $this->form->addItem($ti);
3016 
3017  $fs = array (
3018  "title" => array("max" => 64, "size" => 30),
3019  "position" => array("max" => 64, "size" => 30),
3020  "institution" => array("max" => 200, "size" => 30),
3021  "street" => array("max" => 64, "size" => 30),
3022  "zipcode" => array("max" => 10, "size" => 5),
3023  "city" => array("max" => 64, "size" => 30),
3024  "country" => array("max" => 64, "size" => 30),
3025  "phone" => array("max" => 64, "size" => 30)
3026  );
3027  foreach ($fs as $f => $op)
3028  {
3029  // field
3030  $ti = new ilTextInputGUI($lng->txt($f), "admin_".$f);
3031  $ti->setMaxLength($op["max"]);
3032  $ti->setSize($op["size"]);
3033  $ti->setInfo($lng->txt(""));
3034  $this->form->addItem($ti);
3035  }
3036 
3037  // email
3038  $ti = new ilEmailInputGUI($lng->txt("email"), "admin_email");
3039  $ti->setRequired(true);
3040  $this->form->addItem($ti);
3041 
3042  // feedback recipient
3043  $ti = new ilEmailInputGUI($lng->txt("feedback_recipient"), "feedback_recipient");
3044  $ti->setInfo($lng->txt("feedback_recipient_info"));
3045  $ti->setRequired(true);
3046  $this->form->addItem($ti);
3047 
3048  // error recipient
3049  $ti = new ilEmailInputGUI($lng->txt("error_recipient"), "error_recipient");
3050  $this->form->addItem($ti);
3051 
3052  $this->form->addCommandButton("saveContact", $lng->txt("save"));
3053 
3054  $this->form->setTitle($lng->txt("client_data"));
3055  $this->form->setFormAction("setup.php?cmd=gateway");
3056  }
3057 
3061  public function getContactValues()
3062  {
3063 
3064  $settings = $this->setup->getClient()->getAllSettings();
3065 
3066  $values = $settings;
3067 
3068  $values["inst_name"] = ($this->setup->getClient()->getName())
3069  ? $this->setup->getClient()->getName()
3070  : $this->setup->getClient()->getId();
3071  $values["inst_info"] = $this->setup->getClient()->getDescription();
3072 
3073  $this->form->setValuesByArray($values);
3074  }
3075 
3079  public function saveContact()
3080  {
3081  global $tpl, $lng, $ilCtrl;
3082 
3083  $this->initContactDataForm();
3084  if ($this->form->checkInput())
3085  {
3086  $this->setup->getClient()->setSetting("admin_firstname", $_POST["admin_firstname"]);
3087  $this->setup->getClient()->setSetting("admin_lastname", $_POST["admin_lastname"]);
3088  $this->setup->getClient()->setSetting("admin_title", $_POST["admin_title"]);
3089  $this->setup->getClient()->setSetting("admin_position", $_POST["admin_position"]);
3090  $this->setup->getClient()->setSetting("admin_institution", $_POST["admin_institution"]);
3091  $this->setup->getClient()->setSetting("admin_street", $_POST["admin_street"]);
3092  $this->setup->getClient()->setSetting("admin_zipcode", $_POST["admin_zipcode"]);
3093  $this->setup->getClient()->setSetting("admin_city", $_POST["admin_city"]);
3094  $this->setup->getClient()->setSetting("admin_country", $_POST["admin_country"]);
3095  $this->setup->getClient()->setSetting("admin_phone", $_POST["admin_phone"]);
3096  $this->setup->getClient()->setSetting("admin_email", $_POST["admin_email"]);
3097  $this->setup->getClient()->setSetting("inst_institution", $_POST["inst_institution"]);
3098  $this->setup->getClient()->setSetting("inst_name", $_POST["inst_name"]);
3099  $this->setup->getClient()->setSetting("feedback_recipient", $_POST["feedback_recipient"]);
3100  $this->setup->getClient()->setSetting("error_recipient", $_POST["error_recipient"]);
3101 
3102  // update client.ini
3103  $this->setup->getClient()->setName($_POST["inst_name"]);
3104  $this->setup->getClient()->setDescription($_POST["inst_info"]);
3105  $this->setup->getClient()->ini->write();
3106 
3107  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
3108  ilUtil::redirect("setup.php?cmd=displayContactData");
3109  }
3110 
3111  $this->form->setValuesByPost();
3112  $this->displayContactData(true);
3113  }
3114 
3118 
3122  function displayNIC($a_omit_init = false)
3123  {
3124  $this->checkDisplayMode("nic_registration");
3125  $settings = $this->setup->getClient()->getAllSettings();
3126  $nic_key = $this->setup->getClient()->getNICkey();
3127 
3128  // reload settings
3129  $settings = $this->setup->getClient()->getAllSettings();
3130 //var_dump($settings);
3131  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
3132  {
3133  $this->no_second_nav = true;
3134  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
3135  }
3136  else
3137  {
3138  // reload settings
3139  $settings = $this->setup->getClient()->getAllSettings();
3140 
3141  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic"));
3142  if (!$a_omit_init)
3143  {
3144  $this->initRegistrationForm();
3145  $this->getRegistrationValues();
3146  }
3147  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
3148 
3149  if (isset($settings["nic_enabled"]))
3150  {
3151  $this->setup->getClient()->status["nic"]["status"] = true;
3152  }
3153 
3154  }
3155 
3156  $this->setButtonPrev("proxy");
3157 
3158  if ($this->setup->getClient()->status["nic"]["status"])
3159  {
3160  $this->setButtonNext("finish","finish");
3161  }
3162 
3163  $this->checkPanelMode();
3164  }
3165 
3171  public function initRegistrationForm($a_mode = "edit")
3172  {
3173  global $lng, $ilCtrl;
3174 
3175  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3176  $this->form = new ilPropertyFormGUI();
3177 
3178  // registration type
3179  $radg = new ilRadioGroupInputGUI($lng->txt("nic_registration"), "register");
3180  $radg->setValue(1);
3181  $op1 = new ilRadioOption($lng->txt("nic_reg_online"), 1);
3182  $radg->addOption($op1);
3183  $op1 = new ilRadioOption($lng->txt("nic_reg_disable"), 0, $lng->txt("nic_reg_disable_info"));
3184  $radg->addOption($op1);
3185  $this->form->addItem($radg);
3186 
3187  $this->form->addCommandButton("saveRegistration", $lng->txt("save"));
3188  $this->form->setFormAction("setup.php?cmd=gateway");
3189  }
3190 
3194  public function getRegistrationValues()
3195  {
3196  $settings = $this->setup->getClient()->getAllSettings();
3197  $nic_key = $this->setup->getClient()->getNICkey();
3198 
3199 
3200  $values = array();
3201 
3202  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
3203  {
3204  $values["register"] = 1;
3205  }
3206  /*elseif ($settings["nic_enabled"] == "2")
3207  {
3208  $this->tpl->setVariable("EMAIL",$checked);
3209  }*/
3210  else
3211  {
3212  $values["register"] = 0;
3213  }
3214 
3215  $this->form->setValuesByArray($values);
3216  }
3217 
3221  public function saveRegistration()
3222  {
3223  global $tpl, $lng, $ilCtrl;
3224 
3225  $this->initRegistrationForm();
3226  if ($this->form->checkInput())
3227  {
3228  // check register option
3229  if ($_POST["register"] == 1)
3230  {
3231  // update nic
3232  $this->setup->getClient()->updateNIC($this->setup->ilias_nic_server);
3233 //var_dump($this->setup->getClient()->nic_status);
3234  // online registration failed
3235  if (empty($this->setup->getClient()->nic_status[2]))
3236  {
3237  $this->setup->getClient()->setSetting("nic_enabled","-1");
3238  ilUtil::sendFailure($this->lng->txt("nic_reg_failed"), true);
3239  ilUtil::redirect("setup.php?cmd=displayNIC");
3240  }
3241  else
3242  {
3243  $this->setup->getClient()->setSetting("inst_id",$this->setup->getClient()->nic_status[2]);
3244  $this->setup->getClient()->setSetting("nic_enabled","1");
3245  $this->setup->getClient()->status["nic"]["status"] = true;
3246  ilUtil::sendSuccess($this->lng->txt("nic_reg_enabled"), true);
3247  ilUtil::redirect("setup.php?cmd=displayNIC");
3248  }
3249  }
3250  /*elseif ($_POST["form"]["register"] == 2)
3251  {
3252  $nic_by_email = (int) $_POST["form"]["nic_id"];
3253 
3254  $checksum = md5($nic_key.$nic_by_email);
3255 
3256  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
3257  {
3258  $message = $this->lng->txt("nic_reg_enter_correct_id");
3259  }
3260  else
3261  {
3262  $this->setup->getClient()->setSetting("inst_id",$nic_by_email);
3263  $this->setup->getClient()->setSetting("nic_enabled","1");
3264  $message = $this->lng->txt("nic_reg_enabled");
3265  }
3266  }*/
3267  else
3268  {
3269  $this->setup->getClient()->setSetting("inst_id","0");
3270  $this->setup->getClient()->setSetting("nic_enabled","0");
3271  ilUtil::sendSuccess($this->lng->txt("nic_reg_disabled"), true);
3272  ilUtil::redirect("setup.php?cmd=displayNIC");
3273  }
3274  }
3275 
3276  $this->form->setValuesByPost();
3277  $this->displayNIC(true);
3278  }
3279 
3283 
3287  function displayTools()
3288  {
3289  $this->checkDisplayMode();
3290 
3291  // output
3292  ilUtil::sendInfo();
3293 
3294  // use property forms and add the settings type switch
3295  $ctrl_structure_form = $this->initControlStructureForm();
3296  $settings_type_form = $this->initSettingsTypeForm();
3297  $mp_ns_form = $this->initTreeImplementationForm();
3298 
3299  $this->tpl->setVariable("SETUP_CONTENT",
3300  $ctrl_structure_form->getHTML() . "<br />" .
3301  $settings_type_form->getHTML().'<br />'.
3302  $mp_ns_form->getHTML());
3303 
3304  }
3305 
3306  public function initTreeImplementationForm()
3307  {
3308  include_once ("Services/Form/classes/class.ilPropertyFormGUI.php");
3309  $form = new ilPropertyFormGUI();
3310 
3311  $form->setId('tree_impl');
3312  $form->setTitle($this->lng->txt('tree_implementation'));
3313  $form->setFormAction('setup.php?cmd=gateway');
3314 
3315 
3316  $options = new ilRadioGroupInputGUI('', 'tree_impl_type');
3317  #$options->setRequired(true);
3318 
3319  $set = new ilSetting('common');
3320  $type = ($set->get('main_tree_impl','ns') == 'ns' ? 'ns' : 'mp');
3321 
3322 
3323  $options->setValue($type);
3324 
3325  $ns = new ilRadioOption($this->lng->txt('tree_implementation_ns'), 'ns');
3326  $options->addOption($ns);
3327 
3328  $mp = new ilRadioOption($this->lng->txt('tree_implementation_mp'),'mp');
3329  $options->addOption($mp);
3330 
3331  $form->addItem($options);
3332  $form->addCommandButton('switchTree', $this->lng->txt('tree_implementation_switch_btn'));
3333  $form->setShowTopButtons(false);
3334 
3335  return $form;
3336 
3337  }
3338 
3339  public function switchTree()
3340  {
3341  $set = new ilSetting('common');
3342  $type = ($set->get('main_tree_impl','ns') == 'ns' ? 'ns' : 'mp');
3343 
3344  if($type == 'ns' and $_POST['tree_impl_type'] == 'mp')
3345  {
3346  // To mp
3347  include_once './Services/Tree/classes/class.ilMaterializedPathTree.php';
3349 
3350  $GLOBALS['ilDB']->dropIndexByFields('tree',array('lft'));
3351  $GLOBALS['ilDB']->dropIndexByFields('tree',array('path'));
3352  $GLOBALS['ilDB']->addIndex('tree',array('path'),'i4');
3353 
3354  $set->set('main_tree_impl', 'mp');
3355 
3356  }
3357  elseif($type == 'mp' and $_POST['tree_impl_type'] == 'ns')
3358  {
3359  include_once './Services/Tree/classes/class.ilTree.php';
3360  $GLOBALS['ilSetting'] = $set;
3361  $tree = new ilTree(1);
3362  $tree->renumber(1);
3363 
3364  $GLOBALS['ilDB']->dropIndexByFields('tree',array('lft'));
3365  $GLOBALS['ilDB']->dropIndexByFields('tree',array('path'));
3366  $GLOBALS['ilDB']->addIndex('tree',array('lft'),'i4');
3367 
3368  $set->set('main_tree_impl', 'ns');
3369  }
3370 
3371  ilUtil::sendInfo($this->lng->txt("tree_implementation_switched"), true);
3372  $this->displayTools();
3373  }
3374 
3381  {
3382  include_once ("Services/Form/classes/class.ilPropertyFormGUI.php");
3383  $form = new ilPropertyFormGUI();
3384 
3385  $form->setId("control_structure");
3386  $form->setTitle($this->lng->txt("ctrl_structure"));
3387  $form->setFormAction("setup.php?cmd=gateway");
3388 
3389  $ilDB = $this->setup->getClient()->db;
3390  $cset = $ilDB->query("SELECT count(*) as cnt FROM ctrl_calls");
3391  $crec = $ilDB->fetchAssoc($cset);
3392 
3393  $item = new ilCustomInputGUI($this->lng->txt("ctrl_structure_reload"));
3394  if ($crec["cnt"] == 0)
3395  {
3396  $item->setInfo($this->lng->txt("ctrl_missing_desc"));
3397  }
3398  else
3399  {
3400  $item->setInfo($this->lng->txt("ctrl_structure_desc"));
3401  }
3402  $form->addItem($item);
3403 
3404  $form->addCommandButton("reloadStructure", $this->lng->txt("reload"));
3405  return $form;
3406  }
3407 
3408 
3413  {
3414  global $ilCtrlStructureReader;
3415 
3416  if (!$this->setup->getClient()->db_installed)
3417  {
3418  ilUtil::sendInfo($this->lng->txt("no_db"), true);
3419  $this->displayTools();
3420  return;
3421  }
3422 
3423  // referencing does not work in dbupdate-script
3424  $GLOBALS["ilDB"] = $this->setup->getClient()->getDB();
3425 // BEGIN WebDAV
3426  // read module and service information into db
3427  require_once "./setup/classes/class.ilModuleReader.php";
3428  require_once "./setup/classes/class.ilServiceReader.php";
3429  require_once "./setup/classes/class.ilCtrlStructureReader.php";
3430 
3431  require_once "./Services/Component/classes/class.ilModule.php";
3432  require_once "./Services/Component/classes/class.ilService.php";
3433  $modules = ilModule::getAvailableCoreModules();
3435 
3436  // clear tables
3437  $mr = new ilModuleReader("", "", "");
3438  $mr->clearTables();
3439  foreach($modules as $module)
3440  {
3441  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
3442  $module["subdir"], "Modules");
3443  $mr->getModules();
3444  unset($mr);
3445  }
3446 
3447  // clear tables
3448  $sr = new ilServiceReader("", "", "");
3449  $sr->clearTables();
3450  foreach($services as $service)
3451  {
3452  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
3453  $service["subdir"], "Services");
3454  $sr->getServices();
3455  unset($sr);
3456  }
3457 // END WebDAV
3458 
3459  $ilCtrlStructureReader->readStructure(true);
3460  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
3461  $this->displayTools();
3462  }
3463 
3470  {
3471  include_once("./Services/Administration/classes/class.ilSetting.php");
3472  $type = ilSetting::_getValueType();
3473 
3474  include_once ("Services/Form/classes/class.ilPropertyFormGUI.php");
3475  $form = new ilPropertyFormGUI();
3476 
3477  $form->setId("settings_type");
3478  $form->setTitle($this->lng->txt("settings_type"));
3479  $form->setFormAction("setup.php?cmd=gateway");
3480 
3481  $item = new ilNonEditableValueGUI($this->lng->txt('settings_type_current'));
3482  $item->setValue(strtoupper($type));
3483 
3484  if ($type == "clob")
3485  {
3486  $item->setInfo($this->lng->txt('settings_info_clob'));
3487  $form->addCommandButton("showLongerSettings", $this->lng->txt("settings_show_longer"));
3488  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_text"));
3489  }
3490  else
3491  {
3492  $item->setInfo($this->lng->txt('settings_info_text'));
3493  $form->addCommandButton("changeSettingsType", $this->lng->txt("settings_change_clob"));
3494  }
3495  $form->addItem($item);
3496 
3497  if (is_array($this->longer_settings))
3498  {
3499  $item = new ilCustomInputGUI($this->lng->txt('settings_longer_values'));
3500 
3501  if (count($this->longer_settings))
3502  {
3503  foreach ($this->longer_settings as $row)
3504  {
3505  $subitem = new ilCustomInputGUI(sprintf($this->lng->txt('settings_key_info'), $row['module'], $row['keyword']));
3506  $subitem->setInfo($row['value']);
3507  $item->addSubItem($subitem);
3508  }
3509  }
3510  else
3511  {
3512  $item->setHTML($this->lng->txt('settings_no_longer_values'));
3513  }
3514  $form->addItem($item);
3515  }
3516 
3517  return $form;
3518  }
3519 
3520 
3525  {
3526  include_once("./Services/Administration/classes/class.ilSetting.php");
3527  $old_type = ilSetting::_getValueType();
3528 
3529  if ($old_type == "clob")
3530  {
3531  $longer_settings = ilSetting::_getLongerSettings();
3532  if (count($longer_settings))
3533  {
3534  $this->longer_settings = $longer_settings;
3535  ilUtil::sendFailure($this->lng->txt("settings_too_long"));
3536  }
3537  else
3538  {
3540  }
3541  }
3542  else
3543  {
3545  }
3546 
3547  if ($changed)
3548  {
3549  ilUtil::sendInfo($this->lng->txt("settings_type_changed"));
3550  }
3551 
3552  $this->displayTools();
3553  }
3554 
3555 
3561  {
3562  include_once("./Services/Administration/classes/class.ilSetting.php");
3563  $this->longer_settings = ilSetting::_getLongerSettings();
3564  $this->displayTools();
3565  }
3566 
3571  {
3572  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html", "setup");
3573 
3574  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
3575 
3576  // formular sent
3577  if ($_POST["form"])
3578  {
3579  $pass_old = $this->setup->getPassword();
3580 
3581  if (empty($_POST["form"]["pass_old"]))
3582  {
3583  $message = $this->lng->txt("password_enter_old");
3584  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3585  }
3586 
3587  if (md5($_POST["form"]["pass_old"]) != $pass_old)
3588  {
3589  $message = $this->lng->txt("password_old_wrong");
3590  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3591  }
3592 
3593  if (empty($_POST["form"]["pass"]))
3594  {
3595  $message = $this->lng->txt("password_empty");
3596  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3597  }
3598 
3599  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
3600  {
3601  $message = $this->lng->txt("password_not_match");
3602  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3603  }
3604 
3605  if (md5($_POST["form"]["pass"]) == $pass_old)
3606  {
3607  $message = $this->lng->txt("password_same");
3608  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3609  }
3610 
3611  if (!$this->setup->setPassword($_POST["form"]["pass"]))
3612  {
3613  $message = $this->lng->txt("save_error");
3614  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
3615  }
3616 
3617  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
3618  ilUtil::redirect("setup.php");
3619  }
3620 
3621  // output
3622  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html", "setup");
3623 
3624  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
3625 
3626  // pass form
3627  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3628  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
3629  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
3630  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
3631  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
3632  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
3633  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
3634  }
3635 
3640  {
3641  $this->checkDisplayMode("finish_setup");
3642  $this->no_second_nav = true;
3643 //echo "<b>1</b>";
3644  if ($this->validateSetup())
3645  {
3646  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
3647  "<p>".$this->lng->txt("user").": <b>root</b><br />".
3648  $this->lng->txt("password").": <b>homer</b></p>";
3649  $this->setButtonNext("login_new","login");
3650 //echo "<b>2</b>";
3651  $this->setup->getClient()->reconnect(); // if this is not done, the writing of
3652  // the setup_ok fails (with MDB2 and a larger
3653  // client list), alex 17.1.2008
3654  $this->setup->getClient()->setSetting("setup_ok",1);
3655 //$this->setup->getClient()->setSetting("zzz", "Z");
3656 //echo "<b>3</b>";
3657  $this->setup->getClient()->status["finish"]["status"] = true;
3658 //echo "<b>4</b>";
3659  }
3660  else
3661  {
3662  $txt_info = $this->lng->txt("info_text_finish2");
3663  }
3664 
3665 //echo "<b>5</b>";
3666  // output
3667  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html", "setup");
3668  $this->tpl->setVariable("TXT_INFO",$txt_info);
3669 
3670  $this->setButtonPrev("nic");
3671 //echo "<b>6</b>";
3672  $this->checkPanelMode();
3673 //echo "<b>7</b>";
3674  }
3675 
3680  {
3681  $this->checkDisplayMode();
3682 
3683  // formular sent
3684  if ($_POST["form"]["delete"])
3685  {
3686  $ini = true;
3687  $db = false;
3688  $files = false;
3689 
3690  /* disabled
3691  switch ($_POST["form"]["delete"])
3692  {
3693  case 1:
3694  $ini = true;
3695  break;
3696 
3697  case 2:
3698  $ini = true;
3699  $db = true;
3700  break;
3701 
3702  case 3:
3703  $ini = true;
3704  $db = true;
3705  $files = true;
3706  break;
3707  }
3708  */
3709 
3710  $msg = $this->setup->getClient()->delete($ini,$db,$files);
3711 
3712  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
3713  ilUtil::redirect("setup.php");
3714  }
3715 
3716  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
3717 
3718  // output
3719  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html", "setup");
3720 
3721  // delete panel
3722  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
3723  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
3724  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
3725  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
3726 
3727  $this->checkPanelMode();
3728  }
3729 
3735  function changeAccessMode($a_back)
3736  {
3737  if ($this->setup->getClient()->status["finish"]["status"])
3738  {
3739  $val = ($this->setup->getClient()->ini->readVariable("client","access")) ? "0" : true;
3740  $this->setup->getClient()->ini->setVariable("client","access",$val);
3741  $this->setup->getClient()->ini->write();
3742  $message = "client_access_mode_changed";
3743  }
3744  else
3745  {
3746  $message = "client_setup_not_finished";
3747  }
3748 
3749  ilUtil::sendInfo($this->lng->txt($message),true);
3750 
3751  ilUtil::redirect("setup.php?cmd=".$a_back);
3752  }
3753 
3758  {
3759  if ($_POST["form"])
3760  {
3761  $client = new ilClient($_POST["form"]["default"], $this->setup->db_connections);
3762 
3763  if (!$client->init())
3764  {
3765  $this->setup->raiseError($this->lng->txt("no_valid_client_id"),$this->setup->error_obj->MESSAGE);
3766  }
3767 
3768  $status = $this->setup->getStatus($client);
3769 
3770  if ($status["finish"]["status"])
3771  {
3772  $this->setup->ini->setVariable("clients","default",$client->getId());
3773  $this->setup->ini->write();
3774  $message = "default_client_changed";
3775  }
3776  else
3777  {
3778  $message = "client_setup_not_finished";
3779  }
3780  }
3781 
3782  ilUtil::sendInfo($this->lng->txt($message),true);
3783 
3784  ilUtil::redirect("setup.php");
3785  }
3786 
3791  function validateSetup()
3792  {
3793  foreach ($this->setup->getClient()->status as $key => $val)
3794  {
3795  if ($key != "finish" and $key != "access")
3796  {
3797  if ($val["status"] != true)
3798  {
3799  return false;
3800  }
3801  }
3802  }
3803 
3804 //$this->setup->getClient()->setSetting("zzz", "V");
3805  $clientlist = new ilClientList($this->setup->db_connections);
3806 //$this->setup->getClient()->setSetting("zzz", "W");
3807  $list = $clientlist->getClients();
3808 //$this->setup->getClient()->setSetting("zzz", "X");
3809  if (count($list) == 1)
3810  {
3811  $this->setup->ini->setVariable("clients","default",$this->setup->getClient()->getId());
3812  $this->setup->ini->write();
3813 
3814  $this->setup->getClient()->ini->setVariable("client","access",1);
3815  $this->setup->getClient()->ini->write();
3816  }
3817 //$this->setup->getClient()->setSetting("zzz", "Y");
3818  return true;
3819  }
3820 
3825  {
3826  if (!$this->setup->getClient()->status["db"]["status"])
3827  {
3828  $this->cmd = "db";
3829  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3830  $this->displayDatabase();
3831  }
3832  elseif (!$this->setup->getClient()->status["lang"]["status"])
3833  {
3834  $this->cmd = "lang";
3835  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3836  $this->displayLanguages();
3837  }
3838  elseif (!$this->setup->getClient()->status["contact"]["status"])
3839  {
3840  $this->cmd = "contact";
3841  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3842  $this->displayContactData();
3843  }
3844  elseif(!$this->setup->getClient()->status['proxy']['status'])
3845  {
3846  $this->cmd = "proxy";
3847  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3848  $this->displayProxy();
3849  }
3850  elseif (!$this->setup->getClient()->status["nic"]["status"])
3851  {
3852  $this->cmd = "nic";
3853  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3854  $this->displayNIC();
3855  }
3856  elseif (!$this->setup->getClient()->status["finish"]["status"])
3857  {
3858  $this->cmd = "finish";
3859  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
3860  $this->displayFinishSetup();
3861  }
3862  else
3863  {
3864  return false;
3865  }
3866  }
3867 
3871  function toggleClientList()
3872  {
3873  if ($this->setup->ini->readVariable("clients","list"))
3874  {
3875  $this->setup->ini->setVariable("clients","list","0");
3876  $this->setup->ini->write();
3877  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
3878  }
3879  else
3880  {
3881  $this->setup->ini->setVariable("clients","list","1");
3882  $this->setup->ini->write();
3883  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
3884  }
3885 
3886  ilUtil::redirect("setup.php");
3887  }
3888 
3892 
3894  {
3895  global $ilCtrlStructureReader;
3896 
3897  $ilCtrlStructureReader->setIniFile($this->setup->getClient()->ini);
3898 
3899  include_once "./Services/Database/classes/class.ilDBUpdate.php";
3900  include_once "./Services/AccessControl/classes/class.ilRbacAdmin.php";
3901  include_once "./Services/AccessControl/classes/class.ilRbacReview.php";
3902  include_once "./Services/AccessControl/classes/class.ilRbacSystem.php";
3903  include_once "./Services/Tree/classes/class.ilTree.php";
3904  include_once "./Services/Xml/classes/class.ilSaxParser.php";
3905  include_once "./Services/Object/classes/class.ilObjectDefinition.php";
3906 
3907  // referencing db handler in language class
3908  $ilDB = $this->setup->getClient()->db;
3909  $this->lng->setDbHandler($ilDB);
3910 
3911  // run dbupdate
3912  $dbupdate = new ilDBUpdate($ilDB);
3913  $dbupdate->applyCustomUpdates();
3914 
3915  if ($dbupdate->updateMsg == "no_changes")
3916  {
3917  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
3918  }
3919  else
3920  {
3921  $sep = "";
3922  foreach ($dbupdate->updateMsg as $row)
3923  {
3924  if ($row["msg"] == "update_applied")
3925  {
3926  $a_message.= $sep.$row["nr"];
3927  $sep = ", ";
3928  }
3929  else
3930  {
3931  $e_message.= "<br/>".$this->lng->txt($row["msg"]).": ".$row["nr"];
3932  }
3933  }
3934  if ($a_message != "")
3935  {
3936  $a_message = $this->lng->txt("update_applied").": ".$a_message;
3937  }
3938  }
3939 
3940  ilUtil::sendInfo($a_message.$e_message, true);
3941  ilUtil::redirect("setup.php?cmd=displayDatabase");
3942  }
3943 
3947  function cloneInitForm()
3948  {
3949  global $lng, $ilCtrl;
3950 
3951  $this->checkDisplayMode();
3952 
3953  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3954  $this->form = new ilPropertyFormGUI();
3955 
3956  $this->form->setId("clone_form");
3957  $this->form->setFormAction("setup.php?cmd=gateway");
3958 
3959  if ($this->setup->getClient()->status["access"]["status"] === false and stripos($this->setup->getClient()->getName(),"master") === false and $this->setup->getClient()->getdbType() == "mysql" and $this->setup->getClient()->db_exists )
3960  {
3961  $this->form->setTitle($this->lng->txt("clone_source"));
3962  $clients = array();
3963  $clientlist = new ilClientList($this->setup->db_connections);
3964  $list = $clientlist->getClients();
3965  $clientlistarray = array();
3966 
3967  foreach ($list as $key => $client){
3968  if ((strcmp($key, $this->setup->getClient()->getId()) != '0') && ($client->getDbType() == 'mysql')) { // You cannot clone yourself
3969  $clientlistarray[$client->id] = $client->id;
3970  }
3971  }
3972 
3973  $si = new ilSelectInputGUI($lng->txt("clone_selectsource"), "source");
3974 
3975  $si->setOptions(array_merge(
3976  array("" => "-- ".$lng->txt("please_select")." --"),
3977  $clientlistarray));
3978  $si->setRequired(true);
3979  $this->form->addItem($si);
3980 
3981  $cb = new ilCheckboxInputGUI($lng->txt("clone_areyousure"), "iamsure");
3982  $cb->setRequired(true);
3983  $this->form->addItem($cb);
3984 
3985  $this->form->addCommandButton("cloneSaveSource", $lng->txt("cloneit"));
3986  } else {
3987  $disabledmessage = "<h1>" . $this->lng->txt("clone_disabledmessage") ."</h1><br>";
3988  if (!$this->setup->getClient()->status["access"]["status"] === false) {
3989  $disabledmessage .= $this->lng->txt("clone_clientnotdisabled") . "<br>";
3990  }
3991  if (!stripos($this->setup->getClient()->getName(),"aster") === false) {
3992  $disabledmessage .= $this->lng->txt("clone_clientismaster") . "<br>";
3993  }
3994  if ($this->setup->getClient()->getdbType() != "mysql") {
3995  $disabledmessage .= $this->lng->txt("clone_clientisnotmysql") . "<br>";
3996  }
3997  if (!$this->setup->getClient()->db_exists) {
3998  $disabledmessage .= $this->lng->txt("clone_clientnodatabase") . "<br>";
3999  }
4000  $this->form->setTitle($disabledmessage);
4001  }
4002  }
4003 
4004  function cloneSelectSource() {
4005 
4006  if (!$this->setup->isAdmin())
4007  {
4008  return;
4009  }
4010 
4011  $this->cloneInitForm();
4012  $this->form->setValuesByPost();
4013  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_clone"));
4014  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4015  }
4016 
4017  function cloneSaveSource()
4018  {
4019  global $lng, $ilCtrl;
4020 
4021  if (!$this->setup->isAdmin())
4022  {
4023  return;
4024  }
4025 
4026  $this->cloneInitForm();
4027 
4028  if ($this->form->checkInput())
4029  {
4030  if ($this->form->getInput("iamsure") != "1")
4031  {
4032  $message = $this->lng->txt("clone_youmustcheckiamsure");
4033  $this->setup->raiseError($message,$this->setup->error_obj->MESSAGE);
4034  }
4035  if (!$this->setup->cloneFromSource($this->form->getInput("source")))
4036  {
4037  $message = $this->lng->txt("clone_error");
4038  $this->setup->raiseError($message . " -> " . $this->setup->error,$this->setup->error_obj->MESSAGE);
4039  }
4040 
4041  ilUtil::sendInfo($this->lng->txt("client_cloned"),true);
4042  // ilUtil::redirect("setup.php");
4043  }
4044  $this->form->setValuesByPost();
4045  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_clone"));
4046  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4047  }
4048 
4049  public function displayProxy($a_omit_init = false)
4050  {
4051  $this->checkDisplayMode("proxy");
4052  $settings = $this->setup->getClient()->getAllSettings();
4053 
4054  if (!$a_omit_init)
4055  {
4056  include_once("./Services/Administration/classes/class.ilSetting.php");
4057  $this->initProxyForm();
4058  $this->form->setValuesByArray(array(
4059  'proxy_status' => (bool)$settings['proxy_status'],
4060  'proxy_host' => $settings['proxy_host'],
4061  'proxy_port' => $settings['proxy_port']
4062  ));
4063  if((bool)$settings['proxy_status'])
4064  {
4065  $this->setup->printProxyStatus($this->setup->client);
4066  }
4067  }
4068  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4069  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_proxy"));
4070 
4071 
4072  $check = $this->setup->checkClientProxySettings($this->setup->client);
4073 
4074  $this->setup->getClient()->status["proxy"]["status"] = $check["status"];
4075  $this->setup->getClient()->status["proxy"]["comment"] = $check["comment"];
4076  $this->setup->getClient()->status["proxy"]["text"] = $check["comment"];
4077 
4078  if ($check["status"])
4079  {
4080  $this->setButtonNext("nic");
4081  }
4082 
4083  $this->setButtonPrev("contact");
4084  $this->checkPanelMode();
4085  }
4086  private function initProxyForm()
4087  {
4088  global $lng;
4089 
4090  include_once('Services/Form/classes/class.ilPropertyFormGUI.php');
4091  $this->form = new ilPropertyFormGUI();
4092  $this->form->setFormAction("setup.php?cmd=gateway");
4093 
4094  // Proxy status
4095  $proxs = new ilCheckboxInputGUI($lng->txt('proxy_status'), 'proxy_status');
4096  $proxs->setInfo($lng->txt('proxy_status_info'));
4097  $proxs->setValue(1);
4098  $this->form->addItem($proxs);
4099 
4100  // Proxy availability
4101  $proxa = new ilCustomInputGUI('', 'proxy_availability');
4102  $proxs->addSubItem($proxa);
4103 
4104  // Proxy
4105  $prox = new ilTextInputGUI($lng->txt('proxy_host'), 'proxy_host');
4106  $prox->setInfo($lng->txt('proxy_host_info'));
4107  $proxs->addSubItem($prox);
4108 
4109  // Proxy Port
4110  $proxp = new ilTextInputGUI($lng->txt('proxy_port'), 'proxy_port');
4111  $proxp->setInfo($lng->txt('proxy_port_info'));
4112  $proxp->setSize(10);
4113  $proxp->setMaxLength(10);
4114  $proxs->addSubItem($proxp);
4115 
4116  // save and cancel commands
4117  $this->form->addCommandButton('saveProxy', $lng->txt('save'));
4118  }
4119 
4127  public function saveProxy()
4128  {
4129  global $lng;
4130 
4131  $this->initProxyForm();
4132  $isFormValid = $this->form->checkInput();
4133 
4134  $new_settings['proxy_status'] = (int)$this->form->getInput('proxy_status');
4135  $new_settings['proxy_host'] = trim($this->form->getInput('proxy_host'));
4136  $new_settings['proxy_port'] = trim($this->form->getInput('proxy_port'));
4137 
4138  if($isFormValid)
4139  {
4140  if($new_settings['proxy_status'] == true)
4141  {
4142  if(!strlen($new_settings['proxy_host']))
4143  {
4144  $isFormValid = false;
4145  $this->form->getItemByPostVar('proxy_host')->setAlert($lng->txt('msg_input_is_required'));
4146  }
4147  if(!strlen($new_settings['proxy_port']))
4148  {
4149  $isFormValid = false;
4150  $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('msg_input_is_required'));
4151  }
4152  if(!preg_match('/[0-9]{1,}/', $new_settings['proxy_port']) ||
4153  $new_settings['proxy_port'] < 0 ||
4154  $new_settings['proxy_port'] > 65535)
4155  {
4156  $isFormValid = false;
4157  $this->form->getItemByPostVar('proxy_port')->setAlert($lng->txt('proxy_port_numeric'));
4158  }
4159  }
4160 
4161  if($isFormValid)
4162  {
4163  $this->setup->saveProxySettings($new_settings);
4164 
4165  ilUtil::sendSuccess($lng->txt('saved_successfully'));
4166  $settings = $this->setup->getClient()->getAllSettings();
4167  if($settings['proxy_status'] == true)
4168  {
4169  $this->setup->printProxyStatus($this->setup->client);
4170  }
4171  }
4172  else
4173  {
4174  ilUtil::sendFailure($lng->txt('form_input_not_valid'));
4175  }
4176  }
4177 
4178  $this->form->setValuesByPost();
4179  $this->tpl->setVariable("SETUP_CONTENT", $this->form->getHTML());
4180 
4181 
4182  $this->displayProxy(true);
4183  }
4184 } // END class.ilSetupGUI
4185 ?>