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