ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilSetupGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 require_once "class.ilSetup.php";
34 
35 class ilSetupGUI extends ilSetup
36 {
37  var $tpl; // template object
38  var $lng; // language objet
39  var $log; // log object
40 
41  var $btn_prev_on = false; // toggle previous button on/off
42  var $btn_prev_cmd; // command processed when previous button was clicked
43  var $btn_prev_lng; // previous button label
44 
45  var $btn_next_on = false; // toggle NEXT button on/off
46  var $btn_next_cmd; // command processed when next button was clicked
47  var $btn_next_lng; // next button label
48 
49  var $revision; // cvs revision of this script
50  var $version; // cvs version of this script
51  var $lang; // current language (lang_key)
52 
53  var $cmd; // command variable
54  var $display_mode = "view"; // view mode (setup or details)
55 
60  function ilSetupGUI()
61  {
62  global $tpl, $lng;
63 
64  $this->tpl =& $tpl;
65  $this->lng =& $lng;
66 
67  // CVS - REVISION - DO NOT MODIFY
68  $this->revision = '$Revision: 17651 $';
69  $this->version = "2 ".substr(substr($this->revision,1),0,-2);
70  $this->lang = $this->lng->lang_key;
71 
72  // init setup
73  $this->ilSetup($_SESSION["auth"],$_SESSION["access_mode"]);
74 
75  // init client object if exists
76  $client_id = ($_GET["client_id"]) ? $_GET["client_id"] : $_SESSION["ClientId"];
77 
78  // for security
79  if (!$this->isAdmin() and $client_id != $_SESSION["ClientId"])
80  {
81  $client_id = $_SESSION["ClientId"];
82  }
83 
84  $this->ini_client_exists = $this->newClient($client_id);
85  $this->client->status = $this->getStatus();
86 
87  // determine command
88  if (($this->cmd = $_GET["cmd"]) == "gateway")
89  {
90  // surpress warning if POST is not set
91  @$this->cmd = key($_POST["cmd"]);
92  }
93 
94  // determine display mode here
95  // TODO: depending on previous setting (session)
96  // OR switch to 'setup'-mode if someone logs in as client and client's setup wasn't finished (-> entry in settings table does not exist)
97  if ($this->isAuthenticated() and !$this->client->status["finish"]["status"] and $this->cmd != "clientlist" and $this->cmd != "")
98  {
99  $this->setDisplayMode("setup");
100  }
101  else
102  {
103  $this->setDisplayMode($_SESSION["display_mode"]);
104  }
105 
106  // output starts here
107 
108  // display header
109  $this->displayHeader();
110 
111  // main cmd handling
112  if (!$this->isAuthenticated() or !$this->isInstalled())
113  {
114  // check for first time installation or migrate an old one first
115  if (!$this->isInstalled() or !($this->ini->readVariable("clients","path")))
116  {
117  $this->cmdInstall();
118  }
119  else
120  {
121  $this->displayLogin();
122  }
123  }
124  else
125  {
126  if ($this->isAdmin())
127  {
128  $this->cmdAdmin();
129  }
130  else
131  {
132  $this->cmdClient();
133  }
134  }
135 
136  if (DEBUG)
137  {
138  echo "cmd: ".$this->cmd." | access: ".$this->access_mode." | display: ".$this->display_mode;
139  var_dump($this->client->status);
140  }
141 
142  // display footer
143  $this->displayFooter();
144 
145  // end output
146 
147  } // end constructor
148 
149  // cmd subsets
150 
154  function cmdInstall()
155  {
156  switch ($this->cmd)
157  {
158  case NULL:
159  case "preliminaries":
160  $this->checkPreliminaries();
161  $this->displayPreliminaries();
162  break;
163 
164  case "install":
165  $this->displayMasterSetup();
166  break;
167 
168  case "determineToolsPathInstall":
169  $this->determineToolsPathInstall();
170  break;
171 
172  default:
173  $this->displayError($this->lng->txt("unknown_command"));
174  break;
175  }
176  }
177 
181  function cmdAdmin()
182  {
183  switch ($this->cmd)
184  {
185  case NULL:
186  case "clientlist":
187  $this->setDisplayMode("view");
188  $this->displayClientList();
189  break;
190 
191  case "changepassword":
192  $this->setDisplayMode("view");
193  $this->changeMasterPassword();
194  break;
195 
196  case "mastersettings":
197  $this->setDisplayMode("view");
198  $this->changeMasterSettings();
199  break;
200 
201  case "determineToolsPath":
202  $this->setDisplayMode("view");
203  $this->determineToolsPath();
204  break;
205 
206  case "changedefault":
207  $this->changeDefaultClient();
208  break;
209 
210  case "newclient":
211  $this->cmd = "ini";
212  $this->setDisplayMode("setup");
213  $this->ini_client_exists = $this->newClient();
214  $this->displayIni();
215  break;
216 
217  case "startup":
218  $this->setDisplayMode("setup");
219  $this->ini_client_exists = $this->newClient();
220  $this->displayStartup();
221  break;
222 
223  case "delete":
224  $this->setDisplayMode("view");
225  $this->displayDeleteConfirmation();
226  break;
227 
228  case "togglelist":
229  $this->setDisplayMode("view");
230  $this->toggleClientList();
231  break;
232 
233  case "preliminaries":
234  $this->checkPreliminaries();
235  $this->displayPreliminaries();
236  break;
237 
238  default:
239  $this->cmdClient();
240  break;
241  }
242  }
243 
247  function cmdClient()
248  {
249  switch ($this->cmd)
250  {
251  case NULL:
252  case "view":
253  if ($this->client->db_installed)
254  {
255  $this->setDisplayMode("view");
256  $this->displayClientOverview();
257  }
258  else
259  {
260  $this->cmd = "db";
261  $this->displayDatabase();
262  }
263  break;
264 
265  case "ini":
266  // only allow access to ini if db does not exist yet
267  //if ($this->client->db_installed)
268  //{
269  // $this->cmd = "db";
270  // $this->displayDatabase();
271  //}
272  //else
273  //{
274  $this->displayIni();
275  //}
276  break;
277 
278  case "db":
279  $this->displayDatabase();
280  break;
281 
282  case "lang":
283  if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->error === true)
284  {
286  }
287  else
288  {
289  $this->displayLanguages();
290  }
291  break;
292 
293  case "contact":
294  if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "contact")
295  {
297  }
298  else
299  {
300  $this->displayContactData();
301  }
302  break;
303 
304  case "nic":
305  if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "nic")
306  {
308  }
309  else
310  {
311  $this->displayNIC();
312  }
313  break;
314 
315  case "finish":
316  if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "finish")
317  {
319  }
320  else
321  {
322  $this->displayFinishSetup();
323  }
324  break;
325 
326  case "changeaccess":
327  $this->changeAccessMode($_GET["back"]);
328  break;
329 
330  case "logout":
331  $this->displayLogout();
332  break;
333 
334  case "login":
335  session_destroy();
336  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
337  break;
338 
339  case "login_new":
340  if ($this->client->ini->readVariable("client","access") != "1")
341  {
342  $this->client->ini->setVariable("client","access","1");
343  $this->client->ini->write();
344  }
345 
346  session_destroy();
347  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
348  break;
349 
350  case "tools":
351  $this->displayTools();
352  break;
353 
354  case "reloadStructure":
355  $this->reloadControlStructure();
356  break;
357 
358  default:
359  $this->displayError($this->lng->txt("unknown_command"));
360  break;
361  }
362  }
363 
364  // end cmd subsets
365 
370  {
371  $this->checkDisplayMode();
372 
373  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.client_overview.html");
374 
375  if ($this->client->db_installed)
376  {
377  $settings = $this->client->getAllSettings();
378  }
379 
380  $txt_no_database = $this->lng->txt("no_database");
381 
382  $access_status = ($this->client->status["access"]["status"]) ? "online" : "disabled";
383  $access_button = ($this->client->status["access"]["status"]) ? "disable" : "enable";
384  $access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->client->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
385 
386  // basic data
387  $this->tpl->setVariable("TXT_BASIC_DATA", $this->lng->txt("client_info"));
388  $this->tpl->setVariable("TXT_INST_NAME", $this->lng->txt("inst_name"));
389  $this->tpl->setVariable("TXT_INST_ID", $this->lng->txt("ilias_nic_id"));
390  $this->tpl->setVariable("TXT_CLIENT_ID2", $this->lng->txt("client_id"));
391  $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("db_version"));
392  $this->tpl->setVariable("TXT_ACCESS_STATUS", $this->lng->txt("access_status"));
393 
394  $this->tpl->setVariable("TXT_SERVER_DATA", $this->lng->txt("server_info"));
395  $this->tpl->setVariable("TXT_ILIAS_VERSION", $this->lng->txt("ilias_version"));
396  $this->tpl->setVariable("TXT_HOSTNAME", $this->lng->txt("host"));
397  $this->tpl->setVariable("TXT_IP_ADDRESS", $this->lng->txt("ip_address"));
398  $this->tpl->setVariable("TXT_SERVER_PORT", $this->lng->txt("port"));
399  $this->tpl->setVariable("TXT_SERVER_SOFTWARE", $this->lng->txt("server_software"));
400  $this->tpl->setVariable("TXT_HTTP_PATH", $this->lng->txt("http_path"));
401  $this->tpl->setVariable("TXT_ABSOLUTE_PATH", $this->lng->txt("absolute_path"));
402  $this->tpl->setVariable("TXT_DEFAULT_LANGUAGE", $this->lng->txt("default_language"));
403  $this->tpl->setVariable("TXT_FEEDBACK_RECIPIENT", $this->lng->txt("feedback_recipient"));
404  $this->tpl->setVariable("TXT_ERROR_RECIPIENT", $this->lng->txt("error_recipient"));
405 
406  // paths
407  $this->tpl->setVariable("TXT_SOFTWARE", $this->lng->txt("3rd_party_software"));
408  $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("path_to_convert"));
409  $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("path_to_zip"));
410  $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("path_to_unzip"));
411  $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("path_to_java"));
412  $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("path_to_htmldoc"));
413  $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
414  $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
415  $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
416  $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
417 
418  // display formula data
419 
420  // client data
421  $this->tpl->setVariable("INST_ID",($this->client->db_installed) ? $settings["inst_id"] : $txt_no_database);
422  $this->tpl->setVariable("CLIENT_ID2",$this->client->getId());
423  $this->tpl->setVariable("INST_NAME",($this->client->getName()) ? $this->client->getName() : "&lt;".$this->lng->txt("no_client_name")."&gt;");
424  $this->tpl->setVariable("INST_INFO",$this->client->getDescription());
425  $this->tpl->setVariable("DB_VERSION",($this->client->db_installed) ? $settings["db_version"] : $txt_no_database);
426  $this->tpl->setVariable("ACCESS_STATUS",$this->lng->txt($access_status).$access_link);
427 
428  // server data
429  $this->tpl->setVariable("HTTP_PATH",ILIAS_HTTP_PATH);
430  $this->tpl->setVariable("ABSOLUTE_PATH",ILIAS_ABSOLUTE_PATH);
431  $this->tpl->setVariable("HOSTNAME", $_SERVER["SERVER_NAME"]);
432  $this->tpl->setVariable("SERVER_PORT", $_SERVER["SERVER_PORT"]);
433  $this->tpl->setVariable("SERVER_ADMIN", $_SERVER["SERVER_ADMIN"]); // not used
434  $this->tpl->setVariable("SERVER_SOFTWARE", $_SERVER["SERVER_SOFTWARE"]);
435  $this->tpl->setVariable("IP_ADDRESS", $_SERVER["SERVER_ADDR"]);
436  $this->tpl->setVariable("ILIAS_VERSION", ILIAS_VERSION);
437 
438  $this->tpl->setVariable("FEEDBACK_RECIPIENT",($this->client->db_installed) ? $settings["feedback_recipient"] : $txt_no_database);
439  $this->tpl->setVariable("ERROR_RECIPIENT",($this->client->db_installed) ? $settings["error_recipient"] : $txt_no_database);
440 
441  // paths to tools
442  $not_set = $this->lng->txt("path_not_set");
443 
444  $convert = $this->ini->readVariable("tools","convert");
445  $zip = $this->ini->readVariable("tools","zip");
446  $unzip = $this->ini->readVariable("tools","unzip");
447  $java = $this->ini->readVariable("tools","java");
448  $htmldoc = $this->ini->readVariable("tools","htmldoc");
449  $latex = $this->ini->readVariable("tools", "latex");
450  $vscan = $this->ini->readVariable("tools","vscantype");
451  $scancomm = $this->ini->readVariable("tools","scancommand");
452  $cleancomm = $this->ini->readVariable("tools","cleancommand");
453 
454  $this->tpl->setVariable("CONVERT_PATH",($convert) ? $convert : $not_set);
455  $this->tpl->setVariable("ZIP_PATH",($zip) ? $zip : $not_set);
456  $this->tpl->setVariable("UNZIP_PATH",($unzip) ? $unzip : $not_set);
457  $this->tpl->setVariable("JAVA_PATH",($java) ? $java : $not_set);
458  $this->tpl->setVariable("HTMLDOC_PATH",($htmldoc) ? $htmldoc : $not_set);
459  $this->tpl->setVariable("LATEX_URL",($latex) ? $latex : $not_set);
460  $this->tpl->setVariable("VAL_SCAN_COMMAND",($scancomm) ? $scancomm : $not_set);
461  $this->tpl->setVariable("VAL_CLEAN_COMMAND",($cleancomm) ? $cleancomm : $not_set);
462  $this->tpl->setVariable("VAL_VIRUS_SCANNER",($vscan) ? $vscan : $not_set);
463 
464  $this->tpl->parseCurrentBlock();
465 
466  $this->displayStatusPanel();
467  }
468 
477  function setDisplayMode($a_mode)
478  {
479  // security
480  if ($a_mode != "view" and $a_mode != "setup")
481  {
482  return false;
483  }
484 
485  $this->display_mode = $a_mode;
486  $_SESSION["display_mode"] = $this->display_mode;
487 
488  return true;
489  }
490 
494  function displayHeader()
495  {
496  $languages = $this->lng->getLanguages();
497 
498  $count = (int) round(count($languages) / 2);
499  $num = 1;
500 
501  foreach ($languages as $lang_key)
502  {
503  if ($num === $count)
504  {
505  $this->tpl->touchBlock("lng_new_row");
506  }
507 
508  $this->tpl->setCurrentBlock("languages");
509  $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
510  $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
511  $this->tpl->setVariable("LANG_ICON", $lang_key);
512  $this->tpl->setVariable("LANG_KEY", $lang_key);
513  $this->tpl->setVariable("BORDER", 0);
514  $this->tpl->setVariable("VSPACE", 0);
515  $this->tpl->parseCurrentBlock();
516 
517  $num++;
518  }
519 
520  if (count($languages) % 2)
521  {
522  $this->tpl->touchBlock("lng_empty_cell");
523  }
524 
525  if ($this->cmd != "logout" and $this->isInstalled())
526  {
527  // add client link
528  if ($this->isAdmin())
529  {
530  if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
531  {
532  $this->tpl->setCurrentBlock("add_client");
533  $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
534  $this->tpl->parseCurrentBlock();
535  }
536 
537  // client list link
538  $this->tpl->setCurrentBlock("display_list");
539  $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
540  $this->tpl->parseCurrentBlock();
541 
542  // edit paths link
543  $this->tpl->setCurrentBlock("edit_pathes");
544  $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
545  $this->tpl->parseCurrentBlock();
546 
547  // preliminaries
548  $this->tpl->setCurrentBlock("preliminaries");
549  $this->tpl->setVariable("TXT_PRELIMINARIES",$this->lng->txt("preliminaries"));
550  $this->tpl->parseCurrentBlock();
551 
552  // change password link
553  $this->tpl->setCurrentBlock("change_password");
554  $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
555  $this->tpl->parseCurrentBlock();
556  }
557 
558  // logout link
559  if ($this->isAuthenticated())
560  {
561  $this->tpl->setCurrentBlock("logout");
562  $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
563  $this->tpl->parseCurrentBlock();
564  }
565  }
566 
567  $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
568  $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
569  $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
570  $this->tpl->setVariable("PAGETITLE","Setup");
571  //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
572  $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
573  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","../templates/default/delos_cont.css");
574  $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
575  $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
576  $this->tpl->setVariable("VERSION", $this->version);
577  $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
578  $this->tpl->setVariable("LANG", $this->lang);
579  }
580 
584  function displayFooter()
585  {
586  // footer (not really)
587  if ($this->cmd != "logout")
588  {
589  if ($this->ini_ilias_exists and $this->display_mode == "setup" and $this->client->getId() != "")
590  {
591  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->client->getId().")");
592  }
593  elseif ($this->isAdmin())
594  {
595  $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
596  }
597 
598  $this->displayNavButtons();
599  }
600 
601  $this->tpl->show();
602  }
603 
609  function displayNavButtons()
610  {
611  if (!$this->btn_prev_on and !$this->btn_next_on)
612  {
613  return false;
614  }
615 
616  $this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html");
617 
618  $this->tpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
619 
620  if ($this->btn_prev_on)
621  {
622  $this->tpl->setCurrentBlock("btn_back");
623  $this->tpl->setVariable("TXT_PREV", $this->btn_prev_lng);
624  $this->tpl->setVariable("CMD_PREV", $this->btn_prev_cmd);
625  $this->tpl->parseCurrentBlock();
626  }
627 
628  if ($this->btn_next_on)
629  {
630  $this->tpl->setCurrentBlock("btn_forward");
631  $this->tpl->setVariable("TXT_NEXT", $this->btn_next_lng);
632  $this->tpl->setVariable("CMD_NEXT", $this->btn_next_cmd);
633  $this->tpl->parseCurrentBlock();
634  }
635 
636  return true;
637  }
638 
645  function SetButtonPrev($a_cmd = 0,$a_lng = 0)
646  {
647  $this->btn_prev_on = true;
648  $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
649  $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : "<<&nbsp;&nbsp;&nbsp;".$this->lng->txt("prev");
650  }
651 
658  function SetButtonNext($a_cmd,$a_lng = 0)
659  {
660  $this->btn_next_on = true;
661  $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
662  $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next")."&nbsp;&nbsp;&nbsp;>>";
663  }
664 
669  {
670  $OK = "<font color=\"green\"><strong>OK</strong></font>";
671  $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
672 
673  $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html");
674 
675  $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
676  $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
677  $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
678  $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
679  $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
680  $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));
681  $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));
682 
683  $server_os = php_uname();
684  $server_web = $_SERVER["SERVER_SOFTWARE"];
685  $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
686 
687  if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
688  {
689  $env_comment = $this->lng->txt("env_ok");
690  }
691  else
692  {
693  $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
694  }
695 
696  $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
697  $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
698  $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);
699 
700  $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
701  $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
702 
703  $preliminaries = array("php", "mysql", "root", "folder_create",
704  "cookies_enabled", "dom", "xsl", "gd", "memory");
705  foreach ($preliminaries as $preliminary)
706  {
707  $this->tpl->setCurrentBlock("preliminary");
708  $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_".$preliminary));
709  if ($this->preliminaries_result[$preliminary]["status"] == true)
710  {
711  $this->tpl->setVariable("STATUS_PRE", $OK);
712  }
713  else
714  {
715  $this->tpl->setVariable("STATUS_PRE", $FAILED);
716  }
717  $this->tpl->setVariable("COMMENT_PRE", $this->preliminaries_result[$preliminary]["comment"]);
718  $this->tpl->parseCurrentBlock();
719  }
720 
721  // summary
722  if ($this->preliminaries === true)
723  {
724  if ($this->isInstalled())
725  {
726  $cmd = "mastersettings";
727  }
728  else
729  {
730  $cmd = "install";
731  }
732  $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
733 //echo "-".$this->display_mode."-";
734  $this->setButtonNext($cmd,$btn_text);
735  }
736  else
737  {
738  $this->tpl->setCurrentBlock("premessage");
739  $this->tpl->setVariable("TXT_PRE_ERR", sprintf($this->lng->txt("pre_error"),
740  "http://www.ilias.de/docu/goto.php?target=pg_6531_367&client_id=docu"));
741  $this->tpl->parseCurrentBlock();
742  }
743  }
744 
748  function displayMasterSetup($a_det = false)
749  {
750  if ($_POST["form"])
751  {
752  if (!$this->checkDataDirSetup($_POST["form"]))
753  {
754  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
755  }
756 
757  if (!$this->checkLogSetup($_POST["form"]))
758  {
759  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
760  }
761 
762  if ($a_det)
763  {
764  $_POST["form"] = $this->determineTools($_POST["form"]);
765  }
766 
767  /*if (!$this->checkToolsSetup($_POST["form"]))
768  {
769  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
770  }*/
771 
772  if (!$this->checkPasswordSetup($_POST["form"]))
773  {
774  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
775  }
776 
777  if (!$this->saveMasterSetup($_POST["form"]))
778  {
779  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
780  }
781 
782  ilUtil::sendInfo($this->lng->txt("settings_saved"),true);
783 
784  ilUtil::redirect("setup.php?cmd=mastersettings");
785  }
786 
787  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
788 
789  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_mastersetup.html");
790 
791  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
792 
793  // for checkboxes & radio buttons
794  $checked = "checked=\"checked\"";
795 
796  // general
797  $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("dsfsdave"));
798  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
799  $this->tpl->setVariable("SUBMIT_CMD", "install");
800  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
801  $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("enter_dir_and_filename"));
802  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
803 
804 
805  if ($this->safe_mode)
806  {
807  $this->tpl->setVariable("SAFE_MODE_STYLE", " class=\"message\" ");
808  $this->tpl->setVariable("TXT_SAFE_MODE_INFO", $this->lng->txt("safe_mode_enabled"));
809  }
810  else
811  {
812  $this->tpl->setVariable("TXT_SAFE_MODE_INFO", "");
813  }
814 
815  // determine ws data directory
816  $cwd = getcwd();
817  chdir("..");
818  $data_dir_ws = getcwd()."/data";
819  chdir($cwd);
820 
821  // datadir
822  $this->tpl->setCurrentBlock("setup_datadir");
823  $this->tpl->setVariable("TXT_DATADIR_TITLE", $this->lng->txt("data_directories"));
824  $this->tpl->setVariable("TXT_DATADIR_PATH_IN_WS", $this->lng->txt("data_directory_in_ws"));
825  $this->tpl->setVariable("TXT_DATADIR_PATH_IN_WS_INFO", $this->lng->txt("data_directory_in_ws_info"));
826  $this->tpl->setVariable("TXT_DATADIR_PATH_INFO", $this->lng->txt("data_directory_info"));
827  $this->tpl->setVariable("DATADIR_IN_WS", $data_dir_ws);
828  $this->tpl->setVariable("TXT_DATADIR_PATH", $this->lng->txt("data_directory_outside_ws"));
829  $this->tpl->setVariable("TXT_DATADIR_COMMENT1", $this->lng->txt("datadir_path_comment1"));
830  $this->tpl->setVariable("TXT_CREATE", $this->lng->txt("create_directory"));
831  // values
832  //echo $this->ini->readVariable($this->ini->readVariable("server","presetting"),"data_dir");
833  if ($_SESSION["error_post_vars"]["form"])
834  {
835  $this->tpl->setVariable("DATADIR_PATH", $_SESSION["error_post_vars"]["form"]["datadir_path"]);
836  }
837  elseif ($this->ini->readVariable("server","presetting") != "")
838  {
839  $this->tpl->setVariable("DATADIR_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"data_dir"));
840  }
841 
842 
843 
844  //$chk_datadir_path = ($_SESSION["error_post_vars"]["form"]["chk_datadir_path"]) ? "CHK_DATADIR_PATH_TARGET" : "CHK_DATADIR_PATH_CREATE";
845  $chk_datadir_path = ($_SESSION["error_post_vars"]["form"]["chk_datadir_path"]) ? $checked : "";
846  $this->tpl->setVariable("CHK_DATADIR_PATH",$chk_datadir_path);
847  $this->tpl->parseCurrentBlock();
848 
849  // logging
850  $this->tpl->setCurrentBlock("setup_log");
851  $this->tpl->setVariable("TXT_LOG_TITLE", $this->lng->txt("logging"));
852  $this->tpl->setVariable("TXT_LOG_PATH", $this->lng->txt("log_path"));
853  $this->tpl->setVariable("TXT_LOG_COMMENT", $this->lng->txt("log_path_comment"));
854  $this->tpl->setVariable("TXT_DISABLE_LOGGING", $this->lng->txt("disable_logging"));
855 
856  // values
857  if ($_SESSION["error_post_vars"]["form"])
858  {
859  $this->tpl->setVariable("LOG_PATH", $_SESSION["error_post_vars"]["form"]["log_path"]);
860  }
861  elseif ($this->ini->readVariable("server","presetting") != "")
862  {
863  $this->tpl->setVariable("LOG_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"log"));
864  }
865 
866  $chk_log_path = ($_SESSION["error_post_vars"]["form"]["chk_log_status"]) ? $checked : "";
867  $this->tpl->setVariable("CHK_LOG_STATUS",$chk_log_path);
868  $this->tpl->parseCurrentBlock();
869 
870  // tools
871  $this->tpl->setCurrentBlock("setup_tools");
872  $this->tpl->setVariable("TXT_DISABLE_CHECK", $this->lng->txt("disable_check"));
873  $this->tpl->setVariable("TXT_REQ_TOOLS_TITLE", $this->lng->txt("3rd_party_software_req"));
874  $this->tpl->setVariable("TXT_OPT_TOOLS_TITLE", $this->lng->txt("3rd_party_software_opt"));
875  $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("convert_path"));
876  $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("zip_path"));
877  $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("unzip_path"));
878  $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("java_path"));
879  $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("htmldoc_path"));
880  $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
881 
882  $this->tpl->setVariable("TXT_CONVERT_COMMENT", $this->lng->txt("convert_path_comment"));
883  $this->tpl->setVariable("TXT_ZIP_COMMENT", $this->lng->txt("zip_path_comment"));
884  $this->tpl->setVariable("TXT_UNZIP_COMMENT", $this->lng->txt("unzip_path_comment"));
885  $this->tpl->setVariable("TXT_JAVA_COMMENT", $this->lng->txt("java_path_comment"));
886  $this->tpl->setVariable("TXT_HTMLDOC_COMMENT", $this->lng->txt("htmldoc_path_comment"));
887  $this->tpl->setVariable("TXT_LATEX_URL_COMMENT", $this->lng->txt("latex_url_comment"));
888 
889  // values
890  if ($_SESSION["error_post_vars"]["form"])
891  {
892  $this->tpl->setVariable("CONVERT_PATH", $_SESSION["error_post_vars"]["form"]["convert_path"]);
893  $this->tpl->setVariable("ZIP_PATH", $_SESSION["error_post_vars"]["form"]["zip_path"]);
894  $this->tpl->setVariable("UNZIP_PATH", $_SESSION["error_post_vars"]["form"]["unzip_path"]);
895  $this->tpl->setVariable("JAVA_PATH", $_SESSION["error_post_vars"]["form"]["java_path"]);
896  $this->tpl->setVariable("HTMLDOC_PATH", $_SESSION["error_post_vars"]["form"]["htmldoc_path"]);
897  $this->tpl->setVariable("LATEX_URL", $_SESSION["error_post_vars"]["form"]["latex_url"]);
898  }
899  elseif ($this->ini->readVariable("server","presetting") != "")
900  {
901  $this->tpl->setVariable("CONVERT_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"convert"));
902  $this->tpl->setVariable("ZIP_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"zip"));
903  $this->tpl->setVariable("UNZIP_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"unzip"));
904  $this->tpl->setVariable("JAVA_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"java"));
905  $this->tpl->setVariable("HTMLDOC_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"htmldoc"));
906  $this->tpl->setVariable("LATEX_URL", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"latex"));
907  }
908  else
909  {
910  $det = $this->determineTools();
911  $this->tpl->setVariable("CONVERT_PATH", $det["convert_path"]);
912  $this->tpl->setVariable("ZIP_PATH", $det["zip_path"]);
913  $this->tpl->setVariable("UNZIP_PATH", $det["unzip_path"]);
914  $this->tpl->setVariable("JAVA_PATH", $det["java_path"]);
915  }
916 
917  $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
918  $this->tpl->setVariable("TXT_NONE", $this->lng->txt("none"));
919  $this->tpl->setVariable("TXT_SOPHOS", $this->lng->txt("sophos"));
920  $this->tpl->setVariable("TXT_ANTIVIR", $this->lng->txt("antivir"));
921  $this->tpl->setVariable("TXT_CLAMAV", $this->lng->txt("clamav"));
922  $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
923  $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
924 
925 
926  $chk_convert_path = ($_SESSION["error_post_vars"]["form"]["chk_convert_path"]) ? $checked : "";
927  $chk_zip_path = ($_SESSION["error_post_vars"]["form"]["chk_zip_path"]) ? $checked : "";
928  $chk_unzip_path = ($_SESSION["error_post_vars"]["form"]["chk_unzip_path"]) ? $checked : "";
929  $chk_java_path = ($_SESSION["error_post_vars"]["form"]["chk_java_path"]) ? $checked : "";
930  $chk_htmldoc_path = ($_SESSION["error_post_vars"]["form"]["chk_htmldoc_path"]) ? $checked : "";
931  $chk_latex_url = ($_SESSION["error_post_vars"]["form"]["chk_latex_url"]) ? $checked : "";
932 
933  $this->tpl->setVariable("CHK_CONVERT_PATH", $chk_convert_path);
934  $this->tpl->setVariable("CHK_ZIP_PATH", $chk_zip_path);
935  $this->tpl->setVariable("CHK_UNZIP_PATH", $chk_unzip_path);
936  $this->tpl->setVariable("CHK_JAVA_PATH", $chk_java_path);
937  $this->tpl->setVariable("CHK_HTMLDOC_PATH", $chk_htmldoc_path);
938  $this->tpl->setVariable("CHK_LATEX_URL", $chk_latex_url);
939  $this->tpl->parseCurrentBlock();
940 
941  // setup password
942  $this->tpl->setCurrentBlock("setup_pass");
943  $this->tpl->setVariable("TXT_SETUP_PASS_TITLE", $this->lng->txt("setup_pass_title"));
944  $this->tpl->setVariable("TXT_SETUP_PASS_COMMENT", $this->lng->txt("password_info"));
945  $this->tpl->setVariable("TXT_SETUP_PASS", $this->lng->txt("setup_pass"));
946  $this->tpl->setVariable("TXT_SETUP_PASS2", $this->lng->txt("setup_pass2"));
947  // values
948  $this->tpl->setVariable("SETUP_PASS", $_SESSION["error_post_vars"]["form"]["setup_pass"]);
949  $this->tpl->setVariable("SETUP_PASS2", $_SESSION["error_post_vars"]["form"]["setup_pass2"]);
950  $this->tpl->parseCurrentBlock();
951 
952  $this->setButtonPrev("preliminaries");
953 
954  if ($this->isInstalled())
955  {
956  $this->setButtonNext("list");
957  }
958  }
959 
963  function loginClient()
964  {
965  session_destroy();
966 
967  ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
968  }
969 
973  function displayLogin()
974  {
975  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
976 
977  if ($_POST["form"])
978  {
979  // first check client login
980  if (empty($_POST["form"]["admin_password"]))
981  {
982  if (!$this->loginAsClient($_POST["form"]))
983  {
984  if ($error_msg = $this->getError())
985  {
986  $this->raiseError($this->lng->txt($error_msg),$this->error_obj->MESSAGE);
987  }
988  }
989  }
990  else
991  {
992  if (!$this->loginAsAdmin($_POST["form"]["admin_password"]))
993  {
994  $this->raiseError($this->lng->txt("login_invalid"),$this->error_obj->MESSAGE);
995  }
996  }
997 
998  ilUtil::redirect("setup.php");
999  }
1000 
1001  // output
1002  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_login.html");
1003  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1004  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_login"));
1005 
1006  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_login"));
1007 
1008  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
1009  $this->tpl->setVariable("TXT_CLIENT_LOGIN",$this->lng->txt("client_login"));
1010  $this->tpl->setVariable("TXT_CLIENT_ID",$this->lng->txt("client_id"));
1011  $this->tpl->setVariable("TXT_USERNAME",ucfirst($this->lng->txt("username")));
1012  $this->tpl->setVariable("TXT_PASSWORD",ucfirst($this->lng->txt("password")));
1013  $this->tpl->setVariable("TXT_OR",strtoupper($this->lng->txt("or")));
1014  $this->tpl->setVariable("TXT_ADMIN_LOGIN",$this->lng->txt("admin_login"));
1015  $this->tpl->setVariable("TXT_ADMIN_PASSWORD",ucfirst($this->lng->txt("password")));
1016  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("submit"));
1017  }
1018 
1023  {
1024  $_SESSION["ClientId"] = "";
1025 
1026  $_GET["sort_by"] = ($_GET["sort_by"]) ? $_GET["sort_by"] : "name";
1027 
1028  $clientlist = new ilClientList($this->db_connections);
1029  $list = $clientlist->getClients();
1030 
1031  if (count($list) == 0)
1032  {
1033  ilUtil::sendInfo($this->lng->txt("no_clients_available"),true);
1034  }
1035 
1036  // prepare clientlist
1037  $data = array();
1038  $data["data"] = array();
1039  $data["ctrl"] = array();
1040  $data["cols"] = array("","name","id","login","details","status","access");
1041 
1042  foreach ($list as $key => $client)
1043  {
1044  // check status
1045  $status_arr = $this->getStatus($client);
1046 
1047  if (!$status_arr["db"]["status"])
1048  {
1049  $status = $status_arr["db"]["comment"];
1050  }
1051  elseif (!$status_arr["finish"]["status"])
1052  {
1053  $status = $this->lng->txt("setup_not_finished");
1054  }
1055  else
1056  {
1057  $status = "<font color=\"green\"><strong>OK</strong></font>";
1058  }
1059 
1060  if ($status_arr["access"]["status"])
1061  {
1062  $access = "online";
1063  }
1064  else
1065  {
1066  $access = "disabled";
1067  }
1068 
1069  if ($key == $this->default_client)
1070  {
1071  $default = " checked=\"checked\"";
1072  }
1073  else
1074  {
1075  $default = "";
1076  }
1077 
1078  if ($status_arr["finish"]["status"] and $status_arr["access"]["status"])
1079  {
1080  $login = "<a href=\"../login.php?client_id=".$key."\">Login</a>";
1081  }
1082  else
1083  {
1084  $login = "&nbsp;";
1085  }
1086 
1087  $access_html = "<a href=\"setup.php?cmd=changeaccess&client_id=".$key."&back=clientlist\">".$this->lng->txt($access)."</a>";
1088 
1089  $client_name = ($client->getName()) ? $client->getName() : "&lt;".$this->lng->txt("no_client_name")."&gt;";
1090 
1091  // visible data part
1092  $data["data"][] = array(
1093  "default" => "<input type=\"radio\" name=\"form[default]\" value=\"".$key."\"".$default."/>",
1094  "name" => $client_name."#separator#".$client->getDescription(),
1095  "id" => $key,
1096  "login" => $login,
1097  "details" => "<a href=\"setup.php?cmd=view&client_id=".$key."\">Details</a>",
1098  "status" => $status,
1099  "access_html" => $access_html
1100  );
1101 
1102  }
1103 
1104  $this->maxcount = count($data["data"]);
1105 
1106  // sorting array
1107  $data["data"] = ilUtil::sortArray($data["data"],$_GET["sort_by"],$_GET["sort_order"]);
1108 
1109  $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html");
1110 
1111  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
1112 
1113  ilUtil::sendInfo();
1114 
1115  // load template for table
1116  $this->tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1117  // load template for table content data
1118  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1119 
1120  // common
1121  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("available_clients"));
1122  $this->tpl->setVariable("TXT_LISTSTATUS",($this->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
1123  $this->tpl->setVariable("TXT_TOGGLELIST",($this->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
1124 
1125  $this->tpl->setVariable("FORMACTION","setup.php?cmd=gateway");
1126 
1127  // build table
1128  include_once "../Services/Table/classes/class.ilTableGUI.php";
1129  $tbl = new ilTableGUI();
1130  $tbl->disable("sort");
1131  //$tbl->enable("header");
1132 
1133  $num = 0;
1134 
1135  // title & header columns
1136  $tbl->setTitle(ucfirst($this->lng->txt("select_client")));
1137 
1138  foreach ($data["cols"] as $val)
1139  {
1140  $header_names[] = ucfirst($this->lng->txt($val));
1141  }
1142  $tbl->setHeaderNames($header_names);
1143  $tbl->setHeaderVars($data["cols"],$header_params);
1144  $tbl->setColumnWidth(array("5%","30%","10%","10%","10%","20%","15%"));
1145 
1146  // control
1147  $tbl->setOrderColumn($_GET["sort_by"],"name");
1148  $tbl->setOrderDirection($_GET["sort_order"],"asc");
1149  $tbl->setLimit(0);
1150  $tbl->setOffset(0);
1151  $tbl->setMaxCount($maxcount);
1152 
1153  // show valid actions
1154  $this->tpl->setVariable("COLUMN_COUNTS",count($data["cols"]));
1155 
1156  // footer
1157  //$tbl->setFooter("tbl_footer");
1158 
1159  $tbl->disable("footer");
1160  $tbl->disable("icon");
1161  $tbl->disable("numinfo");
1162 
1163  // render table
1164  $tbl->render();
1165 
1166  if (is_array($data["data"][0]))
1167  {
1168  // table cell
1169  for ($i=0; $i < count($data["data"]); $i++)
1170  {
1171  $data2 = $data["data"][$i];
1172  $ctrl = $data["ctrl"][$i];
1173 
1174  // color changing
1175  $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
1176 
1177  $this->tpl->setCurrentBlock("table_cell");
1178  $this->tpl->setVariable("CELLSTYLE", "tblrow1");
1179  $this->tpl->parseCurrentBlock();
1180 
1181  foreach ($data2 as $key => $val)
1182  {
1183  $this->tpl->setCurrentBlock("text");
1184 
1185  if ($key == "name")
1186  {
1187  $name_field = explode("#separator#",$val);
1188  $val = $name_field[0]."<br/><span class=\"subtitle\">".$name_field[1]."</span>";
1189  }
1190 
1191  $this->tpl->setVariable("TEXT_CONTENT", $val);
1192  $this->tpl->parseCurrentBlock();
1193 
1194  $this->tpl->setCurrentBlock("table_cell");
1195  $this->tpl->parseCurrentBlock();
1196 
1197  } //end foreach
1198 
1199  $this->tpl->setCurrentBlock("tbl_content");
1200  $this->tpl->setVariable("CSS_ROW", $css_row);
1201  $this->tpl->parseCurrentBlock();
1202  }
1203 
1204  $this->tpl->setCurrentBlock("tbl_action_btn");
1205  $this->tpl->setVariable("TPLPATH",TPLPATH);
1206  $this->tpl->setVariable("BTN_NAME","changedefault");
1207  $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("set_default_client"));
1208  $this->tpl->parseCurrentBlock();
1209 
1210  $this->tpl->setCurrentBlock("tbl_action_row");
1211  $this->tpl->setVariable("TPLPATH",TPLPATH);
1212  $this->tpl->setVariable("COLUMN_COUNTS","7");
1213  $this->tpl->parseCurrentBlock();
1214 
1215  }
1216 
1217  //???
1218  $this->btn_next_on = true;
1219  $this->btn_next_lng = $this->lng->txt("create_new_client")." >>";
1220  $this->btn_next_cmd = "newclient";
1221  //$this->displayNavButtons();
1222 
1223  }
1224 
1229  {
1230  $this->changeMasterSettings(true);
1231  }
1232 
1237  {
1238  $this->displayMasterSetup(true);
1239  }
1240 
1244  function determineTools($a_tools = "")
1245  {
1246  $tools = array("convert", "zip", "unzip", "java", "htmldoc");
1247  $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin");
1248  foreach($tools as $tool)
1249  {
1250  // try which command
1251  unset($ret);
1252  @exec("which ".$tool, $ret);
1253  if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
1254  {
1255  $a_tools[$tool."_path"] = $ret[0];
1256  continue;
1257  }
1258 
1259  // try common directories
1260  foreach($dirs as $dir)
1261  {
1262  if (is_file($dir."/".$tool))
1263  {
1264  $a_tools[$tool."_path"] = $dir."/".$tool;
1265  continue;
1266  }
1267  }
1268  }
1269  return $a_tools;
1270  }
1271 
1275  function changeMasterSettings($a_det = false)
1276  {
1277  if ($_POST["form"])
1278  {
1279  if (!$this->checkLogSetup($_POST["form"]))
1280  {
1281  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
1282  }
1283 
1284  /*if (!$this->checkToolsSetup($_POST["form"]))
1285  {
1286  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
1287  }*/
1288 
1289  if ($a_det)
1290  {
1291  $_POST["form"] = $this->determineTools($_POST["form"]);
1292  }
1293 
1294  if (!$this->updateMasterSettings($_POST["form"]))
1295  {
1296  $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
1297  }
1298 
1299  ilUtil::sendInfo($this->lng->txt("settings_saved"),true);
1300  ilUtil::redirect("setup.php?cmd=mastersettings");
1301  }
1302 
1303  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
1304 
1305  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_mastersetup.html");
1306 
1307  $this->tpl->setCurrentBlock("det_tools");
1308  $this->tpl->setVariable("TXT_DET_TOOLS_PATH", $this->lng->txt("determine_tools_paths"));
1309  $this->tpl->setVariable("CMD_DET_TOOLS_PATH", "determineToolsPath");
1310  $this->tpl->parseCurrentBlock();
1311 
1312  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1313 
1314  // for checkboxes & radio buttons
1315  $checked = "checked=\"checked\"";
1316 
1317  // general
1318  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("basic_settings"));
1319  $this->tpl->setVariable("SUBMIT_CMD", "mastersettings");
1320  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1321  $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("enter_dir_and_filename"));
1322  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
1323 
1324  if ($this->safe_mode)
1325  {
1326  $this->tpl->setVariable("SAFE_MODE_STYLE", " class=\"message\" ");
1327  $this->tpl->setVariable("TXT_SAFE_MODE_INFO", $this->lng->txt("safe_mode_enabled"));
1328  }
1329  else
1330  {
1331  $this->tpl->setVariable("TXT_SAFE_MODE_INFO", "");
1332  }
1333 
1334  // determine ws data directory
1335  $cwd = getcwd();
1336  chdir("..");
1337  $data_dir_ws = getcwd()."/data";
1338  chdir($cwd);
1339 
1340  // datadir
1341  $this->tpl->setCurrentBlock("display_datadir");
1342  $this->tpl->setVariable("TXT_DATADIR_TITLE", $this->lng->txt("data_directories"));
1343  $this->tpl->setVariable("TXT_DATADIR_PATH_IN_WS", $this->lng->txt("data_directory_in_ws"));
1344  $this->tpl->setVariable("DATADIR_IN_WS", $data_dir_ws);
1345  $this->tpl->setVariable("TXT_DATADIR_PATH", $this->lng->txt("data_directory_outside_ws"));
1346  $this->tpl->setVariable("DATADIR_PATH", $this->ini->readVariable("clients","datadir"));
1347  $this->tpl->setVariable("TXT_DATADIR_COMMENT2", $this->lng->txt("datadir_path_comment2"));
1348  $this->tpl->parseCurrentBlock();
1349 
1350  // logging
1351  $this->tpl->setCurrentBlock("setup_log");
1352  $this->tpl->setVariable("TXT_LOG_TITLE", $this->lng->txt("logging"));
1353  $this->tpl->setVariable("TXT_LOG_PATH", $this->lng->txt("log_path"));
1354  $this->tpl->setVariable("TXT_LOG_COMMENT", $this->lng->txt("log_path_comment"));
1355  $this->tpl->setVariable("TXT_DISABLE_LOGGING", $this->lng->txt("disable_logging"));
1356  // values
1357  if ($_SESSION["error_post_vars"])
1358  {
1359  $this->tpl->setVariable("LOG_PATH", $_SESSION["error_post_vars"]["form"]["log_path"]);
1360  $chk_log_status = ($_SESSION["error_post_vars"]["form"]["chk_log_status"]) ? $checked : "";
1361  }
1362  else
1363  {
1364  $this->tpl->setVariable("LOG_PATH",$this->ini->readVariable("log","path")."/".$this->ini->readVariable("log","file"));
1365  $chk_log_status = ($this->ini->readVariable("log","enabled")) ? "" : $checked;
1366 
1367  }
1368 
1369  $this->tpl->setVariable("CHK_LOG_STATUS",$chk_log_status);
1370  $this->tpl->parseCurrentBlock();
1371 
1372  // tools
1373  $this->tpl->setCurrentBlock("setup_tools");
1374  $this->tpl->setVariable("TXT_DISABLE_CHECK", $this->lng->txt("disable_check"));
1375  $this->tpl->setVariable("TXT_REQ_TOOLS_TITLE", $this->lng->txt("3rd_party_software_req"));
1376  $this->tpl->setVariable("TXT_OPT_TOOLS_TITLE", $this->lng->txt("3rd_party_software_opt"));
1377  $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("convert_path"));
1378  $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("zip_path"));
1379  $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("unzip_path"));
1380  $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("java_path"));
1381  $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("htmldoc_path"));
1382  $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
1383  $this->tpl->setVariable("TXT_FOP_PATH", $this->lng->txt("fop_path"));
1384 
1385  $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
1386  $this->tpl->setVariable("TXT_NONE", $this->lng->txt("none"));
1387  $this->tpl->setVariable("TXT_SOPHOS", $this->lng->txt("sophos"));
1388  $this->tpl->setVariable("TXT_ANTIVIR", $this->lng->txt("antivir"));
1389  $this->tpl->setVariable("TXT_CLAMAV", $this->lng->txt("clamav"));
1390  $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
1391  $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
1392 
1393  $this->tpl->setVariable("TXT_CONVERT_COMMENT", $this->lng->txt("convert_path_comment"));
1394  $this->tpl->setVariable("TXT_ZIP_COMMENT", $this->lng->txt("zip_path_comment"));
1395  $this->tpl->setVariable("TXT_UNZIP_COMMENT", $this->lng->txt("unzip_path_comment"));
1396  $this->tpl->setVariable("TXT_JAVA_COMMENT", $this->lng->txt("java_path_comment"));
1397  $this->tpl->setVariable("TXT_HTMLDOC_COMMENT", $this->lng->txt("htmldoc_path_comment"));
1398  $this->tpl->setVariable("TXT_LATEX_URL_COMMENT", $this->lng->txt("latex_url_comment"));
1399  $this->tpl->setVariable("TXT_FOP_COMMENT", $this->lng->txt("fop_path_comment"));
1400  // values
1401  if ($_SESSION["error_post_vars"])
1402  {
1403  $vals = $_SESSION["error_post_vars"]["form"];
1404  }
1405  else
1406  {
1407  $vals["convert_path"] = $this->ini->readVariable("tools","convert");
1408  $vals["zip_path"] = $this->ini->readVariable("tools","zip");
1409  $vals["unzip_path"] = $this->ini->readVariable("tools","unzip");
1410  $vals["java_path"] = $this->ini->readVariable("tools","java");
1411  $vals["htmldoc_path"] = $this->ini->readVariable("tools","htmldoc");
1412  $vals["latex_url"] = $this->ini->readVariable("tools","latex");
1413  $vals["fop_path"] = $this->ini->readVariable("tools","fop");
1414  $vals["vscanner_type"] = $this->ini->readVariable("tools", "vscantype");
1415  $vals["scan_command"] = $this->ini->readVariable("tools", "scancommand");
1416  $vals["clean_command"] = $this->ini->readVariable("tools", "cleancommand");
1417  }
1418 
1419  $tools = array("convert" => "testConvert", "zip" => "testZip",
1420  "unzip" => "testUnzip", "java" => "testJava", "htmldoc" => "testHtmldoc",
1421  "latex" => "testLatex");
1422  foreach ($tools as $tool => $func)
1423  {
1424  $end = ($tool == "latex")
1425  ? "url"
1426  : "path";
1427  if (($err = $this->$func($vals[$tool."_".$end])) != "")
1428  {
1429  $this->tpl->setCurrentBlock("warning_".$tool);
1430  $this->tpl->setVariable("TXT_WARNING_".strtoupper($tool), $this->lng->txt($err));
1431  $this->tpl->parseCurrentBlock();
1432  }
1433  }
1434 
1435  $this->tpl->setVariable("CONVERT_PATH", $vals["convert_path"]);
1436  $this->tpl->setVariable("ZIP_PATH", $vals["zip_path"]);
1437  $this->tpl->setVariable("UNZIP_PATH", $vals["unzip_path"]);
1438  $this->tpl->setVariable("JAVA_PATH", $vals["java_path"]);
1439  $this->tpl->setVariable("HTMLDOC_PATH", $vals["htmldoc_path"]);
1440  $this->tpl->setVariable("LATEX_URL", $vals["latex_url"]);
1441  $this->tpl->setVariable("FOP_PATH", $vals["fop_path"]);
1442  $this->tpl->setVariable("STYPE_".
1443  strtoupper($vals["vscanner_type"]), " selected=\"1\" ");
1444  $this->tpl->setVariable("SCAN_COMMAND", $vals["scan_command"]);
1445  $this->tpl->setVariable("CLEAN_COMMAND", $vals["clean_command"]);
1446 
1447  $chk_convert_path = ($_SESSION["error_post_vars"]["form"]["chk_convert_path"]) ? $checked : "";
1448  $chk_zip_path = ($_SESSION["error_post_vars"]["form"]["chk_zip_path"]) ? $checked : "";
1449  $chk_unzip_path = ($_SESSION["error_post_vars"]["form"]["chk_unzip_path"]) ? $checked : "";
1450  $chk_java_path = ($_SESSION["error_post_vars"]["form"]["chk_java_path"]) ? $checked : "";
1451  $chk_htmldoc_path = ($_SESSION["error_post_vars"]["form"]["chk_htmldoc_path"]) ? $checked : "";
1452  $chk_latex_url = ($_SESSION["error_post_vars"]["form"]["chk_latex_url"]) ? $checked : "";
1453  $chk_fop_path = ($_SESSION["error_post_vars"]["form"]["chk_fop_path"]) ? $checked : "";
1454 
1455  $this->tpl->setVariable("CHK_LOG_STATUS", $chk_log_stauts);
1456  $this->tpl->setVariable("CHK_CONVERT_PATH", $chk_convert_path);
1457  $this->tpl->setVariable("CHK_ZIP_PATH", $chk_zip_path);
1458  $this->tpl->setVariable("CHK_UNZIP_PATH", $chk_unzip_path);
1459  $this->tpl->setVariable("CHK_JAVA_PATH", $chk_java_path);
1460  $this->tpl->setVariable("CHK_HTMLDOC_PATH", $chk_htmldoc_path);
1461  $this->tpl->setVariable("CHK_LATEX_URL", $chk_latex_url);
1462  $this->tpl->setVariable("CHK_FOP_PATH", $chk_fop_path);
1463  $this->tpl->parseCurrentBlock();
1464 
1465  $this->btn_next_on = true;
1466  $this->btn_next_lng = $this->lng->txt("create_new_client")." >>";
1467  $this->btn_next_cmd = "newclient";
1468 
1469  }
1470 
1474  function displayIni()
1475  {
1476  $this->checkDisplayMode("create_new_client");
1477 
1478  // checkings
1479  if ($_POST["form"])
1480  {
1481  // check client name
1482  if (!$_POST["form"]["client_id"])
1483  {
1484  $this->raiseError($this->lng->txt("ini_no_client_id"),$this->error_obj->MESSAGE);
1485  }
1486 
1487  if (strlen($_POST["form"]["client_id"]) != strlen(urlencode(($_POST["form"]["client_id"]))))
1488  {
1489  $this->raiseError($this->lng->txt("ini_client_id_invalid"),$this->error_obj->MESSAGE);
1490  }
1491 
1492  if (strlen($_POST["form"]["client_id"]) < 4)
1493  {
1494  $this->raiseError($this->lng->txt("ini_client_id_too_short"),$this->error_obj->MESSAGE);
1495  }
1496 
1497  if (strlen($_POST["form"]["client_id"]) > 32)
1498  {
1499  $this->raiseError($this->lng->txt("ini_client_id_too_long"),$this->error_obj->MESSAGE);
1500  }
1501 
1502  // check database
1503  if (!$_POST["form"]["db_host"])
1504  {
1505  $this->raiseError($this->lng->txt("ini_no_db_host"),$this->error_obj->MESSAGE);
1506  }
1507 
1508  if (!$_POST["form"]["db_name"])
1509  {
1510  $this->raiseError($this->lng->txt("ini_no_db_name"),$this->error_obj->MESSAGE);
1511  }
1512 
1513  if (!$_POST["form"]["db_user"])
1514  {
1515  $this->raiseError($this->lng->txt("ini_no_db_user"),$this->error_obj->MESSAGE);
1516  }
1517 
1518  // create new client object if it does not exist
1519  if (!$this->ini_client_exists)
1520  {
1521  $client_id = $_POST["form"]["client_id"];
1522 
1523  // check for existing client dir (only for newly created clients not renaming)
1524  if (!$this->ini_client_exists and file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$client_id))
1525  {
1526  $this->raiseError($this->lng->txt("ini_client_id_exists"),$this->error_obj->MESSAGE);
1527  }
1528 
1529  $this->newClient($client_id);
1530  }
1531 
1532  // save some old values
1533  $old_db_name = $this->client->getDbName();
1534  $old_client_id = $this->client->getId();
1535  // set client data
1536  $this->client->setId($_POST["form"]["client_id"]);
1537  $this->client->setDbHost($_POST["form"]["db_host"]);
1538  $this->client->setDbName($_POST["form"]["db_name"]);
1539  $this->client->setDbUser($_POST["form"]["db_user"]);
1540  $this->client->setDbPass($_POST["form"]["db_pass"]);
1541  $this->client->setDSN();
1542 
1543  // try to connect to database
1544  if (!$this->client->checkDatabaseHost())
1545  {
1546  $this->raiseError($this->client->getError(),$this->error_obj->MESSAGE);
1547  }
1548 
1549  // check database version
1550  if (!$this->client->isMysql4_1OrHigher())
1551  {
1552  $this->raiseError($this->lng->txt("need_mysql_4_1_or_higher"),$this->error_obj->MESSAGE);
1553  }
1554 
1555  // check if db exists
1556  $db_installed = $this->client->checkDatabaseExists();
1557 
1558  if ($db_installed and (!$this->ini_ilias_exists or ($this->client->getDbName() != $old_db_name)))
1559  {
1560  $_POST["form"]["db_name"] = $old_db_name;
1561  $message = ucfirst($this->lng->txt("database"))." \"".$this->client->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
1562  $this->raiseError($message,$this->error_obj->MESSAGE);
1563  }
1564 
1565  if ($this->ini_client_exists and $old_client_id != $this->client->getId())
1566  {
1567  $message = $this->lng->txt("ini_client_id_no_change");
1568  $this->raiseError($message,$this->error_obj->MESSAGE);
1569  }
1570 
1571  // all ok. create client.ini and save posted data
1572  if (!$this->ini_client_exists)
1573  {
1574  if ($this->saveNewClient())
1575  {
1576  ilUtil::sendInfo($this->lng->txt("settings_saved"));
1577  $this->client->status["ini"]["status"] = true;
1578  }
1579  else
1580  {
1581  $err = $this->getError();
1582  ilUtil::sendInfo($this->lng->txt("save_error").": ".$err);
1583  $this->client->status["ini"]["status"] = false;
1584  $this->client->status["ini"]["comment"] = $err;
1585  }
1586  }
1587  else
1588  {
1589  if ($this->client->ini->write())
1590  {
1591  ilUtil::sendInfo($this->lng->txt("settings_changed"));
1592  $this->client->status["ini"]["status"] = true;
1593  }
1594  else
1595  {
1596  $err = $this->client->ini->getError();
1597  ilUtil::sendInfo($this->lng->txt("save_error").": ".$err);
1598  $this->client->status["ini"]["status"] = false;
1599  $this->client->status["ini"]["comment"] = $err;
1600  }
1601  }
1602  }
1603 
1604  // output
1605  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_ini.html");
1606 
1607  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1608  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
1609 
1610  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
1611 
1612  // display default values, loaded valus or saved error values
1613  if ($_SESSION["error_post_vars"]["form"])
1614  {
1615  $this->tpl->setVariable("CLIENT_ID", $_SESSION["error_post_vars"]["form"]["client_id"]);
1616  $this->tpl->setVariable("DB_HOST", $_SESSION["error_post_vars"]["form"]["db_host"]);
1617  $this->tpl->setVariable("DB_NAME", $_SESSION["error_post_vars"]["form"]["db_name"]);
1618  $this->tpl->setVariable("DB_USER", $_SESSION["error_post_vars"]["form"]["db_user"]);
1619  $this->tpl->setVariable("DB_PASS", $_SESSION["error_post_vars"]["form"]["db_pass"]);
1620  }
1621  else
1622  {
1623  $this->tpl->setVariable("CLIENT_ID", $this->client->getId());
1624  $this->tpl->setVariable("DB_HOST", $this->client->getDbHost());
1625  $this->tpl->setVariable("DB_NAME", $this->client->getDbName());
1626  $this->tpl->setVariable("DB_USER", $this->client->getDbUser());
1627  $this->tpl->setVariable("DB_PASS", $this->client->getDbPass());
1628  }
1629 
1630  $this->tpl->setVariable("TXT_CLIENT_HEADER", $this->lng->txt("inst_identification"));
1631  $this->tpl->setVariable("TXT_CLIENT_ID", $this->lng->txt("client_id"));
1632  $this->tpl->setVariable("TXT_DB_HEADER", $this->lng->txt("db_conn"));
1633  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
1634  $this->tpl->setVariable("TXT_DB_HOST", $this->lng->txt("db_host"));
1635  $this->tpl->setVariable("TXT_DB_NAME", $this->lng->txt("db_name"));
1636  $this->tpl->setVariable("TXT_DB_USER", $this->lng->txt("db_user"));
1637  $this->tpl->setVariable("TXT_DB_PASS", $this->lng->txt("db_pass"));
1638 
1639  if ($this->client->status["ini"]["status"])
1640  {
1641  $this->setButtonNext("db");
1642  }
1643 
1644  $this->checkPanelMode();
1645  }
1646 
1652  function displayError($a_message)
1653  {
1654  $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html");
1655 
1656  $this->tpl->setCurrentBlock("content");
1657  $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
1658  $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
1659  $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
1660  $this->tpl->parseCurrentBlock();
1661 
1662  $this->tpl->show();
1663  exit();
1664  }
1665 
1669  function displayLogout()
1670  {
1671  $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html");
1672 
1673  session_destroy();
1674 
1675  $this->logged_out = true;
1676  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));
1677  $this->tpl->setCurrentBlock("home_link");
1678  $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
1679  $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
1680  $this->tpl->parseCurrentBlock();
1681  }
1682 
1687  {
1688  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1689 
1690  $steps = array();
1691  $steps = $this->getStatus();
1692 
1693  // remove access step
1694  unset($steps["access"]);
1695 
1696  $steps["ini"]["text"] = $this->lng->txt("setup_process_step_ini");
1697  $steps["db"]["text"] = $this->lng->txt("setup_process_step_db");
1698  $steps["lang"]["text"] = $this->lng->txt("setup_process_step_lang");
1699  $steps["contact"]["text"] = $this->lng->txt("setup_process_step_contact");
1700  $steps["nic"]["text"] = $this->lng->txt("setup_process_step_nic");
1701  $steps["finish"]["text"] = $this->lng->txt("setup_process_step_finish");
1702 
1703  $this->tpl->addBlockFile("PROCESS_MENU","process_menu","tpl.process_panel.html");
1704 
1705  $this->tpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
1706 
1707  $num = 1;
1708 
1709  foreach ($steps as $key => $val)
1710  {
1711  $this->tpl->setCurrentBlock("menu_row");
1712  $this->tpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
1713  $this->tpl->setVariable("TXT_ACTION",$val["text"]);
1714  $this->tpl->setVariable("IMG_ARROW", "spacer.gif");
1715 
1716  $num++;
1717 
1718  if ($this->cmd == $key and isset($this->cmd))
1719  {
1720  $this->tpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
1721  $this->tpl->setVariable("IMG_ARROW", "arrow_right.png");
1722  }
1723 
1724  $status = ($val["status"]) ? $OK : "";
1725 
1726  $this->tpl->setVariable("TXT_STATUS",$status);
1727  $this->tpl->parseCurrentBlock();
1728  }
1729  }
1730 
1735  {
1736  $OK = "<font color=\"green\"><strong>OK</strong></font>";
1737 
1738  $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html");
1739 
1740  $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
1741  // display status
1742  if ($this->client->status)
1743  {
1744  foreach ($this->client->status as $key => $val)
1745  {
1746  $status = ($val["status"]) ? $OK : "&nbsp;";
1747  $this->tpl->setCurrentBlock("status_row");
1748  $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
1749  $this->tpl->setVariable("TXT_STATUS",$status);
1750  $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
1751  $this->tpl->parseCurrentBlock();
1752  }
1753  }
1754  }
1755 
1761  function checkDisplayMode($a_title = "")
1762  {
1763  switch ($this->display_mode)
1764  {
1765  case "view":
1766  $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html");
1767  // display tabs
1768  include "./include/inc.client_tabs.php";
1769  $client_name = ($this->client->getName()) ? $this->client->getName() : $this->lng->txt("no_client_name");
1770  $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->client->getId().")");
1771  break;
1772 
1773  case "setup":
1774  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html");
1775  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));
1776  break;
1777 
1778  default:
1779  $this->displayError($this->lng->txt("unknown_display_mode"));
1780  exit();
1781  break;
1782  }
1783  }
1784 
1788  function checkPanelMode()
1789  {
1790  switch ($this->display_mode)
1791  {
1792  case "view":
1793  $this->displayStatusPanel();
1794  break;
1795 
1796  case "setup":
1797  $this->displayProcessPanel();
1798  break;
1799  }
1800  }
1801 
1805  function displayStartup()
1806  {
1807  $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html");
1808 
1809  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
1810  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
1811 
1812  $this->displayProcessPanel();
1813 
1814  $this->setButtonNext("ini");
1815  }
1816 
1820  function displayDatabase()
1821  {
1822  global $ilErr,$ilDB,$ilLog;
1823 
1824  $this->checkDisplayMode("setup_database");
1825 
1826  // checkings
1827  if ($_POST["form"]["db_flag"] == 1)
1828  {
1829  $message = "";
1830 
1831  if (!$this->client->db_installed)
1832  {
1833  if (!$this->client->db_exists)
1834  {
1835  if ($_POST["form"]["chk_db_create"])
1836  {
1837  if (!$this->createDatabase($_POST["collation"]))
1838  {
1839  $message = $this->lng->txt($this->getError());
1840  $this->raiseError($message,$this->error_obj->MESSAGE);
1841  }
1842  }
1843  else
1844  {
1845  $message = $this->lng->txt("database_not_exists_create_first");
1846  $this->raiseError($message,$this->error_obj->MESSAGE);
1847  }
1848  }
1849 
1850  if (!$this->installDatabase())
1851  {
1852  $message = $this->lng->txt($this->getError());
1853  $this->client->status["db"]["status"] = false;
1854  $this->client->status["db"]["comment"] = "install_error";
1855  }
1856  else
1857  {
1858  $message = $this->lng->txt("database_installed");
1859  }
1860  }
1861  else
1862  {
1863  include_once "../classes/class.ilDBUpdate.php";
1864  include_once "../Services/AccessControl/classes/class.ilRbacAdmin.php";
1865  include_once "../Services/AccessControl/classes/class.ilRbacReview.php";
1866  include_once "../Services/AccessControl/classes/class.ilRbacSystem.php";
1867  include_once "../Services/Tree/classes/class.ilTree.php";
1868  include_once "../classes/class.ilSaxParser.php";
1869  include_once "../Services/Object/classes/class.ilObjectDefinition.php";
1870 
1871  // referencing db handler in language class
1872  $this->lng->setDbHandler($this->client->db);
1873 
1874  // referencing does not work in dbupdate-script
1875  $ilDB = new ilDbx($this->client->dsn);
1876 
1877  // run dbupdate
1878  $dbupdate = new ilDBUpdate($ilDB);
1879  $dbupdate->applyUpdate();
1880 
1881  if ($dbupdate->updateMsg == "no_changes")
1882  {
1883  $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
1884  }
1885  else
1886  {
1887  foreach ($dbupdate->updateMsg as $row)
1888  {
1889  $message .= $this->lng->txt($row["msg"]).": ".$row["nr"]."<br/>";
1890  }
1891  }
1892  }
1893  }
1894 
1895  ilUtil::sendInfo($message);
1896 
1897  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html");
1898 
1899  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
1900  $this->tpl->setVariable("DB_HOST", $this->client->getDbHost());
1901  $this->tpl->setVariable("DB_NAME", $this->client->getDbName());
1902  $this->tpl->setVariable("DB_USER", $this->client->getDbUser());
1903  $this->tpl->setVariable("DB_PASS", $this->client->getDbPass());
1904 
1905  if ($this->client->db_installed)
1906  {
1907  // referencing db handler in language class
1908  $this->lng->setDbHandler($this->client->db);
1909 
1910  include_once "../classes/class.ilDBUpdate.php";
1911  $ilDB = new ilDbx($this->client->dsn);
1912  $dbupdate = new ilDBUpdate($ilDB);
1913 
1914  if (!$db_status = $dbupdate->getDBVersionStatus())
1915  {
1916  $remark = "<font color=\"red\">".$this->lng->txt("database_needs_update").
1917  " (".$this->lng->txt("database_version").": ".$dbupdate->currentVersion.
1918  " ; ".$this->lng->txt("file_version").": ".$dbupdate->fileVersion.")</font>";
1919  $this->tpl->setVariable("TXT_INFO", $remark);
1920 
1921  $this->tpl->setCurrentBlock("btn_submit");
1922  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("database_update"));
1923  $this->tpl->parseCurrentBlock();
1924  }
1925  else
1926  {
1927  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("database_is_uptodate"));
1928  $this->client->status["db"]["status"] = true;
1929  $this->client->status["db"]["comment"] = "version ".$dbupdate->getCurrentVersion();
1930  }
1931 
1932  $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("version"));
1933  $this->tpl->setVariable("VAL_DB_VERSION", $ilDB->getMySQLVersion());
1934  //$this->tpl->setVariable("TXT_DB_MODE", $this->lng->txt("ilias_db_mode"));
1935 
1936  /*if ($ilDB->isMySQL4_1OrHigher())
1937  {
1938  $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_1_x_or_higher_mode"));
1939  }
1940  else
1941  {
1942  $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_0_x_or_lower_mode"));
1943  }*/
1944  //$this->tpl->setVariable("TXT_CHECK_VERSIONS", $this->lng->txt("check_db_versions"));
1945  }
1946  else
1947  {
1948  $checked = "";
1949 
1950  if ($_SESSION["error_post_vars"]["form"]["chk_db_create"])
1951  {
1952  $checked = "checked=\"checked\"";
1953  }
1954 
1955  $this->tpl->setCurrentBlock("option_db_create");
1956  $this->tpl->setVariable("TXT_DB_CREATE", $this->lng->txt("database_create"));
1957  $this->tpl->setVariable("DB_CREATE_CHECK",$checked);
1958  $this->tpl->parseCurrentBlock();
1959 
1960  $ilDB = new ilDbx($this->client->dsn_host);
1961 
1962  if ($ilDB->isMySQL4_1OrHigher())
1963  {
1964  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("database_install"));
1965  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db")."<br />".
1966  "<p><code>CREATE DATABASE &lt;your_db&gt; CHARACTER SET utf8 COLLATE &lt;your_collation&gt;</code></p>".
1967  "<p><b>".$this->lng->txt("info_text_db2")."</b></p><br/>");
1968  }
1969  else
1970  {
1971  $this->tpl->setVariable("TXT_INFO", "<p><b>".$this->lng->txt("need_mysql_4_1_or_higher")."</b></p><br />");
1972  }
1973 
1974  // output version
1975  $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("version"));
1976  $this->tpl->setVariable("VAL_DB_VERSION", $ilDB->getMySQLVersion());
1977  //$this->tpl->setVariable("TXT_DB_MODE", $this->lng->txt("ilias_db_mode"));
1978 
1979  /*if ($ilDB->isMySQL4_1OrHigher())
1980  {
1981  $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_1_x_or_higher_mode"));
1982  }
1983  else
1984  {
1985  $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_0_x_or_lower_mode"));
1986  }
1987  $this->tpl->setVariable("TXT_CHECK_VERSIONS", $this->lng->txt("check_db_versions"));*/
1988 
1989  // collation selection ( see utf8 collations at
1990  // http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html )
1991  if ($ilDB->isMySQL4_1OrHigher())
1992  {
1993  $collations = array
1994  (
1995  "utf8_unicode_ci",
1996  "utf8_general_ci",
1997  "utf8_czech_ci",
1998  "utf8_danish_ci",
1999  "utf8_estonian_ci",
2000  "utf8_icelandic_ci",
2001  "utf8_latvian_ci",
2002  "utf8_lithuanian_ci",
2003  "utf8_persian_ci",
2004  "utf8_polish_ci",
2005  "utf8_roman_ci",
2006  "utf8_romanian_ci",
2007  "utf8_slovak_ci",
2008  "utf8_slovenian_ci",
2009  "utf8_spanish2_ci",
2010  "utf8_spanish_ci",
2011  "utf8_swedish_ci",
2012  "utf8_turkish_ci"
2013  );
2014  foreach($collations as $collation)
2015  {
2016  $this->tpl->setCurrentBlock("collation_item");
2017  $this->tpl->setVariable("VAL_COLLATION_ITEM", $collation);
2018  $this->tpl->setVariable("TXT_COLLATION_ITEM", $collation);
2019  $this->tpl->parseCurrentBlock();
2020  }
2021  $this->tpl->setCurrentBlock("collation_selection");
2022  $this->tpl->setVariable("TXT_COLLATION", $this->lng->txt("collation"));
2023  $this->tpl->parseCurrentBlock();
2024  //$this->tpl->setCurrentBlock("setup_content");
2025  //$this->tpl->setVariable("COLLATION_INFO1", $this->lng->txt("info_text_db_collation1"));
2026  //$this->tpl->setVariable("COLLATION_EXAMPLE",
2027  // "<br /><br />".$this->lng->txt("example").": CREATE DATABASE ilias3 CHARACTER SET utf8 COLLATE utf8_unicode_ci");
2028  $this->tpl->setVariable("COLLATION_INFO2", "<br />".$this->lng->txt("info_text_db_collation2")." ".
2029  "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
2030  " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
2031  }
2032  }
2033 
2034  $this->tpl->parseCurrentBlock();
2035 
2036  $this->tpl->setVariable("TXT_SETUP_TITLE", $this->lng->txt("setup_database"));
2037  $this->tpl->setVariable("TXT_DB_HEADER", $this->lng->txt("db_conn"));
2038  $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
2039  $this->tpl->setVariable("TXT_DB_HOST", $this->lng->txt("db_host"));
2040  $this->tpl->setVariable("TXT_DB_NAME", $this->lng->txt("db_name"));
2041  $this->tpl->setVariable("TXT_DB_USER", $this->lng->txt("db_user"));
2042  $this->tpl->setVariable("TXT_DB_PASS", $this->lng->txt("db_pass"));
2043 
2044  // only allow to return to ini if db does not exist yet
2045  if (!$this->client->db_installed)
2046  {
2047  $this->setButtonPrev("ini");
2048  }
2049 
2050  if ($this->client->db_installed and $db_status)
2051  {
2052  $this->setButtonNext("lang");
2053  }
2054 
2055  $this->checkPanelMode();
2056  }
2057 
2061  function displayLanguages()
2062  {
2063  $this->checkDisplayMode("setup_languages");
2064 
2065  if (!$this->client->db_installed)
2066  {
2067  // program should never come to this place
2068  $message = "No database found! Please install database first.";
2069  ilUtil::sendInfo($message);
2070  }
2071 
2072  // checkings
2073  if ($_POST["form"])
2074  {
2075  if (empty($_POST["form"]["lang_id"]))
2076  {
2077  $message = $this->lng->txt("lang_min_one_language");
2078  $this->raiseError($message,$this->error_obj->MESSAGE);
2079  }
2080 
2081  if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
2082  {
2083  $message = $this->lng->txt("lang_not_installed_default");
2084  $this->error = true;
2085  $this->raiseError($message,$this->error_obj->MESSAGE);
2086 
2087  }
2088 
2089  $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
2090 
2091  if (is_array($result))
2092  {
2093  $count = count($result);
2094  $txt = "tet";
2095 
2096  foreach ($result as $key => $lang_key)
2097  {
2098  $list .= $this->lng->txt("lang_".$lang_key);
2099 
2100  if ($count > $key + 1)
2101  {
2102  $list .= ", ";
2103  }
2104  }
2105  }
2106 
2107  $this->client->setDefaultLanguage($_POST["form"]["lang_default"]);
2108  $message = $this->lng->txt("languages_installed");
2109 
2110  if ($result !== true)
2111  {
2112  $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
2113  }
2114  ilUtil::sendInfo($message);
2115  }
2116 
2117  // output
2118  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_lang.html");
2119 
2120  $languages = $this->lng->getInstallableLanguages();
2121  $installed_langs = $this->lng->getInstalledLanguages();
2122  $installed_local_langs = $this->lng->getInstalledLocalLanguages();
2123  $local_langs = $this->lng->getLocalLanguages();
2124  $default_lang = $this->client->getDefaultLanguage();
2125 
2126  $lang_count = count($installed_langs);
2127 
2128  $this->tpl->setVariable("TXT_LANG_HEADER", ucwords($this->lng->txt("available_languages")));
2129  $this->tpl->setVariable("TXT_LANGUAGE", ucwords($this->lng->txt("language")));
2130  $this->tpl->setVariable("TXT_INSTALLED", ucwords($this->lng->txt("installed")));
2131  $this->tpl->setVariable("TXT_INCLUDE_LOCAL", ucwords($this->lng->txt("include_local")));
2132  $this->tpl->setVariable("TXT_DEFAULT", ucwords($this->lng->txt("default")));
2133 
2134  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2135 
2136  $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
2137  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
2138 
2139  if ($lang_count > 0)
2140  {
2141  $this->client->status["lang"]["status"] = true;
2142  $this->client->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
2143  }
2144  else
2145  {
2146  $this->client->status["lang"]["status"] = false;
2147  $this->client->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
2148  }
2149 
2150  foreach ($languages as $lang_key)
2151  {
2152  $this->tpl->setCurrentBlock("language_row");
2153  $this->tpl->setVariable("LANG_KEY", $lang_key);
2154  $this->tpl->setVariable("TXT_LANG", $this->lng->txt("lang_".$lang_key));
2155  $this->tpl->setVariable("BORDER", 0);
2156  $this->tpl->setVariable("VSPACE", 0);
2157 
2158  if (in_array($lang_key,$installed_langs))
2159  {
2160  $this->tpl->setVariable("CHECKED", ("checked=\"checked\""));
2161  }
2162 
2163  if (!in_array($lang_key,$local_langs))
2164  {
2165  $this->tpl->setVariable("LOCAL", ("disabled=\"disabled\""));
2166  }
2167  else if (in_array($lang_key,$installed_local_langs))
2168  {
2169  $this->tpl->setVariable("LOCAL", ("checked=\"checked\""));
2170  }
2171 
2172  if ($lang_key == $default_lang)
2173  {
2174  $this->tpl->setVariable("DEFAULT", ("checked=\"checked\""));
2175  }
2176 
2177  $this->tpl->parseCurrentBlock();
2178  }
2179 
2180  $this->setButtonPrev("db");
2181 
2182  if ($lang_count > 0)
2183  {
2184  $this->setButtonNext("contact");
2185  }
2186 
2187  $this->checkPanelMode();
2188  }
2189 
2194  {
2195  $this->checkDisplayMode("setup_contact_data");
2196 
2197  $settings = $this->client->getAllSettings();
2198 
2199  // formular sent
2200  if ($_POST["form"])
2201  {
2202  // init checking var
2203  $form_valid = true;
2204 
2205  // check required fields
2206  if (empty($_POST["form"]["admin_firstname"]) or empty($_POST["form"]["admin_lastname"])
2207  or empty($_POST["form"]["admin_street"]) or empty($_POST["form"]["admin_zipcode"])
2208  or empty($_POST["form"]["admin_country"]) or empty($_POST["form"]["admin_city"])
2209  or empty($_POST["form"]["admin_phone"]) or empty($_POST["form"]["admin_email"])
2210  or empty($_POST["form"]["inst_name"]) or empty($_POST["form"]["inst_info"]))
2211  {
2212  $form_valid = false;
2213  $message = $this->lng->txt("fill_out_required_fields");
2214  //$this->raiseError($message,$this->error_obj->MESSAGE);
2215  ilUtil::sendInfo($message);
2216  }
2217 
2218  // admin email
2219  if (!ilUtil::is_email($_POST["form"]["admin_email"]) and $form_valid)
2220  {
2221  $form_valid = false;
2222  $message = $this->lng->txt("input_error").": '".$this->lng->txt("email")."'<br/>".$this->lng->txt("email_not_valid");
2223  ilUtil::sendInfo($message);
2224  //$this->raiseError($message,$this->error_obj->MESSAGE);
2225  }
2226 
2227  if (!$form_valid) //required fields not satisfied. Set formular to already fill in values
2228  {
2229  // load user modified settings again
2230  // contact
2231  $settings["admin_firstname"] = ilUtil::prepareFormOutput($_POST["form"]["admin_firstname"],true);
2232  $settings["admin_lastname"] = ilUtil::prepareFormOutput($_POST["form"]["admin_lastname"],true);
2233  $settings["admin_title"] = ilUtil::prepareFormOutput($_POST["form"]["admin_title"],true);
2234  $settings["admin_position"] = ilUtil::prepareFormOutput($_POST["form"]["admin_position"],true);
2235  $settings["admin_institution"] = ilUtil::prepareFormOutput($_POST["form"]["admin_institution"],true);
2236  $settings["admin_street"] = ilUtil::prepareFormOutput($_POST["form"]["admin_street"],true);
2237  $settings["admin_zipcode"] = ilUtil::prepareFormOutput($_POST["form"]["admin_zipcode"],true);
2238  $settings["admin_city"] = ilUtil::prepareFormOutput($_POST["form"]["admin_city"],true);
2239  $settings["admin_country"] = ilUtil::prepareFormOutput($_POST["form"]["admin_country"],true);
2240  $settings["admin_phone"] = ilUtil::prepareFormOutput($_POST["form"]["admin_phone"],true);
2241  $settings["admin_email"] = ilUtil::prepareFormOutput($_POST["form"]["admin_email"],true);
2242 
2243  // client
2244  $settings["inst_name"] = ilUtil::prepareFormOutput($_POST["form"]["inst_name"],true);
2245  $settings["inst_info"] = ilUtil::prepareFormOutput($_POST["form"]["inst_info"],true);
2246  $settings["inst_institution"] = ilUtil::prepareFormOutput($_POST["form"]["inst_institution"],true);
2247  }
2248  else // all required fields ok
2249  {
2250 
2251  // write new settings
2252  // contact
2253  $this->client->setSetting("admin_firstname",ilUtil::stripSlashes($_POST["form"]["admin_firstname"]));
2254  $this->client->setSetting("admin_lastname",ilUtil::stripSlashes($_POST["form"]["admin_lastname"]));
2255  $this->client->setSetting("admin_title",ilUtil::stripSlashes($_POST["form"]["admin_title"]));
2256  $this->client->setSetting("admin_position",ilUtil::stripSlashes($_POST["form"]["admin_position"]));
2257  $this->client->setSetting("admin_institution",ilUtil::stripSlashes($_POST["form"]["admin_institution"]));
2258  $this->client->setSetting("admin_street",ilUtil::stripSlashes($_POST["form"]["admin_street"]));
2259  $this->client->setSetting("admin_zipcode",ilUtil::stripSlashes($_POST["form"]["admin_zipcode"]));
2260  $this->client->setSetting("admin_city",ilUtil::stripSlashes($_POST["form"]["admin_city"]));
2261  $this->client->setSetting("admin_country",ilUtil::stripSlashes($_POST["form"]["admin_country"]));
2262  $this->client->setSetting("admin_phone",ilUtil::stripSlashes($_POST["form"]["admin_phone"]));
2263  $this->client->setSetting("admin_email",ilUtil::stripSlashes($_POST["form"]["admin_email"]));
2264  $this->client->setSetting("inst_institution",ilUtil::stripSlashes($_POST["form"]["inst_institution"]));
2265  $this->client->setSetting("inst_name",ilUtil::stripSlashes($_POST["form"]["inst_name"]));
2266 
2267  // update client.ini
2268  $this->client->setName(ilUtil::stripSlashes($_POST["form"]["inst_name"]));
2269  $this->client->setDescription(ilUtil::stripSlashes($_POST["form"]["inst_info"]));
2270  $this->client->ini->write();
2271 
2272  // reload settings
2273  $settings = $this->client->getAllSettings();
2274  // feedback
2275  ilUtil::sendInfo($this->lng->txt("saved_successfully"));
2276  }
2277  }
2278 
2279  // output
2280  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_contact.html");
2281 
2282  // client values
2283  $this->tpl->setVariable("INST_NAME",ilUtil::prepareFormOutput(($this->client->getName()) ? $this->client->getName() : $this->client->getId()));
2284  $this->tpl->setVariable("INST_INFO",ilUtil::prepareFormOutput($this->client->getDescription()));
2285  $this->tpl->setVariable("INST_INSTITUTION",ilUtil::prepareFormOutput($settings["inst_institution"]));
2286 
2287  // contact values
2288  $this->tpl->setVariable("ADMIN_FIRSTNAME",ilUtil::prepareFormOutput($settings["admin_firstname"]));
2289  $this->tpl->setVariable("ADMIN_LASTNAME",ilUtil::prepareFormOutput($settings["admin_lastname"]));
2290  $this->tpl->setVariable("ADMIN_TITLE",ilUtil::prepareFormOutput($settings["admin_title"]));
2291  $this->tpl->setVariable("ADMIN_POSITION",ilUtil::prepareFormOutput($settings["admin_position"]));
2292  $this->tpl->setVariable("ADMIN_INSTITUTION",ilUtil::prepareFormOutput($settings["admin_institution"]));
2293  $this->tpl->setVariable("ADMIN_STREET",ilUtil::prepareFormOutput($settings["admin_street"]));
2294  $this->tpl->setVariable("ADMIN_ZIPCODE",ilUtil::prepareFormOutput($settings["admin_zipcode"]));
2295  $this->tpl->setVariable("ADMIN_CITY",ilUtil::prepareFormOutput($settings["admin_city"]));
2296  $this->tpl->setVariable("ADMIN_COUNTRY",ilUtil::prepareFormOutput($settings["admin_country"]));
2297  $this->tpl->setVariable("ADMIN_PHONE",ilUtil::prepareFormOutput($settings["admin_phone"]));
2298  $this->tpl->setVariable("ADMIN_EMAIL",ilUtil::prepareFormOutput($settings["admin_email"]));
2299 
2300  // client text
2301  $this->tpl->setVariable("TXT_INST_DATA", $this->lng->txt("client_data"));
2302  $this->tpl->setVariable("TXT_INST_NAME", $this->lng->txt("client_name"));
2303  $this->tpl->setVariable("TXT_INST_INFO", $this->lng->txt("client_info"));
2304  $this->tpl->setVariable("TXT_INST_INSTITUTION", $this->lng->txt("client_institution"));
2305 
2306  // contact text
2307  $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
2308  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
2309  $this->tpl->setVariable("TXT_FIRSTNAME", $this->lng->txt("firstname"));
2310  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("lastname"));
2311  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
2312  $this->tpl->setVariable("TXT_POSITION", $this->lng->txt("position"));
2313  $this->tpl->setVariable("TXT_INSTITUTION", $this->lng->txt("institution"));
2314  $this->tpl->setVariable("TXT_STREET", $this->lng->txt("street"));
2315  $this->tpl->setVariable("TXT_ZIPCODE", $this->lng->txt("zipcode"));
2316  $this->tpl->setVariable("TXT_CITY", $this->lng->txt("city"));
2317  $this->tpl->setVariable("TXT_COUNTRY", $this->lng->txt("country"));
2318  $this->tpl->setVariable("TXT_PHONE", $this->lng->txt("phone"));
2319  $this->tpl->setVariable("TXT_EMAIL", $this->lng->txt("email"));
2320  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2321 
2322  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2323  $this->tpl->setVariable("TXT_SETUP_TITLE","contact information & client data");
2324  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
2325 
2326  $this->setButtonPrev("lang");
2327 
2328  $check = $this->checkClientContact($this->client);
2329 
2330  $this->client->status["contact"]["status"] = $check["status"];
2331  $this->client->status["contact"]["comment"] = $check["comment"];
2332 
2333  if ($check["status"])
2334  {
2335  $this->setButtonNext("nic");
2336  }
2337 
2338  $this->checkPanelMode();
2339  }
2340 
2344  function displayNIC()
2345  {
2346  $this->checkDisplayMode("nic_registration");
2347  $settings = $this->client->getAllSettings();
2348  $nic_key = $this->client->getNICkey();
2349 
2350  // formular sent
2351  if ($_POST["form"])
2352  {
2353  // check register option
2354  if ($_POST["form"]["register"] == 1)
2355  {
2356  // update nic
2357  $this->client->updateNIC($this->ilias_nic_server);
2358 
2359  // online registration failed
2360  if (empty($this->client->nic_status[2]))
2361  {
2362  $this->client->setSetting("nic_enabled","-1");
2363  $message = $this->lng->txt("nic_reg_failed");
2364  }
2365  else
2366  {
2367  $this->client->setSetting("inst_id",$this->client->nic_status[2]);
2368  $this->client->setSetting("nic_enabled","1");
2369  $this->client->status["nic"]["status"] = true;
2370  $message = $this->lng->txt("nic_reg_enabled");
2371  }
2372  }
2373  elseif ($_POST["form"]["register"] == 2)
2374  {
2375  $nic_by_email = (int) $_POST["form"]["nic_id"];
2376 
2377  $checksum = md5($nic_key.$nic_by_email);
2378 
2379  if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
2380  {
2381  $message = $this->lng->txt("nic_reg_enter_correct_id");
2382  }
2383  else
2384  {
2385  $this->client->setSetting("inst_id",$nic_by_email);
2386  $this->client->setSetting("nic_enabled","1");
2387  $message = $this->lng->txt("nic_reg_enabled");
2388  }
2389  }
2390  else
2391  {
2392  $this->client->setSetting("inst_id","0");
2393  $this->client->setSetting("nic_enabled","0");
2394  $message = $this->lng->txt("nic_reg_disabled");
2395  }
2396 
2397  ilUtil::sendInfo($message);
2398  }
2399 
2400  // reload settings
2401  $settings = $this->client->getAllSettings();
2402 
2403  if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
2404  {
2405  $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
2406  }
2407  else
2408  {
2409  // reload settings
2410  $settings = $this->client->getAllSettings();
2411 
2412  $email_subject = rawurlencode("NIC registration request");
2413  $email_body = base64_encode($this->client->getURLStringForNIC($this->ilias_nic_server));
2414  $email_link = "<a href=\"mailto:ilias-nic@uni-koeln.de?subject=".$email_subject."&body=".$email_body."\">".$this->lng->txt("email")."</a>";
2415 
2416  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic1")." ".$email_link." ".$this->lng->txt("info_text_nic2"));
2417 
2418  // output
2419  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_nic.html");
2420 
2421  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2422 
2423  // register form
2424  $this->tpl->setVariable("TXT_NIC_ENTER_ID",$this->lng->txt("nic_reg_enter_id"));
2425  $this->tpl->setVariable("TXT_NIC_ENTER_CHECKSUM",$this->lng->txt("nic_reg_enter_checksum"));
2426  $this->tpl->setVariable("TXT_NIC_REGISTER",$this->lng->txt("nic_registration"));
2427  $this->tpl->setVariable("TXT_NIC_ENABLE",$this->lng->txt("nic_reg_online"));
2428  $this->tpl->setVariable("TXT_NIC_EMAIL",$this->lng->txt("nic_reg_email"));
2429  $this->tpl->setVariable("TXT_NIC_DISABLE",$this->lng->txt("nic_reg_disable")." <span class=\"subtitle\">".$this->lng->txt("nic_reg_disable_comment")."</span>");
2430 
2431  $checked = "checked=\"checked\"";
2432 
2433  if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
2434  {
2435  $this->tpl->setVariable("ENABLED",$checked);
2436  }
2437  elseif ($settings["nic_enabled"] == "2")
2438  {
2439  $this->tpl->setVariable("EMAIL",$checked);
2440  }
2441  else
2442  {
2443  $this->tpl->setVariable("DISABLED",$checked);
2444  }
2445 
2446  if (isset($settings["nic_enabled"]))
2447  {
2448  $this->client->status["nic"]["status"] = true;
2449  }
2450  }
2451 
2452  $this->setButtonPrev("contact");
2453 
2454  if ($this->client->status["nic"]["status"])
2455  {
2456  $this->setButtonNext("finish","finish");
2457  }
2458 
2459  $this->checkPanelMode();
2460  }
2461 
2465  function displayTools()
2466  {
2467  $this->checkDisplayMode();
2468 
2469  // output
2470  ilUtil::sendInfo();
2471  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html");
2472  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2473  $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
2474  $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
2475  $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
2476 
2477  $q = "SELECT count(*) as cnt FROM ctrl_calls";
2478  $cset = $this->client->db->query($q);
2479  $crec = $cset->fetchRow(DB_FETCHMODE_ASSOC);
2480  if ($crec["cnt"] == 0)
2481  {
2482  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2483  $this->lng->txt("ctrl_missing_desc"));
2484  }
2485  else
2486  {
2487  $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
2488  $this->lng->txt("ctrl_structure_desc"));
2489  }
2490 
2491  $this->tpl->parseCurrentBlock();
2492 
2493  //$this->checkPanelMode();
2494  }
2495 
2500  {
2501  global $ilCtrlStructureReader;
2502 
2503  if (!$this->client->db_installed)
2504  {
2505  ilUtil::sendInfo($this->lng->txt("no_db"), true);
2506  $this->displayTools();
2507  return;
2508  }
2509 
2510  // referencing does not work in dbupdate-script
2511  $GLOBALS["ilDB"] = new ilDbx($this->client->dsn);
2512 // BEGIN WebDAV
2513  // read module and service information into db
2514  require_once "./classes/class.ilModuleReader.php";
2515  require_once "./classes/class.ilServiceReader.php";
2516  require_once "./classes/class.ilCtrlStructureReader.php";
2517 
2518  chdir("..");
2519  require_once "./Services/Component/classes/class.ilModule.php";
2520  require_once "./Services/Component/classes/class.ilService.php";
2521  $modules = ilModule::getAvailableCoreModules();
2523  chdir("./setup");
2524 
2526  foreach($modules as $module)
2527  {
2528  $mr = new ilModuleReader(ILIAS_ABSOLUTE_PATH."/Modules/".$module["subdir"]."/module.xml",
2529  $module["subdir"], "Modules");
2530  $mr->getModules();
2531  unset($mr);
2532  }
2533 
2535  foreach($services as $service)
2536  {
2537  $sr = new ilServiceReader(ILIAS_ABSOLUTE_PATH."/Services/".$service["subdir"]."/service.xml",
2538  $service["subdir"], "Services");
2539  $sr->getServices();
2540  unset($sr);
2541  }
2542 // END WebDAV
2543 
2544  $ilCtrlStructureReader->readStructure(true);
2545  ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
2546  $this->displayTools();
2547  }
2548 
2549 
2550 
2555  {
2556  $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
2557 
2558  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
2559 
2560  // formular sent
2561  if ($_POST["form"])
2562  {
2563  $pass_old = $this->getPassword();
2564 
2565  if (empty($_POST["form"]["pass_old"]))
2566  {
2567  $message = $this->lng->txt("password_enter_old");
2568  $this->raiseError($message,$this->error_obj->MESSAGE);
2569  }
2570 
2571  if (md5($_POST["form"]["pass_old"]) != $pass_old)
2572  {
2573  $message = $this->lng->txt("password_old_wrong");
2574  $this->raiseError($message,$this->error_obj->MESSAGE);
2575  }
2576 
2577  if (empty($_POST["form"]["pass"]))
2578  {
2579  $message = $this->lng->txt("password_empty");
2580  $this->raiseError($message,$this->error_obj->MESSAGE);
2581  }
2582 
2583  if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
2584  {
2585  $message = $this->lng->txt("password_not_match");
2586  $this->raiseError($message,$this->error_obj->MESSAGE);
2587  }
2588 
2589  if (md5($_POST["form"]["pass"]) == $pass_old)
2590  {
2591  $message = $this->lng->txt("password_same");
2592  $this->raiseError($message,$this->error_obj->MESSAGE);
2593  }
2594 
2595  if (!$this->setPassword($_POST["form"]["pass"]))
2596  {
2597  $message = $this->lng->txt("save_error");
2598  $this->raiseError($message,$this->error_obj->MESSAGE);
2599  }
2600 
2601  ilUtil::sendInfo($this->lng->txt("password_changed"),true);
2602  ilUtil::redirect("setup.php");
2603  }
2604 
2605  // output
2606  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html");
2607 
2608  $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
2609 
2610  // pass form
2611  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2612  $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
2613  $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
2614  $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
2615  $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
2616  $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
2617  $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
2618  }
2619 
2624  {
2625  $this->checkDisplayMode("finish_setup");
2626 
2627 //echo "<b>1</b>";
2628  if ($this->validateSetup())
2629  {
2630  $txt_info = $this->lng->txt("info_text_finish1")."<br /><br />".
2631  "<p>".$this->lng->txt("user").": <b>root</b><br />".
2632  $this->lng->txt("password").": <b>homer</b></p>";
2633  $this->setButtonNext("login_new","login");
2634 //echo "<b>2</b>";
2635  $this->client->reconnect(); // if this is not done, the writing of
2636  // the setup_ok fails (with MDB2 and a larger
2637  // client list), alex 17.1.2008
2638  $this->client->setSetting("setup_ok",1);
2639 //$this->client->setSetting("zzz", "Z");
2640 //echo "<b>3</b>";
2641  $this->client->status["finish"]["status"] = true;
2642 //echo "<b>4</b>";
2643  }
2644  else
2645  {
2646  $txt_info = $this->lng->txt("info_text_finish2");
2647  }
2648 
2649 //echo "<b>5</b>";
2650  // output
2651  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html");
2652  $this->tpl->setVariable("TXT_INFO",$txt_info);
2653 
2654  $this->setButtonPrev("nic");
2655 //echo "<b>6</b>";
2656  $this->checkPanelMode();
2657 //echo "<b>7</b>";
2658  }
2659 
2664  {
2665  $this->checkDisplayMode();
2666 
2667  // formular sent
2668  if ($_POST["form"]["delete"])
2669  {
2670  $ini = true;
2671  $db = false;
2672  $files = false;
2673 
2674  /* disabled
2675  switch ($_POST["form"]["delete"])
2676  {
2677  case 1:
2678  $ini = true;
2679  break;
2680 
2681  case 2:
2682  $ini = true;
2683  $db = true;
2684  break;
2685 
2686  case 3:
2687  $ini = true;
2688  $db = true;
2689  $files = true;
2690  break;
2691  }
2692  */
2693 
2694  $msg = $this->client->delete($ini,$db,$files);
2695 
2696  ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
2697  ilUtil::redirect("setup.php");
2698  }
2699 
2700  $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
2701 
2702  // output
2703  $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html");
2704 
2705  // delete panel
2706  $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
2707  $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
2708  $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
2709  $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
2710 
2711  $this->checkPanelMode();
2712  }
2713 
2719  function changeAccessMode($a_back)
2720  {
2721  if ($this->client->status["finish"]["status"])
2722  {
2723  $val = ($this->client->ini->readVariable("client","access")) ? "0" : true;
2724  $this->client->ini->setVariable("client","access",$val);
2725  $this->client->ini->write();
2726  $message = "client_access_mode_changed";
2727  }
2728  else
2729  {
2730  $message = "client_setup_not_finished";
2731  }
2732 
2733  ilUtil::sendInfo($this->lng->txt($message),true);
2734 
2735  ilUtil::redirect("setup.php?cmd=".$a_back);
2736  }
2737 
2742  {
2743  if ($_POST["form"])
2744  {
2745  $client = new ilClient($_POST["form"]["default"], $this->db_connections);
2746 
2747  if (!$client->init())
2748  {
2749  $this->raiseError($this->lng->txt("no_valid_client_id"),$this->error_obj->MESSAGE);
2750  }
2751 
2752  $status = $this->getStatus($client);
2753 
2754  if ($status["finish"]["status"])
2755  {
2756  $this->ini->setVariable("clients","default",$client->getId());
2757  $this->ini->write();
2758  $message = "default_client_changed";
2759  }
2760  else
2761  {
2762  $message = "client_setup_not_finished";
2763  }
2764  }
2765 
2766  ilUtil::sendInfo($this->lng->txt($message),true);
2767 
2768  ilUtil::redirect("setup.php");
2769  }
2770 
2775  function validateSetup()
2776  {
2777  foreach ($this->client->status as $key => $val)
2778  {
2779  if ($key != "finish" and $key != "access")
2780  {
2781  if ($val["status"] != true)
2782  {
2783  return false;
2784  }
2785  }
2786  }
2787 
2788 //$this->client->setSetting("zzz", "V");
2789  $clientlist = new ilClientList($this->db_connections);
2790 //$this->client->setSetting("zzz", "W");
2791  $list = $clientlist->getClients();
2792 //$this->client->setSetting("zzz", "X");
2793  if (count($list) == 1)
2794  {
2795  $this->ini->setVariable("clients","default",$this->client->getId());
2796  $this->ini->write();
2797 
2798  $this->client->ini->setVariable("client","access",1);
2799  $this->client->ini->write();
2800  }
2801 //$this->client->setSetting("zzz", "Y");
2802  return true;
2803  }
2804 
2809  {
2810  if (!$this->client->status["db"]["status"])
2811  {
2812  $this->cmd = "db";
2813  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
2814  $this->displayDatabase();
2815  }
2816  elseif (!$this->client->status["lang"]["status"])
2817  {
2818  $this->cmd = "lang";
2819  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
2820  $this->displayLanguages();
2821  }
2822  elseif (!$this->client->status["contact"]["status"])
2823  {
2824  $this->cmd = "contact";
2825  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
2826  $this->displayContactData();
2827  }
2828  elseif (!$this->client->status["nic"]["status"])
2829  {
2830  $this->cmd = "nic";
2831  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
2832  $this->displayNIC();
2833  }
2834  elseif (!$this->client->status["finish"]["status"])
2835  {
2836  $this->cmd = "finish";
2837  ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
2838  $this->displayFinishSetup();
2839  }
2840  else
2841  {
2842  return false;
2843  }
2844  }
2845 
2849  function toggleClientList()
2850  {
2851  if ($this->ini->readVariable("clients","list"))
2852  {
2853  $this->ini->setVariable("clients","list","0");
2854  $this->ini->write();
2855  ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
2856  }
2857  else
2858  {
2859  $this->ini->setVariable("clients","list","1");
2860  $this->ini->write();
2861  ilUtil::sendInfo($this->lng->txt("list_enabled"),true);
2862  }
2863 
2864  ilUtil::redirect("setup.php");
2865  }
2866 
2872  /*
2873  public function initBasicSettingsForm($a_mode = "edit")
2874  {
2875  global $lng;
2876 
2877  chdir ("..");
2878  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2879  chdir ("./setup");
2880 
2881  $this->form_gui = new ilPropertyFormGUI();
2882 
2883  $this->form_gui->setTitle($this->lng->txt("change_basic_settings"));
2884 
2885  // Property Title
2886  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_title"), "block_title");
2887  $text_input->setInfo("");
2888  $text_input->setRequired(true);
2889  $text_input->setMaxLength(200);
2890  $this->form_gui->addItem($text_input);
2891 
2892  // Property FeedUrl
2893  $text_input = new ilTextInputGUI($lng->txt("block_feed_block_feed_url"), "block_feed_url");
2894  $text_input->setInfo($lng->txt("block_feed_block_feed_url_info"));
2895  $text_input->setRequired(true);
2896  $text_input->setMaxLength(250);
2897  $this->form_gui->addItem($text_input);
2898 
2899 
2900  // save and cancel commands
2901  if ($a_mode == "create")
2902  {
2903  $this->form_gui->addCommandButton("save", $lng->txt("save"));
2904  $this->form_gui->addCommandButton("cancelSave", $lng->txt("cancel"));
2905  }
2906  else
2907  {
2908  $this->form_gui->addCommandButton("update", $lng->txt("save"));
2909  $this->form_gui->addCommandButton("cancelUpdate", $lng->txt("cancel"));
2910  }
2911 
2912  $this->form_gui->setTitle($lng->txt("block_feed_block_head"));
2913  $this->form_gui->setFormAction("setup.php?cmd=gateway");
2914  }*/
2915 
2916 } // END class.ilSetupGUI
2917 ?>