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