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