ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilStartUpGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
5 
16 {
17 
21  function ilStartUpGUI()
22  {
23  global $ilCtrl;
24 
25  $this->ctrl =& $ilCtrl;
26 
27  $ilCtrl->saveParameter($this, array("rep_ref_id", "lang", "target", "client_id"));
28  }
29 
33  function &executeCommand()
34  {
35  global $ilLog;
36 
37  $cmd = $this->ctrl->getCmd("processIndexPHP",array('processIndexPHP','showLogin'));
38  $ilLog->write(__METHOD__.' cmd = '.$cmd);
39  $next_class = $this->ctrl->getNextClass($this);
40 
41  switch($next_class)
42  {
43  case 'ilLoginPageGUI':
44  break;
45 
46  case "ilaccountregistrationgui":
47  require_once("Services/Registration/classes/class.ilAccountRegistrationGUI.php");
48  return $this->ctrl->forwardCommand(new ilAccountRegistrationGUI());
49 
50  case "ilpasswordassistancegui":
51  require_once("Services/Init/classes/class.ilPasswordAssistanceGUI.php");
52  return $this->ctrl->forwardCommand(new ilPasswordAssistanceGUI());
53 
54  default:
55  return $this->$cmd();
56  }
57  }
58 
62  function jumpToRegistration()
63  {
64  $this->ctrl->setCmdClass("ilaccountregistrationgui");
65  $this->ctrl->setCmd("");
66  $this->executeCommand();
67  }
68 
73  {
74  $this->ctrl->setCmdClass("ilpasswordassistancegui");
75  $this->ctrl->setCmd("");
76  $this->executeCommand();
77  }
78 
84  function showLogin()
85  {
86  global $ilSetting, $ilAuth, $tpl, $ilias, $lng;
87 
88  $status = $ilAuth->getStatus();
89  if ($status == "" && isset($_GET["auth_stat"]))
90  {
91  $status = $_GET["auth_stat"];
92  }
93 
94  if($ilAuth->getAuth() && !$status)
95  {
96  // deprecated?
97  if ($_GET["rep_ref_id"] != "")
98  {
99  $_GET["ref_id"] = $_GET["rep_ref_id"];
100  }
101  $this->processStartingPage();
102  }
103 
104  // if authentication of soap user failed, but email address is
105  // known, show users and ask for password
106  if ($status == AUTH_SOAP_NO_ILIAS_USER_BUT_EMAIL)
107  {
108  $this->showUserMappingSelection();
109  return;
110  }
111 
112  // check for session cookies enabled
113  if (!isset($_COOKIE['iltest']))
114  {
115  if (empty($_GET['cookies']))
116  {
117  $additional_params = '';
118 
119  if(IS_PAYMENT_ENABLED)
120  {
121  if((int)$_GET['forceShoppingCartRedirect'])# && (int)$_SESSION['price_id'] && (int)$_SESSION['pobject_id'])
122  {
123  $additional_params .= '&login_to_purchase_object=1&forceShoppingCartRedirect=1';
124  }
125  }
126 
127  ilUtil::setCookie("iltest","cookie",false);
128  ilUtil::redirect("login.php?target=".$_GET["target"]."&soap_pw=".$_GET["soap_pw"].
129  "&ext_uid=".$_GET["ext_uid"]."&cookies=nocookies&client_id=".
130  rawurlencode(CLIENT_ID)."&lang=".$lng->getLangKey().$additional_params);
131  }
132  else
133  {
134  $_COOKIE['iltest'] = "";
135  }
136  }
137  else
138  {
139  unset($_GET['cookies']);
140  }
141 
142  if ($ilSetting->get("shib_active") && $ilSetting->get("shib_hos_type"))
143  {
144  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
145  // Check if we user selects Home Organization
146  $WAYF = new ShibWAYF();
147  }
148 
149  if (isset($WAYF) && $WAYF->is_selection())
150  {
151  if ($WAYF->is_valid_selection())
152  {
153  // Set cookie
154  $WAYF->setSAMLCookie();
155 
156  // Redirect
157  $WAYF->redirect();
158  }
159  }
160 
161  $failure = $success = null;
162 
163  if(IS_PAYMENT_ENABLED)
164  {
165  if(isset($_GET['forceShoppingCartRedirect']) && (int)$_GET['forceShoppingCartRedirect'] == 1)
166  {
167  $this->ctrl->setParameter($this, 'forceShoppingCartRedirect', 1);
168  ilSession::set('forceShoppingCartRedirect', 1);
169  }
170 
171  if (isset($_GET['login_to_purchase_object']) && $_GET['login_to_purchase_object'])
172  {
173  $lng->loadLanguageModule('payment');
174  $failure = $lng->txt("payment_login_to_buy_object");
175  ilSession::set('forceShoppingCartRedirect', 1);
176  }
177  }
178 
179  // :TODO: handle internally?
180  if (isset($_GET['reg_confirmation_msg']) && strlen(trim($_GET['reg_confirmation_msg'])))
181  {
182  $lng->loadLanguageModule('registration');
183  if($_GET['reg_confirmation_msg'] == 'reg_account_confirmation_successful')
184  {
185  $success = $lng->txt(trim($_GET['reg_confirmation_msg']));
186  }
187  else
188  {
189  $failure = $lng->txt(trim($_GET['reg_confirmation_msg']));
190  }
191  }
192  else if(isset($_GET['reached_session_limit']) && $_GET['reached_session_limit'])
193  {
194  $failure = $lng->txt("reached_session_limit");
195  }
196  else if(isset($_GET['accdel']) && $_GET['accdel'])
197  {
198  $lng->loadLanguageModule('user');
199  $failure = $lng->txt("user_account_deleted_confirmation");
200  }
201 
202  if (!empty($status))
203  {
204  switch ($status)
205  {
206  case AUTH_IDLED:
207  // lang variable err_idled not existing
208  // $tpl->setVariable(TXT_MSG_LOGIN_FAILED, $lng->txt("err_idled"));
209  // fallthrough
210 
211  case AUTH_EXPIRED:
212  $failure = $lng->txt("err_session_expired");
213  break;
214 
216  $failure = $lng->txt("err_auth_cas_no_ilias_user");
217  break;
218 
220  $failure = $lng->txt("err_auth_soap_no_ilias_user");
221  break;
222 
224  $failure = $lng->txt("err_auth_ldap_no_ilias_user");
225  break;
226 
228  $failure = $lng->txt("err_auth_radius_no_ilias_user");
229  break;
230 
231  case AUTH_MODE_INACTIVE:
232  $failure = $lng->txt("err_auth_mode_inactive");
233  break;
234 
235  case AUTH_APACHE_FAILED:
236  $failure = $lng->txt("err_auth_apache_failed");
237  break;
238 
240  $lng->loadLanguageModule('cptch');
242  $ilAuth->logout();
243  session_destroy();
244  $failure = $lng->txt("cptch_wrong_input");
245  break;
246 
247  // special cases: extended user validation failed
248  // ilAuth was successful, so we have to logout here
249 
250  case AUTH_USER_WRONG_IP:
252  $ilAuth->logout();
253  session_destroy();
254 
255  $failure = $lng->txt("wrong_ip_detected")." (".$_SERVER["REMOTE_ADDR"].")";
256  break;
257 
260  $ilAuth->logout();
261  session_destroy();
262 
263  $failure = $lng->txt("simultaneous_login_detected");
264  break;
265 
268  $username = $ilAuth->getExceededUserName(); // #16327
269  $ilAuth->logout();
270 
271  // user could reactivate by code?
272  if($ilSetting->get('user_reactivate_code'))
273  {
274  return $this->showCodeForm($username);
275  }
276 
277  session_destroy();
278 
279  $failure = $lng->txt("time_limit_reached");
280  break;
281 
282  case AUTH_USER_INACTIVE:
284  $ilAuth->logout();
285  session_destroy();
286 
287  $failure = $lng->txt("err_inactive");
288  break;
289 
290  // special cases end
291 
292 
293  case AUTH_WRONG_LOGIN:
294  default:
295  $add = "";
296  $auth_error = $ilias->getAuthError();
297  if (is_object($auth_error))
298  {
299  $add = "<br>".$auth_error->getMessage();
300  }
301  $failure = $lng->txt("err_wrong_login").$add;
302  break;
303  }
304  }
305 
306  if (isset($_GET['cu']) && $_GET['cu'])
307  {
308  $lng->loadLanguageModule("auth");
309  $success = $lng->txt("auth_account_code_used");
310  }
311 
312 
313  // --- render
314 
315  // Instantiate login template
316  self::initStartUpTemplate("tpl.login.html");
317 
318  // we need the template for this
319  if($failure)
320  {
322  }
323  else if($success)
324  {
326  }
327 
328  $page_editor_html = $this->getLoginPageEditorHTML();
329  $page_editor_html = $this->showLoginInformation($page_editor_html);
330  $page_editor_html = $this->showLoginForm($page_editor_html);
331  $page_editor_html = $this->showCASLoginForm($page_editor_html);
332  $page_editor_html = $this->showShibbolethLoginForm($page_editor_html);
333  $page_editor_html = $this->showOpenIdLoginForm($page_editor_html);
334  $page_editor_html = $this->showLanguageSelection($page_editor_html);
335  $page_editor_html = $this->showRegistrationLinks($page_editor_html);
336  $page_editor_html = $this->showTermsOfServiceLink($page_editor_html);
337 
338  $page_editor_html = $this->purgePlaceholders($page_editor_html);
339 
340 
341 
342  // not controlled by login page editor
343 
344  $tpl->setVariable("PAGETITLE", $lng->txt("startpage"));
345  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
346 
347  $this->ctrl->setTargetScript("ilias.php");
348  $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
349 
350  // browser does not accept cookies
351  if (isset($_GET['cookies']) && $_GET['cookies'] == 'nocookies')
352  {
353  ilUtil::sendFailure($lng->txt("err_no_cookies"));
354  }
355 
356  if(strlen($page_editor_html))
357  {
358  $tpl->setVariable('LPE',$page_editor_html);
359  }
360 
361  $tpl->fillCssFiles();
362  $tpl->fillJavaScriptFiles();
363 
364  $tpl->show("DEFAULT", false);
365  }
366 
367  protected function showCodeForm($a_username = null, $a_form = null)
368  {
369  global $tpl, $lng;
370 
371  self::initStartUpTemplate("tpl.login_reactivate_code.html");
372 
373  ilUtil::sendFailure($lng->txt("time_limit_reached"));
374 
375  if(!$a_form)
376  {
377  $a_form = $this->initCodeForm($a_username);
378  }
379 
380  $tpl->setVariable("FORM", $a_form->getHTML());
381  $tpl->show("DEFAULT", false);
382  }
383 
384  protected function initCodeForm($a_username)
385  {
386  global $lng, $ilCtrl;
387 
388  $lng->loadLanguageModule("auth");
389 
390  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
391 
392  $form = new ilPropertyFormGUI();
393  $form->setFormAction($ilCtrl->getFormAction($this, 'showcodeform'));
394  $form->setTitle($lng->txt('auth_account_code_title'));
395 
396  $count = new ilTextInputGUI($lng->txt('auth_account_code'), 'code');
397  $count->setRequired(true);
398  $count->setInfo($lng->txt('auth_account_code_info'));
399  $form->addItem($count);
400 
401  // #11658
402  $uname = new ilHiddenInputGUI("uname");
403  $uname->setValue($a_username);
404  $form->addItem($uname);
405 
406  $form->addCommandButton('processCode', $lng->txt('send'));
407 
408  return $form;
409  }
410 
411  protected function processCode()
412  {
413  global $lng, $ilAuth, $ilCtrl;
414 
415  $uname = $_POST["uname"];
416 
417  $form = $this->initCodeForm($uname);
418  if($uname && $form->checkInput())
419  {
420  $code = $form->getInput("code");
421 
422  include_once "Services/User/classes/class.ilAccountCode.php";
423  if(ilAccountCode::isUnusedCode($code))
424  {
425  $valid_until = ilAccountCode::getCodeValidUntil($code);
426 
427  if(!$user_id = ilObjUser::_lookupId($uname))
428  {
429  $this->showLogin();
430  return false;
431  }
432 
433  $invalid_code = false;
434  $user = new ilObjUser($user_id);
435 
436  if($valid_until === "0")
437  {
438  $user->setTimeLimitUnlimited(true);
439  }
440  else
441  {
442  if(is_numeric($valid_until))
443  {
444  $valid_until = strtotime("+".$valid_until."days");
445  }
446  else
447  {
448  $valid_until = explode("-", $valid_until);
449  $valid_until = mktime(23, 59, 59, $valid_until[1],
450  $valid_until[2], $valid_until[0]);
451  if($valid_until < time())
452  {
453  $invalid_code = true;
454  }
455  }
456 
457  if(!$invalid_code)
458  {
459  $user->setTimeLimitUnlimited(false);
460  $user->setTimeLimitUntil($valid_until);
461  }
462  }
463 
464  if(!$invalid_code)
465  {
466  $user->setActive(true);
467  $user->update();
468 
469  ilAccountCode::useCode($code);
470 
471  $ilCtrl->setParameter($this, "cu", 1);
472  $ilCtrl->redirect($this, "showLogin");
473  }
474  }
475 
476  $lng->loadLanguageModule("user");
477  $field = $form->getItemByPostVar("code");
478  $field->setAlert($lng->txt("user_account_code_not_valid"));
479  }
480 
481  $form->setValuesByPost();
482  $this->showCodeForm($uname, $form);
483  }
484 
485 
486 
492  protected function showLoginForm($page_editor_html)
493  {
494  global $ilSetting,$lng,$tpl;
495 
496  // @todo move this to auth utils.
497  // login via ILIAS (this also includes radius and ldap)
498  // If local authentication is enabled for shibboleth users, we
499  // display the login form for ILIAS here.
500  if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
501  $ilSetting->get("shib_auth_allow_local")) &&
502  $ilSetting->get("auth_mode") != AUTH_CAS)
503  {
504  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
505  $form = new ilPropertyFormGUI();
506  //$form->setTableWidth('500');
507  $form->setFormAction($this->ctrl->getFormAction($this,''));
508  $form->setName("formlogin");
509  $form->setShowTopButtons(false);
510  $form->setTitle($lng->txt("login_to_ilias"));
511 
512  // auth selection
513  include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
515  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
516  {
517  $visible_auth_methods = array();
518  $radg = new ilRadioGroupInputGUI($lng->txt("auth_selection"), "auth_mode");
519  foreach(ilAuthUtils::_getMultipleAuthModeOptions($lng) as $key => $option)
520  {
521  if(isset($option['hide_in_ui']) && $option['hide_in_ui'])
522  {
523  continue;
524  }
525 
526  $op1 = new ilRadioOption($option['txt'], $key);
527  $radg->addOption($op1);
528  if (isset($option['checked']))
529  {
530  $radg->setValue($key);
531  }
532  $visible_auth_methods[] = $op1;
533  }
534 
535  if(count($visible_auth_methods) == 1)
536  {
537  $first_auth_method = current($visible_auth_methods);
538  $hidden_auth_method = new ilHiddenInputGUI("auth_mode");
539  $hidden_auth_method->setValue($first_auth_method->getValue());
540  $form->addItem($hidden_auth_method);
541  }
542  else
543  {
544  $form->addItem($radg);
545  }
546  }
547 
548  $ti = new ilTextInputGUI($lng->txt("username"), "username");
549  $ti->setSize(20);
550  $ti->setRequired(true);
551  $form->addItem($ti);
552 
553  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
554  $pi->setRetype(false);
555  $pi->setSize(20);
556  $pi->setDisableHtmlAutoComplete(false);
557  $pi->setRequired(true);
558  $form->addItem($pi);
559  $form->addCommandButton("showLogin", $lng->txt("log_in"));
560 
561  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
562  if(ilCaptchaUtil::isActiveForLogin())
563  {
564  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
565  $captcha = new ilCaptchaInputGUI($lng->txt('captcha_code'), 'captcha_code');
566  $captcha->setRequired(true);
567  $form->addItem($captcha);
568  }
569 
570  return $this->substituteLoginPageElements(
571  $tpl,
572  $page_editor_html,
573  $form->getHTML(),
574  '[list-login-form]',
575  'LOGIN_FORM'
576  );
577 
578  }
579  return $page_editor_html;
580  }
581 
587  protected function showLoginInformation($page_editor_html)
588  {
589  global $lng,$tpl;
590 
591  if(strlen($page_editor_html))
592  {
593  // page editor active return
594  return $page_editor_html;
595  }
596 
597  $loginSettings = new ilSetting("login_settings");
598  $information = $loginSettings->get("login_message_".$lng->getLangKey());
599 
600  if(strlen(trim($information)))
601  {
602  $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
603  }
604  return $page_editor_html;
605  }
606 
613  protected function showCASLoginForm($page_editor_html)
614  {
615  global $ilSetting, $lng;
616 
617 
618  // cas login link
619  if ($ilSetting->get("cas_active"))
620  {
621  $tpl = new ilTemplate('tpl.login_form_cas.html', true, true, 'Services/Init');
622  $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
623  $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.png"));
624  $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
625  $this->ctrl->setParameter($this, "forceCASLogin", "1");
626  $tpl->setVariable("TARGET_CAS_LOGIN",$this->ctrl->getLinkTarget($this, "showLogin"));
627  $this->ctrl->setParameter($this, "forceCASLogin", "");
628 
629  return $this->substituteLoginPageElements(
630  $GLOBALS['tpl'],
631  $page_editor_html,
632  $tpl->get(),
633  '[list-cas-login-form]',
634  'CAS_LOGIN_FORM'
635  );
636  }
637  return $page_editor_html;
638  }
639 
645  protected function showShibbolethLoginForm($page_editor_html)
646  {
647  global $ilSetting, $lng;
648 
649  // Refactoring with ilFormPropertyGUI
650  // [...]
651 
652  // shibboleth login link
653  if ($ilSetting->get("shib_active")) {
654  $tpl = new ilTemplate('tpl.login_form_shibboleth.html', true, true, 'Services/Init');
655 
656  $tpl->setVariable('SHIB_FORMACTION', './shib_login.php'); // Bugfix http://ilias.de/mantis/view.php?id=10662 {$tpl->setVariable('SHIB_FORMACTION', $this->ctrl->getFormAction($this));}
657 
658  if ($ilSetting->get("shib_hos_type") == 'external_wayf') {
659  $tpl->setCurrentBlock("shibboleth_login");
660  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
661  $tpl->setVariable("IL_TARGET", $_GET["target"]);
662  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
663  $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
664  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", sprintf($lng->txt("shib_general_login_instructions"), $ilSetting->get("shib_federation_name")) . ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt("administrator") . '</a>.');
665  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
666  $tpl->parseCurrentBlock();
667  } elseif ($ilSetting->get("shib_hos_type") == 'embedded_wayf') {
668  $tpl->setCurrentBlock("shibboleth_custom_login");
669  $customInstructions = stripslashes($ilSetting->get("shib_login_instructions"));
670  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $customInstructions);
671  $tpl->parseCurrentBlock();
672  } else {
673  $tpl->setCurrentBlock("shibboleth_wayf_login");
674  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
675  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
676  $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
677  $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
678  $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
679  $tpl->setVariable("TXT_SHIB_LOGIN_INSTRUCTIONS", $lng->txt("shib_general_wayf_login_instructions") . ' <a href="mailto:' . $ilSetting->get("admin_email") . '">ILIAS ' . $lng->txt("administrator") . '</a>.');
680  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
681 
682  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
683  $WAYF = new ShibWAYF();
684 
685  $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
686  $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
687  $tpl->setVariable("ILW_TARGET", $_GET["target"]);
688  $tpl->parseCurrentBlock();
689  }
690 
691  return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, $tpl->get(), '[list-shibboleth-login-form]', 'SHIB_LOGIN_FORM');
692  }
693 
694  return $page_editor_html;
695  }
696 
697 
707  protected function substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
708  {
709  if(!strlen($page_editor_html))
710  {
711  $tpl->setVariable($fallback_tplvar,$element_html);
712  return $page_editor_html;
713  }
714  // Try to replace placeholders
715  if(!stristr($page_editor_html, $placeholder))
716  {
717  $tpl->setVariable($fallback_tplvar,$element_html);
718  return $page_editor_html;
719  }
720  return str_replace($placeholder, $element_html, $page_editor_html);
721  }
722 
727  protected function getLoginPageEditorHTML()
728  {
729  global $lng, $tpl;
730 
731  include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
733  $active_lang = $lpe->getIliasEditorLanguage($lng->getLangKey());
734 
735  if(!$active_lang)
736  {
737  return '';
738  }
739 
740  // if page does not exist, return nothing
741  include_once './Services/COPage/classes/class.ilPageUtil.php';
742  if(!ilPageUtil::_existsAndNotEmpty('auth', ilLanguage::lookupId($active_lang)))
743  {
744  return '';
745  }
746 
747  include_once './Services/Authentication/classes/class.ilLoginPage.php';
748  include_once './Services/Authentication/classes/class.ilLoginPageGUI.php';
749 
750  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
751  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0));
752  $tpl->setCurrentBlock("SyntaxStyle");
753  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",ilObjStyleSheet::getSyntaxStylePath());
754  $tpl->parseCurrentBlock();
755 
756  // get page object
757  $page_gui = new ilLoginPageGUI(ilLanguage::lookupId($active_lang));
758 
759  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
760  $page_gui->setStyleId(0, 'auth');
761 
762  $page_gui->setPresentationTitle("");
763  $page_gui->setTemplateOutput(false);
764  $page_gui->setHeader("");
765  $ret = $page_gui->showPage();
766 
767  return $ret;
768  }
769 
774  protected function showLanguageSelection($page_editor_html)
775  {
776  global $lng;
777 
778  $languages = $lng->getInstalledLanguages();
779  if(count($languages) <= 1)
780  {
781  return $page_editor_html;
782  }
783 
784  $ltpl = new ilTemplate('tpl.login_form_lang_selection.html',true,true,'Services/Init');
785  foreach ($languages as $lang_key)
786  {
787  $ltpl->setCurrentBlock("languages");
788  $ltpl->setVariable("LANG_KEY", $lang_key);
789  $ltpl->setVariable("LANG_NAME",
790  ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_".$lang_key));
791  $ltpl->setVariable("BORDER", 0);
792  $ltpl->setVariable("VSPACE", 0);
793  $ltpl->parseCurrentBlock();
794  }
795  $ltpl->setCurrentBlock('lang_selection');
796  $ltpl->setVariable("TXT_OK", $lng->txt("ok"));
797  $ltpl->setVariable("LANG_FORM_ACTION",$this->ctrl->getFormAction($this));
798  $ltpl->setVariable("TXT_CHOOSE_LANGUAGE", $lng->txt("choose_language"));
799  $ltpl->setVariable("LANG_ID", $lng->getLangKey());
800  $ltpl->parseCurrentBlock();
801 
802  return $this->substituteLoginPageElements(
803  $GLOBALS['tpl'],
804  $page_editor_html,
805  $ltpl->get(),
806  '[list-language-selection]',
807  'LANG_SELECTION'
808  );
809 
810  }
811 
820  protected function showRegistrationLinks($page_editor_html)
821  {
822  global $lng, $ilSetting, $ilIliasIniFile, $ilAccess;
823 
824  $rtpl = new ilTemplate('tpl.login_registration_links.html',true,true,'Services/Init');
825 
826  // allow new registrations?
827  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
829  {
830  $rtpl->setCurrentBlock("new_registration");
831  $rtpl->setVariable("REGISTER", $lng->txt("registration"));
832  $rtpl->setVariable("CMD_REGISTER",
833  $this->ctrl->getLinkTargetByClass("ilaccountregistrationgui", ""));
834  $rtpl->parseCurrentBlock();
835  }
836  // allow password assistance? Surpress option if Authmode is not local database
837  if ($ilSetting->get("password_assistance"))
838  {
839  $rtpl->setCurrentBlock("password_assistance");
840  $rtpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
841  $rtpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
842  $rtpl->setVariable("CMD_FORGOT_PASSWORD",
843  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
844  $rtpl->setVariable("CMD_FORGOT_USERNAME",
845  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
846  $rtpl->setVariable("LANG_ID", $lng->getLangKey());
847  $rtpl->parseCurrentBlock();
848  }
849 
850  if ($ilSetting->get("pub_section") &&
851  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", ROOT_FOLDER_ID))
852  {
853  $rtpl->setCurrentBlock("homelink");
854  $rtpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$lng->getLangKey());
855  $rtpl->setVariable("TXT_HOME",$lng->txt("home"));
856  $rtpl->parseCurrentBlock();
857  }
858 
859  if ($ilIliasIniFile->readVariable("clients","list"))
860  {
861  $rtpl->setCurrentBlock("client_list");
862  $rtpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
863  $rtpl->setVariable("CMD_CLIENT_LIST",$this->ctrl->getLinkTarget($this, "showClientList"));
864  $rtpl->parseCurrentBlock();
865  }
866 
867  return $this->substituteLoginPageElements(
868  $GLOBALS['tpl'],
869  $page_editor_html,
870  $rtpl->get(),
871  '[list-registration-link]',
872  'REG_PWD_CLIENT_LINKS'
873  );
874  }
875 
881  protected function showTermsOfServiceLink($page_editor_html)
882  {
886  global $lng;
887 
888 
889  try
890  {
891  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
892  if(ilTermsOfServiceHelper::isEnabled() && ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng))
893  {
894  $utpl = new ilTemplate('tpl.login_terms_of_service_link.html', true, true, 'Services/Init');
895  $utpl->setVariable('TXT_TERMS_OF_SERVICE', $lng->txt('usr_agreement'));
896  $utpl->setVariable('LINK_TERMS_OF_SERVICE', $this->ctrl->getLinkTarget($this, 'showTermsOfService'));
897 
898  return $this->substituteLoginPageElements(
899  $GLOBALS['tpl'],
900  $page_editor_html,
901  $utpl->get(),
902  '[list-user-agreement]',
903  'USER_AGREEMENT'
904  );
905  }
906  }
908  {
909  }
910 
911  return $this->substituteLoginPageElements(
912  $GLOBALS['tpl'],
913  $page_editor_html,
914  '',
915  '[list-user-agreement]',
916  'USER_AGREEMENT'
917  );
918  }
919 
925  protected function purgePlaceholders($page_editor_html)
926  {
927  return str_replace(
928  array(
929  '[list-language-selection] ',
930  '[list-registration-link]',
931  '[list-user-agreement]',
932  '[list-login-form]',
933  '[list-cas-login-form]',
934  '[list-shibboleth-login-form]',
935  '[list-openid-login-form]'
936  ),
937  array('','','','','','',''),
938  $page_editor_html
939  );
940  }
941 
946  public function showAccountMigration($a_message = '')
947  {
952  global $tpl, $lng;
953 
954  $lng->loadLanguageModule('auth');
955  self::initStartUpTemplate('tpl.login_account_migration.html');
956 
957  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
958  $form = new ilPropertyFormGUI();
959  $form->setFormAction($this->ctrl->getFormAction($this,'migrateAccount'));
960 
961  $form->setTitle($lng->txt('auth_account_migration'));
962  $form->addCommandButton('migrateAccount', $lng->txt('save'));
963  $form->addCommandButton('showLogin', $lng->txt('cancel'));
964 
965  $rad = new ilRadioGroupInputGUI($lng->txt('auth_account_migration_name'),'account_migration');
966  $rad->setValue(1);
967 
968  $keep = new ilRadioOption($lng->txt('auth_account_migration_keep'),1,$lng->txt('auth_info_migrate'));
969  $user = new ilTextInputGUI($lng->txt('login'),'mig_username');
970  $user->setRequired(true);
971  $user->setValue(ilUtil::prepareFormOutput($_POST['mig_username']));
972  $user->setSize(32);
973  $user->setMaxLength(128);
974  $keep->addSubItem($user);
975 
976  $pass = new ilPasswordInputGUI($lng->txt('password'),'mig_password');
977  $pass->setRetype(false);
978  $pass->setRequired(true);
979  $pass->setValue(ilUtil::prepareFormOutput($_POST['mig_password']));
980  $pass->setSize(12);
981  $pass->setMaxLength(128);
982  $keep->addSubItem($pass);
983  $rad->addOption($keep);
984 
985  $new = new ilRadioOption($lng->txt('auth_account_migration_new'),2,$lng->txt('auth_info_add'));
986  $rad->addOption($new);
987 
988  $form->addItem($rad);
989 
990  $tpl->setVariable('MIG_FORM',$form->getHTML());
991 
992  if(strlen($a_message))
993  {
994  ilUtil::sendFailure($a_message);
995  }
996 
997  $tpl->show('DEFAULT');
998  }
999 
1006  public function migrateAccount()
1007  {
1008  global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
1009 
1010  $lng->loadLanguageModule('auth');
1011 
1012  if(!isset($_POST['account_migration']))
1013  {
1014  $this->showAccountMigration($lng->txt('err_choose_migration_type'));
1015  return false;
1016  }
1017 
1018  if($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
1019  {
1020  $this->showAccountMigration($lng->txt('err_wrong_login'));
1021  return false;
1022  }
1023 
1024  if($_POST['account_migration'] == 1)
1025  {
1026  if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
1027  {
1028  $this->showAccountMigration($lng->txt('err_wrong_login'));
1029  return false;
1030  }
1031  $_POST['username'] = $_POST['mig_username'];
1032  $_POST['password'] = $_POST['mig_password'];
1033 
1034  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1035  include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
1036 
1038  $ilAuth->start();
1039  if(!$ilAuth->checkAuth())
1040  {
1041  $ilAuth->logout();
1042  $this->showAccountMigration($lng->txt('err_wrong_login'));
1043  return false;
1044  }
1045 
1046  $user = new ilObjUser($user_id);
1047  $user->setAuthMode(ilSession::get('tmp_auth_mode'));
1048  $user->setExternalAccount(ilSession::get('tmp_external_account'));
1049  $user->setActive(true);
1050  $user->update();
1051 
1052  // Assign to default role
1053  if(is_array(ilSession::get('tmp_roles')))
1054  {
1055  foreach(ilSession::get('tmp_roles') as $role)
1056  {
1057  $rbacadmin->assignUser((int) $role,$user->getId());
1058  }
1059  }
1060 
1061  // Log migration
1062  $ilLog->write(__METHOD__.': Migrated '.ilSession::get('tmp_external_account').' to ILIAS account '.$user->getLogin().'.');
1063  }
1064  elseif($_POST['account_migration'] == 2)
1065  {
1066  switch(ilSession::get('tmp_auth_mode'))
1067  {
1068  case 'apache':
1069  $_POST['username'] = ilSession::get('tmp_external_account');
1070  $_POST['password'] = ilSession::get('tmp_pass');
1071 
1072  include_once('Services/AuthApache/classes/class.ilAuthContainerApache.php');
1073  $container = new ilAuthContainerApache();
1074  $container->forceCreation(true);
1075  $ilAuth = ilAuthFactory::factory($container);
1076  $ilAuth->start();
1077  break;
1078 
1079  case 'ldap':
1080  $_POST['username'] = ilSession::get('tmp_external_account');
1081  $_POST['password'] = ilSession::get('tmp_pass');
1082 
1083  include_once('Services/LDAP/classes/class.ilAuthContainerLDAP.php');
1084  $container = new ilAuthContainerLDAP();
1085  $container->forceCreation(true);
1086  $ilAuth = ilAuthFactory::factory($container);
1087  $ilAuth->start();
1088  break;
1089 
1090  case 'radius':
1091  $_POST['username'] = ilSession::get('tmp_external_account');
1092  $_POST['password'] = ilSession::get('tmp_pass');
1093 
1094  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1095  include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
1096 
1097  $container = new ilAuthContainerRadius();
1098  $container->forceCreation(true);
1099  $ilAuth = ilAuthFactory::factory($container);
1100  $ilAuth->start();
1101  break;
1102 
1103  case 'openid':
1104  $_POST['username'] = ilSession::get('dummy');
1105  $_POST['password'] = ilSession::get('dummy');
1106  $_POST['oid_username'] = ilSession::get('tmp_oid_username');
1107  $_POST['oid_provider'] = ilSession::get('tmp_oid_provider');
1108  //ilSession::set('force_creation', true);
1109 
1110  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1111  include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
1112 
1113  $container = new ilAuthContainerOpenId();
1114  $container->forceCreation(true);
1116  include_once './Services/OpenId/classes/class.ilAuthOpenId.php';
1117  $ilAuth = ilAuthFactory::factory($container);
1118 
1119  // logout first to initiate a new login session
1120  $ilAuth->logout();
1121  ilSession::_destroy(session_id());
1122  ilSession::set('force_creation', true);
1123  $ilAuth->start();
1124  }
1125  // Redirect to acceptance
1126  ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=".$_GET["target"]."&cmd=getAcceptance");
1127  }
1128  // show personal desktop
1129  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
1130  }
1131 
1135  function showLogout()
1136  {
1137  global $tpl, $ilSetting, $ilAuth, $lng, $ilIliasIniFile;
1138 
1140  $ilAuth->logout();
1141  session_destroy();
1142 
1143  // reset cookie
1144  $client_id = $_COOKIE["ilClientId"];
1145  ilUtil::setCookie("ilClientId","");
1146 
1147  //instantiate logout template
1148  self::initStartUpTemplate("tpl.logout.html");
1149 
1150  if ($ilSetting->get("pub_section"))
1151  {
1152  $tpl->setCurrentBlock("homelink");
1153  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1154  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
1155  $tpl->parseCurrentBlock();
1156  }
1157 
1158  if ($ilIliasIniFile->readVariable("clients","list"))
1159  {
1160  $tpl->setCurrentBlock("client_list");
1161  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1162  $this->ctrl->setParameter($this, "client_id", $client_id);
1163  $tpl->setVariable("CMD_CLIENT_LIST",
1164  $this->ctrl->getLinkTarget($this, "showClientList"));
1165  $tpl->parseCurrentBlock();
1166  $this->ctrl->setParameter($this, "client_id", "");
1167  }
1168 
1169  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
1170  $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
1171  $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
1172  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1173 
1174  $tpl->show();
1175  }
1176 
1182  {
1183  global $ilAuth, $tpl, $lng;
1184 
1185  $valid = $ilAuth->getValidationData();
1186 
1187  self::initStartUpTemplate("tpl.user_mapping_selection.html");
1188  $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
1189 
1190 
1191  if ($ilAuth->sub_status == AUTH_WRONG_LOGIN)
1192  {
1193  ilUtil::sendFailure($lng->txt("err_wrong_login"));
1194  }
1195 
1196  include_once('./Services/User/classes/class.ilObjUser.php');
1197  if (count($email_user) == 1)
1198  {
1199  //$user = new ilObjUser(key($email_user));
1200  $tpl->setCurrentBlock("one_user");
1201  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
1202  $tpl->setVariable("VAL_USERNAME", current($email_user));
1203  $tpl->setVariable("USER_ID", key($email_user));
1204  $tpl->parseCurrentBlock();
1205  }
1206  else
1207  {
1208  foreach($email_user as $key => $login)
1209  {
1210  $tpl->setCurrentBlock("user");
1211  $tpl->setVariable("USR_ID", $key);
1212  $tpl->setVariable("VAL_USER", $login);
1213  $tpl->parseCurrentBlock();
1214  }
1215  $tpl->setCurrentBlock("multpiple_user");
1216  $tpl->parseCurrentBlock();
1217  }
1218 
1219  $tpl->setCurrentBlock("content");
1220  $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
1221  $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
1222  $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
1223  $tpl->setVariable("FORMACTION",
1224  $this->ctrl->getFormAction($this));
1225  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
1226  if (count($email_user) == 1)
1227  {
1228  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
1229  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
1230  }
1231  else
1232  {
1233  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
1234  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
1235  }
1236  $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
1237  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
1238  $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
1239  $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
1240 
1241  $tpl->show();
1242  }
1243 
1247  function showClientList()
1248  {
1249  global $tpl, $ilIliasIniFile, $ilCtrl;
1250 //echo "1";
1251  if (!$ilIliasIniFile->readVariable("clients","list"))
1252  {
1253  $this->processIndexPHP();
1254  return;
1255  }
1256 //echo "2";
1257  $tpl = new ilTemplate("tpl.main.html", true, true);
1258  $tpl->setAddFooter(false); // no client yet
1259 
1260  // to do: get standard style
1261  $tpl->setVariable("PAGETITLE","Client List");
1262  $tpl->setVariable("LOCATION_STYLESHEET","./templates/default/delos.css");
1263 
1264  // load client list template
1265  self::initStartUpTemplate("tpl.client_list.html");
1266 
1267  // load template for table
1268  $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1269 
1270  // load template for table content data
1271  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1272 
1273  // load table content data
1274  require_once("setup/classes/class.ilClientList.php");
1275  require_once("setup/classes/class.ilClient.php");
1276  require_once("setup/classes/class.ilDBConnections.php");
1277  require_once("./Services/Table/classes/class.ilTableGUI.php");
1278  $this->db_connections = new ilDBConnections();
1279  $clientlist = new ilClientList($this->db_connections);
1280  $list = $clientlist->getClients();
1281 
1282  if (count($list) == 0)
1283  {
1284  header("Location: ./setup/setup.php");
1285  exit();
1286  }
1287 
1288  $hasPublicSection = false;
1289  foreach ($list as $key => $client)
1290  {
1291  $client->setDSN();
1292 
1293  if ($client->checkDatabaseExists(true) and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
1294  {
1295  $this->ctrl->setParameter($this, "client_id", $key);
1296  $tmp = array();
1297  $tmp[] = $client->getName();
1298  $tmp[] = "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">Login page</a>";
1299 
1300  if($client->getSetting('pub_section'))
1301  {
1302  $hasPublicSection = true;
1303  $tmp[] = "<a href=\"" . "ilias.php?baseClass=ilRepositoryGUI&client_id=" . urlencode($key) . "\">Start page</a>";
1304  }
1305  else
1306  {
1307  $tmp[] = '';
1308  }
1309 
1310  $data[] = $tmp;
1311  }
1312  }
1313 
1314  // create table
1315  $tbl = new ilTableGUI();
1316 
1317  // title & header columns
1318  if($hasPublicSection)
1319  {
1320  $tbl->setTitle("Available Clients");
1321  $tbl->setHeaderNames(array("Installation Name","Login","Public Access"));
1322  $tbl->setHeaderVars(array("name","index","login"));
1323  $tbl->setColumnWidth(array("50%","25%","25%"));
1324  }
1325  else
1326  {
1327  $tbl->setTitle("Available Clients");
1328  $tbl->setHeaderNames(array("Installation Name","Login",''));
1329  $tbl->setHeaderVars(array("name","login",''));
1330  $tbl->setColumnWidth(array("70%","25%",'1px'));
1331  }
1332 
1333  // control
1334  $tbl->setOrderColumn($_GET["sort_by"],"name");
1335  $tbl->setOrderDirection($_GET["sort_order"]);
1336  $tbl->setLimit($_GET["limit"]);
1337  $tbl->setOffset($_GET["offset"]);
1338 
1339  // content
1340  $tbl->setData($data);
1341 
1342  // footer
1343  $tbl->setFooter("tblfooter");
1344 
1345  // styles
1346  $tbl->setStyle("table","std");
1347 
1348  $tbl->disable("icon");
1349  $tbl->disable("numinfo");
1350  $tbl->disable("sort");
1351 
1352  // render table
1353  $tbl->render();
1354  $tpl->show("DEFAULT", true, true);
1355  }
1356 
1363  {
1364  global $tpl;
1365 
1366  $str = "<p style=\"margin:15px;\">
1367  You need to enable Session Cookies in your Browser to use ILIAS.
1368  <br/>
1369  <br/><b>Firefox</b>
1370  <br/>Tools -> Options -> Privacy -> Cookies
1371  <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
1372  <br/>cookies' auf 'until I close Firefox'
1373  <br/>
1374  <br/><b>Mozilla/Netscape</b>
1375  <br/>Edit -> Preferences -> Privacy&Security -> Cookies
1376  <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
1377  <br/>session only'.
1378  <br/>
1379  <br/><b>Internet Explorer</b>
1380  <br/>Tools -> Internet Options -> Privacy -> Advanced
1381  <br/>- Check 'Override automatic cookie handling'
1382  <br/>- Check 'Always allow session cookies'
1383  </p>";
1384  $tpl->setVariable("CONTENT", $str);
1385  $tpl->show();
1386  }
1387 
1391  protected function getAcceptance()
1392  {
1393  $this->showTermsOfService();
1394  }
1395 
1399  protected function showTermsOfService()
1400  {
1407  global $lng, $tpl, $ilUser, $ilSetting;
1408 
1409  $back_to_login = ('getAcceptance' != $this->ctrl->getCmd());
1410 
1411  self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
1412  $tpl->setVariable('TXT_PAGEHEADLINE', $lng->txt('usr_agreement'));
1413 
1414  // #9728
1415  $lang_opts = array();
1416  foreach($lng->getInstalledLanguages() as $lang_key)
1417  {
1418  $lang_opts[$lang_key] = ilLanguage::_lookupEntry($lang_key, "meta", "meta_l_" . $lang_key);
1419  }
1420 
1421  if(sizeof($lang_opts) > 1) // #11237
1422  {
1423  asort($lang_opts);
1424  foreach($lang_opts as $lang_key => $lang_caption)
1425  {
1426  $tpl->setCurrentBlock('lang_headline_languages');
1427  $tpl->setVariable('LANG_HEADLINE_LANGUAGES_LANG_NAME', $lang_caption);
1428  $tpl->setVariable('LANG_HEADLINE_LANGUAGES_LANG_KEY', $lang_key);
1429  if($lang_key == $lng->getLangKey())
1430  {
1431  $tpl->setVariable('LANG_HEADLINE_LANGUAGES_SELECTED_LANG', ' selected="selected"');
1432  }
1433  $tpl->parseCurrentBlock();
1434  }
1435 
1436  $tpl->setCurrentBlock('lang_headline');
1437  $tpl->setVariable('LANG_CHANGE_CMD', $this->ctrl->getCmd());
1438  $tpl->setVariable('LANG_CHANGE_FORMACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
1439  $tpl->setVariable('LANG_CHANGE_TXT_OK', $lng->txt('ok'));
1440  $tpl->setVariable('LANG_CHANGE_TXT_CHOOSE_LANGUAGE', $lng->txt('choose_language'));
1441  $tpl->setCurrentBlock('lang_headline');
1442  }
1443 
1444  try
1445  {
1446  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
1448 
1449  if('getAcceptance' == $this->ctrl->getCmd())
1450  {
1451  if(isset($_POST['status']) && 'accepted' == $_POST['status'])
1452  {
1453  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
1454  ilTermsOfServiceHelper::trackAcceptance($ilUser, $document);
1455 
1456  if(ilSession::get('orig_request_target'))
1457  {
1458  $target = ilSession::get('orig_request_target');
1459  ilSession::set('orig_request_target', '');
1460  ilUtil::redirect($target);
1461  }
1462  else
1463  {
1464  ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
1465  }
1466  }
1467 
1468  $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
1469  $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
1470  $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $lng->txt('accept_usr_agreement'));
1471  $tpl->setVariable('TXT_SUBMIT', $lng->txt('submit'));
1472  }
1473 
1474  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->getContent());
1475  }
1477  {
1478  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', sprintf($lng->txt('no_agreement_description'), 'mailto:' . $ilSetting->get('feedback_recipient')));
1479  }
1480 
1481  $tpl->show();
1482  }
1483 
1487  function processIndexPHP()
1488  {
1489  global $ilIliasIniFile, $ilAuth, $ilSetting;
1490 
1491  // display client selection list if enabled
1492  if (!isset($_GET["client_id"]) &&
1493  $_GET["cmd"] == "" &&
1494  $ilIliasIniFile->readVariable("clients","list"))
1495  {
1496  return $this->showClientList();
1497  }
1498 
1499  if($ilAuth->getAuth() && $ilAuth->getStatus() == "")
1500  {
1501  $this->processStartingPage();
1502  }
1503 
1504  //
1505  // index.php is called and public section is enabled
1506  //
1507  // && $ilAuth->status == -101 is important for soap auth (public section on + user mapping, alex)
1508  // $ilAuth->status -1 is given, if session ends (if public section -> jump to public section)
1509 
1510  if ($ilSetting->get("pub_section") && $_POST["sendLogin"] != "1"
1511  && ($ilAuth->getStatus() != -101 && $_GET["soap_pw"] == ""))
1512  {
1514  }
1515  else
1516  {
1517  // index.php is called and public section is disabled
1518  $this->showLogin();
1519  }
1520  }
1521 
1527  function processStartingPage()
1528  {
1532  global $ilUser;
1533 
1534  // fallback, should never happen
1535  if ($ilUser->getId() == ANONYMOUS_USER_ID)
1536  {
1538  }
1539  else
1540  {
1541  // for password change and incomplete profile
1542  // see ilPersonalDesktopGUI
1543 
1544  if(IS_PAYMENT_ENABLED)
1545  {
1546  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
1548 
1549  if((int)$_GET['forceShoppingCartRedirect'])
1550  {
1551  ilUtil::redirect('ilias.php?baseClass=ilShopController&cmd=redirect&redirect_class=ilshopshoppingcartgui');
1552  }
1553  }
1554 
1555  if(!$_GET["target"])
1556  {
1557  // Redirect here to switch back to http if desired
1558  include_once './Services/User/classes/class.ilUserUtil.php';
1560  }
1561  else
1562  {
1563  // will handle shop redirects, too
1564  ilUtil::redirect("goto.php?target=".$_GET["target"]);
1565  }
1566  }
1567  }
1568 
1569  function _checkGoto($a_target)
1570  {
1571  global $objDefinition, $ilPluginAdmin, $ilUser;
1572 
1573  if (is_object($ilPluginAdmin))
1574  {
1575  // get user interface plugins
1576  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1577 
1578  // search
1579  foreach ($pl_names as $pl)
1580  {
1581  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1582  $gui_class = $ui_plugin->getUIClassInstance();
1583  $resp = $gui_class->checkGotoHook($a_target);
1584  if ($resp["target"] !== false)
1585  {
1586  $a_target = $resp["target"];
1587  break;
1588  }
1589  }
1590  }
1591 
1592  if ($a_target == "")
1593  {
1594  return false;
1595  }
1596 
1597  $t_arr = explode("_", $a_target);
1598  $type = $t_arr[0];
1599 
1600  if ($type == "git")
1601  {
1602  $type = "glo";
1603  }
1604 
1605  if ($type == "pg" | $type == "st")
1606  {
1607  $type = "lm";
1608  }
1609 
1610  $class = $objDefinition->getClassName($type);
1611  if ($class == "")
1612  {
1613  return false;
1614  }
1615 
1616  $location = $objDefinition->getLocation($type);
1617  $full_class = "ilObj".$class."Access";
1618  include_once($location."/class.".$full_class.".php");
1619 
1620  $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
1621 
1622  // if no access and repository object => check for parent course/group
1623  if(!$ret &&
1624  !stristr($a_target, "_wsp") &&
1625  $ilUser->getId() != ANONYMOUS_USER_ID && // #10637
1626  !$objDefinition->isAdministrationObject($type) &&
1627  $objDefinition->isRBACObject($type) &&
1628  $t_arr[1])
1629  {
1630  global $tree, $rbacsystem, $ilAccess;
1631 
1632  // original type "pg" => pg_<page_id>[_<ref_id>]
1633  if($t_arr[0] == "pg")
1634  {
1635  if(isset($t_arr[2]))
1636  {
1637  $ref_id = $t_arr[2];
1638  }
1639  else
1640  {
1641  $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
1643  if($ref_id)
1644  {
1645  $ref_id = array_shift($ref_id);
1646  }
1647  }
1648  }
1649  else
1650  {
1651  $ref_id = $t_arr[1];
1652  }
1653 
1654  include_once "Services/Membership/classes/class.ilParticipants.php";
1655  $block_obj = array();
1656 
1657  // walk path to find parent container
1658  $path = $tree->getPathId($ref_id);
1659  array_pop($path);
1660  foreach($path as $path_ref_id)
1661  {
1662  $redirect_infopage = false;
1663  $add_member_role = false;
1664 
1665  $ptype = ilObject::_lookupType($path_ref_id, true);
1666  $pobj_id = ilObject::_lookupObjId($path_ref_id);
1667 
1668  // core checks: timings/object-specific
1669  if(!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) ||
1670  !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype))
1671  {
1672  // object in path is inaccessible - aborting
1673  return false;
1674  }
1675  else if($ptype == "crs")
1676  {
1677  // check if already participant
1678  include_once "Modules/Course/classes/class.ilCourseParticipant.php";
1679  $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
1680  if(!$participants->isAssigned())
1681  {
1682  // subscription currently possible?
1683  include_once "Modules/Course/classes/class.ilObjCourse.php";
1684  if(ilObjCourse::_isActivated($pobj_id) &&
1686  {
1687  $block_obj[] = $path_ref_id;
1688  $add_member_role = true;
1689  }
1690  else
1691  {
1692  $redirect_infopage = true;
1693  }
1694  }
1695  }
1696  else if($ptype == "grp")
1697  {
1698  // check if already participant
1699  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
1700  if(!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId()))
1701  {
1702  // subscription currently possible?
1703  include_once "Modules/Group/classes/class.ilObjGroup.php";
1704  $group_obj = new ilObjGroup($path_ref_id);
1705  if($group_obj->isRegistrationEnabled())
1706  {
1707  $block_obj[] = $path_ref_id;
1708  $add_member_role = true;
1709  }
1710  else
1711  {
1712  $redirect_infopage = true;
1713  }
1714  }
1715  }
1716 
1717  // add members roles for all "blocking" objects
1718  if($add_member_role)
1719  {
1720  // cannot join? goto will never work, so redirect to current object
1721  $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
1722  if(!$rbacsystem->checkAccess("join", $path_ref_id))
1723  {
1724  $redirect_infopage = true;
1725  }
1726  else
1727  {
1728  $rbacsystem->addTemporaryRole($ilUser->getId(),
1729  ilParticipants::getDefaultMemberRole($path_ref_id));
1730  }
1731  }
1732 
1733  // redirect to infopage of 1st blocking object in path
1734  if($redirect_infopage)
1735  {
1736  if($rbacsystem->checkAccess("visible", $path_ref_id))
1737  {
1738  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
1739  "&ref_id=".$path_ref_id."&cmd=infoScreen");
1740  }
1741  else
1742  {
1743  return false;
1744  }
1745  }
1746  }
1747 
1748  // check if access will be possible with all (possible) member roles added
1749  $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
1750  if($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) // #12128
1751  {
1752  // this won't work with lm-pages (see above)
1753  // include_once "Services/Link/classes/class.ilLink.php";
1754  // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
1755 
1756  // keep original target
1757  $_SESSION["pending_goto"] = "goto.php?target=".$a_target;
1758 
1759  // redirect to 1st non-member object in path
1760  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
1761  "&ref_id=".array_shift($block_obj));
1762  }
1763  }
1764 
1765  return $ret;
1766  }
1767 
1768  public function confirmRegistration()
1769  {
1770  global $lng, $ilias, $ilLog;
1771 
1772  ilUtil::setCookie('iltest', 'cookie', false);
1773 
1774  if(!isset($_GET['rh']) || !strlen(trim($_GET['rh'])))
1775  {
1776  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
1777  }
1778 
1779  try
1780  {
1781  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
1782  $oRegSettings = new ilRegistrationSettings();
1783 
1786  $oUser->setActive(true);
1787  if($oRegSettings->passwordGenerationEnabled())
1788  {
1789  $passwd = ilUtil::generatePasswords(1);
1790  $password = $passwd[0];
1791  $oUser->setPasswd($password, IL_PASSWD_PLAIN);
1792  $oUser->setLastPasswordChangeTS( time() );
1793  }
1794  $oUser->update();
1795 
1796  $usr_lang = $oUser->getPref('language');
1797 
1798  if($lng->getLangKey() != $usr_lang)
1799  {
1800  $lng = new ilLanguage($usr_lang);
1801  }
1802 
1803  // send email
1804  // try individual account mail in user administration
1805  include_once("Services/Mail/classes/class.ilAccountMail.php");
1806  include_once './Services/User/classes/class.ilObjUserFolder.php';
1807  $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
1808  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
1809  {
1810  $acc_mail = new ilAccountMail();
1811  $acc_mail->setUser($oUser);
1812  if($oRegSettings->passwordGenerationEnabled())
1813  {
1814  $acc_mail->setUserPassword($password);
1815  }
1816  $acc_mail->send();
1817  }
1818  else // do default mail
1819  {
1820  include_once 'Services/Mail/classes/class.ilMail.php';
1821  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
1822 
1823  // mail subject
1824  $subject = $lng->txt("reg_mail_subject");
1825 
1826  // mail body
1827  $body = $lng->txt("reg_mail_body_salutation")." ".$oUser->getFullname().",\n\n".
1828  $lng->txt("reg_mail_body_text1")."\n\n".
1829  $lng->txt("reg_mail_body_text2")."\n".
1830  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
1831  $body .= $lng->txt("login").": ".$oUser->getLogin()."\n";
1832 
1833  if($oRegSettings->passwordGenerationEnabled())
1834  {
1835  $body.= $lng->txt("passwd").": ".$password."\n";
1836  }
1837 
1838  $body.= "\n";
1839  $body.= $lng->txt('reg_mail_body_forgot_password_info')."\n";
1840 
1841  $body.= "\n";
1842 
1843  $body .= ($lng->txt("reg_mail_body_text3")."\n\r");
1844  $body .= $oUser->getProfileAsString($lng);
1845  $mail_obj->enableSoap(false);
1846  $mail_obj->appendInstallationSignature(true);
1847  $mail_obj->sendMail($oUser->getEmail(), '', '',
1848  $subject,
1849  $body,
1850  array(), array('normal'));
1851  }
1852 
1853  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang='.$usr_lang);
1854  }
1855  catch(ilRegConfirmationLinkExpiredException $exception)
1856  {
1857  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1858  $soap_client = new ilSoapClient();
1859  $soap_client->setResponseTimeout(1);
1860  $soap_client->enableWSDL(true);
1861  $soap_client->init();
1862 
1863  $ilLog->write(__METHOD__.': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
1864 
1865  $soap_client->call
1866  (
1867  'deleteExpiredDualOptInUserObjects',
1868  array
1869  (
1870  $_COOKIE['PHPSESSID'].'::'.$_COOKIE['ilClientId'], // session id and client id, not used for checking access -> not possible for anonymous
1871  $exception->getCode() // user id
1872  )
1873  );
1874 
1875  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
1876  }
1877  catch(ilRegistrationHashNotFoundException $exception)
1878  {
1879  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
1880  }
1881  }
1882 
1887  protected function showOpenIdLoginForm($page_editor_html)
1888  {
1889  global $lng,$tpl;
1890 
1891  include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
1892  if(!ilOpenIdSettings::getInstance()->isActive())
1893  {
1894  return $page_editor_html;
1895  }
1896 
1897  $lng->loadLanguageModule('auth');
1898 
1899  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1900  $form = new ilPropertyFormGUI();
1901  //$form->setTableWidth('500');
1902  $form->setShowTopButtons(false);
1903  $form->setFormAction($this->ctrl->getFormAction($this));
1904  $form->setTitle($lng->txt('login_to_ilias_via_openid'));
1905 
1906  $openid = new ilTextInputGUI($lng->txt('auth_openid_login'),'oid_username');
1907  $openid->setSize(18);
1908  $openid->setMaxLength(255);
1909  $openid->setRequired(true);
1910  $openid->setCssClass('ilOpenIDBox');
1911  $openid->setInfo($lng->txt('auth_openid_login_info_a'));
1912  $form->addItem($openid);
1913 
1914  include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
1915  $pro = new ilSelectInputGUI($lng->txt('auth_openid_provider'),'oid_provider');
1916  $pro->setOptions(ilOpenIdProviders::getInstance()->getProviderSelection());
1917  $pro->setValue(ilOpenIdProviders::getInstance()->getSelectedProvider());
1918  $form->addItem($pro);
1919  $form->addCommandButton("showLogin", $lng->txt("log_in"));
1920 
1921  return $this->substituteLoginPageElements(
1922  $tpl,
1923  $page_editor_html,
1924  $form->getHTML(),
1925  '[list-openid-login-form]',
1926  'OID_LOGIN_FORM'
1927  );
1928  }
1929 
1936  public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_show_logout = false)
1937  {
1945  global $tpl, $lng, $ilCtrl, $ilSetting, $ilAccess;
1946 
1947  // #13574 - basic.js is included with ilTemplate, so jQuery is needed, too
1948  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1950 
1951  $tpl->addBlockfile('CONTENT', 'content', 'tpl.startup_screen.html', 'Services/Init');
1952  $tpl->setVariable('HEADER_ICON', ilUtil::getImagePath('HeaderIcon.png'));
1953 
1954  if($a_show_back)
1955  {
1956  // #13400
1957  $param = 'client_id=' . $_COOKIE['ilClientId'] . '&lang=' . $lng->getLangKey();
1958 
1959  $tpl->setCurrentBlock('link_item_bl');
1960  $tpl->setVariable('LINK_TXT', $lng->txt('login_to_ilias'));
1961  $tpl->setVariable('LINK_URL', 'login.php?cmd=force_login&'.$param);
1962  $tpl->parseCurrentBlock();
1963 
1964  if($ilSetting->get('pub_section') &&
1965  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, 'read', '', ROOT_FOLDER_ID))
1966  {
1967  $tpl->setVariable('LINK_URL', 'index.php?'.$param);
1968  $tpl->setVariable('LINK_TXT', $lng->txt('home'));
1969  $tpl->parseCurrentBlock();
1970  }
1971  }
1972  else if($a_show_logout)
1973  {
1974  $tpl->setCurrentBlock('link_item_bl');
1975  $tpl->setVariable('LINK_TXT', $lng->txt('logout'));
1976  $tpl->setVariable('LINK_URL', ILIAS_HTTP_PATH . '/logout.php');
1977  $tpl->parseCurrentBlock();
1978  }
1979 
1980  if(is_array($a_tmpl))
1981  {
1982  $template_file = $a_tmpl[0];
1983  $template_dir = $a_tmpl[1];
1984  }
1985  else
1986  {
1987  $template_file = $a_tmpl;
1988  $template_dir = 'Services/Init';
1989  }
1990  $tpl->addBlockFile('STARTUP_CONTENT', 'startup_content', $template_file, $template_dir);
1991  }
1992 }