• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

setup/classes/class.ilSetupGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00033 require_once "class.ilSetup.php";
00034 
00035 class ilSetupGUI extends ilSetup
00036 {
00037         var $tpl;       // template object
00038         var $lng;       // language objet
00039         var $log;       // log object
00040         
00041         var $btn_prev_on = false;   // toggle previous button on/off
00042         var $btn_prev_cmd;          // command processed when previous button was clicked
00043         var $btn_prev_lng;          // previous button label
00044 
00045         var $btn_next_on = false;   // toggle NEXT button on/off
00046         var $btn_next_cmd;          // command processed when next button was clicked
00047         var $btn_next_lng;          // next button label
00048 
00049         var $revision;              // cvs revision of this script
00050         var $version;               // cvs version of this script
00051         var $lang;                  // current language (lang_key)
00052 
00053         var $cmd;                       // command variable
00054         var $display_mode = "view";     // view mode (setup or details)
00055 
00060         function ilSetupGUI()
00061         {
00062                 global $tpl, $lng;
00063 
00064                 $this->tpl =& $tpl;
00065                 $this->lng =& $lng;
00066 
00067                 // CVS - REVISION - DO NOT MODIFY
00068                 $this->revision = '$Revision: 15990 $';
00069                 $this->version = "2 ".substr(substr($this->revision,1),0,-2);
00070                 $this->lang = $this->lng->lang_key;
00071 
00072                 // init setup
00073                 $this->ilSetup($_SESSION["auth"],$_SESSION["access_mode"]);
00074 
00075                 // init client object if exists
00076                 $client_id = ($_GET["client_id"]) ? $_GET["client_id"] : $_SESSION["ClientId"];
00077 
00078                 // for security
00079                 if (!$this->isAdmin() and $client_id != $_SESSION["ClientId"])
00080                 {
00081                         $client_id = $_SESSION["ClientId"];
00082                 }
00083 
00084                 $this->ini_client_exists = $this->newClient($client_id);
00085                 $this->client->status = $this->getStatus();
00086 
00087                 // determine command
00088                 if (($this->cmd = $_GET["cmd"]) == "gateway")
00089                 {
00090                         // surpress warning if POST is not set
00091                         @$this->cmd = key($_POST["cmd"]);
00092                 }
00093 
00094                 // determine display mode here
00095                 // TODO: depending on previous setting (session)
00096                 // 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)
00097                 if ($this->isAuthenticated() and !$this->client->status["finish"]["status"] and $this->cmd != "clientlist" and $this->cmd != "")
00098                 {
00099                         $this->setDisplayMode("setup");
00100                 }
00101                 else
00102                 {
00103                         $this->setDisplayMode($_SESSION["display_mode"]);
00104                 }
00105 
00106                 // output starts here
00107 
00108                 // display header
00109                 $this->displayHeader();
00110 
00111                 // main cmd handling
00112                 if (!$this->isAuthenticated() or !$this->isInstalled())
00113                 {
00114                         // check for first time installation or migrate an old one first
00115                         if (!$this->isInstalled() or !($this->ini->readVariable("clients","path")))
00116                         {
00117                                 $this->cmdInstall();
00118                         }
00119                         else
00120                         {
00121                                 $this->displayLogin();
00122                         }
00123                 }
00124                 else
00125                 {
00126                         if ($this->isAdmin())
00127                         {
00128                                 $this->cmdAdmin();
00129                         }
00130                         else
00131                         {
00132                                 $this->cmdClient();
00133                         }
00134                 }
00135 
00136                 if (DEBUG)
00137                 {
00138                         echo "cmd: ".$this->cmd." | access: ".$this->access_mode." | display: ".$this->display_mode;
00139                         var_dump($this->client->status);
00140                 }
00141 
00142                 // display footer
00143                 $this->displayFooter();
00144 
00145                 // end output
00146 
00147         }  // end constructor
00148 
00149         // cmd subsets
00150 
00154         function cmdInstall()
00155         {
00156                 switch ($this->cmd)
00157                 {
00158                         case NULL:
00159                         case "preliminaries":
00160                                 $this->checkPreliminaries();
00161                                 $this->displayPreliminaries();
00162                                 break;
00163 
00164                         case "install":
00165                                 $this->displayMasterSetup();
00166                                 break;
00167                                 
00168                         case "determineToolsPathInstall":
00169                                 $this->determineToolsPathInstall();
00170                                 break;
00171 
00172                         default:
00173                                 $this->displayError($this->lng->txt("unknown_command"));
00174                                 break;
00175                 }
00176         }
00177 
00181         function cmdAdmin()
00182         {
00183                 switch ($this->cmd)
00184                 {
00185                         case NULL:
00186                         case "clientlist":
00187                                 $this->setDisplayMode("view");
00188                                 $this->displayClientList();
00189                                 break;
00190 
00191                         case "changepassword":
00192                                 $this->setDisplayMode("view");
00193                                 $this->changeMasterPassword();
00194                                 break;
00195 
00196                         case "mastersettings":
00197                                 $this->setDisplayMode("view");
00198                                 $this->changeMasterSettings();
00199                                 break;
00200                                 
00201                         case "determineToolsPath":
00202                                 $this->setDisplayMode("view");
00203                                 $this->determineToolsPath();
00204                                 break;
00205 
00206                         case "changedefault":
00207                                 $this->changeDefaultClient();
00208                                 break;  
00209 
00210                         case "newclient":
00211                                 $this->cmd = "ini";
00212                                 $this->setDisplayMode("setup");
00213                                 $this->ini_client_exists = $this->newClient();
00214                                 $this->displayIni();
00215                                 break;  
00216 
00217                         case "startup":
00218                                 $this->setDisplayMode("setup");
00219                                 $this->ini_client_exists = $this->newClient();
00220                                 $this->displayStartup();
00221                                 break;
00222 
00223                         case "delete":
00224                                 $this->setDisplayMode("view");
00225                                 $this->displayDeleteConfirmation();
00226                                 break;
00227 
00228                         case "togglelist":
00229                                 $this->setDisplayMode("view");
00230                                 $this->toggleClientList();
00231                                 break;
00232 
00233                         default:
00234                                 $this->cmdClient();
00235                                 break;
00236                 }
00237         }
00238         
00242         function cmdClient()
00243         {
00244                 switch ($this->cmd)
00245                 {
00246                         case NULL:
00247                         case "view":
00248                                 if ($this->client->db_installed)
00249                                 {
00250                                         $this->setDisplayMode("view"); 
00251                                         $this->displayClientOverview();
00252                                 }
00253                                 else
00254                                 {
00255                                         $this->cmd = "db";
00256                                         $this->displayDatabase();
00257                                 }
00258                                 break;
00259                                 
00260                         case "ini":
00261                                 // only allow access to ini if db does not exist yet
00262                                 if ($this->client->db_installed)
00263                                 {
00264                                         $this->cmd = "db";
00265                                         $this->displayDatabase();
00266                                 }
00267                                 else
00268                                 {
00269                                         $this->displayIni();
00270                                 }
00271                                 break;
00272                                 
00273                         case "db":
00274                                 $this->displayDatabase();
00275                                 break;
00276         
00277                         case "lang":
00278                                 if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "lang" and $this->error === true)
00279                                 {
00280                                         $this->jumpToFirstUnfinishedSetupStep();
00281                                 }
00282                                 else
00283                                 {
00284                                         $this->displayLanguages();
00285                                 }
00286                                 break;
00287 
00288                         case "contact":
00289                                 if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "contact")
00290                                 {
00291                                         $this->jumpToFirstUnfinishedSetupStep();
00292                                 }
00293                                 else
00294                                 {
00295                                         $this->displayContactData();
00296                                 }
00297                                 break;
00298         
00299                         case "nic":
00300                                 if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "nic")
00301                                 {
00302                                         $this->jumpToFirstUnfinishedSetupStep();
00303                                 }
00304                                 else
00305                                 {
00306                                         $this->displayNIC();
00307                                 }
00308                                 break;
00309         
00310                         case "finish":
00311                                 if (!isset($_GET["lang"]) and !$this->client->status["finish"]["status"] and $_GET["cmd"] == "finish")
00312                                 {
00313                                         $this->jumpToFirstUnfinishedSetupStep();
00314                                 }
00315                                 else
00316                                 {
00317                                         $this->displayFinishSetup();
00318                                 }
00319                                 break;
00320 
00321                         case "changeaccess":
00322                                 $this->changeAccessMode($_GET["back"]);
00323                                 break;
00324 
00325                         case "logout":
00326                                 $this->displayLogout();
00327                                 break;
00328 
00329                         case "login":
00330                                 session_destroy();
00331                                 ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
00332                                 break;
00333 
00334                         case "login_new":
00335                                 if ($this->client->ini->readVariable("client","access") != "1")
00336                                 {
00337                                         $this->client->ini->setVariable("client","access","1");
00338                                         $this->client->ini->write();
00339                                 }
00340 
00341                                 session_destroy();
00342                                 ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
00343                                 break;
00344 
00345                         case "tools":
00346                                 $this->displayTools();
00347                                 break;
00348                                 
00349                         case "reloadStructure":
00350                                 $this->reloadControlStructure();
00351                                 break;
00352 
00353                         default:
00354                                 $this->displayError($this->lng->txt("unknown_command"));
00355                                 break;
00356                 }
00357         }
00358 
00359         // end cmd subsets 
00360 
00364         function displayClientOverview()
00365         {       
00366                 $this->checkDisplayMode();
00367         
00368                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.client_overview.html");
00369 
00370                 if ($this->client->db_installed)
00371                 {
00372                         $settings = $this->client->getAllSettings();
00373                 }
00374                 
00375                 $txt_no_database = $this->lng->txt("no_database");
00376 
00377                 $access_status = ($this->client->status["access"]["status"]) ? "online" : "disabled";
00378                 $access_button = ($this->client->status["access"]["status"]) ? "disable" : "enable";
00379                 $access_link = "&nbsp;&nbsp;[<a href=\"setup.php?cmd=changeaccess&client_id=".$this->client->getId()."&back=view\">".$this->lng->txt($access_button)."</a>]";
00380                 
00381                 // basic data
00382                 $this->tpl->setVariable("TXT_BASIC_DATA", $this->lng->txt("client_info"));
00383                 $this->tpl->setVariable("TXT_INST_NAME", $this->lng->txt("inst_name"));
00384                 $this->tpl->setVariable("TXT_INST_ID", $this->lng->txt("ilias_nic_id"));
00385                 $this->tpl->setVariable("TXT_CLIENT_ID2", $this->lng->txt("client_id"));
00386                 $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("db_version"));
00387                 $this->tpl->setVariable("TXT_ACCESS_STATUS", $this->lng->txt("access_status"));
00388                 
00389                 $this->tpl->setVariable("TXT_SERVER_DATA", $this->lng->txt("server_info"));
00390                 $this->tpl->setVariable("TXT_ILIAS_VERSION", $this->lng->txt("ilias_version"));
00391                 $this->tpl->setVariable("TXT_HOSTNAME", $this->lng->txt("host"));
00392                 $this->tpl->setVariable("TXT_IP_ADDRESS", $this->lng->txt("ip_address"));
00393                 $this->tpl->setVariable("TXT_SERVER_PORT", $this->lng->txt("port"));
00394                 $this->tpl->setVariable("TXT_SERVER_SOFTWARE", $this->lng->txt("server_software"));
00395                 $this->tpl->setVariable("TXT_HTTP_PATH", $this->lng->txt("http_path"));
00396                 $this->tpl->setVariable("TXT_ABSOLUTE_PATH", $this->lng->txt("absolute_path"));
00397                 $this->tpl->setVariable("TXT_DEFAULT_LANGUAGE", $this->lng->txt("default_language"));
00398                 $this->tpl->setVariable("TXT_FEEDBACK_RECIPIENT", $this->lng->txt("feedback_recipient"));
00399                 $this->tpl->setVariable("TXT_ERROR_RECIPIENT", $this->lng->txt("error_recipient"));
00400 
00401                 // paths
00402                 $this->tpl->setVariable("TXT_SOFTWARE", $this->lng->txt("3rd_party_software"));
00403                 $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("path_to_convert"));
00404                 $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("path_to_zip"));
00405                 $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("path_to_unzip"));
00406                 $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("path_to_java"));
00407                 $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("path_to_htmldoc"));
00408                 $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
00409                 $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
00410                 $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
00411                 $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
00412 
00413                 // display formula data
00414 
00415                 // client data
00416                 $this->tpl->setVariable("INST_ID",($this->client->db_installed) ? $settings["inst_id"] : $txt_no_database);
00417                 $this->tpl->setVariable("CLIENT_ID2",$this->client->getId());
00418                 $this->tpl->setVariable("INST_NAME",($this->client->getName()) ? $this->client->getName() : "&lt;".$this->lng->txt("no_client_name")."&gt;");
00419                 $this->tpl->setVariable("INST_INFO",$this->client->getDescription());
00420                 $this->tpl->setVariable("DB_VERSION",($this->client->db_installed) ? $settings["db_version"] : $txt_no_database);
00421                 $this->tpl->setVariable("ACCESS_STATUS",$this->lng->txt($access_status).$access_link);
00422 
00423                 // server data
00424                 $this->tpl->setVariable("HTTP_PATH",ILIAS_HTTP_PATH);
00425                 $this->tpl->setVariable("ABSOLUTE_PATH",ILIAS_ABSOLUTE_PATH);
00426                 $this->tpl->setVariable("HOSTNAME", $_SERVER["SERVER_NAME"]);
00427                 $this->tpl->setVariable("SERVER_PORT", $_SERVER["SERVER_PORT"]);
00428                 $this->tpl->setVariable("SERVER_ADMIN", $_SERVER["SERVER_ADMIN"]);  // not used
00429                 $this->tpl->setVariable("SERVER_SOFTWARE", $_SERVER["SERVER_SOFTWARE"]);
00430                 $this->tpl->setVariable("IP_ADDRESS", $_SERVER["SERVER_ADDR"]);
00431                 $this->tpl->setVariable("ILIAS_VERSION", ILIAS_VERSION);
00432 
00433                 $this->tpl->setVariable("FEEDBACK_RECIPIENT",($this->client->db_installed) ? $settings["feedback_recipient"] : $txt_no_database);
00434                 $this->tpl->setVariable("ERROR_RECIPIENT",($this->client->db_installed) ? $settings["error_recipient"] : $txt_no_database);
00435 
00436                 // paths to tools
00437                 $not_set = $this->lng->txt("path_not_set");
00438                                 
00439                 $convert = $this->ini->readVariable("tools","convert");
00440                 $zip = $this->ini->readVariable("tools","zip");
00441                 $unzip = $this->ini->readVariable("tools","unzip");
00442                 $java = $this->ini->readVariable("tools","java");
00443                 $htmldoc = $this->ini->readVariable("tools","htmldoc");
00444                 $latex = $this->ini->readVariable("tools", "latex");
00445                 $vscan = $this->ini->readVariable("tools","vscantype");
00446                 $scancomm = $this->ini->readVariable("tools","scancommand");
00447                 $cleancomm = $this->ini->readVariable("tools","cleancommand");
00448                 
00449                 $this->tpl->setVariable("CONVERT_PATH",($convert) ? $convert : $not_set);
00450                 $this->tpl->setVariable("ZIP_PATH",($zip) ? $zip : $not_set);
00451                 $this->tpl->setVariable("UNZIP_PATH",($unzip) ? $unzip : $not_set);
00452                 $this->tpl->setVariable("JAVA_PATH",($java) ? $java : $not_set);
00453                 $this->tpl->setVariable("HTMLDOC_PATH",($htmldoc) ? $htmldoc : $not_set);
00454                 $this->tpl->setVariable("LATEX_URL",($latex) ? $latex : $not_set);
00455                 $this->tpl->setVariable("VAL_SCAN_COMMAND",($scancomm) ? $scancomm : $not_set);
00456                 $this->tpl->setVariable("VAL_CLEAN_COMMAND",($cleancomm) ? $cleancomm : $not_set);
00457                 $this->tpl->setVariable("VAL_VIRUS_SCANNER",($vscan) ? $vscan : $not_set);
00458 
00459                 $this->tpl->parseCurrentBlock();
00460 
00461                 $this->displayStatusPanel();
00462         }
00463 
00472         function setDisplayMode($a_mode)
00473         {
00474                 // security
00475                 if ($a_mode != "view" and $a_mode != "setup")
00476                 {
00477                         return false;
00478                 }
00479 
00480                 $this->display_mode = $a_mode;
00481                 $_SESSION["display_mode"] = $this->display_mode;
00482                 
00483                 return true;
00484         }
00485         
00489         function displayHeader()
00490         {
00491                 $languages = $this->lng->getLanguages();
00492 
00493                 $count = (int) round(count($languages) / 2);
00494                 $num = 1;
00495 
00496                 foreach ($languages as $lang_key)
00497                 {
00498                         if ($num === $count)
00499                         {
00500                                 $this->tpl->touchBlock("lng_new_row");
00501                         }
00502 
00503                         $this->tpl->setCurrentBlock("languages");
00504                         $this->tpl->setVariable("LINK_LANG", "./setup.php?cmd=".$this->cmd."&amp;lang=".$lang_key);
00505                         $this->tpl->setVariable("LANG_NAME", $this->lng->txt("meta_l_".$lang_key));
00506                         $this->tpl->setVariable("LANG_ICON", $lang_key);
00507                         $this->tpl->setVariable("LANG_KEY", $lang_key);
00508                         $this->tpl->setVariable("BORDER", 0);
00509                         $this->tpl->setVariable("VSPACE", 0);
00510                         $this->tpl->parseCurrentBlock();
00511 
00512                         $num++;
00513                 }
00514 
00515                 if (count($languages) % 2)
00516                 {
00517                         $this->tpl->touchBlock("lng_empty_cell");
00518                 }
00519 
00520                 if ($this->cmd != "logout" and $this->isInstalled())
00521                 {
00522                         // add client link
00523                         if ($this->isAdmin())
00524                         {
00525                                 if ($this->display_mode == "view" or $this->cmd == "clientlist" or $this->cmd == "changepassword" or $this->cmd == "mastersettings")
00526                                 {
00527                                         $this->tpl->setCurrentBlock("add_client");
00528                                         $this->tpl->setVariable("TXT_ADD_CLIENT",ucfirst($this->lng->txt("new_client")));
00529                                         $this->tpl->parseCurrentBlock();
00530                                 }
00531 
00532                                 // client list link
00533                                 $this->tpl->setCurrentBlock("display_list");
00534                                 $this->tpl->setVariable("TXT_LIST",ucfirst($this->lng->txt("list_clients")));
00535                                 $this->tpl->parseCurrentBlock();
00536 
00537                                 // edit paths link
00538                                 $this->tpl->setCurrentBlock("edit_pathes");
00539                                 $this->tpl->setVariable("TXT_EDIT_PATHES",$this->lng->txt("basic_settings"));
00540                                 $this->tpl->parseCurrentBlock();
00541 
00542                                 // change password link
00543                                 $this->tpl->setCurrentBlock("change_password");
00544                                 $this->tpl->setVariable("TXT_CHANGE_PASSWORD",ucfirst($this->lng->txt("password")));
00545                                 $this->tpl->parseCurrentBlock();
00546                         }
00547 
00548                         // logout link
00549                         if ($this->isAuthenticated())
00550                         {
00551                                 $this->tpl->setCurrentBlock("logout");
00552                                 $this->tpl->setVariable("TXT_LOGOUT",$this->lng->txt("logout"));
00553                                 $this->tpl->parseCurrentBlock();
00554                         }
00555                 }
00556 
00557                 $this->tpl->setVariable("VAL_CMD", $_GET["cmd"]);
00558                 $this->tpl->setVariable("TXT_OK",$this->lng->txt("change"));
00559                 $this->tpl->setVariable("TXT_CHOOSE_LANGUAGE",$this->lng->txt("choose_language"));
00560                 $this->tpl->setVariable("PAGETITLE","Setup");
00561                 //$this->tpl->setVariable("LOCATION_STYLESHEET","./templates/blueshadow.css");
00562                 $this->tpl->setVariable("LOCATION_STYLESHEET","../templates/default/delos.css");
00563                 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET","../templates/default/delos_cont.css");
00564                 $this->tpl->setVariable("TXT_ILIAS_VERSION", "ILIAS ".ILIAS_VERSION);
00565                 $this->tpl->setVariable("TXT_SETUP",$this->lng->txt("setup"));
00566                 $this->tpl->setVariable("VERSION", $this->version);
00567                 $this->tpl->setVariable("TXT_VERSION", $this->lng->txt("version"));
00568                 $this->tpl->setVariable("LANG", $this->lang);
00569         }
00570 
00574         function displayFooter()
00575         {
00576                 // footer (not really)
00577                 if ($this->cmd != "logout")
00578                 {
00579                         if ($this->ini_ilias_exists and $this->display_mode == "setup" and $this->client->getId() != "")
00580                         {
00581                                 $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("client_id").": ".$this->client->getId().")");
00582                         }
00583                         elseif ($this->isAdmin())
00584                         {
00585                                 $this->tpl->setVariable("TXT_ACCESS_MODE","(".$this->lng->txt("root_access").")");
00586                         }
00587                 
00588                         $this->displayNavButtons();
00589                 }
00590                 
00591                 $this->tpl->show();
00592         }
00593 
00599         function displayNavButtons()
00600         {
00601                 if (!$this->btn_prev_on and !$this->btn_next_on)
00602                 {
00603                         return false;
00604                 }
00605                 
00606                 $this->tpl->addBlockFile("NAVBUTTONS","navbuttons","tpl.navbuttons.html");
00607 
00608                 $this->tpl->setVariable("FORMACTION_BUTTONS","setup.php?cmd=gateway");
00609 
00610                 if ($this->btn_prev_on)
00611                 {
00612                         $this->tpl->setCurrentBlock("btn_back");
00613                         $this->tpl->setVariable("TXT_PREV", $this->btn_prev_lng);   
00614                         $this->tpl->setVariable("CMD_PREV", $this->btn_prev_cmd);   
00615                         $this->tpl->parseCurrentBlock();
00616                 }
00617                 
00618                 if ($this->btn_next_on)
00619                 {
00620                         $this->tpl->setCurrentBlock("btn_forward");
00621                         $this->tpl->setVariable("TXT_NEXT", $this->btn_next_lng);
00622                         $this->tpl->setVariable("CMD_NEXT", $this->btn_next_cmd);   
00623                         $this->tpl->parseCurrentBlock();
00624                 }
00625                 
00626                 return true;
00627         }
00628 
00635         function SetButtonPrev($a_cmd = 0,$a_lng = 0)
00636         {
00637                 $this->btn_prev_on = true;
00638                 $this->btn_prev_cmd = ($a_cmd) ? $a_cmd : "gateway";
00639                 $this->btn_prev_lng = ($a_lng) ? $this->lng->txt($a_lng) : "<<&nbsp;&nbsp;&nbsp;".$this->lng->txt("prev");
00640         }
00641 
00648         function SetButtonNext($a_cmd,$a_lng = 0)
00649         {
00650                 $this->btn_next_on = true;
00651                 $this->btn_next_cmd = ($a_cmd) ? $a_cmd : "gateway";
00652                 $this->btn_next_lng = ($a_lng) ? $this->lng->txt($a_lng) : $this->lng->txt("next")."&nbsp;&nbsp;&nbsp;>>";
00653         }
00654 
00658         function displayPreliminaries()
00659         {
00660                 $OK = "<font color=\"green\"><strong>OK</strong></font>";
00661                 $FAILED = "<strong><font color=\"red\">FAILED</font></strong>";
00662                 
00663                 $this->tpl->addBlockFile("CONTENT","content","tpl.preliminaries.html");
00664                 
00665                 $this->tpl->setVariable("TXT_SETUP_TITLE",$this->lng->txt("ilias_setup"));
00666                 $this->tpl->setVariable("TXT_SETUP_WELCOME", $this->lng->txt("setup_welcome"));
00667                 $this->tpl->setVariable("TXT_SETUP_INIFILE_DESC", $this->lng->txt("setup_inifile_desc"));
00668                 $this->tpl->setVariable("TXT_SETUP_DATABASE_DESC", $this->lng->txt("setup_database_desc"));
00669                 $this->tpl->setVariable("TXT_SETUP_LANGUAGES_DESC", $this->lng->txt("setup_languages_desc"));
00670                 $this->tpl->setVariable("TXT_SETUP_PASSWORD_DESC", $this->lng->txt("setup_password_desc"));     
00671                 $this->tpl->setVariable("TXT_SETUP_NIC_DESC", $this->lng->txt("setup_nic_desc"));   
00672         
00673                 $server_os = php_uname();
00674                 $server_web = $_SERVER["SERVER_SOFTWARE"];
00675                 $environment = $this->lng->txt("env_using")." ".$server_os." <br/>".$this->lng->txt("with")." ".$server_web;
00676                 
00677                 if ((stristr($server_os,"linux") || stristr($server_os,"windows")) && stristr($server_web,"apache"))
00678                 {
00679                         $env_comment = $this->lng->txt("env_ok");       
00680                 }
00681                 else
00682                 {
00683                         $env_comment = "<font color=\"red\">".$this->lng->txt("env_warning")."</font>";
00684                 }
00685                         
00686                 $this->tpl->setVariable("TXT_ENV_TITLE", $this->lng->txt("environment"));
00687                 $this->tpl->setVariable("TXT_ENV_INTRO", $environment);
00688                 $this->tpl->setVariable("TXT_ENV_COMMENT", $env_comment);   
00689                 
00690                 $this->tpl->setVariable("TXT_PRE_TITLE", $this->lng->txt("preliminaries"));
00691                 $this->tpl->setVariable("TXT_PRE_INTRO", $this->lng->txt("pre_intro"));
00692 
00693                 // display phpversion
00694                 $this->tpl->setCurrentBlock("preliminary");
00695                 $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_php_version").": ".$arCheck["php"]["version"]);
00696 
00697                 if ($this->preliminaries_result["php"]["status"] == true)
00698                 {
00699                         $this->tpl->setVariable("STATUS_PRE", $OK);
00700                 }
00701                 else
00702                 {
00703                         $this->tpl->setVariable("STATUS_PRE", $FAILED);
00704                         $this->tpl->setVariable("COMMENT_PRE", $this->preliminaries_result["php"]["comment"]);
00705                 }
00706 
00707                 $this->tpl->parseCurrentBlock();
00708         
00709                 // check if ilias3 folder is writable
00710                 $this->tpl->setCurrentBlock("preliminary");
00711                 $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_folder_write"));
00712 
00713                 if ($this->preliminaries_result["root"]["status"] == true)
00714                 {
00715                         $this->tpl->setVariable("STATUS_PRE", $OK);
00716                 }
00717                 else
00718                 {
00719                         $this->tpl->setVariable("STATUS_PRE", $FAILED);
00720                         $this->tpl->setVariable("COMMENT_PRE", $this->preliminaries_result["root"]["comment"]);
00721                 }
00722                 $this->tpl->parseCurrentBlock();
00723                 
00724                 // check if ilias3 can create new folders
00725                 $this->tpl->setCurrentBlock("preliminary");
00726                 $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_folder_create"));
00727 
00728                 if ($this->preliminaries_result["create"]["status"] == true)
00729                 {
00730                         $this->tpl->setVariable("STATUS_PRE", $OK);
00731                 }
00732                 else
00733                 {
00734                         $this->tpl->setVariable("STATUS_PRE", $FAILED);
00735                         $this->tpl->setVariable("COMMENT_PRE", $this->preliminaries_result["create"]["comment"]);
00736                 }
00737 
00738                 $this->tpl->parseCurrentBlock();
00739 
00740                 // check cookies
00741                 $this->tpl->setCurrentBlock("preliminary");
00742                 $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_cookies_enabled"));
00743 
00744                 if ($this->preliminaries_result["cookies"]["status"] == true)
00745                 {
00746                         $this->tpl->setVariable("STATUS_PRE", $OK);
00747                 }
00748                 else
00749                 {
00750                         $this->tpl->setVariable("STATUS_PRE", $FAILED);
00751                         $this->tpl->setVariable("COMMENT_PRE", $this->preliminaries_result["cookies"]["comment"]);
00752                 }
00753 
00754                 $this->tpl->parseCurrentBlock();
00755 
00756                 // check javascript
00757                 $this->tpl->setCurrentBlock("preliminary_js");
00758                 $this->tpl->setVariable("TXT_PRE", $this->lng->txt("pre_javascript_enabled"));
00759                 $this->tpl->setVariable("STATUS_PRE", $FAILED);
00760                 $this->tpl->setVariable("COMMENT_PRE", $this->lng->txt("pre_javascript_comment"));
00761                 $this->tpl->parseCurrentBlock();
00762 
00763                 // summary
00764                 if ($this->preliminaries === true)
00765                 {
00766                         $cmd = "install";
00767 
00768                         $btn_text = ($this->cmd == "preliminaries") ? "" : "installation";
00769                         $this->setButtonNext($cmd,$btn_text);
00770                 }
00771                 else
00772                 {
00773                         $this->tpl->setCurrentBlock("premessage");
00774                         $this->tpl->setVariable("TXT_PRE_ERR", $this->lng->txt("pre_error"));
00775                         $this->tpl->parseCurrentBlock();
00776                 }
00777         }
00778         
00782         function displayMasterSetup($a_det = false)
00783         {
00784                 if ($_POST["form"])
00785                 {
00786                         if (!$this->checkDataDirSetup($_POST["form"]))
00787                         {
00788                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
00789                         }
00790         
00791                         if (!$this->checkLogSetup($_POST["form"]))
00792                         {
00793                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
00794                         }
00795 
00796                         if ($a_det)
00797                         {
00798                                 $_POST["form"] = $this->determineTools($_POST["form"]);
00799                         }
00800                         
00801                         /*if (!$this->checkToolsSetup($_POST["form"]))
00802                         {
00803                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
00804                         }*/
00805                         
00806                         if (!$this->checkPasswordSetup($_POST["form"]))
00807                         {
00808                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
00809                         }
00810 
00811                         if (!$this->saveMasterSetup($_POST["form"]))
00812                         {
00813                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
00814                         }           
00815                         
00816                         ilUtil::sendInfo($this->lng->txt("settings_saved"),true);
00817                         
00818                         ilUtil::redirect("setup.php?cmd=mastersettings");
00819                 }
00820 
00821                 $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
00822 
00823                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_mastersetup.html");
00824 
00825                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
00826                 
00827                 // for checkboxes & radio buttons
00828                 $checked = "checked=\"checked\"";
00829 
00830                 // general
00831                 $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("dsfsdave"));
00832                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("setup_basic_settings"));
00833                 $this->tpl->setVariable("SUBMIT_CMD", "install");
00834                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
00835                 $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("enter_dir_and_filename"));
00836                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_first_install")."<br/>".$this->lng->txt("info_text_pathes"));
00837                 $this->tpl->setVariable("TXT_DET_TOOLS_PATH", $this->lng->txt("determine_tools_paths"));
00838                 $this->tpl->setVariable("CMD_DET_TOOLS_PATH", "determineToolsPathInstall");
00839 
00840                 
00841                 if ($this->safe_mode)
00842                 {
00843                         $this->tpl->setVariable("SAFE_MODE_STYLE", " class=\"message\" ");
00844                         $this->tpl->setVariable("TXT_SAFE_MODE_INFO", $this->lng->txt("safe_mode_enabled"));
00845                 }
00846                 else
00847                 {
00848                         $this->tpl->setVariable("TXT_SAFE_MODE_INFO", "");
00849                 }
00850 
00851                 // datadir
00852                 $this->tpl->setCurrentBlock("setup_datadir");
00853                 $this->tpl->setVariable("TXT_DATADIR_TITLE", $this->lng->txt("main_datadir_outside_webspace"));
00854                 $this->tpl->setVariable("TXT_DATADIR_PATH", $this->lng->txt("datadir_path"));
00855                 $this->tpl->setVariable("TXT_DATADIR_COMMENT1", $this->lng->txt("datadir_path_comment1"));
00856                 $this->tpl->setVariable("TXT_CREATE", $this->lng->txt("create_directory"));
00857                 // values
00858                 //echo $this->ini->readVariable($this->ini->readVariable("server","presetting"),"data_dir");
00859                 if ($_SESSION["error_post_vars"]["form"])
00860                 {
00861                         $this->tpl->setVariable("DATADIR_PATH", $_SESSION["error_post_vars"]["form"]["datadir_path"]);
00862                 }
00863                 elseif ($this->ini->readVariable("server","presetting") != "")
00864                 {
00865                         $this->tpl->setVariable("DATADIR_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"data_dir"));
00866                 }
00867 
00868 
00869                         
00870                 //$chk_datadir_path = ($_SESSION["error_post_vars"]["form"]["chk_datadir_path"]) ? "CHK_DATADIR_PATH_TARGET" : "CHK_DATADIR_PATH_CREATE";
00871                 $chk_datadir_path = ($_SESSION["error_post_vars"]["form"]["chk_datadir_path"]) ? $checked : "";
00872                 $this->tpl->setVariable("CHK_DATADIR_PATH",$chk_datadir_path);
00873                 $this->tpl->parseCurrentBlock();
00874                 
00875                 // logging
00876                 $this->tpl->setCurrentBlock("setup_log");
00877                 $this->tpl->setVariable("TXT_LOG_TITLE", $this->lng->txt("logging"));
00878                 $this->tpl->setVariable("TXT_LOG_PATH", $this->lng->txt("log_path"));
00879                 $this->tpl->setVariable("TXT_LOG_COMMENT", $this->lng->txt("log_path_comment"));
00880                 $this->tpl->setVariable("TXT_DISABLE_LOGGING", $this->lng->txt("disable_logging"));
00881 
00882                 // values
00883                 if ($_SESSION["error_post_vars"]["form"])
00884                 {
00885                         $this->tpl->setVariable("LOG_PATH", $_SESSION["error_post_vars"]["form"]["log_path"]);
00886                 }
00887                 elseif ($this->ini->readVariable("server","presetting") != "")
00888                 {
00889                         $this->tpl->setVariable("LOG_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"log"));
00890                 }
00891 
00892                 $chk_log_path = ($_SESSION["error_post_vars"]["form"]["chk_log_status"]) ? $checked : "";
00893                 $this->tpl->setVariable("CHK_LOG_STATUS",$chk_log_path);
00894                 $this->tpl->parseCurrentBlock();
00895 
00896                 // tools
00897                 $this->tpl->setCurrentBlock("setup_tools");
00898                 $this->tpl->setVariable("TXT_DISABLE_CHECK", $this->lng->txt("disable_check"));
00899                 $this->tpl->setVariable("TXT_TOOLS_TITLE", $this->lng->txt("3rd_party_software"));
00900                 $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("convert_path"));
00901                 $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("zip_path"));
00902                 $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("unzip_path"));
00903                 $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("java_path"));
00904                 $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("htmldoc_path"));
00905                 $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
00906 
00907                 $this->tpl->setVariable("TXT_CONVERT_COMMENT", $this->lng->txt("convert_path_comment"));
00908                 $this->tpl->setVariable("TXT_ZIP_COMMENT", $this->lng->txt("zip_path_comment"));
00909                 $this->tpl->setVariable("TXT_UNZIP_COMMENT", $this->lng->txt("unzip_path_comment"));
00910                 $this->tpl->setVariable("TXT_JAVA_COMMENT", $this->lng->txt("java_path_comment"));
00911                 $this->tpl->setVariable("TXT_HTMLDOC_COMMENT", $this->lng->txt("htmldoc_path_comment"));
00912                 $this->tpl->setVariable("TXT_LATEX_URL_COMMENT", $this->lng->txt("latex_url_comment"));
00913 
00914                 // values
00915                 if ($_SESSION["error_post_vars"]["form"])
00916                 {
00917                         $this->tpl->setVariable("CONVERT_PATH", $_SESSION["error_post_vars"]["form"]["convert_path"]);
00918                         $this->tpl->setVariable("ZIP_PATH", $_SESSION["error_post_vars"]["form"]["zip_path"]);
00919                         $this->tpl->setVariable("UNZIP_PATH", $_SESSION["error_post_vars"]["form"]["unzip_path"]);
00920                         $this->tpl->setVariable("JAVA_PATH", $_SESSION["error_post_vars"]["form"]["java_path"]);
00921                         $this->tpl->setVariable("HTMLDOC_PATH", $_SESSION["error_post_vars"]["form"]["htmldoc_path"]);
00922                         $this->tpl->setVariable("LATEX_URL", $_SESSION["error_post_vars"]["form"]["latex_url"]);
00923                 }
00924                 elseif ($this->ini->readVariable("server","presetting") != "")
00925                 {
00926                         $this->tpl->setVariable("CONVERT_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"convert"));
00927                         $this->tpl->setVariable("ZIP_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"zip"));
00928                         $this->tpl->setVariable("UNZIP_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"unzip"));
00929                         $this->tpl->setVariable("JAVA_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"java"));
00930                         $this->tpl->setVariable("HTMLDOC_PATH", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"htmldoc"));
00931                         $this->tpl->setVariable("LATEX_URL", $this->ini->readVariable($this->ini->readVariable("server","presetting"),"latex"));
00932                 }
00933                                                                 
00934                 $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
00935                 $this->tpl->setVariable("TXT_NONE", $this->lng->txt("none"));
00936                 $this->tpl->setVariable("TXT_SOPHOS", $this->lng->txt("sophos"));
00937                 $this->tpl->setVariable("TXT_ANTIVIR", $this->lng->txt("antivir"));
00938                 $this->tpl->setVariable("TXT_CLAMAV", $this->lng->txt("clamav"));
00939                 $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
00940                 $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
00941 
00942 
00943                 $chk_convert_path = ($_SESSION["error_post_vars"]["form"]["chk_convert_path"]) ? $checked : "";
00944                 $chk_zip_path = ($_SESSION["error_post_vars"]["form"]["chk_zip_path"]) ? $checked : "";
00945                 $chk_unzip_path = ($_SESSION["error_post_vars"]["form"]["chk_unzip_path"]) ? $checked : "";
00946                 $chk_java_path = ($_SESSION["error_post_vars"]["form"]["chk_java_path"]) ? $checked : "";
00947                 $chk_htmldoc_path = ($_SESSION["error_post_vars"]["form"]["chk_htmldoc_path"]) ? $checked : "";
00948                 $chk_latex_url = ($_SESSION["error_post_vars"]["form"]["chk_latex_url"]) ? $checked : "";
00949 
00950                 $this->tpl->setVariable("CHK_CONVERT_PATH", $chk_convert_path);
00951                 $this->tpl->setVariable("CHK_ZIP_PATH", $chk_zip_path);
00952                 $this->tpl->setVariable("CHK_UNZIP_PATH", $chk_unzip_path);
00953                 $this->tpl->setVariable("CHK_JAVA_PATH", $chk_java_path);
00954                 $this->tpl->setVariable("CHK_HTMLDOC_PATH", $chk_htmldoc_path);
00955                 $this->tpl->setVariable("CHK_LATEX_URL", $chk_latex_url);
00956                 $this->tpl->parseCurrentBlock();
00957                 
00958                 // setup password
00959                 $this->tpl->setCurrentBlock("setup_pass");
00960                 $this->tpl->setVariable("TXT_SETUP_PASS_TITLE", $this->lng->txt("setup_pass_title"));
00961                 $this->tpl->setVariable("TXT_SETUP_PASS_COMMENT", $this->lng->txt("password_info"));
00962                 $this->tpl->setVariable("TXT_SETUP_PASS", $this->lng->txt("setup_pass"));
00963                 $this->tpl->setVariable("TXT_SETUP_PASS2", $this->lng->txt("setup_pass2"));
00964                 // values
00965                 $this->tpl->setVariable("SETUP_PASS", $_SESSION["error_post_vars"]["form"]["setup_pass"]);
00966                 $this->tpl->setVariable("SETUP_PASS2", $_SESSION["error_post_vars"]["form"]["setup_pass2"]);
00967                 $this->tpl->parseCurrentBlock();
00968                 
00969                 $this->setButtonPrev("preliminaries");
00970 
00971                 if ($this->isInstalled())
00972                 {
00973                         $this->setButtonNext("list");
00974                 }
00975         }
00976         
00980         function loginClient()
00981         {
00982                 session_destroy();
00983                 
00984                 ilUtil::redirect(ILIAS_HTTP_PATH."/login.php?client_id=".$this->client->getId());
00985         }
00986         
00990         function displayLogin()
00991         {
00992                 $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
00993 
00994                 if ($_POST["form"])
00995                 {
00996                         // first check client login
00997                         if (empty($_POST["form"]["admin_password"]))
00998                         {
00999                                 if (!$this->loginAsClient($_POST["form"]))
01000                                 {
01001                                         if ($error_msg = $this->getError())
01002                                         {
01003                                                 $this->raiseError($this->lng->txt($error_msg),$this->error_obj->MESSAGE);
01004                                         }
01005                                 }
01006                         }
01007                         else
01008                         {
01009                                 if (!$this->loginAsAdmin($_POST["form"]["admin_password"]))
01010                                 {
01011                                         $this->raiseError($this->lng->txt("login_invalid"),$this->error_obj->MESSAGE);
01012                                 }
01013                         }
01014 
01015                         ilUtil::redirect("setup.php");
01016                 }
01017 
01018                 // output
01019                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_login.html");
01020                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
01021                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_login"));
01022 
01023                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_login"));
01024 
01025                 $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
01026                 $this->tpl->setVariable("TXT_CLIENT_LOGIN",$this->lng->txt("client_login"));
01027                 $this->tpl->setVariable("TXT_CLIENT_ID",$this->lng->txt("client_id"));
01028                 $this->tpl->setVariable("TXT_USERNAME",ucfirst($this->lng->txt("username")));
01029                 $this->tpl->setVariable("TXT_PASSWORD",ucfirst($this->lng->txt("password")));
01030                 $this->tpl->setVariable("TXT_OR",strtoupper($this->lng->txt("or")));
01031                 $this->tpl->setVariable("TXT_ADMIN_LOGIN",$this->lng->txt("admin_login"));
01032                 $this->tpl->setVariable("TXT_ADMIN_PASSWORD",ucfirst($this->lng->txt("password")));
01033                 $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt("submit"));
01034         }
01035 
01039         function displayClientList()
01040         {
01041                 $_SESSION["ClientId"] = "";
01042                 
01043                 $_GET["sort_by"] = ($_GET["sort_by"]) ? $_GET["sort_by"] : "name";
01044 
01045                 $clientlist = new ilClientList();
01046                 $list = $clientlist->getClients();
01047 
01048                 if (count($list) == 0)
01049                 {
01050                         ilUtil::sendInfo($this->lng->txt("no_clients_available"),true);
01051                 }
01052                 
01053                 // prepare clientlist
01054                 $data = array();
01055                 $data["data"] = array();
01056                 $data["ctrl"] = array();
01057                 $data["cols"] = array("","name","id","login","details","status","access");
01058 
01059                 foreach ($list as $key => $client)
01060                 {
01061                         // check status 
01062                         $status_arr = $this->getStatus($client);
01063 
01064                         if (!$status_arr["db"]["status"])
01065                         {
01066                                 $status = $status_arr["db"]["comment"];
01067                         }
01068                         elseif (!$status_arr["finish"]["status"])
01069                         {
01070                                 $status = $this->lng->txt("setup_not_finished");
01071                         }
01072                         else
01073                         {
01074                                 $status = "<font color=\"green\"><strong>OK</strong></font>";
01075                         }
01076                         
01077                         if ($status_arr["access"]["status"])
01078                         {
01079                                 $access = "online";
01080                         }
01081                         else
01082                         {
01083                                 $access = "disabled";
01084                         }
01085                         
01086                         if ($key == $this->default_client)
01087                         {
01088                                 $default = " checked=\"checked\"";
01089                         }
01090                         else
01091                         {
01092                                 $default = "";
01093                         }
01094                         
01095                         if ($status_arr["finish"]["status"] and $status_arr["access"]["status"])
01096                         {
01097                                 $login = "<a href=\"../login.php?client_id=".$key."\">Login</a>";
01098                         }
01099                         else
01100                         {
01101                                 $login = "&nbsp;";
01102                         }
01103 
01104                         $access_html = "<a href=\"setup.php?cmd=changeaccess&client_id=".$key."&back=clientlist\">".$this->lng->txt($access)."</a>";
01105                         
01106                         $client_name = ($client->getName()) ? $client->getName() : "&lt;".$this->lng->txt("no_client_name")."&gt;";
01107                         
01108                         // visible data part
01109                         $data["data"][] = array(
01110                                                         "default"       => "<input type=\"radio\" name=\"form[default]\" value=\"".$key."\"".$default."/>",
01111                                                         "name"          => $client_name."#separator#".$client->getDescription(),
01112                                                         "id"            => $key,
01113                                                         "login"         => $login,
01114                                                         "details"       => "<a href=\"setup.php?cmd=view&client_id=".$key."\">Details</a>",
01115                                                         "status"        => $status,
01116                                                         "access_html"   => $access_html
01117                                                         );
01118 
01119                 }
01120 
01121                 $this->maxcount = count($data["data"]);
01122 
01123                 // sorting array
01124                 $data["data"] = ilUtil::sortArray($data["data"],$_GET["sort_by"],$_GET["sort_order"]);
01125 
01126                 $this->tpl->addBlockFile("CONTENT","content","tpl.clientlist.html");
01127                 
01128                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_list"));
01129                 
01130                 ilUtil::sendInfo();
01131 
01132                 // load template for table
01133                 $this->tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
01134                 // load template for table content data
01135                 $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
01136 
01137                 // common
01138                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("available_clients"));
01139                 $this->tpl->setVariable("TXT_LISTSTATUS",($this->ini->readVariable("clients","list")) ? $this->lng->txt("display_clientlist") : $this->lng->txt("hide_clientlist"));
01140                 $this->tpl->setVariable("TXT_TOGGLELIST",($this->ini->readVariable("clients","list")) ? $this->lng->txt("disable") : $this->lng->txt("enable"));
01141 
01142                 $this->tpl->setVariable("FORMACTION","setup.php?cmd=gateway");
01143 
01144                 // build table
01145                 include_once "../Services/Table/classes/class.ilTableGUI.php";
01146                 $tbl = new ilTableGUI();
01147                 $tbl->disable("sort");
01148                 //$tbl->enable("header");
01149 
01150                 $num = 0;
01151 
01152                 // title & header columns
01153                 $tbl->setTitle(ucfirst($this->lng->txt("select_client")));
01154 
01155                 foreach ($data["cols"] as $val)
01156                 {
01157                         $header_names[] = ucfirst($this->lng->txt($val));
01158                 }
01159                 $tbl->setHeaderNames($header_names);
01160                 $tbl->setHeaderVars($data["cols"],$header_params);
01161                 $tbl->setColumnWidth(array("5%","30%","10%","10%","10%","20%","15%"));
01162                 
01163                 // control
01164                 $tbl->setOrderColumn($_GET["sort_by"],"name");
01165                 $tbl->setOrderDirection($_GET["sort_order"],"asc");
01166                 $tbl->setLimit(0);
01167                 $tbl->setOffset(0);
01168                 $tbl->setMaxCount($maxcount);
01169                 
01170                 // show valid actions
01171                 $this->tpl->setVariable("COLUMN_COUNTS",count($data["cols"]));
01172                 
01173                 // footer
01174                 //$tbl->setFooter("tbl_footer");
01175                 
01176                 $tbl->disable("footer");
01177                 $tbl->disable("icon");
01178                 $tbl->disable("numinfo");
01179                 
01180                 // render table
01181                 $tbl->render();
01182 
01183                 if (is_array($data["data"][0]))
01184                 {
01185                         // table cell
01186                         for ($i=0; $i < count($data["data"]); $i++)
01187                         {
01188                                 $data2 = $data["data"][$i];
01189                                 $ctrl = $data["ctrl"][$i];
01190 
01191                                 // color changing
01192                                 $css_row = ilUtil::switchColor($i+1,"tblrow1","tblrow2");
01193 
01194                                 $this->tpl->setCurrentBlock("table_cell");
01195                                 $this->tpl->setVariable("CELLSTYLE", "tblrow1");
01196                                 $this->tpl->parseCurrentBlock();
01197 
01198                                 foreach ($data2 as $key => $val)
01199                                 {
01200                                         $this->tpl->setCurrentBlock("text");
01201                                         
01202                                         if ($key == "name")
01203                                         {
01204                                                 $name_field = explode("#separator#",$val);
01205                                                 $val = $name_field[0]."<br/><span class=\"subtitle\">".$name_field[1]."</span>";
01206                                         }
01207 
01208                                         $this->tpl->setVariable("TEXT_CONTENT", $val);                  
01209                                         $this->tpl->parseCurrentBlock();
01210 
01211                                         $this->tpl->setCurrentBlock("table_cell");
01212                                         $this->tpl->parseCurrentBlock();
01213 
01214                                 } //end foreach
01215 
01216                                 $this->tpl->setCurrentBlock("tbl_content");
01217                                 $this->tpl->setVariable("CSS_ROW", $css_row);
01218                                 $this->tpl->parseCurrentBlock();
01219                         }
01220 
01221                         $this->tpl->setCurrentBlock("tbl_action_btn");
01222                         $this->tpl->setVariable("TPLPATH",TPLPATH);         
01223                         $this->tpl->setVariable("BTN_NAME","changedefault");
01224                         $this->tpl->setVariable("BTN_VALUE",$this->lng->txt("set_default_client"));
01225                         $this->tpl->parseCurrentBlock();
01226 
01227                         $this->tpl->setCurrentBlock("tbl_action_row");
01228                         $this->tpl->setVariable("TPLPATH",TPLPATH);         
01229                         $this->tpl->setVariable("COLUMN_COUNTS","7");
01230                         $this->tpl->parseCurrentBlock();
01231 
01232                 }
01233         }
01234 
01238         function determineToolsPath()
01239         {
01240                 $this->changeMasterSettings(true);
01241         }
01242         
01246         function determineToolsPathInstall()
01247         {
01248                 $this->displayMasterSetup(true);
01249         }
01250         
01254         function determineTools($a_tools)
01255         {
01256                 $tools = array("convert", "zip", "unzip", "java", "htmldoc");
01257                 $dirs = array("/usr/local", "/usr/local/bin", "/usr/bin", "/bin", "/sw/bin");
01258                 foreach($tools as $tool)
01259                 {
01260                         // try which command
01261                         unset($ret);
01262                         @exec("which ".$tool, $ret);
01263                         if (substr($ret[0], 0, 3) != "no " && substr($ret[0], 0, 1) == "/")
01264                         {
01265                                 $a_tools[$tool."_path"] = $ret[0];
01266                                 continue;
01267                         }
01268                         
01269                         // try common directories
01270                         foreach($dirs as $dir)
01271                         {
01272                                 if (is_file($dir."/".$tool))
01273                                 {
01274                                         $a_tools[$tool."_path"] = $dir."/".$tool;
01275                                         continue;
01276                                 }
01277                         }
01278                 }
01279                 return $a_tools;
01280         }
01281         
01285         function changeMasterSettings($a_det = false)
01286         {
01287                 if ($_POST["form"])
01288                 {
01289                         if (!$this->checkLogSetup($_POST["form"]))
01290                         {
01291                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
01292                         }
01293 
01294                         /*if (!$this->checkToolsSetup($_POST["form"]))
01295                         {
01296                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
01297                         }*/
01298 
01299                         if ($a_det)
01300                         {
01301                                 $_POST["form"] = $this->determineTools($_POST["form"]);
01302                         }
01303                         
01304                         if (!$this->updateMasterSettings($_POST["form"]))
01305                         {
01306                                 $this->raiseError($this->lng->txt($this->getError()),$this->error_obj->MESSAGE);
01307                         }
01308 
01309                         ilUtil::sendInfo($this->lng->txt("settings_saved"),true);
01310                         ilUtil::redirect("setup.php?cmd=mastersettings");
01311                 }
01312 
01313                 $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
01314 
01315                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_mastersetup.html");
01316 
01317                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
01318 
01319                 // for checkboxes & radio buttons
01320                 $checked = "checked=\"checked\"";
01321 
01322                 // general
01323                 $this->tpl->setVariable("TXT_HEADER", $this->lng->txt("change_basic_settings"));
01324                 $this->tpl->setVariable("SUBMIT_CMD", "mastersettings");
01325                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01326                 $this->tpl->setVariable("TXT_ENTER_DIR_AND_FILENAME", $this->lng->txt("enter_dir_and_filename"));
01327                 $this->tpl->setVariable("TXT_DET_TOOLS_PATH", $this->lng->txt("determine_tools_paths"));
01328                 $this->tpl->setVariable("CMD_DET_TOOLS_PATH", "determineToolsPath");
01329                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_pathes"));
01330                 
01331                 if ($this->safe_mode)
01332                 {
01333                         $this->tpl->setVariable("SAFE_MODE_STYLE", " class=\"message\" ");
01334                         $this->tpl->setVariable("TXT_SAFE_MODE_INFO", $this->lng->txt("safe_mode_enabled"));
01335                 }
01336                 else
01337                 {
01338                         $this->tpl->setVariable("TXT_SAFE_MODE_INFO", "");
01339                 }
01340                 // datadir
01341                 $this->tpl->setCurrentBlock("display_datadir");
01342                 $this->tpl->setVariable("TXT_DATADIR_TITLE", $this->lng->txt("main_datadir_outside_webspace"));
01343                 $this->tpl->setVariable("TXT_DATADIR_PATH", $this->lng->txt("datadir_path"));
01344                 $this->tpl->setVariable("DATADIR_PATH", $this->ini->readVariable("clients","datadir"));
01345                 $this->tpl->setVariable("TXT_DATADIR_COMMENT2", $this->lng->txt("datadir_path_comment2"));
01346                 $this->tpl->parseCurrentBlock();
01347 
01348                 // logging
01349                 $this->tpl->setCurrentBlock("setup_log");
01350                 $this->tpl->setVariable("TXT_LOG_TITLE", $this->lng->txt("logging"));
01351                 $this->tpl->setVariable("TXT_LOG_PATH", $this->lng->txt("log_path"));
01352                 $this->tpl->setVariable("TXT_LOG_COMMENT", $this->lng->txt("log_path_comment"));
01353                 $this->tpl->setVariable("TXT_DISABLE_LOGGING", $this->lng->txt("disable_logging"));
01354                 // values
01355                 if ($_SESSION["error_post_vars"])
01356                 {
01357                         $this->tpl->setVariable("LOG_PATH", $_SESSION["error_post_vars"]["form"]["log_path"]);
01358                         $chk_log_status = ($_SESSION["error_post_vars"]["form"]["chk_log_status"]) ? $checked : "";
01359                 }
01360                 else
01361                 {
01362                         $this->tpl->setVariable("LOG_PATH",$this->ini->readVariable("log","path")."/".$this->ini->readVariable("log","file"));
01363                         $chk_log_status = ($this->ini->readVariable("log","enabled")) ? "" : $checked;
01364 
01365                 }
01366 
01367                 $this->tpl->setVariable("CHK_LOG_STATUS",$chk_log_status);
01368                 $this->tpl->parseCurrentBlock();
01369 
01370                 // tools
01371                 $this->tpl->setCurrentBlock("setup_tools");
01372                 $this->tpl->setVariable("TXT_DISABLE_CHECK", $this->lng->txt("disable_check"));
01373                 $this->tpl->setVariable("TXT_TOOLS_TITLE", $this->lng->txt("3rd_party_software"));
01374                 $this->tpl->setVariable("TXT_CONVERT_PATH", $this->lng->txt("convert_path"));
01375                 $this->tpl->setVariable("TXT_ZIP_PATH", $this->lng->txt("zip_path"));
01376                 $this->tpl->setVariable("TXT_UNZIP_PATH", $this->lng->txt("unzip_path"));
01377                 $this->tpl->setVariable("TXT_JAVA_PATH", $this->lng->txt("java_path"));
01378                 $this->tpl->setVariable("TXT_HTMLDOC_PATH", $this->lng->txt("htmldoc_path"));
01379                 $this->tpl->setVariable("TXT_LATEX_URL", $this->lng->txt("url_to_latex"));
01380                 $this->tpl->setVariable("TXT_FOP_PATH", $this->lng->txt("fop_path"));
01381                 
01382                 $this->tpl->setVariable("TXT_VIRUS_SCANNER", $this->lng->txt("virus_scanner"));
01383                 $this->tpl->setVariable("TXT_NONE", $this->lng->txt("none"));
01384                 $this->tpl->setVariable("TXT_SOPHOS", $this->lng->txt("sophos"));
01385                 $this->tpl->setVariable("TXT_ANTIVIR", $this->lng->txt("antivir"));
01386                 $this->tpl->setVariable("TXT_CLAMAV", $this->lng->txt("clamav"));
01387                 $this->tpl->setVariable("TXT_SCAN_COMMAND", $this->lng->txt("scan_command"));
01388                 $this->tpl->setVariable("TXT_CLEAN_COMMAND", $this->lng->txt("clean_command"));
01389 
01390                 $this->tpl->setVariable("TXT_CONVERT_COMMENT", $this->lng->txt("convert_path_comment"));
01391                 $this->tpl->setVariable("TXT_ZIP_COMMENT", $this->lng->txt("zip_path_comment"));
01392                 $this->tpl->setVariable("TXT_UNZIP_COMMENT", $this->lng->txt("unzip_path_comment"));
01393                 $this->tpl->setVariable("TXT_JAVA_COMMENT", $this->lng->txt("java_path_comment"));
01394                 $this->tpl->setVariable("TXT_HTMLDOC_COMMENT", $this->lng->txt("htmldoc_path_comment"));
01395                 $this->tpl->setVariable("TXT_LATEX_URL_COMMENT", $this->lng->txt("latex_url_comment"));
01396                 $this->tpl->setVariable("TXT_FOP_COMMENT", $this->lng->txt("fop_path_comment"));
01397                 // values
01398                 if ($_SESSION["error_post_vars"])
01399                 {
01400                         $vals = $_SESSION["error_post_vars"]["form"];
01401                 }
01402                 else
01403                 {
01404                         $vals["convert_path"] = $this->ini->readVariable("tools","convert");
01405                         $vals["zip_path"] = $this->ini->readVariable("tools","zip");
01406                         $vals["unzip_path"] = $this->ini->readVariable("tools","unzip");
01407                         $vals["java_path"] = $this->ini->readVariable("tools","java");
01408                         $vals["htmldoc_path"] = $this->ini->readVariable("tools","htmldoc");
01409                         $vals["latex_url"] = $this->ini->readVariable("tools","latex");
01410                         $vals["fop_path"] = $this->ini->readVariable("tools","fop");
01411                         $vals["vscanner_type"] = $this->ini->readVariable("tools", "vscantype");
01412                         $vals["scan_command"] = $this->ini->readVariable("tools", "scancommand");
01413                         $vals["clean_command"] = $this->ini->readVariable("tools", "cleancommand");
01414                 }
01415                 
01416                 $tools = array("convert" => "testConvert", "zip" => "testZip",
01417                         "unzip" => "testUnzip", "java" => "testJava", "htmldoc" => "testHtmldoc",
01418                         "latex" => "testLatex");
01419                 foreach ($tools as $tool => $func)
01420                 {
01421                         $end = ($tool == "latex")
01422                                 ? "url"
01423                                 : "path";
01424                         if (($err = $this->$func($vals[$tool."_".$end])) != "")
01425                         {
01426                                 $this->tpl->setCurrentBlock("warning_".$tool);
01427                                 $this->tpl->setVariable("TXT_WARNING_".strtoupper($tool), $this->lng->txt($err));
01428                                 $this->tpl->parseCurrentBlock();
01429                         }
01430                 }
01431 
01432                 $this->tpl->setVariable("CONVERT_PATH", $vals["convert_path"]);
01433                 $this->tpl->setVariable("ZIP_PATH", $vals["zip_path"]);
01434                 $this->tpl->setVariable("UNZIP_PATH", $vals["unzip_path"]);
01435                 $this->tpl->setVariable("JAVA_PATH", $vals["java_path"]);
01436                 $this->tpl->setVariable("HTMLDOC_PATH", $vals["htmldoc_path"]);
01437                 $this->tpl->setVariable("LATEX_URL", $vals["latex_url"]);
01438                 $this->tpl->setVariable("FOP_PATH", $vals["fop_path"]);
01439                 $this->tpl->setVariable("STYPE_".
01440                         strtoupper($vals["vscanner_type"]), " selected=\"1\" ");
01441                 $this->tpl->setVariable("SCAN_COMMAND", $vals["scan_command"]);
01442                 $this->tpl->setVariable("CLEAN_COMMAND", $vals["clean_command"]);
01443                 
01444                 $chk_convert_path = ($_SESSION["error_post_vars"]["form"]["chk_convert_path"]) ? $checked : "";
01445                 $chk_zip_path = ($_SESSION["error_post_vars"]["form"]["chk_zip_path"]) ? $checked : "";
01446                 $chk_unzip_path = ($_SESSION["error_post_vars"]["form"]["chk_unzip_path"]) ? $checked : "";
01447                 $chk_java_path = ($_SESSION["error_post_vars"]["form"]["chk_java_path"]) ? $checked : "";
01448                 $chk_htmldoc_path = ($_SESSION["error_post_vars"]["form"]["chk_htmldoc_path"]) ? $checked : "";
01449                 $chk_latex_url = ($_SESSION["error_post_vars"]["form"]["chk_latex_url"]) ? $checked : "";
01450                 $chk_fop_path = ($_SESSION["error_post_vars"]["form"]["chk_fop_path"]) ? $checked : "";
01451 
01452                 $this->tpl->setVariable("CHK_LOG_STATUS", $chk_log_stauts);
01453                 $this->tpl->setVariable("CHK_CONVERT_PATH", $chk_convert_path);
01454                 $this->tpl->setVariable("CHK_ZIP_PATH", $chk_zip_path);
01455                 $this->tpl->setVariable("CHK_UNZIP_PATH", $chk_unzip_path);
01456                 $this->tpl->setVariable("CHK_JAVA_PATH", $chk_java_path);
01457                 $this->tpl->setVariable("CHK_HTMLDOC_PATH", $chk_htmldoc_path);
01458                 $this->tpl->setVariable("CHK_LATEX_URL", $chk_latex_url);
01459                 $this->tpl->setVariable("CHK_FOP_PATH", $chk_fop_path);
01460                 $this->tpl->parseCurrentBlock();
01461                 
01462                 $this->btn_next_on = true;
01463                 $this->btn_next_lng = $this->lng->txt("create_new_client")." >>";
01464                 $this->btn_next_cmd = "newclient";
01465 
01466         }
01467 
01471         function displayIni()
01472         {
01473                 $this->checkDisplayMode("create_new_client");
01474                 
01475                 // checkings
01476                 if ($_POST["form"])
01477                 {
01478                         // check client name
01479                         if (!$_POST["form"]["client_id"])
01480                         {
01481                                 $this->raiseError($this->lng->txt("ini_no_client_id"),$this->error_obj->MESSAGE);
01482                         }
01483 
01484                         if (strlen($_POST["form"]["client_id"]) != strlen(urlencode(($_POST["form"]["client_id"]))))
01485                         {
01486                                 $this->raiseError($this->lng->txt("ini_client_id_invalid"),$this->error_obj->MESSAGE);
01487                         }           
01488 
01489                         if (strlen($_POST["form"]["client_id"]) < 4)
01490                         {
01491                                 $this->raiseError($this->lng->txt("ini_client_id_too_short"),$this->error_obj->MESSAGE);
01492                         }
01493 
01494                         if (strlen($_POST["form"]["client_id"]) > 32)
01495                         {
01496                                 $this->raiseError($this->lng->txt("ini_client_id_too_long"),$this->error_obj->MESSAGE);
01497                         }
01498 
01499                         // check database
01500                         if (!$_POST["form"]["db_host"])
01501                         {
01502                                 $this->raiseError($this->lng->txt("ini_no_db_host"),$this->error_obj->MESSAGE);
01503                         }
01504 
01505                         if (!$_POST["form"]["db_name"])
01506                         {
01507                                 $this->raiseError($this->lng->txt("ini_no_db_name"),$this->error_obj->MESSAGE);
01508                         }
01509                         
01510                         if (!$_POST["form"]["db_user"])
01511                         {
01512                                 $this->raiseError($this->lng->txt("ini_no_db_user"),$this->error_obj->MESSAGE);
01513                         }
01514 
01515                         // create new client object if it does not exist
01516                         if (!$this->ini_client_exists)
01517                         {
01518                                 $client_id = $_POST["form"]["client_id"];
01519                                 
01520                                 // check for existing client dir (only for newly created clients not renaming)
01521                                 if (!$this->ini_client_exists and file_exists(ILIAS_ABSOLUTE_PATH."/".ILIAS_WEB_DIR."/".$client_id))
01522                                 {
01523                                         $this->raiseError($this->lng->txt("ini_client_id_exists"),$this->error_obj->MESSAGE);
01524                                 }
01525 
01526                                 $this->newClient($client_id);
01527                         }
01528 
01529                         // save some old values
01530                         $old_db_name = $this->client->getDbName();
01531                         $old_client_id = $this->client->getId();            
01532                         // set client data 
01533                         $this->client->setId($_POST["form"]["client_id"]);
01534                         $this->client->setDbHost($_POST["form"]["db_host"]);
01535                         $this->client->setDbName($_POST["form"]["db_name"]);
01536                         $this->client->setDbUser($_POST["form"]["db_user"]);
01537                         $this->client->setDbPass($_POST["form"]["db_pass"]);
01538                         $this->client->setDSN();
01539                         
01540                         // try to connect to database
01541                         if (!$this->client->checkDatabaseHost())
01542                         {
01543                                 $this->raiseError($this->lng->txt($this->client->getError()),$this->error_obj->MESSAGE);
01544                         }
01545                         
01546                         // check if db exists
01547                         $db_installed = $this->client->checkDatabaseExists();
01548 
01549                         if ($db_installed and (!$this->ini_ilias_exists or ($this->client->getDbName() != $old_db_name)))
01550                         {
01551                                 $_POST["form"]["db_name"] = $old_db_name;
01552                                 $message = ucfirst($this->lng->txt("database"))." \"".$this->client->getDbName()."\" ".$this->lng->txt("ini_db_name_exists");
01553                                 $this->raiseError($message,$this->error_obj->MESSAGE);
01554                         }
01555                         
01556                         if ($this->ini_client_exists and $old_client_id != $this->client->getId())
01557                         {
01558                                 $message = $this->lng->txt("ini_client_id_no_change");
01559                                 $this->raiseError($message,$this->error_obj->MESSAGE);
01560                         }
01561 
01562                         // all ok. create client.ini and save posted data
01563                         if (!$this->ini_client_exists)
01564                         {
01565                                 if ($this->saveNewClient())
01566                                 {
01567                                         ilUtil::sendInfo($this->lng->txt("settings_saved"));
01568                                         $this->client->status["ini"]["status"] = true;
01569                                 }
01570                                 else
01571                                 {
01572                                         $err = $this->getError();
01573                                         ilUtil::sendInfo($this->lng->txt("save_error").": ".$err);
01574                                         $this->client->status["ini"]["status"] = false;
01575                                         $this->client->status["ini"]["comment"] = $err;
01576                                 }
01577                         }
01578                         else
01579                         {
01580                                 if ($this->client->ini->write())
01581                                 {
01582                                         ilUtil::sendInfo($this->lng->txt("settings_changed"));
01583                                         $this->client->status["ini"]["status"] = true;
01584                                 }
01585                                 else
01586                                 {
01587                                         $err = $this->client->ini->getError();
01588                                         ilUtil::sendInfo($this->lng->txt("save_error").": ".$err);
01589                                         $this->client->status["ini"]["status"] = false;
01590                                         $this->client->status["ini"]["comment"] = $err;
01591                                 }
01592                         }
01593                 }
01594 
01595                 // output
01596                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_ini.html");
01597                 
01598                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
01599                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
01600                 
01601                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_ini"));
01602                 
01603                 // display default values, loaded valus or saved error values
01604                 if ($_SESSION["error_post_vars"]["form"])
01605                 {
01606                         $this->tpl->setVariable("CLIENT_ID", $_SESSION["error_post_vars"]["form"]["client_id"]);
01607                         $this->tpl->setVariable("DB_HOST", $_SESSION["error_post_vars"]["form"]["db_host"]);    
01608                         $this->tpl->setVariable("DB_NAME", $_SESSION["error_post_vars"]["form"]["db_name"]);        
01609                         $this->tpl->setVariable("DB_USER", $_SESSION["error_post_vars"]["form"]["db_user"]);        
01610                         $this->tpl->setVariable("DB_PASS", $_SESSION["error_post_vars"]["form"]["db_pass"]);
01611                 }
01612                 else
01613                 {
01614                         $this->tpl->setVariable("CLIENT_ID", $this->client->getId());
01615                         $this->tpl->setVariable("DB_HOST", $this->client->getDbHost()); 
01616                         $this->tpl->setVariable("DB_NAME", $this->client->getDbName());     
01617                         $this->tpl->setVariable("DB_USER", $this->client->getDbUser());     
01618                         $this->tpl->setVariable("DB_PASS", $this->client->getDbPass());     
01619                 }
01620 
01621                 $this->tpl->setVariable("TXT_CLIENT_HEADER", $this->lng->txt("inst_identification"));
01622                 $this->tpl->setVariable("TXT_CLIENT_ID", $this->lng->txt("client_id"));
01623                 $this->tpl->setVariable("TXT_DB_HEADER", $this->lng->txt("db_conn"));
01624                 $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
01625                 $this->tpl->setVariable("TXT_DB_HOST", $this->lng->txt("db_host"));
01626                 $this->tpl->setVariable("TXT_DB_NAME", $this->lng->txt("db_name")); 
01627                 $this->tpl->setVariable("TXT_DB_USER", $this->lng->txt("db_user"));
01628                 $this->tpl->setVariable("TXT_DB_PASS", $this->lng->txt("db_pass"));
01629 
01630                 if ($this->client->status["ini"]["status"])
01631                 {
01632                         $this->setButtonNext("db");
01633                 }
01634                 
01635                 $this->checkPanelMode();
01636         }
01637         
01643         function displayError($a_message)
01644         {
01645                 $this->tpl->addBlockFile("CONTENT", "content", "tpl.error.html");
01646                 
01647                 $this->tpl->setCurrentBlock("content");
01648                 $this->tpl->setVariable("FORMACTION", $_SESSION["referer"]);
01649                 $this->tpl->setVariable("TXT_BACK", $this->lng->txt("back"));
01650                 $this->tpl->setVariable("ERROR_MESSAGE",($a_message));
01651                 $this->tpl->parseCurrentBlock();
01652                 
01653                 $this->tpl->show();
01654                 exit();
01655         }
01656 
01660         function displayLogout()
01661         {
01662                 $this->tpl->addBlockFile("CONTENT","content","tpl.logout.html");
01663 
01664                 session_destroy();
01665 
01666                 $this->logged_out = true;
01667                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("logged_out"));        
01668                 $this->tpl->setCurrentBlock("home_link");
01669                 $this->tpl->setVariable("TXT_INDEX",$this->lng->txt("ilias_homepage"));
01670                 $this->tpl->setVariable("LNK_INDEX",ILIAS_HTTP_PATH."/index.php");
01671                 $this->tpl->parseCurrentBlock();
01672         }
01673 
01677         function displayProcessPanel()
01678         {
01679                 $OK = "<font color=\"green\"><strong>OK</strong></font>";
01680                 
01681                 $steps = array();
01682                 $steps = $this->getStatus();
01683                 
01684                 // remove access step
01685                 unset($steps["access"]);
01686                 
01687                 $steps["ini"]["text"]       = $this->lng->txt("setup_process_step_ini");
01688                 $steps["db"]["text"]        = $this->lng->txt("setup_process_step_db");
01689                 $steps["lang"]["text"]      = $this->lng->txt("setup_process_step_lang");
01690                 $steps["contact"]["text"]   = $this->lng->txt("setup_process_step_contact");
01691                 $steps["nic"]["text"]       = $this->lng->txt("setup_process_step_nic");
01692                 $steps["finish"]["text"]    = $this->lng->txt("setup_process_step_finish");
01693                 
01694                 $this->tpl->addBlockFile("PROCESS_MENU","process_menu","tpl.process_panel.html");
01695 
01696                 $this->tpl->setVariable("TXT_SETUP_PROCESS_STATUS",$this->lng->txt("setup_process_status"));
01697 
01698                 $num = 1;
01699 
01700                 foreach ($steps as $key => $val)
01701                 {
01702                         $this->tpl->setCurrentBlock("menu_row");
01703                         $this->tpl->setVariable("TXT_STEP",$this->lng->txt("step")." ".$num.": &nbsp;");
01704                         $this->tpl->setVariable("TXT_ACTION",$val["text"]);
01705                         $this->tpl->setVariable("IMG_ARROW", "spacer.gif");
01706                         
01707                         $num++;
01708 
01709                         if ($this->cmd == $key and isset($this->cmd))
01710                         {
01711                                 $this->tpl->setVariable("HIGHLIGHT", " style=\"font-weight:bold;\"");
01712                                 $this->tpl->setVariable("IMG_ARROW", "arrow_right.png");
01713                         }
01714                         
01715                         $status = ($val["status"]) ? $OK : "";          
01716                         
01717                         $this->tpl->setVariable("TXT_STATUS",$status);
01718                         $this->tpl->parseCurrentBlock();
01719                 }
01720         }
01721 
01725         function displayStatusPanel()
01726         {
01727                 $OK = "<font color=\"green\"><strong>OK</strong></font>";
01728 
01729                 $this->tpl->addBlockFile("STATUS_PANEL","status_panel","tpl.status_panel.html");
01730 
01731                 $this->tpl->setVariable("TXT_OVERALL_STATUS", $this->lng->txt("overall_status"));
01732                 // display status
01733                 if ($this->client->status)
01734                 {
01735                         foreach ($this->client->status as $key => $val)
01736                         {
01737                                 $status = ($val["status"]) ? $OK : "&nbsp;";
01738                                 $this->tpl->setCurrentBlock("status_row");
01739                                 $this->tpl->setVariable("TXT_STEP", $this->lng->txt("step_".$key));
01740                                 $this->tpl->setVariable("TXT_STATUS",$status);
01741                                 $this->tpl->setVariable("TXT_COMMENT",$val["comment"]);
01742                                 $this->tpl->parseCurrentBlock();
01743                         }
01744                 }
01745         }
01746         
01752         function checkDisplayMode($a_title = "")
01753         {
01754                 switch ($this->display_mode)
01755                 {
01756                         case "view":
01757                                 $this->tpl->addBlockFile("CONTENT","content","tpl.clientview.html");
01758                                 // display tabs
01759                                 include "./include/inc.client_tabs.php";
01760                                 $client_name = ($this->client->getName()) ? $this->client->getName() : $this->lng->txt("no_client_name");
01761                                 $this->tpl->setVariable("TXT_HEADER",$client_name." (".$this->lng->txt("client_id").": ".$this->client->getId().")");       
01762                                 break;
01763                         
01764                         case "setup":
01765                                 $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html");
01766                                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt($a_title));        
01767                                 break;
01768 
01769                         default:
01770                                 $this->displayError($this->lng->txt("unknown_display_mode"));
01771                                 exit();
01772                                 break;
01773                 }
01774         }
01775 
01779         function checkPanelMode()
01780         {
01781                 switch ($this->display_mode)
01782                 {
01783                         case "view":
01784                                 $this->displayStatusPanel();                
01785                                 break;
01786                         
01787                         case "setup":
01788                                 $this->displayProcessPanel();
01789                                 break;
01790                 }
01791         }
01792 
01796         function displayStartup()
01797         {
01798                 $this->tpl->addBlockFile("CONTENT","content","tpl.clientsetup.html");
01799                 
01800                 $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_first_client"));
01801                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("setup_first_client"));
01802                 
01803                 $this->displayProcessPanel();
01804                 
01805                 $this->setButtonNext("ini");
01806         }
01807 
01811         function displayDatabase()
01812         {
01813                 global $ilErr,$ilDB,$ilLog;
01814 
01815                 $this->checkDisplayMode("setup_database");
01816 
01817                 // checkings
01818                 if ($_POST["form"]["db_flag"] == 1)
01819                 {
01820                         $message = "";
01821                         
01822                         if (!$this->client->db_installed)
01823                         {
01824                                 if (!$this->client->db_exists)
01825                                 {
01826                                         if ($_POST["form"]["chk_db_create"])
01827                                         {
01828                                                 if (!$this->createDatabase($_POST["collation"]))
01829                                                 {
01830                                                         $message = $this->lng->txt($this->getError());
01831                                                         $this->raiseError($message,$this->error_obj->MESSAGE);
01832                                                 }
01833                                         }
01834                                         else
01835                                         {
01836                                                 $message = $this->lng->txt("database_not_exists_create_first");
01837                                                 $this->raiseError($message,$this->error_obj->MESSAGE);                  
01838                                         }
01839                                 }
01840                                 
01841                                 if (!$this->installDatabase())
01842                                 {
01843                                         $message = $this->lng->txt($this->getError());
01844                                         $this->client->status["db"]["status"] = false;
01845                                         $this->client->status["db"]["comment"] = "install_error";
01846                                 }
01847                                 else
01848                                 {
01849                                         $message = $this->lng->txt("database_installed");
01850                                 }
01851                         }
01852                         else
01853                         {
01854                                 include_once "../classes/class.ilDBUpdate.php";
01855                                 include_once "../Services/AccessControl/classes/class.ilRbacAdmin.php";
01856                                 include_once "../Services/AccessControl/classes/class.ilRbacReview.php";
01857                                 include_once "../Services/AccessControl/classes/class.ilRbacSystem.php";
01858                                 include_once "../Services/Tree/classes/class.ilTree.php";
01859                                 include_once "../classes/class.ilSaxParser.php";
01860                                 include_once "../classes/class.ilObjectDefinition.php";
01861 
01862                                 // referencing db handler in language class
01863                                 $this->lng->setDbHandler($this->client->db);
01864 
01865                                 // referencing does not work in dbupdate-script
01866                                 $ilDB = new ilDbx($this->client->dsn);
01867 
01868                                 // run dbupdate
01869                                 $dbupdate = new ilDBUpdate($ilDB);
01870                                 $dbupdate->applyUpdate();
01871                         
01872                                 if ($dbupdate->updateMsg == "no_changes")
01873                                 {
01874                                         $message = $this->lng->txt("no_changes").". ".$this->lng->txt("database_is_uptodate");
01875                                 }
01876                                 else
01877                                 {
01878                                         foreach ($dbupdate->updateMsg as $row)
01879                                         {
01880                                                 $message .= $this->lng->txt($row["msg"]).": ".$row["nr"]."<br/>";
01881                                         }
01882                                 }
01883                         }
01884                 }
01885 
01886                 ilUtil::sendInfo($message);
01887 
01888                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_db.html");
01889                 
01890                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
01891                 $this->tpl->setVariable("DB_HOST", $this->client->getDbHost());
01892                 $this->tpl->setVariable("DB_NAME", $this->client->getDbName());     
01893                 $this->tpl->setVariable("DB_USER", $this->client->getDbUser());     
01894                 $this->tpl->setVariable("DB_PASS", $this->client->getDbPass());
01895 
01896                 if ($this->client->db_installed)
01897                 {
01898                         // referencing db handler in language class
01899                         $this->lng->setDbHandler($this->client->db);
01900 
01901                         include_once "../classes/class.ilDBUpdate.php";
01902                         $ilDB = new ilDbx($this->client->dsn);
01903                         $dbupdate = new ilDBUpdate($ilDB);
01904 
01905                         if (!$db_status = $dbupdate->getDBVersionStatus())
01906                         {
01907                                 $remark = "<font color=\"red\">".$this->lng->txt("database_needs_update").
01908                                                                   " (".$this->lng->txt("database_version").": ".$dbupdate->currentVersion.
01909                                                                   " ; ".$this->lng->txt("file_version").": ".$dbupdate->fileVersion.")</font>";
01910                                 $this->tpl->setVariable("TXT_INFO", $remark);
01911                                 
01912                                 $this->tpl->setCurrentBlock("btn_submit");
01913                                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("database_update"));
01914                                 $this->tpl->parseCurrentBlock();
01915                         }
01916                         else
01917                         {
01918                                 $this->tpl->setVariable("TXT_INFO",$this->lng->txt("database_is_uptodate"));
01919                                 $this->client->status["db"]["status"] = true;
01920                                 $this->client->status["db"]["comment"] = "version ".$dbupdate->getCurrentVersion();
01921                         }
01922                         
01923                         $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("version"));
01924                         $this->tpl->setVariable("VAL_DB_VERSION", $ilDB->getMySQLVersion());
01925                         $this->tpl->setVariable("TXT_DB_MODE", $this->lng->txt("ilias_db_mode"));
01926                         
01927                         if ($ilDB->isMySQL4_1OrHigher())
01928                         {
01929                                 $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_1_x_or_higher_mode"));
01930                         }
01931                         else
01932                         {
01933                                 $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_0_x_or_lower_mode"));
01934                         }
01935                         $this->tpl->setVariable("TXT_CHECK_VERSIONS", $this->lng->txt("check_db_versions"));
01936                 }
01937                 else
01938                 {
01939                         $checked = "";
01940 
01941                         if ($_SESSION["error_post_vars"]["form"]["chk_db_create"])
01942                         {
01943                                 $checked = "checked=\"checked\"";
01944                         }
01945 
01946                         $this->tpl->setCurrentBlock("option_db_create");
01947                         $this->tpl->setVariable("TXT_DB_CREATE", $this->lng->txt("database_create"));
01948                         $this->tpl->setVariable("DB_CREATE_CHECK",$checked);
01949                         $this->tpl->parseCurrentBlock();
01950 
01951                         $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("database_install"));
01952                         $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_db"));
01953                         
01954                         // output version
01955                         $ilDB = new ilDbx($this->client->dsn_host);
01956                         $this->tpl->setVariable("TXT_DB_VERSION", $this->lng->txt("version"));
01957                         $this->tpl->setVariable("VAL_DB_VERSION", $ilDB->getMySQLVersion());
01958                         $this->tpl->setVariable("TXT_DB_MODE", $this->lng->txt("ilias_db_mode"));
01959                         
01960                         if ($ilDB->isMySQL4_1OrHigher())
01961                         {
01962                                 $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_1_x_or_higher_mode"));
01963                         }
01964                         else
01965                         {
01966                                 $this->tpl->setVariable("VAL_DB_MODE", $this->lng->txt("mysql_4_0_x_or_lower_mode"));
01967                         }
01968                         $this->tpl->setVariable("TXT_CHECK_VERSIONS", $this->lng->txt("check_db_versions"));
01969                         
01970                         // collation selection ( see utf8 collations at
01971                         // http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html )
01972                         if ($ilDB->isMySQL4_1OrHigher())
01973                         {
01974                                 $collations = array
01975                                 (
01976                                         "utf8_unicode_ci",
01977                                         "utf8_general_ci",
01978                                         "utf8_czech_ci",
01979                                         "utf8_danish_ci",
01980                                         "utf8_estonian_ci",
01981                                         "utf8_icelandic_ci",
01982                                         "utf8_latvian_ci",
01983                                         "utf8_lithuanian_ci",
01984                                         "utf8_persian_ci",
01985                                         "utf8_polish_ci",
01986                                         "utf8_roman_ci",
01987                                         "utf8_romanian_ci",
01988                                         "utf8_slovak_ci",
01989                                         "utf8_slovenian_ci",
01990                                         "utf8_spanish2_ci",
01991                                         "utf8_spanish_ci",
01992                                         "utf8_swedish_ci",
01993                                         "utf8_turkish_ci"
01994                                 );
01995                                 foreach($collations as $collation)
01996                                 {
01997                                         $this->tpl->setCurrentBlock("collation_item");
01998                                         $this->tpl->setVariable("VAL_COLLATION_ITEM", $collation);
01999                                         $this->tpl->setVariable("TXT_COLLATION_ITEM", $collation);
02000                                         $this->tpl->parseCurrentBlock();
02001                                 }
02002                                 $this->tpl->setCurrentBlock("collation_selection");
02003                                 $this->tpl->setVariable("TXT_COLLATION", $this->lng->txt("collation"));
02004                                 $this->tpl->parseCurrentBlock();
02005                                 //$this->tpl->setCurrentBlock("setup_content");
02006                                 $this->tpl->setVariable("COLLATION_INFO1", $this->lng->txt("info_text_db_collation1"));
02007                                 $this->tpl->setVariable("COLLATION_EXAMPLE",
02008                                         "<br /><br />".$this->lng->txt("example").": CREATE DATABASE ilias3 CHARACTER SET utf8 COLLATE utf8_unicode_ci");
02009                                 $this->tpl->setVariable("COLLATION_INFO2", "<br /><br />".$this->lng->txt("info_text_db_collation2")." ".
02010                                         "<a target=\"_new\" href=\"http://dev.mysql.com/doc/mysql/en/charset-unicode-sets.html\">".
02011                                         " MySQL Reference Manual :: 10.11.1 Unicode Character Sets</a>");
02012                         }
02013                 }
02014                 
02015                 $this->tpl->parseCurrentBlock();
02016                 
02017                 $this->tpl->setVariable("TXT_SETUP_TITLE", $this->lng->txt("setup_database"));
02018                 $this->tpl->setVariable("TXT_DB_HEADER", $this->lng->txt("db_conn"));
02019                 $this->tpl->setVariable("TXT_DB_TYPE", $this->lng->txt("db_type"));
02020                 $this->tpl->setVariable("TXT_DB_HOST", $this->lng->txt("db_host"));
02021                 $this->tpl->setVariable("TXT_DB_NAME", $this->lng->txt("db_name")); 
02022                 $this->tpl->setVariable("TXT_DB_USER", $this->lng->txt("db_user"));
02023                 $this->tpl->setVariable("TXT_DB_PASS", $this->lng->txt("db_pass"));
02024                 
02025                 // only allow to return to ini if db does not exist yet
02026                 if (!$this->client->db_installed)
02027                 {
02028                         $this->setButtonPrev("ini");
02029                 }
02030                 
02031                 if ($this->client->db_installed and $db_status)
02032                 {
02033                         $this->setButtonNext("lang");
02034                 }
02035                 
02036                 $this->checkPanelMode();
02037         }
02038         
02042         function displayLanguages()
02043         {
02044                 $this->checkDisplayMode("setup_languages");
02045 
02046                 if (!$this->client->db_installed)
02047                 {
02048                         // program should never come to this place
02049                         $message = "No database found! Please install database first.";
02050                         ilUtil::sendInfo($message);
02051                 }
02052         
02053                 // checkings
02054                 if ($_POST["form"])
02055                 {
02056                         if (empty($_POST["form"]["lang_id"]))
02057                         {
02058                                 $message = $this->lng->txt("lang_min_one_language");
02059                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02060                         }
02061                         
02062                         if (!in_array($_POST["form"]["lang_default"],$_POST["form"]["lang_id"]))
02063                         {
02064                                 $message = $this->lng->txt("lang_not_installed_default");
02065                                 $this->error = true;
02066                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02067 
02068                         }
02069                         
02070                         $result = $this->lng->installLanguages($_POST["form"]["lang_id"], $_POST["form"]["lang_local"]);
02071                         
02072                         if (is_array($result))
02073                         {
02074                                 $count = count($result);
02075                                 $txt = "tet";
02076                                 
02077                                 foreach ($result as $key => $lang_key)
02078                                 {
02079                                         $list .= $this->lng->txt("lang_".$lang_key);
02080                                         
02081                                         if ($count > $key + 1)
02082                                         {
02083                                                 $list .= ", ";
02084                                         }
02085                                 }
02086                         }
02087 
02088                         $this->client->setDefaultLanguage($_POST["form"]["lang_default"]);
02089                         $message = $this->lng->txt("languages_installed");
02090                         
02091                         if ($result !== true)
02092                         {
02093                                 $message .= "<br/>(".$this->lng->txt("langs_not_valid_not_installed").": ".$list.")";
02094                         }
02095                         ilUtil::sendInfo($message);
02096                 }
02097 
02098                 // output
02099                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_lang.html");
02100 
02101                 $languages = $this->lng->getInstallableLanguages();
02102                 $installed_langs = $this->lng->getInstalledLanguages();
02103                 $installed_local_langs = $this->lng->getInstalledLocalLanguages();
02104                 $local_langs = $this->lng->getLocalLanguages();
02105                 $default_lang = $this->client->getDefaultLanguage();
02106                 
02107                 $lang_count = count($installed_langs);
02108                 
02109                 $this->tpl->setVariable("TXT_LANG_HEADER", ucwords($this->lng->txt("available_languages")));
02110                 $this->tpl->setVariable("TXT_LANGUAGE", ucwords($this->lng->txt("language")));
02111                 $this->tpl->setVariable("TXT_INSTALLED", ucwords($this->lng->txt("installed")));
02112                 $this->tpl->setVariable("TXT_INCLUDE_LOCAL", ucwords($this->lng->txt("include_local")));
02113                 $this->tpl->setVariable("TXT_DEFAULT", ucwords($this->lng->txt("default")));
02114 
02115                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
02116                 
02117                 $this->tpl->setVariable("TXT_SETUP_TITLE",ucfirst(trim($this->lng->txt("setup_languages"))));
02118                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_lang"));
02119                 
02120                 if ($lang_count > 0)
02121                 {
02122                         $this->client->status["lang"]["status"] = true;
02123                         $this->client->status["lang"]["comment"] = $lang_count." ".$this->lng->txt("languages_installed");
02124                 }
02125                 else
02126                 {
02127                         $this->client->status["lang"]["status"] = false;
02128                         $this->client->status["lang"]["comment"] = $this->lng->txt("lang_none_installed");
02129                 }
02130 
02131                 foreach ($languages as $lang_key)
02132                 {
02133                         $this->tpl->setCurrentBlock("language_row");
02134                         $this->tpl->setVariable("LANG_KEY", $lang_key);
02135                         $this->tpl->setVariable("TXT_LANG", $this->lng->txt("lang_".$lang_key));
02136                         $this->tpl->setVariable("BORDER", 0);
02137                         $this->tpl->setVariable("VSPACE", 0);
02138 
02139                         if (in_array($lang_key,$installed_langs))
02140                         {
02141                                 $this->tpl->setVariable("CHECKED", ("checked=\"checked\""));
02142                         }
02143 
02144                         if (!in_array($lang_key,$local_langs))
02145                         {
02146                                 $this->tpl->setVariable("LOCAL", ("disabled=\"disabled\""));        
02147                         }
02148                         else if (in_array($lang_key,$installed_local_langs))
02149                         {
02150                                 $this->tpl->setVariable("LOCAL", ("checked=\"checked\""));
02151                         }
02152 
02153                         if ($lang_key == $default_lang)
02154                         {
02155                                 $this->tpl->setVariable("DEFAULT", ("checked=\"checked\""));
02156                         }
02157 
02158                         $this->tpl->parseCurrentBlock();
02159                 }
02160                 
02161                 $this->setButtonPrev("db");
02162                 
02163                 if ($lang_count > 0)
02164                 {
02165                         $this->setButtonNext("contact");
02166                 }
02167                 
02168                 $this->checkPanelMode();
02169         }
02170         
02174         function displayContactData()
02175         {
02176                 $this->checkDisplayMode("setup_contact_data");
02177         
02178                 $settings = $this->client->getAllSettings();
02179 
02180                 // formular sent
02181                 if ($_POST["form"])
02182                 {
02183                         // init checking var
02184                         $form_valid = true;
02185 
02186                         // check required fields
02187                         if (empty($_POST["form"]["admin_firstname"]) or empty($_POST["form"]["admin_lastname"])
02188                                 or empty($_POST["form"]["admin_street"]) or empty($_POST["form"]["admin_zipcode"])
02189                                 or empty($_POST["form"]["admin_country"]) or empty($_POST["form"]["admin_city"])
02190                                 or empty($_POST["form"]["admin_phone"]) or empty($_POST["form"]["admin_email"])
02191                                 or empty($_POST["form"]["inst_name"]) or empty($_POST["form"]["inst_info"]))
02192                         {
02193                                 $form_valid = false;
02194                                 $message = $this->lng->txt("fill_out_required_fields");
02195                                 //$this->raiseError($message,$this->error_obj->MESSAGE);
02196                                 ilUtil::sendInfo($message);
02197                         }
02198                         
02199                         // admin email
02200                         if (!ilUtil::is_email($_POST["form"]["admin_email"]) and $form_valid)
02201                         {
02202                                 $form_valid = false;
02203                                 $message = $this->lng->txt("input_error").": '".$this->lng->txt("email")."'<br/>".$this->lng->txt("email_not_valid");
02204                                 ilUtil::sendInfo($message);
02205                                 //$this->raiseError($message,$this->error_obj->MESSAGE);
02206                         }
02207 
02208                         if (!$form_valid)   //required fields not satisfied. Set formular to already fill in values
02209                         {
02210                                 // load user modified settings again
02211                                 // contact
02212                                 $settings["admin_firstname"] = ilUtil::prepareFormOutput($_POST["form"]["admin_firstname"],true);
02213                                 $settings["admin_lastname"] = ilUtil::prepareFormOutput($_POST["form"]["admin_lastname"],true);
02214                                 $settings["admin_title"] = ilUtil::prepareFormOutput($_POST["form"]["admin_title"],true);
02215                                 $settings["admin_position"] = ilUtil::prepareFormOutput($_POST["form"]["admin_position"],true);
02216                                 $settings["admin_institution"] = ilUtil::prepareFormOutput($_POST["form"]["admin_institution"],true);
02217                                 $settings["admin_street"] = ilUtil::prepareFormOutput($_POST["form"]["admin_street"],true);
02218                                 $settings["admin_zipcode"] = ilUtil::prepareFormOutput($_POST["form"]["admin_zipcode"],true);
02219                                 $settings["admin_city"] = ilUtil::prepareFormOutput($_POST["form"]["admin_city"],true);
02220                                 $settings["admin_country"] = ilUtil::prepareFormOutput($_POST["form"]["admin_country"],true);
02221                                 $settings["admin_phone"] = ilUtil::prepareFormOutput($_POST["form"]["admin_phone"],true);
02222                                 $settings["admin_email"] = ilUtil::prepareFormOutput($_POST["form"]["admin_email"],true);
02223 
02224                                 // client
02225                                 $settings["inst_name"] = ilUtil::prepareFormOutput($_POST["form"]["inst_name"],true);
02226                                 $settings["inst_info"] = ilUtil::prepareFormOutput($_POST["form"]["inst_info"],true);
02227                                 $settings["inst_institution"] = ilUtil::prepareFormOutput($_POST["form"]["inst_institution"],true);
02228                         }
02229                         else // all required fields ok
02230                         {
02231 
02232                                 // write new settings
02233                                 // contact
02234                                 $this->client->setSetting("admin_firstname",ilUtil::stripSlashes($_POST["form"]["admin_firstname"]));
02235                                 $this->client->setSetting("admin_lastname",ilUtil::stripSlashes($_POST["form"]["admin_lastname"]));
02236                                 $this->client->setSetting("admin_title",ilUtil::stripSlashes($_POST["form"]["admin_title"]));
02237                                 $this->client->setSetting("admin_position",ilUtil::stripSlashes($_POST["form"]["admin_position"]));
02238                                 $this->client->setSetting("admin_institution",ilUtil::stripSlashes($_POST["form"]["admin_institution"]));
02239                                 $this->client->setSetting("admin_street",ilUtil::stripSlashes($_POST["form"]["admin_street"]));
02240                                 $this->client->setSetting("admin_zipcode",ilUtil::stripSlashes($_POST["form"]["admin_zipcode"]));
02241                                 $this->client->setSetting("admin_city",ilUtil::stripSlashes($_POST["form"]["admin_city"]));
02242                                 $this->client->setSetting("admin_country",ilUtil::stripSlashes($_POST["form"]["admin_country"]));
02243                                 $this->client->setSetting("admin_phone",ilUtil::stripSlashes($_POST["form"]["admin_phone"]));
02244                                 $this->client->setSetting("admin_email",ilUtil::stripSlashes($_POST["form"]["admin_email"]));
02245                                 $this->client->setSetting("inst_institution",ilUtil::stripSlashes($_POST["form"]["inst_institution"]));
02246                                 $this->client->setSetting("inst_name",ilUtil::stripSlashes($_POST["form"]["inst_name"]));
02247 
02248                                 // update client.ini
02249                                 $this->client->setName(ilUtil::stripSlashes($_POST["form"]["inst_name"]));
02250                                 $this->client->setDescription(ilUtil::stripSlashes($_POST["form"]["inst_info"]));
02251                                 $this->client->ini->write();
02252 
02253                                 // reload settings
02254                                 $settings = $this->client->getAllSettings();
02255                                 // feedback
02256                                 ilUtil::sendInfo($this->lng->txt("saved_successfully"));
02257                         }
02258                 }
02259 
02260                 // output
02261                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_contact.html");
02262 
02263                 // client values
02264                 $this->tpl->setVariable("INST_NAME",ilUtil::prepareFormOutput(($this->client->getName()) ? $this->client->getName() : $this->client->getId()));
02265                 $this->tpl->setVariable("INST_INFO",ilUtil::prepareFormOutput($this->client->getDescription()));
02266                 $this->tpl->setVariable("INST_INSTITUTION",ilUtil::prepareFormOutput($settings["inst_institution"]));
02267 
02268                 // contact values
02269                 $this->tpl->setVariable("ADMIN_FIRSTNAME",ilUtil::prepareFormOutput($settings["admin_firstname"]));
02270                 $this->tpl->setVariable("ADMIN_LASTNAME",ilUtil::prepareFormOutput($settings["admin_lastname"]));
02271                 $this->tpl->setVariable("ADMIN_TITLE",ilUtil::prepareFormOutput($settings["admin_title"]));
02272                 $this->tpl->setVariable("ADMIN_POSITION",ilUtil::prepareFormOutput($settings["admin_position"]));
02273                 $this->tpl->setVariable("ADMIN_INSTITUTION",ilUtil::prepareFormOutput($settings["admin_institution"]));
02274                 $this->tpl->setVariable("ADMIN_STREET",ilUtil::prepareFormOutput($settings["admin_street"]));
02275                 $this->tpl->setVariable("ADMIN_ZIPCODE",ilUtil::prepareFormOutput($settings["admin_zipcode"]));
02276                 $this->tpl->setVariable("ADMIN_CITY",ilUtil::prepareFormOutput($settings["admin_city"]));
02277                 $this->tpl->setVariable("ADMIN_COUNTRY",ilUtil::prepareFormOutput($settings["admin_country"]));
02278                 $this->tpl->setVariable("ADMIN_PHONE",ilUtil::prepareFormOutput($settings["admin_phone"]));
02279                 $this->tpl->setVariable("ADMIN_EMAIL",ilUtil::prepareFormOutput($settings["admin_email"]));
02280                 
02281                 // client text
02282                 $this->tpl->setVariable("TXT_INST_DATA", $this->lng->txt("client_data"));
02283                 $this->tpl->setVariable("TXT_INST_NAME", $this->lng->txt("client_name"));
02284                 $this->tpl->setVariable("TXT_INST_INFO", $this->lng->txt("client_info"));
02285                 $this->tpl->setVariable("TXT_INST_INSTITUTION", $this->lng->txt("client_institution"));
02286 
02287                 // contact text
02288                 $this->tpl->setVariable("TXT_CONTACT_DATA", $this->lng->txt("contact_data"));
02289                 $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
02290                 $this->tpl->setVariable("TXT_FIRSTNAME", $this->lng->txt("firstname"));
02291                 $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("lastname"));
02292                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("title"));
02293                 $this->tpl->setVariable("TXT_POSITION", $this->lng->txt("position"));
02294                 $this->tpl->setVariable("TXT_INSTITUTION", $this->lng->txt("institution"));
02295                 $this->tpl->setVariable("TXT_STREET", $this->lng->txt("street"));
02296                 $this->tpl->setVariable("TXT_ZIPCODE", $this->lng->txt("zipcode"));
02297                 $this->tpl->setVariable("TXT_CITY", $this->lng->txt("city"));
02298                 $this->tpl->setVariable("TXT_COUNTRY", $this->lng->txt("country"));
02299                 $this->tpl->setVariable("TXT_PHONE", $this->lng->txt("phone"));
02300                 $this->tpl->setVariable("TXT_EMAIL", $this->lng->txt("email"));
02301                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
02302                 
02303                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
02304                 $this->tpl->setVariable("TXT_SETUP_TITLE","contact information & client data");
02305                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_contact"));
02306                 
02307                 $this->setButtonPrev("lang");
02308                 
02309                 $check = $this->checkClientContact($this->client);
02310 
02311                 $this->client->status["contact"]["status"] = $check["status"];
02312                 $this->client->status["contact"]["comment"] = $check["comment"];
02313 
02314                 if ($check["status"])
02315                 {
02316                         $this->setButtonNext("nic");
02317                 }
02318                 
02319                 $this->checkPanelMode();
02320         }
02321 
02325         function displayNIC()
02326         {
02327                 $this->checkDisplayMode("nic_registration");
02328                 $settings = $this->client->getAllSettings();
02329                 $nic_key = $this->client->getNICkey();
02330                 
02331                 // formular sent
02332                 if ($_POST["form"])
02333                 {
02334                         // check register option
02335                         if ($_POST["form"]["register"] == 1)
02336                         {
02337                                 // update nic
02338                                 $this->client->updateNIC($this->ilias_nic_server);
02339                                 
02340                                 // online registration failed
02341                                 if (empty($this->client->nic_status[2]))
02342                                 {
02343                                         $this->client->setSetting("nic_enabled","-1");
02344                                         $message = $this->lng->txt("nic_reg_failed");               
02345                                 }
02346                                 else
02347                                 {
02348                                         $this->client->setSetting("inst_id",$this->client->nic_status[2]);
02349                                         $this->client->setSetting("nic_enabled","1");
02350                                         $this->client->status["nic"]["status"] = true;
02351                                         $message = $this->lng->txt("nic_reg_enabled");      
02352                                 }
02353                         }
02354                         elseif ($_POST["form"]["register"] == 2)
02355                         {
02356                                 $nic_by_email = (int) $_POST["form"]["nic_id"];
02357                                 
02358                                 $checksum = md5($nic_key.$nic_by_email);
02359                                 
02360                                 if (!$nic_by_email or $_POST["form"]["nic_checksum"] != $checksum)
02361                                 {
02362                                         $message = $this->lng->txt("nic_reg_enter_correct_id");     
02363                                 }
02364                                 else
02365                                 {
02366                                         $this->client->setSetting("inst_id",$nic_by_email);
02367                                         $this->client->setSetting("nic_enabled","1");
02368                                         $message = $this->lng->txt("nic_reg_enabled");      
02369                                 }
02370                         }
02371                         else
02372                         {
02373                                 $this->client->setSetting("inst_id","0");
02374                                 $this->client->setSetting("nic_enabled","0");
02375                                 $message = $this->lng->txt("nic_reg_disabled");
02376                         }
02377 
02378                         ilUtil::sendInfo($message);
02379                 }
02380                 
02381                 // reload settings
02382                 $settings = $this->client->getAllSettings();
02383                 
02384                 if ($settings["nic_enabled"] == "1" && $settings["inst_id"] > 0)
02385                 {
02386                         $this->tpl->setVariable("TXT_INFO",$this->lng->txt("info_text_nic3")." ".$settings["inst_id"].".");
02387                 }
02388                 else
02389                 {
02390                         // reload settings
02391                         $settings = $this->client->getAllSettings();
02392                         
02393                         $email_subject = rawurlencode("NIC registration request");
02394                         $email_body = base64_encode($this->client->getURLStringForNIC($this->ilias_nic_server));
02395                         $email_link = "<a href=\"mailto:ilias-nic@uni-koeln.de?subject=".$email_subject."&body=".$email_body."\">".$this->lng->txt("email")."</a>";
02396 
02397                         $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_nic1")." ".$email_link." ".$this->lng->txt("info_text_nic2"));
02398 
02399                         // output
02400                         $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_nic.html");
02401         
02402                         $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
02403         
02404                         // register form
02405                         $this->tpl->setVariable("TXT_NIC_ENTER_ID",$this->lng->txt("nic_reg_enter_id"));
02406                         $this->tpl->setVariable("TXT_NIC_ENTER_CHECKSUM",$this->lng->txt("nic_reg_enter_checksum"));
02407                         $this->tpl->setVariable("TXT_NIC_REGISTER",$this->lng->txt("nic_registration"));
02408                         $this->tpl->setVariable("TXT_NIC_ENABLE",$this->lng->txt("nic_reg_online"));
02409                         $this->tpl->setVariable("TXT_NIC_EMAIL",$this->lng->txt("nic_reg_email"));
02410                         $this->tpl->setVariable("TXT_NIC_DISABLE",$this->lng->txt("nic_reg_disable")." <span class=\"subtitle\">".$this->lng->txt("nic_reg_disable_comment")."</span>");
02411         
02412                         $checked = "checked=\"checked\"";
02413                         
02414                         if (!isset($settings["nic_enabled"]) or $settings["nic_enabled"] == "1")
02415                         {
02416                                 $this->tpl->setVariable("ENABLED",$checked);
02417                         }
02418                         elseif ($settings["nic_enabled"] == "2")
02419                         {
02420                                 $this->tpl->setVariable("EMAIL",$checked);
02421                         }
02422                         else
02423                         {
02424                                 $this->tpl->setVariable("DISABLED",$checked);
02425                         }
02426         
02427                         if (isset($settings["nic_enabled"]))
02428                         {
02429                                 $this->client->status["nic"]["status"] = true;
02430                         }
02431                 }
02432 
02433                 $this->setButtonPrev("contact");
02434                 
02435                 if ($this->client->status["nic"]["status"])
02436                 {
02437                         $this->setButtonNext("finish","finish");
02438                 }
02439                 
02440                 $this->checkPanelMode();
02441         }
02442         
02446         function displayTools()
02447         {
02448                 $this->checkDisplayMode();
02449                 
02450                 // output
02451                 ilUtil::sendInfo();
02452                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_tools.html");
02453                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
02454                 $this->tpl->setVariable("TXT_TOOLS", $this->lng->txt("tools"));
02455                 $this->tpl->setVariable("TXT_CTRL_STRUCTURE", $this->lng->txt("ctrl_structure"));
02456                 $this->tpl->setVariable("TXT_RELOAD", $this->lng->txt("reload"));
02457 
02458                 $q = "SELECT count(*) as cnt FROM ctrl_calls";
02459                 $cset = $this->client->db->query($q);
02460                 $crec = $cset->fetchRow(DB_FETCHMODE_ASSOC);
02461                 if ($crec["cnt"] == 0)
02462                 {
02463                         $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
02464                                 $this->lng->txt("ctrl_missing_desc"));
02465                 }
02466                 else
02467                 {
02468                         $this->tpl->setVariable("TXT_CTRL_STRUCTURE_DESC",
02469                                 $this->lng->txt("ctrl_structure_desc"));
02470                 }
02471 
02472                 $this->tpl->parseCurrentBlock();
02473                 
02474                 //$this->checkPanelMode();
02475         }
02476 
02480         function reloadControlStructure()
02481         {
02482                 global $ilCtrlStructureReader;
02483                 
02484                 if (!$this->client->db_installed)
02485                 {
02486                         ilUtil::sendInfo($this->lng->txt("no_db"), true);
02487                         $this->displayTools();
02488                         return;
02489                 }
02490                 
02491                 // referencing does not work in dbupdate-script
02492                 $GLOBALS["ilDB"] = new ilDbx($this->client->dsn);
02493                 $ilCtrlStructureReader->readStructure(true);
02494                 ilUtil::sendInfo($this->lng->txt("ctrl_structure_reloaded"), true);
02495                 $this->displayTools();
02496         }
02497 
02498 
02499         
02503         function changeMasterPassword()
02504         {
02505                 $this->tpl->addBlockFile("CONTENT","content","tpl.std_layout.html");
02506                 
02507                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_password"));
02508 
02509                 // formular sent
02510                 if ($_POST["form"])
02511                 {
02512                         $pass_old = $this->getPassword();
02513 
02514                         if (empty($_POST["form"]["pass_old"]))
02515                         {
02516                                 $message = $this->lng->txt("password_enter_old");
02517                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02518                         }
02519                                 
02520                         if (md5($_POST["form"]["pass_old"]) != $pass_old)
02521                         {
02522                                 $message = $this->lng->txt("password_old_wrong");
02523                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02524                         }
02525                         
02526                         if (empty($_POST["form"]["pass"]))
02527                         {
02528                                 $message = $this->lng->txt("password_empty");
02529                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02530                         }
02531                         
02532                         if ($_POST["form"]["pass"] != $_POST["form"]["pass2"])
02533                         {
02534                                 $message = $this->lng->txt("password_not_match");
02535                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02536                         }
02537                         
02538                         if (md5($_POST["form"]["pass"]) == $pass_old)
02539                         {
02540                                 $message = $this->lng->txt("password_same");
02541                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02542                         }
02543                         
02544                         if (!$this->setPassword($_POST["form"]["pass"]))
02545                         {
02546                                 $message = $this->lng->txt("save_error");
02547                                 $this->raiseError($message,$this->error_obj->MESSAGE);
02548                         }
02549 
02550                         ilUtil::sendInfo($this->lng->txt("password_changed"),true);
02551                         ilUtil::redirect("setup.php");
02552                 }
02553                 
02554                 // output
02555                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_change_admin_password.html");
02556 
02557                 $this->tpl->setVariable("TXT_HEADER",$this->lng->txt("password_new_master"));
02558 
02559                 // pass form
02560                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
02561                 $this->tpl->setVariable("TXT_REQUIRED_FIELDS", $this->lng->txt("required_field"));
02562                 $this->tpl->setVariable("TXT_PASS_TITLE",$this->lng->txt("change_password"));
02563                 $this->tpl->setVariable("TXT_PASS_OLD",$this->lng->txt("set_oldpasswd"));
02564                 $this->tpl->setVariable("TXT_PASS",$this->lng->txt("set_newpasswd"));
02565                 $this->tpl->setVariable("TXT_PASS2",$this->lng->txt("password_retype"));
02566                 $this->tpl->setVariable("TXT_SAVE", $this->lng->txt("save"));
02567         }
02568 
02572         function displayFinishSetup()
02573         {
02574                 $this->checkDisplayMode("finish_setup");
02575 
02576                 if ($this->validateSetup())
02577                 {
02578                         $txt_info = $this->lng->txt("info_text_finish1");
02579                         $this->setButtonNext("login_new","login");
02580                         $this->client->setSetting("setup_ok",1);
02581                         $this->client->status["finish"]["status"] = true;
02582                 }
02583                 else
02584                 {
02585                         $txt_info = $this->lng->txt("info_text_finish2");
02586                 }
02587                 
02588                 // output
02589                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.clientsetup_finish.html");
02590                 $this->tpl->setVariable("TXT_INFO",$txt_info);
02591                 
02592                 $this->setButtonPrev("nic");
02593                 
02594                 $this->checkPanelMode();
02595         }
02596         
02600         function displayDeleteConfirmation()
02601         {
02602                 $this->checkDisplayMode();
02603 
02604                 // formular sent
02605                 if ($_POST["form"]["delete"])
02606                 {
02607                         $ini = true;
02608                         $db = false;
02609                         $files = false;
02610                 
02611                         /* disabled
02612                         switch ($_POST["form"]["delete"])
02613                         {
02614                                 case 1:
02615                                         $ini = true;
02616                                         break;
02617                         
02618                                 case 2:
02619                                         $ini = true;
02620                                         $db = true;
02621                                         break;
02622 
02623                                 case 3:
02624                                         $ini = true;
02625                                         $db = true;
02626                                         $files = true;
02627                                         break;      
02628                         }
02629                         */
02630                         
02631                         $msg = $this->client->delete($ini,$db,$files);
02632 
02633                         ilUtil::sendInfo($this->lng->txt("client_deleted"),true);
02634                         ilUtil::redirect("setup.php");
02635                 }
02636 
02637                 $this->tpl->setVariable("TXT_INFO", $this->lng->txt("info_text_delete"));
02638                 
02639                 // output
02640                 $this->tpl->addBlockFile("SETUP_CONTENT","setup_content","tpl.form_delete_client.html");
02641 
02642                 // delete panel
02643                 $this->tpl->setVariable("FORMACTION", "setup.php?cmd=gateway");
02644                 $this->tpl->setVariable("TXT_DELETE", $this->lng->txt("delete"));
02645                 $this->tpl->setVariable("TXT_DELETE_CONFIRM", $this->lng->txt("delete_confirm"));
02646                 $this->tpl->setVariable("TXT_DELETE_INFO", $this->lng->txt("delete_info"));
02647 
02648                 $this->checkPanelMode();
02649         }
02650         
02656         function changeAccessMode($a_back)
02657         {
02658                 if ($this->client->status["finish"]["status"])
02659                 {
02660                         $val = ($this->client->ini->readVariable("client","access")) ? "0" : true;
02661                         $this->client->ini->setVariable("client","access",$val);
02662                         $this->client->ini->write();
02663                         $message = "client_access_mode_changed";
02664                 }
02665                 else
02666                 {
02667                         $message = "client_setup_not_finished";
02668                 }
02669                 
02670                 ilUtil::sendInfo($this->lng->txt($message),true);
02671                 
02672                 ilUtil::redirect("setup.php?cmd=".$a_back);
02673         }
02674         
02678         function changeDefaultClient()
02679         {
02680                 if ($_POST["form"])
02681                 {
02682                         $client = new ilClient($_POST["form"]["default"]);
02683 
02684                         if (!$client->init())
02685                         {
02686                                 $this->raiseError($this->lng->txt("no_valid_client_id"),$this->error_obj->MESSAGE);
02687                         }
02688                         
02689                         $status = $this->getStatus($client);
02690                 
02691                         if ($status["finish"]["status"])
02692                         {
02693                                 $this->ini->setVariable("clients","default",$client->getId());
02694                                 $this->ini->write();
02695                                 $message = "default_client_changed";
02696                         }
02697                         else
02698                         {
02699                                 $message = "client_setup_not_finished";
02700                         }
02701                 }
02702                 
02703                 ilUtil::sendInfo($this->lng->txt($message),true);
02704                 
02705                 ilUtil::redirect("setup.php");
02706         }
02707 
02712         function validateSetup()
02713         {
02714                 foreach ($this->client->status as $key => $val)
02715                 {
02716                         if ($key != "finish" and $key != "access")
02717                         {
02718                                 if ($val["status"] != true)
02719                                 {
02720                                         return false;
02721                                 }
02722                         }
02723                 }
02724                 
02725                 $clientlist = new ilClientList();
02726                 $list = $clientlist->getClients();
02727                 
02728                 if (count($list) == 1)
02729                 {
02730                         $this->ini->setVariable("clients","default",$this->client->getId());
02731                         $this->ini->write();
02732 
02733                         $this->client->ini->setVariable("client","access",1);
02734                         $this->client->ini->write();
02735                 }
02736 
02737                 return true;
02738         }
02739         
02743         function jumpToFirstUnfinishedSetupStep()
02744         {
02745                 if (!$this->client->status["db"]["status"])
02746                 {
02747                         $this->cmd = "db";
02748                         ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
02749                         $this->displayDatabase();
02750                 }
02751                 elseif (!$this->client->status["lang"]["status"])
02752                 {
02753                         $this->cmd = "lang";
02754                         ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
02755                         $this->displayLanguages();      
02756                 }
02757                 elseif (!$this->client->status["contact"]["status"])
02758                 {
02759                         $this->cmd = "contact";
02760                         ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
02761                         $this->displayContactData();        
02762                 }
02763                 elseif (!$this->client->status["nic"]["status"])
02764                 {
02765                         $this->cmd = "nic";
02766                         ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
02767                         $this->displayNIC();        
02768                 }
02769                 elseif (!$this->client->status["finish"]["status"])
02770                 {
02771                         $this->cmd = "finish";
02772                         ilUtil::sendInfo($this->lng->txt("finish_initial_setup_first"),true);
02773                         $this->displayFinishSetup();        
02774                 }
02775                 else
02776                 {
02777                         return false;
02778                 }
02779         }
02780 
02784         function toggleClientList()
02785         {
02786                 if ($this->ini->readVariable("clients","list"))
02787                 {
02788                         $this->ini->setVariable("clients","list","0");
02789                         $this->ini->write();
02790                         ilUtil::sendInfo($this->lng->txt("list_disabled"),true);
02791                 }
02792                 else
02793                 {
02794                         $this->ini->setVariable("clients","list","1");
02795                         $this->ini->write();
02796                         ilUtil::sendInfo($this->lng->txt("list_enabled"),true);             
02797                 }
02798                 
02799                 ilUtil::redirect("setup.php");
02800         }
02801         
02807         /*
02808         public function initBasicSettingsForm($a_mode = "edit")
02809         {
02810                 global $lng;
02811                 
02812                 chdir ("..");
02813                 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
02814                 chdir ("./setup");
02815                 
02816                 $this->form_gui = new ilPropertyFormGUI();
02817                 
02818                 $this->form_gui->setTitle($this->lng->txt("change_basic_settings"));
02819                 
02820                 // Property Title
02821                 $text_input = new ilTextInputGUI($lng->txt("block_feed_block_title"), "block_title");
02822                 $text_input->setInfo("");
02823                 $text_input->setRequired(true);
02824                 $text_input->setMaxLength(200);
02825                 $this->form_gui->addItem($text_input);
02826                 
02827                 // Property FeedUrl
02828                 $text_input = new ilTextInputGUI($lng->txt("block_feed_block_feed_url"), "block_feed_url");
02829                 $text_input->setInfo($lng->txt("block_feed_block_feed_url_info"));
02830                 $text_input->setRequired(true);
02831                 $text_input->setMaxLength(250);
02832                 $this->form_gui->addItem($text_input);
02833                 
02834                 
02835                 // save and cancel commands
02836                 if ($a_mode == "create")
02837                 {
02838                         $this->form_gui->addCommandButton("save", $lng->txt("save"));
02839                         $this->form_gui->addCommandButton("cancelSave", $lng->txt("cancel"));
02840                 }
02841                 else
02842                 {
02843                         $this->form_gui->addCommandButton("update", $lng->txt("save"));
02844                         $this->form_gui->addCommandButton("cancelUpdate", $lng->txt("cancel"));
02845                 }
02846                 
02847                 $this->form_gui->setTitle($lng->txt("block_feed_block_head"));
02848                 $this->form_gui->setFormAction("setup.php?cmd=gateway");
02849         }*/
02850         
02851 } // END class.ilSetupGUI
02852 ?>

Generated on Fri Dec 13 2013 17:57:03 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1