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