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

Services/Init/classes/class.ilStartUpGUI.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2005 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 class ilStartUpGUI
00034 {
00035 
00039         function ilStartUpGUI()
00040         {
00041                 global $ilCtrl;
00042 
00043                 $this->ctrl =& $ilCtrl;
00044 
00045                 $ilCtrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
00046         }
00047 
00051         function &executeCommand()
00052         {
00053                 $cmd = $this->ctrl->getCmd("processIndexPHP");
00054                 $next_class = $this->ctrl->getNextClass($this);
00055 
00056                 switch($next_class)
00057                 {
00058                         case "ilregistrationgui":
00059                                 require_once("Services/Registration/classes/class.ilRegistrationGUI.php");
00060                                 return $this->ctrl->forwardCommand(new ilRegistrationGUI());
00061                                 break;
00062 
00063                         case "ilpasswordassistancegui":
00064                                 require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
00065                                 return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
00066                                 break;
00067 
00068                         default:
00069                                 return $this->$cmd();
00070                                 break;
00071                 }
00072         }
00073 
00077         function jumpToRegistration()
00078         {
00079                 $this->ctrl->setCmdClass("ilregistrationgui");
00080                 $this->ctrl->setCmd("");
00081                 $this->executeCommand();
00082         }
00083 
00087         function jumpToPasswordAssistance()
00088         {
00089                 $this->ctrl->setCmdClass("ilpasswordassistancegui");
00090                 $this->ctrl->setCmd("");
00091                 $this->executeCommand();
00092         }
00093 
00097         function showLogin()
00098         {
00099                 global $ilSetting, $ilAuth, $ilUser, $tpl, $ilIliasIniFile, $ilias;
00100 
00101                 // if authentication of soap user failed, but email address is
00102                 // known, show users and ask for password
00103                 $status = $ilAuth->getStatus();
00104                 if ($status == "")
00105                 {
00106                         $status = $_GET["auth_stat"];
00107                 }
00108                 if ($status == AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL)
00109                 {
00110                         $this->showUserMappingSelection();
00111                         return;
00112                 }
00113 
00114                 // login language selection is post type
00115                 if ($_POST["lang"] != "")
00116                 {
00117                         $_GET["lang"] = ilUtil::stripSlashes($_POST["lang"]);
00118                 }
00119 
00120                 // check for session cookies enabled
00121                 if (!isset($_COOKIE['iltest']))
00122                 {
00123                         if (empty($_GET['cookies']))
00124                         {
00125                                 setcookie("iltest","cookie");
00126                                 //header('Location: '.$_SERVER['PHP_SELF']."?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".$_GET['client_id']."&lang=".$_GET['lang']);
00127                                 header("Location: login.php?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"]."&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".rawurlencode(CLIENT_ID)."&lang=".$_GET['lang']);
00128                         }
00129                         else
00130                         {
00131                                 $_COOKIE['iltest'] = "";
00132                         }
00133                 }
00134                 else
00135                 {
00136                         unset($_GET['cookies']);
00137                 }
00138 
00139                 // check correct setup
00140                 if (!$ilSetting->get("setup_ok"))
00141                 {
00142                         die("Setup is not completed. Please run setup routine again. (Login)");
00143                 }
00144 
00145                 if ($ilSetting->get("shib_active") && $ilSetting->get("shib_hos_type"))
00146                 {
00147                         require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
00148                         // Check if we user selects Home Organization
00149                         $WAYF = new ShibWAYF();
00150                 }
00151 
00152                 if (isset($WAYF) && $WAYF->isSelection())
00153                 {
00154                         if ($WAYF->isValidSelection())
00155                         {
00156                                 // Set cookie
00157                                 $WAYF->setSAMLCookie();
00158 
00159                                 // Redirect
00160                                 $WAYF->redirect();
00161                         }
00162                 }
00163                 elseif ($ilAuth->getAuth())
00164                 {
00165                         // Or we do authentication here
00166                         // To do: check whether some $ilInit method could be used here.
00167 
00168                         if(!$ilUser->checkTimeLimit())
00169                         {
00170                                 $ilAuth->logout();
00171                                 session_destroy();
00172 
00173                                 // to do: get rid of this
00174                                 ilUtil::redirect('login.php?time_limit=true');
00175                         }
00176 
00177                         include_once './Services/Tracking/classes/class.ilOnlineTracking.php';
00178                         ilOnlineTracking::_addUser($ilUser->getId());
00179 
00180                         // handle chat kicking
00181                         if ($ilSetting->get("chat_active"))
00182                         {
00183                                 include_once "./Modules/Chat/classes/class.ilChatServerCommunicator.php";
00184                                 include_once "./Modules/Chat/classes/class.ilChatRoom.php";
00185 
00186                                 ilChatServerCommunicator::_login();
00187                                 ilChatRoom::_unkick($ilUser->getId());
00188                         }
00189 
00190                         // update last forum visit
00191                         include_once './Modules/Forum/classes/class.ilObjForum.php';
00192                         ilObjForum::_updateOldAccess($ilUser->getId());
00193 
00194                         if ($_GET["rep_ref_id"] != "")
00195                         {
00196                                 $_GET["ref_id"] = $_GET["rep_ref_id"];
00197                         }
00198                         $this->processStartingPage();
00199                         exit;
00200                 }
00201 
00202                 // Instantiate login template
00203                 // Use Shibboleth-only authentication if auth_mode is set to Shibboleth
00204                 $tpl->addBlockFile("CONTENT", "content", "tpl.login.html");
00205 
00206                 //language handling
00207                 if ($_GET["lang"] == "")
00208                 {
00209                         $_GET["lang"] = $ilIliasIniFile->readVariable("language","default");
00210                 }
00211 
00212                 //instantiate language
00213                 $lng = new ilLanguage($_GET["lang"]);
00214 
00215                 $tpl->setVariable("TXT_OK", $lng->txt("ok"));
00216 
00217                 $languages = $lng->getInstalledLanguages();
00218 
00219                 foreach ($languages as $lang_key)
00220                 {
00221                         $tpl->setCurrentBlock("languages");
00222                         $tpl->setVariable("LANG_KEY", $lang_key);
00223                         $tpl->setVariable("LANG_NAME",
00224                                 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00225                         $tpl->setVariable("BORDER", 0);
00226                         $tpl->setVariable("VSPACE", 0);
00227                         $tpl->parseCurrentBlock();
00228                 }
00229 
00230                 // allow new registrations?
00231                 include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
00232                 if (ilRegistrationSettings::_lookupRegistrationType() != IL_REG_DISABLED)
00233                 {
00234                         $tpl->setCurrentBlock("new_registration");
00235                         $tpl->setVariable("REGISTER", $lng->txt("registration"));
00236                         $tpl->setVariable("CMD_REGISTER",
00237                                 $this->ctrl->getLinkTargetByClass("ilregistrationgui", ""));
00238                         $tpl->parseCurrentBlock();
00239                 }
00240                 // allow password assistance? Surpress option if Authmode is not local database
00241                 if ($ilSetting->get("password_assistance"))
00242                 {
00243                         $tpl->setCurrentBlock("password_assistance");
00244                         $tpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
00245                         $tpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
00246                         $tpl->setVariable("CMD_FORGOT_PASSWORD",
00247                                 $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
00248                         $tpl->setVariable("CMD_FORGOT_USERNAME",
00249                                 $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
00250                         $tpl->setVariable("LANG_ID", $_GET["lang"]);
00251                         $tpl->parseCurrentBlock();
00252                 }
00253 
00254                 if ($ilSetting->get("pub_section"))
00255                 {
00256                         $tpl->setCurrentBlock("homelink");
00257                         $tpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$_GET["lang"]);
00258                         $tpl->setVariable("TXT_HOME",$lng->txt("home"));
00259                         $tpl->parseCurrentBlock();
00260                 }
00261 
00262                 if ($ilIliasIniFile->readVariable("clients","list"))
00263                 {
00264                         $tpl->setCurrentBlock("client_list");
00265                         $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
00266                         $tpl->setVariable("CMD_CLIENT_LIST",
00267                                 $this->ctrl->getLinkTarget($this, "showClientList"));
00268                         $tpl->parseCurrentBlock();
00269                 }
00270 
00271                 // shibboleth login link
00272                 if ($ilSetting->get("shib_active"))
00273                 {
00274                         if($ilSetting->get("shib_hos_type") != 'external_wayf'){
00275                                 $tpl->setCurrentBlock("shibboleth_wayf_login");
00276                                 $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
00277                                 $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
00278                                 $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
00279                                 $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
00280                                 $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
00281                                 $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $lng->txt("shib_general_wayf_login_instructions").' <a href="mailto:'.$ilias->getSetting("admin_email").'">ILIAS '. $lng->txt("administrator").'</a>.');
00282                                 $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
00283                                 $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
00284                                 $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
00285                                 $tpl->setVariable("ILW_TARGET", $_GET["target"]);
00286 
00287                                 $tpl->parseCurrentBlock();
00288                         } else {
00289                                 $tpl->setCurrentBlock("shibboleth_login");
00290                                 $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
00291                                 $tpl->setVariable("IL_TARGET", $_GET["target"]);
00292                                 $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
00293                                 $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
00294                                         $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", sprintf($lng->txt("shib_general_login_instructions"),$ilSetting->get("shib_federation_name")).' <a href="mailto:'.$ilias->getSetting("admin_email").'">ILIAS '. $lng->txt("administrator").'</a>.');
00295                                 $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
00296                                 $tpl->parseCurrentBlock();
00297                         }
00298                 }
00299 
00300                 // cas login link
00301                 if ($ilSetting->get("cas_active"))
00302                 {
00303                         $tpl->setCurrentBlock("cas_login");
00304                         $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
00305                         $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.gif"));
00306                         $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
00307                         $this->ctrl->setParameter($this, "forceCASLogin", "1");
00308                         $tpl->setVariable("TARGET_CAS_LOGIN",
00309                                 $this->ctrl->getLinkTarget($this, "showLogin"));
00310                         $this->ctrl->setParameter($this, "forceCASLogin", "");
00311                         $tpl->parseCurrentBlock();
00312                 }
00313 
00314                 // Show selection of auth modes
00315                 include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
00316                 $det = ilAuthModeDetermination::_getInstance();
00317                 if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
00318                 {
00319                         foreach(ilAuthUtils::_getMultipleAuthModeOptions($lng) as $key => $option)
00320                         {
00321                                 $tpl->setCurrentBlock('auth_mode_row');
00322                                 $tpl->setVariable('VAL_AUTH_MODE',$key);
00323                                 $tpl->setVariable('AUTH_CHECKED',isset($option['checked']) ? 'checked=checked' : '');
00324                                 $tpl->setVariable('TXT_AUTH_MODE',$option['txt']);
00325                                 $tpl->parseCurrentBlock();
00326                         }
00327                         
00328                         $tpl->setCurrentBlock('auth_selection');
00329                         $tpl->setVariable('TXT_AUTH_MODE',$lng->txt('auth_selection'));
00330                         $tpl->parseCurrentBlock();
00331                 }               
00332                 // login via ILIAS (this also includes radius and ldap)
00333                 if ($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH &&
00334                         $ilSetting->get("auth_mode") != AUTH_CAS)
00335                 {
00336                         $loginSettings = new ilSetting("login_settings");
00337                         if ($_GET["lang"] == false)
00338                         {                               
00339                                 $information = $loginSettings->get("login_message_".$lng->getDefaultLanguage());                                                        
00340                         }
00341                         else
00342                         {                               
00343                                 $information = $loginSettings->get("login_message_".$_GET["lang"]);     
00344                         }
00345                                                 
00346                         if(strlen(trim($information)))
00347                         {
00348                                 $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
00349                         }
00350                         $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
00351                         $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
00352                         $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
00353                         $tpl->setVariable("USERNAME", ilUtil::prepareFormOutput($_POST["username"], true));
00354                         $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
00355                         $tpl->parseCurrentBlock();
00356                 }
00357 
00358                 $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
00359                 
00360                 $this->ctrl->setTargetScript("login.php");
00361                 $tpl->setVariable("FORMACTION",
00362                         $this->ctrl->getFormAction($this));
00363 //echo "-".htmlentities($this->ctrl->getFormAction($this, "showLogin"))."-";
00364                 $tpl->setVariable("LANG_FORM_ACTION",
00365                         $this->ctrl->getFormAction($this));
00366                 $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00367                 $tpl->setVariable("LANG_ID", $_GET["lang"]);
00368 
00369                 if ($_GET["inactive"])
00370                 {
00371                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_inactive"));
00372                 }
00373                 elseif ($_GET["expired"])
00374                 {
00375                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_session_expired"));
00376                 }
00377 
00378                 // TODO: Move this to header.inc since an expired session could not detected in login script
00379                 $status = $ilAuth->getStatus();
00380                 
00381                 
00382                 if ($status == "")
00383                 {
00384                         $status = $_GET["auth_stat"];
00385                 }
00386                 $auth_error = $ilias->getAuthError();
00387 
00388                 if (!empty($status))
00389                 {
00390                         switch ($status)
00391                         {
00392                                 case AUTH_EXPIRED:
00393                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED', $lng->txt("err_session_expired"));
00394                                         break;
00395                                 case AUTH_IDLED:
00396                                         // lang variable err_idled not existing
00397                                         //$tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
00398                                         break;
00399 
00400                                 case AUTH_CAS_NO_ILIAS_USER:
00401                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
00402                                                 $lng->txt("err_auth_cas_no_ilias_user"));
00403                                         break;
00404 
00405                                 case AUTH_SOAP_NO_ILIAS_USER:
00406                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
00407                                         $lng->txt("err_auth_soap_no_ilias_user"));
00408                                         break;
00409 
00410                                 case AUTH_LDAP_NO_ILIAS_USER:
00411                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
00412                                                 $lng->txt('err_auth_ldap_no_ilias_user'));
00413                                         break;
00414                                 
00415                                 case AUTH_RADIUS_NO_ILIAS_USER:
00416                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
00417                                                 $lng->txt('err_auth_radius_no_ilias_user'));
00418                                         break;
00419                                         
00420                                 case AUTH_MODE_INACTIVE:
00421                                         $tpl->setVariable('TXT_MSG_LOGIN_FAILED',
00422                                                 $lng->txt('err_auth_mode_inactive'));
00423                                         break;
00424                                                         
00425                                         
00426                                 case AUTH_WRONG_LOGIN:
00427                                 default:
00428                                         $add = "";
00429                                         if (is_object($auth_error))
00430                                         {
00431                                                 $add = "<br>".$auth_error->getMessage();
00432                                         }
00433                                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_wrong_login").$add);
00434                                         break;
00435                         }
00436                 }
00437 
00438 
00439                 if ($_GET['time_limit'])
00440                 {
00441                         $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt('time_limit_reached'));
00442                 }
00443 
00444                 // output wrong IP message
00445                 if($_GET['wrong_ip'])
00446                 {
00447                         $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt('wrong_ip_detected')." (".$_SERVER["REMOTE_ADDR"].")");
00448                 }
00449 
00450                 $this->ctrl->setTargetScript("ilias.php");
00451                 $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
00452                 $tpl->setVariable("USER_AGREEMENT", $lng->txt("usr_agreement"));
00453                 $tpl->setVariable("LINK_USER_AGREEMENT",
00454                         $this->ctrl->getLinkTarget($this, "showUserAgreement"));
00455 
00456                 // browser does not accept cookies
00457                 if ($_GET['cookies'] == 'nocookies')
00458                 {
00459                         $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_no_cookies"));
00460                         $tpl->setVariable("COOKIES_HOWTO", $lng->txt("cookies_howto"));
00461                         $tpl->setVariable("LINK_NO_COOKIES",
00462                                 $this->ctrl->getLinkTarget($this, "showNoCookiesScreen"));
00463                 }
00464 
00465                 $tpl->show("DEFAULT", false);
00466         }
00467         
00475         public function showAccountMigration($a_message = '')
00476         {
00477                 global $tpl,$lng;
00478                 
00479                 $lng->loadLanguageModule('auth');
00480                 $tpl->addBlockFile("CONTENT", "content", "tpl.login_account_migration.html");
00481                 $tpl->addJavaScript('./Services/Authentication/js/account_migration.js');
00482                 
00483                 if(strlen($a_message))
00484                 {
00485                         ilUtil::sendInfo($a_message);
00486                 }
00487                 $tpl->setVariable('FORMACTION',$this->ctrl->getFormAction($this,'migrateAccount'));
00488                 $tpl->setVariable('TXT_ACCOUNT_MIGRATION',$lng->txt('auth_account_migration'));
00489                 $tpl->setVariable('INFO_MIGRATE',$lng->txt('auth_info_migrate'));
00490                 $tpl->setVariable('INFO_ADD',$lng->txt('auth_info_add'));
00491                 
00492                 $tpl->setVariable('MIG_USER',$_POST['username']);
00493                 $tpl->setVariable('TXT_USER',$lng->txt('login'));
00494                 $tpl->setVariable('TXT_PASS',$lng->txt('password'));
00495                 
00496                 $tpl->setVariable('TXT_SUBMIT',$lng->txt('save'));
00497                 $tpl->setVariable('TXT_CANCEL',$lng->txt('cancel'));
00498                 
00499                 $tpl->show('DEFAULT');          
00500         }
00501         
00508         public function migrateAccount()
00509         {
00510                 global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
00511                 
00512                 $lng->loadLanguageModule('auth');
00513                 
00514                 if(!isset($_POST['account_migration']))
00515                 {
00516                         $this->showAccountMigration($lng->txt('err_choose_migration_type'));
00517                         return false;
00518                 }
00519                 
00520                 if($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
00521                 {
00522                         $this->showAccountMigration($lng->txt('err_wrong_login'));
00523                         return false;
00524                 }
00525                 
00526                 if($_POST['account_migration'] == 1)
00527                 {
00528                         if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
00529                         {
00530                                 $this->showAccountMigration($lng->txt('err_wrong_login'));
00531                                 return false;
00532                         }
00533                         $_POST['username'] = $_POST['mig_username'];
00534                         $_POST['password'] = $_POST['mig_password'];
00535                         $auth_params = array(
00536                                 'dsn'             => IL_DSN,
00537                                 'table'       => $ilClientIniFile->readVariable("auth", "table"),
00538                                 'usernamecol' => $ilClientIniFile->readVariable("auth", "usercol"),
00539                                 'passwordcol' => $ilClientIniFile->readVariable("auth", "passcol")
00540                                 );
00541                         $ilAuth = new Auth("DB", $auth_params,"",false);
00542                         $ilAuth->start();
00543                         if(!$ilAuth->getAuth())
00544                         {
00545                                 $ilAuth->logout();
00546                                 $this->showAccountMigration($lng->txt('err_wrong_login'));
00547                                 return false;
00548                         }
00549 
00550                         $user = new ilObjUser($user_id);
00551                         $user->setAuthMode($_SESSION['tmp_auth_mode']);
00552                         $user->setExternalAccount($_SESSION['tmp_external_account']);
00553                         $user->update();
00554                         
00555                         // Assign to default role
00556                         if(is_array($_SESSION['tmp_roles']))
00557                         {
00558                                 foreach($_SESSION['tmp_roles'] as $role)
00559                                 {
00560                                         $rbacadmin->assignUser((int) $role,$user->getId());
00561                                 }
00562                         }
00563 
00564                         // Log migration
00565                         $ilLog->write(__METHOD__.': Migrated '.$_SESSION['tmp_external_account'].' to ILIAS account '.$user->getLogin().'.');
00566                 }
00567                 elseif($_POST['account_migration'] == 2)
00568                 {
00569                         switch($_SESSION['tmp_auth_mode'])
00570                         {
00571                                 case 'ldap':
00572                                         $_POST['username'] = $_SESSION['tmp_external_account'];
00573                                         $_POST['password'] = $_SESSION['tmp_pass'];
00574                                         
00575                                         include_once('Services/LDAP/classes/class.ilAuthLDAP.php');
00576                                         $ilAuth = new ilAuthLDAP();
00577                                         $ilAuth->forceCreation(true);
00578                                         $ilAuth->setIdle($ilClientIniFile->readVariable("session","expire"), false);
00579                                         $ilAuth->setExpire(0);
00580                                         $ilAuth->start();
00581                                         break;
00582                                 
00583                                 case 'radius':
00584                                         $_POST['username'] = $_SESSION['tmp_external_account'];
00585                                         $_POST['password'] = $_SESSION['tmp_pass'];
00586                                         
00587                                         include_once('Services/Radius/classes/class.ilAuthRadius.php');
00588                                         $ilAuth = new ilAuthRadius();
00589                                         $ilAuth->forceCreation(true);
00590                                         $ilAuth->setIdle($ilClientIniFile->readVariable("session","expire"), false);
00591                                         $ilAuth->setExpire(0);
00592                                         $ilAuth->start();
00593                                         break;
00594                         }
00595                 }
00596                 // show personal desktop
00597                 ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
00598         }
00599 
00603         function showLogout()
00604         {
00605                 global $tpl, $ilSetting, $ilAuth, $lng, $ilIliasIniFile;
00606 
00607                 // LOGOUT CHAT USER
00608                 if($ilSetting->get("chat_active"))
00609                 {
00610                         include_once "./Modules/Chat/classes/class.ilChatServerCommunicator.php";
00611                         ilChatServerCommunicator::_logout();
00612                 }
00613 
00614                 $ilAuth->logout();
00615                 session_destroy();
00616 
00617                 // reset cookie
00618                 $client_id = $_COOKIE["ilClientId"];
00619                 setcookie("ilClientId","");
00620                 $_COOKIE["ilClientId"] = "";
00621 
00622                 //instantiate logout template
00623                 $tpl->addBlockFile("CONTENT", "content", "tpl.logout.html");
00624 
00625                 if ($ilSetting->get("pub_section"))
00626                 {
00627                         $tpl->setCurrentBlock("homelink");
00628                         $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$_GET['lang']);
00629                         $tpl->setVariable("TXT_HOME",$lng->txt("home"));
00630                         $tpl->parseCurrentBlock();
00631                 }
00632 
00633                 if ($ilIliasIniFile->readVariable("clients","list"))
00634                 {
00635                         $tpl->setCurrentBlock("client_list");
00636                         $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
00637                         $tpl->setVariable("CMD_CLIENT_LIST",
00638                                 $this->ctrl->getLinkTarget($this, "showClientList"));
00639                         $tpl->parseCurrentBlock();
00640                 }
00641 
00642                 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
00643                 $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
00644                 $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
00645                 $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$_GET['lang']);
00646 
00647                 $tpl->show();
00648         }
00649 
00654         function showUserMappingSelection()
00655         {
00656                 global $ilAuth, $tpl, $lng;
00657 
00658                 $valid = $ilAuth->getValidationData();
00659 
00660                 $tpl->addBlockFile("CONTENT", "content", "tpl.user_mapping_selection.html");
00661                 $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
00662 
00663 
00664                 if ($ilAuth->sub_status == AUTH_WRONG_LOGIN)
00665                 {
00666                         $tpl->setCurrentBlock("msg");
00667                         $tpl->setVariable("TXT_MSG_LOGIN_FAILED", $lng->txt("err_wrong_login"));
00668                         $tpl->parseCurrentBlock();
00669                 }
00670 
00671                 include_once('./Services/User/classes/class.ilObjUser.php');
00672                 if (count($email_user) == 1)
00673                 {
00674                         //$user = new ilObjUser(key($email_user));
00675                         $tpl->setCurrentBlock("one_user");
00676                         $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
00677                         $tpl->setVariable("VAL_USERNAME", current($email_user));
00678                         $tpl->setVariable("USER_ID", key($email_user));
00679                         $tpl->parseCurrentBlock();
00680                 }
00681                 else
00682                 {
00683                         foreach($email_user as $key => $login)
00684                         {
00685                                 $tpl->setCurrentBlock("user");
00686                                 $tpl->setVariable("USR_ID", $key);
00687                                 $tpl->setVariable("VAL_USER", $login);
00688                                 $tpl->parseCurrentBlock();
00689                         }
00690                         $tpl->setCurrentBlock("multpiple_user");
00691                         $tpl->parseCurrentBlock();
00692                 }
00693 
00694                 $tpl->setCurrentBlock("content");
00695                 $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
00696                 $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
00697                 $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
00698                 $tpl->setVariable("FORMACTION",
00699                         $this->ctrl->getFormAction($this));
00700                 $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
00701                 if (count($email_user) == 1)
00702                 {
00703                         $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
00704                         $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
00705                 }
00706                 else
00707                 {
00708                         $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
00709                         $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
00710                 }
00711                 $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
00712                 $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
00713                 $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
00714                 $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
00715 
00716                 $tpl->show();
00717         }
00718 
00722         function showClientList()
00723         {
00724                 global $tpl, $ilIliasIniFile, $ilCtrl;
00725 //echo "1";
00726                 if (!$ilIliasIniFile->readVariable("clients","list"))
00727                 {
00728                         $this->processIndexPHP();
00729                         return;
00730                 }
00731 //echo "2";
00732                 $tpl = new ilTemplate("tpl.main.html", true, true);
00733 
00734                 // to do: get standard style
00735                 $tpl->setVariable("PAGETITLE","Client List");
00736                 $tpl->setVariable("LOCATION_STYLESHEET","./templates/default/delos.css");
00737 
00738                 // load client list template
00739                 $tpl->addBlockfile("CONTENT", "content", "tpl.client_list.html");
00740 
00741                 // load template for table
00742                 $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
00743 
00744                 // load template for table content data
00745                 $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
00746 
00747                 // load table content data
00748                 require_once("setup/classes/class.ilClientList.php");
00749                 require_once("setup/classes/class.ilClient.php");
00750                 require_once("./Services/Table/classes/class.ilTableGUI.php");
00751                 $clientlist = new ilClientList();
00752                 $list = $clientlist->getClients();
00753 
00754                 if (count($list) == 0)
00755                 {
00756                         header("Location: ./setup/setup.php");
00757                         exit();
00758                 }
00759 
00760                 foreach ($list as $key => $client)
00761                 {
00762                         if ($client->checkDatabaseExists() and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
00763                         {
00764                                 $this->ctrl->setParameter($this, "client_id", $key);
00765                                 //$data[] = array(
00766                                 //                              $client->getName(),
00767                                 //                              "<a href=\"".$ilCtrl->getLinkTarget($this, "processIndexPHP")."\">Start page</a>",
00768                                 //                              "<a href=\"".$ilCtrl->getLinkTarget($this, "showLogin")."\">Login page</a>"
00769                                 //                              );
00770                                 $data[] = array(
00771                                                                 $client->getName(),
00772                                                                 "<a href=\"".$ilCtrl->getLinkTarget($this, "processIndexPHP")."\">Start page</a>",
00773                                                                 "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">Login page</a>"
00774                                                                 );
00775                         }
00776                 }
00777                 $this->ctrl->setParameter($this, "client_id", "");
00778 
00779                 // create table
00780                 $tbl = new ilTableGUI();
00781 
00782                 // title & header columns
00783                 $tbl->setTitle("Available Clients");
00784                 $tbl->setHeaderNames(array("Installation Name","Public Access","Login"));
00785                 $tbl->setHeaderVars(array("name","index","login"));
00786                 $tbl->setColumnWidth(array("50%","25%","25%"));
00787 
00788                 // control
00789                 $tbl->setOrderColumn($_GET["sort_by"],"name");
00790                 $tbl->setOrderDirection($_GET["sort_order"]);
00791                 $tbl->setLimit($_GET["limit"]);
00792                 $tbl->setOffset($_GET["offset"]);
00793 
00794                 // content
00795                 $tbl->setData($data);
00796 
00797                 // footer
00798                 $tbl->setFooter("tblfooter");
00799 
00800                 // styles
00801                 $tbl->setStyle("table","std");
00802 
00803                 $tbl->disable("icon");
00804                 $tbl->disable("numinfo");
00805 
00806                 // render table
00807                 $tbl->render();
00808                 $tpl->show();
00809         }
00810 
00816         function showNoCookiesScreen()
00817         {
00818                 global $tpl;
00819 
00820                 $str = "<p style=\"margin:15px;\">
00821                         You need to enable Session Cookies in your Browser to use ILIAS.
00822                         <br/>
00823                         <br/><b>Firefox</b>
00824                         <br/>Tools -> Options -> Privacy -> Cookies
00825                         <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
00826                         <br/>cookies' auf 'until I close Firefox'
00827                         <br/>
00828                         <br/><b>Mozilla/Netscape</b>
00829                         <br/>Edit -> Preferences -> Privacy&Security -> Cookies
00830                         <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
00831                         <br/>session only'.
00832                         <br/>
00833                         <br/><b>Internet Explorer</b>
00834                         <br/>Tools -> Internet Options -> Privacy -> Advanced
00835                         <br/>- Check 'Override automatic cookie handling'
00836                         <br/>- Check 'Always allow session cookies'
00837                         </p>";
00838                 $tpl->setVariable("CONTENT", $str);
00839                 $tpl->show();
00840         }
00841 
00845         function getAcceptance()
00846         {
00847                 $this->showUserAgreement();
00848         }
00849 
00853         function showUserAgreement()
00854         {
00855                 global $lng, $tpl, $ilUser;
00856 
00857                 require_once "./Services/User/classes/class.ilUserAgreement.php";
00858 
00859                 $tpl->addBlockFile("CONTENT", "content", "tpl.view_usr_agreement.html");
00860                 $tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
00861 
00862                 ilUtil::sendInfo();
00863                 // display infopanel if something happened
00864                 ilUtil::infoPanel();
00865 
00866                 $tpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
00867                 $tpl->setVariable("TXT_OK", $lng->txt("ok"));
00868 
00869                 // language selection
00870                 $languages = $lng->getInstalledLanguages();
00871 
00872                 $count = (int) round(count($languages) / 2);
00873                 $num = 1;
00874 
00875                 foreach ($languages as $lang_key)
00876                 {
00877                         $tpl->setCurrentBlock("languages");
00878                         $tpl->setVariable("LANG_VAL_CMD", $this->ctrl->getCmd());
00879                         $tpl->setVariable("AGR_LANG_ACTION",
00880                                 $this->ctrl->getFormAction($this));
00881                         $tpl->setVariable("LANG_NAME",
00882                                 ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
00883                         $tpl->setVariable("LANG_ICON", $lang_key);
00884                         $tpl->setVariable("LANG_KEY", $lang_key);
00885                         $tpl->setVariable("BORDER", 0);
00886                         $tpl->setVariable("VSPACE", 0);
00887                         $tpl->parseCurrentBlock();
00888 
00889                         $num++;
00890                 }
00891                 $tpl->setCurrentBlock("content");
00892 
00893                 // display tabs
00894                 $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("usr_agreement"));
00895                 $tpl->setVariable("TXT_PAGETITLE", "ILIAS3 - ".$lng->txt("usr_agreement"));
00896                 $tpl->setVariable("TXT_USR_AGREEMENT", ilUserAgreement::_getText());
00897 
00898                 if ($this->ctrl->getCmd() == "getAcceptance")
00899                 {
00900                         if ($_POST["status"]=="accepted")
00901                         {
00902                                 $ilUser->writeAccepted();
00903                                 ilUtil::redirect("index.php?target=".$_GET["target"]."&client_id=".CLIENT_ID);
00904                         }
00905                         $tpl->setVariable("VAL_CMD", "getAcceptance");
00906                         $tpl->setVariable("AGR_LANG_ACTION",
00907                                 $this->ctrl->getFormAction($this));
00908                         $tpl->setCurrentBlock("get_acceptance");
00909                         $tpl->setVariable("FORM_ACTION",
00910                                 $this->ctrl->getFormAction($this));
00911                         $tpl->setVariable("ACCEPT_CHECKBOX", ilUtil::formCheckbox(0, "status", "accepted"));
00912                         $tpl->setVariable("ACCEPT_AGREEMENT", $lng->txt("accept_usr_agreement"));
00913                         $tpl->setVariable("TXT_SUBMIT", $lng->txt("submit"));
00914                         $tpl->parseCurrentBlock();
00915                 }
00916                 else
00917                 {
00918                         $tpl->setCurrentBlock("back");
00919                         $tpl->setVariable("BACK", $lng->txt("back"));
00920                         $tpl->setVariable("LINK_BACK",
00921                                 $this->ctrl->getLinkTargetByClass("ilstartupgui", "showLogin"));
00922                         $tpl->parseCurrentBlock();
00923                 }
00924 
00925                 $tpl->show();
00926 
00927 
00928         }
00929 
00933         function processIndexPHP()
00934         {
00935                 global $ilIliasIniFile, $ilAuth, $ilSetting, $ilInit;
00936 
00937                 // display client selection list if enabled
00938                 if (!isset($_GET["client_id"]) &&
00939                         $_GET["cmd"] == "" &&
00940                         $ilIliasIniFile->readVariable("clients","list"))
00941                 {
00942                         $this->showClientList();
00943                         //include_once "./include/inc.client_list.php";
00944                         exit();
00945                 }
00946 
00947                 /*
00948                 if ($_GET["cmd"] == "login")
00949                 {
00950                         $rep_ref_id = $_SESSION["il_rep_ref_id"];
00951 
00952                         $ilAuth->logout();
00953                         session_destroy();
00954 
00955                         // reset cookie
00956                         $client_id = $_COOKIE["ilClientId"];
00957                         setcookie("ilClientId","");
00958                         $_COOKIE["ilClientId"] = "";
00959 
00960                         $_GET["client_id"] = $client_id;
00961                         $_GET["rep_ref_id"] = $rep_ref_id;
00962 
00963 
00964                         ilUtil::redirect("login.php?client_id=".$client_id."&lang=".$_GET['lang'].
00965                                 "&rep_ref_id=".$rep_ref_id);
00966                 }*/
00967 
00968 
00969                 // if no start page was given, ILIAS defaults to the standard login page
00970                 if ($start == "")
00971                 {
00972                         $start = "login.php";
00973                 }
00974 
00975 
00976                 //
00977                 // index.php is called and public section is enabled
00978                 //
00979                 // && $ilAuth->status == -101 is important for soap auth (public section on + user mapping, alex)
00980                 // $ilAuth->status -1 is given, if session ends (if public section -> jump to public section)
00981                 if ($ilSetting->get("pub_section") && $_POST["sendLogin"] != "1"
00982                         && ($ilAuth->getStatus() != -101 && $_GET["soap_pw"] == ""))
00983                 {
00984                         //
00985                         // TO DO: THE FOLLOWING BLOCK IS COPY&PASTED FROM HEADER.INC
00986 
00987                         $_POST["username"] = "anonymous";
00988                         $_POST["password"] = "anonymous";
00989                         $ilAuth->start();
00990                         if (ANONYMOUS_USER_ID == "")
00991                         {
00992                                 die ("Public Section enabled, but no Anonymous user found.");
00993                         }
00994                         if (!$ilAuth->getAuth())
00995                         {
00996                                 die("ANONYMOUS user with the object_id ".ANONYMOUS_USER_ID." not found!");
00997                         }
00998 
00999                         // get user id
01000                         $ilInit->initUserAccount();
01001                         $this->processStartingPage();
01002                         exit;
01003                 }
01004                 else
01005                 {
01006                         // index.php is called and public section is disabled
01007                         $this->showLogin();
01008                 }
01009         }
01010 
01011 
01017         function processStartingPage()
01018         {
01019                 global $ilBench, $ilCtrl, $ilAccess, $lng;
01020 //echo "here";
01021                 if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID || !empty($_GET["ref_id"]))
01022                 {
01023 //echo "A";
01024                         // if anonymous and a target given...
01025                         if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID && $_GET["target"] != "")
01026                         {
01027                                 // target is accessible -> goto target
01028                                 if      ($this->_checkGoto($_GET["target"]))
01029                                 {
01030 //echo "B";
01031                                         ilUtil::redirect("./goto.php?target=".$_GET["target"]);
01032                                 }
01033                                 else    // target is not accessible -> login
01034                                 {
01035 //echo "C";
01036                                         $this->showLogin();
01037                                 }
01038                         }
01039 
01040                         // just go to public section
01041                         if (empty($_GET["ref_id"]))
01042                         {
01043                                 $_GET["ref_id"] = ROOT_FOLDER_ID;
01044                         }
01045                         $ilCtrl->initBaseClass("");
01046                         $ilCtrl->setCmd("frameset");
01047                         $start_script = "repository.php";
01048                         include($start_script);
01049                         return true;
01050                 }
01051                 else
01052                 {
01053                         if      (!$this->_checkGoto($_GET["target"]))
01054                         {
01055                                 // message if target given but not accessible
01056                                 if ($_GET["target"] != "")
01057                                 {
01058                                         $tarr = explode("_", $_GET["target"]);
01059                                         if ($tarr[0] != "pg" && $tarr[0] != "st" && $tarr[1] > 0)
01060                                         {
01061                                                 ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
01062                                                         ilObject::_lookupTitle(ilObject::_lookupObjId($tarr[1]))), true);
01063                                         }
01064                                 }
01065 
01066                                 // show personal desktop
01067                                 #$ilCtrl->initBaseClass("ilPersonalDesktopGUI");
01068                                 #$start_script = "ilias.php";
01069                                 // Redirect here to switch back to http if desired
01070                                 ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
01071                         }
01072                         else
01073                         {
01074 //echo "3";
01075                                 ilUtil::redirect("./goto.php?target=".$_GET["target"]);
01076                         }
01077                 }
01078 
01079                 include($start_script);
01080         }
01081 
01082         function _checkGoto($a_target)
01083         {
01084                 global $objDefinition;
01085 
01086                 if ($a_target == "")
01087                 {
01088                         return false;
01089                 }
01090 
01091                 $t_arr = explode("_", $_GET["target"]);
01092                 $type = $t_arr[0];
01093 
01094                 if ($type == "git")
01095                 {
01096                         $type = "glo";
01097                 }
01098 
01099                 if ($type == "pg" | $type == "st")
01100                 {
01101                         $type = "lm";
01102                 }
01103 
01104                 $class = $objDefinition->getClassName($type);
01105                 if ($class == "")
01106                 {
01107                         return false;
01108                 }
01109                 $location = $objDefinition->getLocation($type);
01110                 $full_class = "ilObj".$class."Access";
01111                 include_once($location."/class.".$full_class.".php");
01112 
01113                 return call_user_func(array($full_class, "_checkGoto"),
01114                         $a_target);
01115         }
01116 
01117 }
01118 ?>

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