ILIAS  Release_5_0_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->showRegistrationLinks($page_editor_html);
335  $page_editor_html = $this->showTermsOfServiceLink($page_editor_html);
336 
337  $page_editor_html = $this->purgePlaceholders($page_editor_html);
338 
339 
340 
341  // not controlled by login page editor
342 
343  $tpl->setVariable("PAGETITLE", $lng->txt("startpage"));
344  $tpl->setVariable("ILIAS_RELEASE", $ilSetting->get("ilias_version"));
345 
346  $this->ctrl->setTargetScript("ilias.php");
347  $tpl->setVariable("PHP_SELF", $_SERVER['PHP_SELF']);
348 
349  // browser does not accept cookies
350  if (isset($_GET['cookies']) && $_GET['cookies'] == 'nocookies')
351  {
352  ilUtil::sendFailure($lng->txt("err_no_cookies"));
353  }
354 
355  if(strlen($page_editor_html))
356  {
357  $tpl->setVariable('LPE',$page_editor_html);
358  }
359 
360  $tpl->fillCssFiles();
361  $tpl->fillJavaScriptFiles();
362 
363  $tpl->show("DEFAULT", false);
364  }
365 
366  protected function showCodeForm($a_username = null, $a_form = null)
367  {
368  global $tpl, $lng;
369 
370  self::initStartUpTemplate("tpl.login_reactivate_code.html");
371 
372  ilUtil::sendFailure($lng->txt("time_limit_reached"));
373 
374  if(!$a_form)
375  {
376  $a_form = $this->initCodeForm($a_username);
377  }
378 
379  $tpl->setVariable("FORM", $a_form->getHTML());
380  $tpl->show("DEFAULT", false);
381  }
382 
383  protected function initCodeForm($a_username)
384  {
385  global $lng, $ilCtrl;
386 
387  $lng->loadLanguageModule("auth");
388 
389  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
390 
391  $form = new ilPropertyFormGUI();
392  $form->setFormAction($ilCtrl->getFormAction($this, 'showcodeform'));
393  $form->setTitle($lng->txt('auth_account_code_title'));
394 
395  $count = new ilTextInputGUI($lng->txt('auth_account_code'), 'code');
396  $count->setRequired(true);
397  $count->setInfo($lng->txt('auth_account_code_info'));
398  $form->addItem($count);
399 
400  // #11658
401  $uname = new ilHiddenInputGUI("uname");
402  $uname->setValue($a_username);
403  $form->addItem($uname);
404 
405  $form->addCommandButton('processCode', $lng->txt('send'));
406 
407  return $form;
408  }
409 
410  protected function processCode()
411  {
412  global $lng, $ilAuth, $ilCtrl;
413 
414  $uname = $_POST["uname"];
415 
416  $form = $this->initCodeForm($uname);
417  if($uname && $form->checkInput())
418  {
419  $code = $form->getInput("code");
420 
421  include_once "Services/User/classes/class.ilAccountCode.php";
422  if(ilAccountCode::isUnusedCode($code))
423  {
424  $valid_until = ilAccountCode::getCodeValidUntil($code);
425 
426  if(!$user_id = ilObjUser::_lookupId($uname))
427  {
428  $this->showLogin();
429  return false;
430  }
431 
432  $invalid_code = false;
433  $user = new ilObjUser($user_id);
434 
435  if($valid_until === "0")
436  {
437  $user->setTimeLimitUnlimited(true);
438  }
439  else
440  {
441  if(is_numeric($valid_until))
442  {
443  $valid_until = strtotime("+".$valid_until."days");
444  }
445  else
446  {
447  $valid_until = explode("-", $valid_until);
448  $valid_until = mktime(23, 59, 59, $valid_until[1],
449  $valid_until[2], $valid_until[0]);
450  if($valid_until < time())
451  {
452  $invalid_code = true;
453  }
454  }
455 
456  if(!$invalid_code)
457  {
458  $user->setTimeLimitUnlimited(false);
459  $user->setTimeLimitUntil($valid_until);
460  }
461  }
462 
463  if(!$invalid_code)
464  {
465  $user->setActive(true);
466 
467  ilAccountCode::useCode($code);
468 
469  // apply registration code role assignments
471 
472  // apply registration code time limits
473  ilAccountCode::applyAccessLimits($user, $code);
474 
475  $user->update();
476 
477  $ilCtrl->setParameter($this, "cu", 1);
478  $ilCtrl->redirect($this, "showLogin");
479  }
480  }
481 
482  $lng->loadLanguageModule("user");
483  $field = $form->getItemByPostVar("code");
484  $field->setAlert($lng->txt("user_account_code_not_valid"));
485  }
486 
487  $form->setValuesByPost();
488  $this->showCodeForm($uname, $form);
489  }
490 
491 
492 
498  protected function showLoginForm($page_editor_html)
499  {
500  global $ilSetting,$lng,$tpl;
501 
502  // @todo move this to auth utils.
503  // login via ILIAS (this also includes radius and ldap)
504  // If local authentication is enabled for shibboleth users, we
505  // display the login form for ILIAS here.
506  if (($ilSetting->get("auth_mode") != AUTH_SHIBBOLETH ||
507  $ilSetting->get("shib_auth_allow_local")) &&
508  $ilSetting->get("auth_mode") != AUTH_CAS)
509  {
510  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
511  $form = new ilPropertyFormGUI();
512  //$form->setTableWidth('500');
513  $form->setFormAction($this->ctrl->getFormAction($this,''));
514  $form->setName("formlogin");
515  $form->setShowTopButtons(false);
516  $form->setTitle($lng->txt("login_to_ilias"));
517 
518  // auth selection
519  include_once('./Services/Authentication/classes/class.ilAuthModeDetermination.php');
521  if(ilAuthUtils::_hasMultipleAuthenticationMethods() and $det->isManualSelection())
522  {
523  $visible_auth_methods = array();
524  $radg = new ilRadioGroupInputGUI($lng->txt("auth_selection"), "auth_mode");
525  foreach(ilAuthUtils::_getMultipleAuthModeOptions($lng) as $key => $option)
526  {
527  if(isset($option['hide_in_ui']) && $option['hide_in_ui'])
528  {
529  continue;
530  }
531 
532  $op1 = new ilRadioOption($option['txt'], $key);
533  $radg->addOption($op1);
534  if (isset($option['checked']))
535  {
536  $radg->setValue($key);
537  }
538  $visible_auth_methods[] = $op1;
539  }
540 
541  if(count($visible_auth_methods) == 1)
542  {
543  $first_auth_method = current($visible_auth_methods);
544  $hidden_auth_method = new ilHiddenInputGUI("auth_mode");
545  $hidden_auth_method->setValue($first_auth_method->getValue());
546  $form->addItem($hidden_auth_method);
547  }
548  else
549  {
550  $form->addItem($radg);
551  }
552  }
553 
554  $ti = new ilTextInputGUI($lng->txt("username"), "username");
555  $ti->setSize(20);
556  $ti->setRequired(true);
557  $form->addItem($ti);
558 
559  $pi = new ilPasswordInputGUI($lng->txt("password"), "password");
560  $pi->setRetype(false);
561  $pi->setSize(20);
562  $pi->setDisableHtmlAutoComplete(false);
563  $pi->setRequired(true);
564  $form->addItem($pi);
565  $form->addCommandButton("showLogin", $lng->txt("log_in"));
566 
567  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
568  if(ilCaptchaUtil::isActiveForLogin())
569  {
570  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
571  $captcha = new ilCaptchaInputGUI($lng->txt('captcha_code'), 'captcha_code');
572  $captcha->setRequired(true);
573  $form->addItem($captcha);
574  }
575 
576  return $this->substituteLoginPageElements(
577  $tpl,
578  $page_editor_html,
579  $form->getHTML(),
580  '[list-login-form]',
581  'LOGIN_FORM'
582  );
583 
584  }
585  return $page_editor_html;
586  }
587 
593  protected function showLoginInformation($page_editor_html)
594  {
595  global $lng,$tpl;
596 
597  if(strlen($page_editor_html))
598  {
599  // page editor active return
600  return $page_editor_html;
601  }
602 
603  $loginSettings = new ilSetting("login_settings");
604  $information = $loginSettings->get("login_message_".$lng->getLangKey());
605 
606  if(strlen(trim($information)))
607  {
608  $tpl->setVariable("TXT_LOGIN_INFORMATION", $information);
609  }
610  return $page_editor_html;
611  }
612 
619  protected function showCASLoginForm($page_editor_html)
620  {
621  global $ilSetting, $lng;
622 
623 
624  // cas login link
625  if ($ilSetting->get("cas_active"))
626  {
627  $tpl = new ilTemplate('tpl.login_form_cas.html', true, true, 'Services/Init');
628  $tpl->setVariable("TXT_CAS_LOGIN", $lng->txt("login_to_ilias_via_cas"));
629  $tpl->setVariable("TXT_CAS_LOGIN_BUTTON", ilUtil::getImagePath("cas_login_button.png"));
630  $tpl->setVariable("TXT_CAS_LOGIN_INSTRUCTIONS", $ilSetting->get("cas_login_instructions"));
631  $this->ctrl->setParameter($this, "forceCASLogin", "1");
632  $tpl->setVariable("TARGET_CAS_LOGIN",$this->ctrl->getLinkTarget($this, "showLogin"));
633  $this->ctrl->setParameter($this, "forceCASLogin", "");
634 
635  return $this->substituteLoginPageElements(
636  $GLOBALS['tpl'],
637  $page_editor_html,
638  $tpl->get(),
639  '[list-cas-login-form]',
640  'CAS_LOGIN_FORM'
641  );
642  }
643  return $page_editor_html;
644  }
645 
651  protected function showShibbolethLoginForm($page_editor_html)
652  {
653  global $ilSetting, $lng;
654 
655  // Refactoring with ilFormPropertyGUI
656  // [...]
657 
658  // shibboleth login link
659  if ($ilSetting->get("shib_active")) {
660  $tpl = new ilTemplate('tpl.login_form_shibboleth.html', true, true, 'Services/Init');
661 
662  $tpl->setVariable('SHIB_FORMACTION', './shib_login.php'); // Bugfix http://ilias.de/mantis/view.php?id=10662 {$tpl->setVariable('SHIB_FORMACTION', $this->ctrl->getFormAction($this));}
663 
664  if ($ilSetting->get("shib_hos_type") == 'external_wayf') {
665  $tpl->setCurrentBlock("shibboleth_login");
666  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
667  $tpl->setVariable("IL_TARGET", $_GET["target"]);
668  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
669  $tpl->setVariable("TXT_SHIB_LOGIN_BUTTON", $ilSetting->get("shib_login_button"));
670  $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>.');
671  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
672  $tpl->parseCurrentBlock();
673  } elseif ($ilSetting->get("shib_hos_type") == 'embedded_wayf') {
674  $tpl->setCurrentBlock("shibboleth_custom_login");
675  $customInstructions = stripslashes($ilSetting->get("shib_login_instructions"));
676  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $customInstructions);
677  $tpl->parseCurrentBlock();
678  } else {
679  $tpl->setCurrentBlock("shibboleth_wayf_login");
680  $tpl->setVariable("TXT_SHIB_LOGIN", $lng->txt("login_to_ilias_via_shibboleth"));
681  $tpl->setVariable("TXT_SHIB_FEDERATION_NAME", $ilSetting->get("shib_federation_name"));
682  $tpl->setVariable("TXT_SELECT_HOME_ORGANIZATION", sprintf($lng->txt("shib_select_home_organization"), $ilSetting->get("shib_federation_name")));
683  $tpl->setVariable("TXT_CONTINUE", $lng->txt("btn_next"));
684  $tpl->setVariable("TXT_SHIB_HOME_ORGANIZATION", $lng->txt("shib_home_organization"));
685  $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>.');
686  $tpl->setVariable("TXT_SHIB_CUSTOM_LOGIN_INSTRUCTIONS", $ilSetting->get("shib_login_instructions"));
687 
688  require_once "./Services/AuthShibboleth/classes/class.ilShibbolethWAYF.php";
689  $WAYF = new ShibWAYF();
690 
691  $tpl->setVariable("TXT_SHIB_INVALID_SELECTION", $WAYF->showNotice());
692  $tpl->setVariable("SHIB_IDP_LIST", $WAYF->generateSelection());
693  $tpl->setVariable("ILW_TARGET", $_GET["target"]);
694  $tpl->parseCurrentBlock();
695  }
696 
697  return $this->substituteLoginPageElements($GLOBALS['tpl'], $page_editor_html, $tpl->get(), '[list-shibboleth-login-form]', 'SHIB_LOGIN_FORM');
698  }
699 
700  return $page_editor_html;
701  }
702 
703 
713  protected function substituteLoginPageElements($tpl, $page_editor_html, $element_html, $placeholder, $fallback_tplvar)
714  {
715  if(!strlen($page_editor_html))
716  {
717  $tpl->setVariable($fallback_tplvar,$element_html);
718  return $page_editor_html;
719  }
720  // Try to replace placeholders
721  if(!stristr($page_editor_html, $placeholder))
722  {
723  $tpl->setVariable($fallback_tplvar,$element_html);
724  return $page_editor_html;
725  }
726  return str_replace($placeholder, $element_html, $page_editor_html);
727  }
728 
733  protected function getLoginPageEditorHTML()
734  {
735  global $lng, $tpl;
736 
737  include_once './Services/Authentication/classes/class.ilAuthLoginPageEditorSettings.php';
739  $active_lang = $lpe->getIliasEditorLanguage($lng->getLangKey());
740 
741  if(!$active_lang)
742  {
743  return '';
744  }
745 
746  // if page does not exist, return nothing
747  include_once './Services/COPage/classes/class.ilPageUtil.php';
748  if(!ilPageUtil::_existsAndNotEmpty('auth', ilLanguage::lookupId($active_lang)))
749  {
750  return '';
751  }
752 
753  include_once './Services/Authentication/classes/class.ilLoginPage.php';
754  include_once './Services/Authentication/classes/class.ilLoginPageGUI.php';
755 
756  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
757  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",ilObjStyleSheet::getContentStylePath(0));
758  $tpl->setCurrentBlock("SyntaxStyle");
759  $tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",ilObjStyleSheet::getSyntaxStylePath());
760  $tpl->parseCurrentBlock();
761 
762  // get page object
763  $page_gui = new ilLoginPageGUI(ilLanguage::lookupId($active_lang));
764 
765  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
766  $page_gui->setStyleId(0, 'auth');
767 
768  $page_gui->setPresentationTitle("");
769  $page_gui->setTemplateOutput(false);
770  $page_gui->setHeader("");
771  $ret = $page_gui->showPage();
772 
773  return $ret;
774  }
775 
784  protected function showRegistrationLinks($page_editor_html)
785  {
786  global $lng, $ilSetting, $ilIliasIniFile, $ilAccess;
787 
788  $rtpl = new ilTemplate('tpl.login_registration_links.html',true,true,'Services/Init');
789 
790  // allow new registrations?
791  include_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
793  {
794  $rtpl->setCurrentBlock("new_registration");
795  $rtpl->setVariable("REGISTER", $lng->txt("registration"));
796  $rtpl->setVariable("CMD_REGISTER",
797  $this->ctrl->getLinkTargetByClass("ilaccountregistrationgui", ""));
798  $rtpl->parseCurrentBlock();
799  }
800  // allow password assistance? Surpress option if Authmode is not local database
801  if ($ilSetting->get("password_assistance"))
802  {
803  $rtpl->setCurrentBlock("password_assistance");
804  $rtpl->setVariable("FORGOT_PASSWORD", $lng->txt("forgot_password"));
805  $rtpl->setVariable("FORGOT_USERNAME", $lng->txt("forgot_username"));
806  $rtpl->setVariable("CMD_FORGOT_PASSWORD",
807  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", ""));
808  $rtpl->setVariable("CMD_FORGOT_USERNAME",
809  $this->ctrl->getLinkTargetByClass("ilpasswordassistancegui", "showUsernameAssistanceForm"));
810  $rtpl->setVariable("LANG_ID", $lng->getLangKey());
811  $rtpl->parseCurrentBlock();
812  }
813 
814  if ($ilSetting->get("pub_section") &&
815  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, "read", "", ROOT_FOLDER_ID))
816  {
817  $rtpl->setCurrentBlock("homelink");
818  $rtpl->setVariable("CLIENT_ID","?client_id=".$_COOKIE["ilClientId"]."&lang=".$lng->getLangKey());
819  $rtpl->setVariable("TXT_HOME",$lng->txt("home"));
820  $rtpl->parseCurrentBlock();
821  }
822 
823  if ($ilIliasIniFile->readVariable("clients","list"))
824  {
825  $rtpl->setCurrentBlock("client_list");
826  $rtpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
827  $rtpl->setVariable("CMD_CLIENT_LIST",$this->ctrl->getLinkTarget($this, "showClientList"));
828  $rtpl->parseCurrentBlock();
829  }
830 
831  return $this->substituteLoginPageElements(
832  $GLOBALS['tpl'],
833  $page_editor_html,
834  $rtpl->get(),
835  '[list-registration-link]',
836  'REG_PWD_CLIENT_LINKS'
837  );
838  }
839 
845  protected function showTermsOfServiceLink($page_editor_html)
846  {
850  global $lng;
851 
852 
853  try
854  {
855  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
856  if(ilTermsOfServiceHelper::isEnabled() && ilTermsOfServiceSignableDocumentFactory::getByLanguageObject($lng))
857  {
858  $utpl = new ilTemplate('tpl.login_terms_of_service_link.html', true, true, 'Services/Init');
859  $utpl->setVariable('TXT_TERMS_OF_SERVICE', $lng->txt('usr_agreement'));
860  $utpl->setVariable('LINK_TERMS_OF_SERVICE', $this->ctrl->getLinkTarget($this, 'showTermsOfService'));
861 
862  return $this->substituteLoginPageElements(
863  $GLOBALS['tpl'],
864  $page_editor_html,
865  $utpl->get(),
866  '[list-user-agreement]',
867  'USER_AGREEMENT'
868  );
869  }
870  }
872  {
873  }
874 
875  return $this->substituteLoginPageElements(
876  $GLOBALS['tpl'],
877  $page_editor_html,
878  '',
879  '[list-user-agreement]',
880  'USER_AGREEMENT'
881  );
882  }
883 
889  protected function purgePlaceholders($page_editor_html)
890  {
891  return str_replace(
892  array(
893  '[list-language-selection] ',
894  '[list-registration-link]',
895  '[list-user-agreement]',
896  '[list-login-form]',
897  '[list-cas-login-form]',
898  '[list-shibboleth-login-form]',
899  '[list-openid-login-form]'
900  ),
901  array('','','','','','',''),
902  $page_editor_html
903  );
904  }
905 
910  public function showAccountMigration($a_message = '')
911  {
916  global $tpl, $lng;
917 
918  $lng->loadLanguageModule('auth');
919  self::initStartUpTemplate('tpl.login_account_migration.html');
920 
921  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
922  $form = new ilPropertyFormGUI();
923  $form->setFormAction($this->ctrl->getFormAction($this,'migrateAccount'));
924 
925  $form->setTitle($lng->txt('auth_account_migration'));
926  $form->addCommandButton('migrateAccount', $lng->txt('save'));
927  $form->addCommandButton('showLogin', $lng->txt('cancel'));
928 
929  $rad = new ilRadioGroupInputGUI($lng->txt('auth_account_migration_name'),'account_migration');
930  $rad->setValue(1);
931 
932  $keep = new ilRadioOption($lng->txt('auth_account_migration_keep'),1,$lng->txt('auth_info_migrate'));
933  $user = new ilTextInputGUI($lng->txt('login'),'mig_username');
934  $user->setRequired(true);
935  $user->setValue(ilUtil::prepareFormOutput($_POST['mig_username']));
936  $user->setSize(32);
937  $user->setMaxLength(128);
938  $keep->addSubItem($user);
939 
940  $pass = new ilPasswordInputGUI($lng->txt('password'),'mig_password');
941  $pass->setRetype(false);
942  $pass->setRequired(true);
943  $pass->setValue(ilUtil::prepareFormOutput($_POST['mig_password']));
944  $pass->setSize(12);
945  $pass->setMaxLength(128);
946  $keep->addSubItem($pass);
947  $rad->addOption($keep);
948 
949  $new = new ilRadioOption($lng->txt('auth_account_migration_new'),2,$lng->txt('auth_info_add'));
950  $rad->addOption($new);
951 
952  $form->addItem($rad);
953 
954  $tpl->setVariable('MIG_FORM',$form->getHTML());
955 
956  if(strlen($a_message))
957  {
958  ilUtil::sendFailure($a_message);
959  }
960 
961  $tpl->show('DEFAULT');
962  }
963 
970  public function migrateAccount()
971  {
972  global $lng,$ilClientIniFile,$ilLog,$rbacadmin;
973 
974  $lng->loadLanguageModule('auth');
975 
976  if(!isset($_POST['account_migration']))
977  {
978  $this->showAccountMigration($lng->txt('err_choose_migration_type'));
979  return false;
980  }
981 
982  if($_POST['account_migration'] == 1 and (!strlen($_POST['mig_username']) or !strlen($_POST['mig_password'])))
983  {
984  $this->showAccountMigration($lng->txt('err_wrong_login'));
985  return false;
986  }
987 
988  if($_POST['account_migration'] == 1)
989  {
990  if(!$user_id = ilObjUser::_lookupId(ilUtil::stripSlashes($_POST['mig_username'])))
991  {
992  $this->showAccountMigration($lng->txt('err_wrong_login'));
993  return false;
994  }
995  $_POST['username'] = $_POST['mig_username'];
996  $_POST['password'] = $_POST['mig_password'];
997 
998  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
999  include_once './Services/Database/classes/class.ilAuthContainerMDB2.php';
1000 
1002  $ilAuth->start();
1003  if(!$ilAuth->checkAuth())
1004  {
1005  $ilAuth->logout();
1006  $this->showAccountMigration($lng->txt('err_wrong_login'));
1007  return false;
1008  }
1009 
1010  $user = new ilObjUser($user_id);
1011  $user->setAuthMode(ilSession::get('tmp_auth_mode'));
1012  $user->setExternalAccount(ilSession::get('tmp_external_account'));
1013  $user->setActive(true);
1014  $user->update();
1015 
1016  // Assign to default role
1017  if(is_array(ilSession::get('tmp_roles')))
1018  {
1019  foreach(ilSession::get('tmp_roles') as $role)
1020  {
1021  $rbacadmin->assignUser((int) $role,$user->getId());
1022  }
1023  }
1024 
1025  // Log migration
1026  $ilLog->write(__METHOD__.': Migrated '.ilSession::get('tmp_external_account').' to ILIAS account '.$user->getLogin().'.');
1027  }
1028  elseif($_POST['account_migration'] == 2)
1029  {
1030  switch(ilSession::get('tmp_auth_mode'))
1031  {
1032  case 'apache':
1033  $_POST['username'] = ilSession::get('tmp_external_account');
1034  $_POST['password'] = ilSession::get('tmp_pass');
1035 
1036  include_once('Services/AuthApache/classes/class.ilAuthContainerApache.php');
1037  $container = new ilAuthContainerApache();
1038  $container->forceCreation(true);
1039  $ilAuth = ilAuthFactory::factory($container);
1040  $ilAuth->start();
1041  break;
1042 
1043  case 'ldap':
1044  $_POST['username'] = ilSession::get('tmp_external_account');
1045  $_POST['password'] = ilSession::get('tmp_pass');
1046 
1047  include_once('Services/LDAP/classes/class.ilAuthContainerLDAP.php');
1048  $container = new ilAuthContainerLDAP();
1049  $container->forceCreation(true);
1050  $ilAuth = ilAuthFactory::factory($container);
1051  $ilAuth->start();
1052  break;
1053 
1054  case 'radius':
1055  $_POST['username'] = ilSession::get('tmp_external_account');
1056  $_POST['password'] = ilSession::get('tmp_pass');
1057 
1058  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1059  include_once './Services/Radius/classes/class.ilAuthContainerRadius.php';
1060 
1061  $container = new ilAuthContainerRadius();
1062  $container->forceCreation(true);
1063  $ilAuth = ilAuthFactory::factory($container);
1064  $ilAuth->start();
1065  break;
1066 
1067  case 'openid':
1068  $_POST['username'] = ilSession::get('dummy');
1069  $_POST['password'] = ilSession::get('dummy');
1070  $_POST['oid_username'] = ilSession::get('tmp_oid_username');
1071  $_POST['oid_provider'] = ilSession::get('tmp_oid_provider');
1072  //ilSession::set('force_creation', true);
1073 
1074  include_once './Services/Authentication/classes/class.ilAuthFactory.php';
1075  include_once './Services/OpenId/classes/class.ilAuthContainerOpenId.php';
1076 
1077  $container = new ilAuthContainerOpenId();
1078  $container->forceCreation(true);
1080  include_once './Services/OpenId/classes/class.ilAuthOpenId.php';
1081  $ilAuth = ilAuthFactory::factory($container);
1082 
1083  // logout first to initiate a new login session
1084  $ilAuth->logout();
1085  ilSession::_destroy(session_id());
1086  ilSession::set('force_creation', true);
1087  $ilAuth->start();
1088  }
1089  // Redirect to acceptance
1090  ilUtil::redirect("ilias.php?baseClass=ilStartUpGUI&cmdClass=ilstartupgui&target=".$_GET["target"]."&cmd=getAcceptance");
1091  }
1092  // show personal desktop
1093  ilUtil::redirect('ilias.php?baseClass=ilPersonalDesktopGUI');
1094  }
1095 
1099  function showLogout()
1100  {
1101  global $tpl, $ilSetting, $ilAuth, $lng, $ilIliasIniFile;
1102 
1104  $ilAuth->logout();
1105  session_destroy();
1106 
1107  // reset cookie
1108  $client_id = $_COOKIE["ilClientId"];
1109  ilUtil::setCookie("ilClientId","");
1110 
1111  //instantiate logout template
1112  self::initStartUpTemplate("tpl.logout.html");
1113 
1114  if ($ilSetting->get("pub_section"))
1115  {
1116  $tpl->setCurrentBlock("homelink");
1117  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1118  $tpl->setVariable("TXT_HOME",$lng->txt("home"));
1119  $tpl->parseCurrentBlock();
1120  }
1121 
1122  if ($ilIliasIniFile->readVariable("clients","list"))
1123  {
1124  $tpl->setCurrentBlock("client_list");
1125  $tpl->setVariable("TXT_CLIENT_LIST", $lng->txt("to_client_list"));
1126  $this->ctrl->setParameter($this, "client_id", $client_id);
1127  $tpl->setVariable("CMD_CLIENT_LIST",
1128  $this->ctrl->getLinkTarget($this, "showClientList"));
1129  $tpl->parseCurrentBlock();
1130  $this->ctrl->setParameter($this, "client_id", "");
1131  }
1132 
1133  $tpl->setVariable("TXT_PAGEHEADLINE", $lng->txt("logout"));
1134  $tpl->setVariable("TXT_LOGOUT_TEXT", $lng->txt("logout_text"));
1135  $tpl->setVariable("TXT_LOGIN", $lng->txt("login_to_ilias"));
1136  $tpl->setVariable("CLIENT_ID","?client_id=".$client_id."&lang=".$lng->getLangKey());
1137 
1138  $tpl->show();
1139  }
1140 
1146  {
1147  global $ilAuth, $tpl, $lng;
1148 
1149  $valid = $ilAuth->getValidationData();
1150 
1151  self::initStartUpTemplate("tpl.user_mapping_selection.html");
1152  $email_user = ilObjUser::_getLocalAccountsForEmail($valid["email"]);
1153 
1154 
1155  if ($ilAuth->getSubStatus() == AUTH_WRONG_LOGIN)
1156  {
1157  ilUtil::sendFailure($lng->txt("err_wrong_login"));
1158  }
1159 
1160  include_once('./Services/User/classes/class.ilObjUser.php');
1161  if (count($email_user) == 1)
1162  {
1163  //$user = new ilObjUser(key($email_user));
1164  $tpl->setCurrentBlock("one_user");
1165  $tpl->setVariable("TXT_USERNAME", $lng->txt("username"));
1166  $tpl->setVariable("VAL_USERNAME", current($email_user));
1167  $tpl->setVariable("USER_ID", key($email_user));
1168  $tpl->parseCurrentBlock();
1169  }
1170  else
1171  {
1172  foreach($email_user as $key => $login)
1173  {
1174  $tpl->setCurrentBlock("user");
1175  $tpl->setVariable("USR_ID", $key);
1176  $tpl->setVariable("VAL_USER", $login);
1177  $tpl->parseCurrentBlock();
1178  }
1179  $tpl->setCurrentBlock("multpiple_user");
1180  $tpl->parseCurrentBlock();
1181  }
1182 
1183  $tpl->setCurrentBlock("content");
1184  $this->ctrl->setParameter($this, "ext_uid", urlencode($_GET["ext_uid"]));
1185  $this->ctrl->setParameter($this, "soap_pw", urlencode($_GET["soap_pw"]));
1186  $this->ctrl->setParameter($this, "auth_stat", $_GET["auth_stat"]);
1187  $tpl->setVariable("FORMACTION",
1188  $this->ctrl->getFormAction($this));
1189  $tpl->setVariable("TXT_ILIAS_LOGIN", $lng->txt("login_to_ilias"));
1190  if (count($email_user) == 1)
1191  {
1192  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation"));
1193  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_2"));
1194  }
1195  else
1196  {
1197  $tpl->setVariable("TXT_EXPLANATION", $lng->txt("ums_explanation_3"));
1198  $tpl->setVariable("TXT_EXPLANATION_2", $lng->txt("ums_explanation_4"));
1199  }
1200  $tpl->setVariable("TXT_CREATE_USER", $lng->txt("ums_create_new_account"));
1201  $tpl->setVariable("TXT_PASSWORD", $lng->txt("password"));
1202  $tpl->setVariable("PASSWORD", ilUtil::prepareFormOutput($_POST["password"]));
1203  $tpl->setVariable("TXT_SUBMIT", $lng->txt("login"));
1204 
1205  $tpl->show();
1206  }
1207 
1211  function showClientList()
1212  {
1213  global $tpl, $ilIliasIniFile, $ilCtrl;
1214 //echo "1";
1215  if (!$ilIliasIniFile->readVariable("clients","list"))
1216  {
1217  $this->processIndexPHP();
1218  return;
1219  }
1220 //echo "2";
1221  $tpl = new ilTemplate("tpl.main.html", true, true);
1222  $tpl->setAddFooter(false); // no client yet
1223 
1224  // to do: get standard style
1225  $tpl->setVariable("PAGETITLE","Client List");
1226  $tpl->setVariable("LOCATION_STYLESHEET","./templates/default/delos.css");
1227 
1228  // load client list template
1229  self::initStartUpTemplate("tpl.client_list.html");
1230 
1231  // load template for table
1232  $tpl->addBlockfile("CLIENT_LIST", "client_list", "tpl.table.html");
1233 
1234  // load template for table content data
1235  $tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.obj_tbl_rows.html");
1236 
1237  // load table content data
1238  require_once("setup/classes/class.ilClientList.php");
1239  require_once("setup/classes/class.ilClient.php");
1240  require_once("setup/classes/class.ilDBConnections.php");
1241  require_once("./Services/Table/classes/class.ilTableGUI.php");
1242  $this->db_connections = new ilDBConnections();
1243  $clientlist = new ilClientList($this->db_connections);
1244  $list = $clientlist->getClients();
1245 
1246  if (count($list) == 0)
1247  {
1248  header("Location: ./setup/setup.php");
1249  exit();
1250  }
1251 
1252  $hasPublicSection = false;
1253  foreach ($list as $key => $client)
1254  {
1255  $client->setDSN();
1256 
1257  if ($client->checkDatabaseExists(true) and $client->ini->readVariable("client","access") and $client->getSetting("setup_ok"))
1258  {
1259  $this->ctrl->setParameter($this, "client_id", $key);
1260  $tmp = array();
1261  $tmp[] = $client->getName();
1262  $tmp[] = "<a href=\""."login.php?cmd=force_login&client_id=".urlencode($key)."\">Login page</a>";
1263 
1264  if($client->getSetting('pub_section'))
1265  {
1266  $hasPublicSection = true;
1267  $tmp[] = "<a href=\"" . "ilias.php?baseClass=ilRepositoryGUI&client_id=" . urlencode($key) . "\">Start page</a>";
1268  }
1269  else
1270  {
1271  $tmp[] = '';
1272  }
1273 
1274  $data[] = $tmp;
1275  }
1276  }
1277 
1278  // create table
1279  $tbl = new ilTableGUI();
1280 
1281  // title & header columns
1282  if($hasPublicSection)
1283  {
1284  $tbl->setTitle("Available Clients");
1285  $tbl->setHeaderNames(array("Installation Name","Login","Public Access"));
1286  $tbl->setHeaderVars(array("name","index","login"));
1287  $tbl->setColumnWidth(array("50%","25%","25%"));
1288  }
1289  else
1290  {
1291  $tbl->setTitle("Available Clients");
1292  $tbl->setHeaderNames(array("Installation Name","Login",''));
1293  $tbl->setHeaderVars(array("name","login",''));
1294  $tbl->setColumnWidth(array("70%","25%",'1px'));
1295  }
1296 
1297  // control
1298  $tbl->setOrderColumn($_GET["sort_by"],"name");
1299  $tbl->setOrderDirection($_GET["sort_order"]);
1300  $tbl->setLimit($_GET["limit"]);
1301  $tbl->setOffset($_GET["offset"]);
1302 
1303  // content
1304  $tbl->setData($data);
1305 
1306  $tbl->disable("icon");
1307  $tbl->disable("numinfo");
1308  $tbl->disable("sort");
1309  $tbl->disable("footer");
1310 
1311  // render table
1312  $tbl->render();
1313  $tpl->show("DEFAULT", true, true);
1314  }
1315 
1322  {
1323  global $tpl;
1324 
1325  $str = "<p style=\"margin:15px;\">
1326  You need to enable Session Cookies in your Browser to use ILIAS.
1327  <br/>
1328  <br/><b>Firefox</b>
1329  <br/>Tools -> Options -> Privacy -> Cookies
1330  <br/>Enable 'Allow sites to set cookies' and activate option 'Keep
1331  <br/>cookies' auf 'until I close Firefox'
1332  <br/>
1333  <br/><b>Mozilla/Netscape</b>
1334  <br/>Edit -> Preferences -> Privacy&Security -> Cookies
1335  <br/>Go to 'Cookie Lifetime Policy' and check option 'Accept for current
1336  <br/>session only'.
1337  <br/>
1338  <br/><b>Internet Explorer</b>
1339  <br/>Tools -> Internet Options -> Privacy -> Advanced
1340  <br/>- Check 'Override automatic cookie handling'
1341  <br/>- Check 'Always allow session cookies'
1342  </p>";
1343  $tpl->setVariable("CONTENT", $str);
1344  $tpl->show();
1345  }
1346 
1350  protected function getAcceptance()
1351  {
1352  $this->showTermsOfService();
1353  }
1354 
1358  protected function showTermsOfService()
1359  {
1366  global $lng, $tpl, $ilUser, $ilSetting;
1367 
1368  $back_to_login = ('getAcceptance' != $this->ctrl->getCmd());
1369 
1370  self::initStartUpTemplate('tpl.view_terms_of_service.html', $back_to_login, !$back_to_login);
1371  $tpl->setVariable('TXT_PAGEHEADLINE', $lng->txt('usr_agreement'));
1372 
1373  try
1374  {
1375  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceSignableDocumentFactory.php';
1377 
1378  if('getAcceptance' == $this->ctrl->getCmd())
1379  {
1380  if(isset($_POST['status']) && 'accepted' == $_POST['status'])
1381  {
1382  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceHelper.php';
1383  ilTermsOfServiceHelper::trackAcceptance($ilUser, $document);
1384 
1385  if(ilSession::get('orig_request_target'))
1386  {
1387  $target = ilSession::get('orig_request_target');
1388  ilSession::set('orig_request_target', '');
1389  ilUtil::redirect($target);
1390  }
1391  else
1392  {
1393  ilUtil::redirect('index.php?target=' . $_GET['target'] . '&client_id=' . CLIENT_ID);
1394  }
1395  }
1396 
1397  $tpl->setVariable('FORM_ACTION', $this->ctrl->getFormAction($this, $this->ctrl->getCmd()));
1398  $tpl->setVariable('ACCEPT_CHECKBOX', ilUtil::formCheckbox(0, 'status', 'accepted'));
1399  $tpl->setVariable('ACCEPT_TERMS_OF_SERVICE', $lng->txt('accept_usr_agreement'));
1400  $tpl->setVariable('TXT_SUBMIT', $lng->txt('submit'));
1401  }
1402 
1403  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', $document->getContent());
1404  }
1406  {
1407  $tpl->setVariable('TERMS_OF_SERVICE_CONTENT', sprintf($lng->txt('no_agreement_description'), 'mailto:' . ilUtil::prepareFormOutput($ilSetting->get('feedback_recipient'))));
1408  }
1409 
1410  $tpl->show();
1411  }
1412 
1416  function processIndexPHP()
1417  {
1418  global $ilIliasIniFile, $ilAuth, $ilSetting;
1419 
1420  // display client selection list if enabled
1421  if (!isset($_GET["client_id"]) &&
1422  $_GET["cmd"] == "" &&
1423  $ilIliasIniFile->readVariable("clients","list"))
1424  {
1425  return $this->showClientList();
1426  }
1427 
1428  if($ilAuth->getAuth() && $ilAuth->getStatus() == "")
1429  {
1430  $this->processStartingPage();
1431  }
1432 
1433  //
1434  // index.php is called and public section is enabled
1435  //
1436  // && $ilAuth->status == -101 is important for soap auth (public section on + user mapping, alex)
1437  // $ilAuth->status -1 is given, if session ends (if public section -> jump to public section)
1438 
1439  if ($ilSetting->get("pub_section") && $_POST["sendLogin"] != "1"
1440  && ($ilAuth->getStatus() != -101 && $_GET["soap_pw"] == ""))
1441  {
1443  }
1444  else
1445  {
1446  // index.php is called and public section is disabled
1447  $this->showLogin();
1448  }
1449  }
1450 
1456  function processStartingPage()
1457  {
1461  global $ilUser;
1462 
1463  // fallback, should never happen
1464  if ($ilUser->getId() == ANONYMOUS_USER_ID)
1465  {
1467  }
1468  else
1469  {
1470  // for password change and incomplete profile
1471  // see ilPersonalDesktopGUI
1472 
1473  if(IS_PAYMENT_ENABLED)
1474  {
1475  include_once './Services/Payment/classes/class.ilPaymentShoppingCart.php';
1477 
1478  if((int)$_GET['forceShoppingCartRedirect'])
1479  {
1480  ilUtil::redirect('ilias.php?baseClass=ilShopController&cmd=redirect&redirect_class=ilshopshoppingcartgui');
1481  }
1482  }
1483 
1484  if(!$_GET["target"])
1485  {
1486  // Redirect here to switch back to http if desired
1487  include_once './Services/User/classes/class.ilUserUtil.php';
1489  }
1490  else
1491  {
1492  // will handle shop redirects, too
1493  ilUtil::redirect("goto.php?target=".$_GET["target"]);
1494  }
1495  }
1496  }
1497 
1498  function _checkGoto($a_target)
1499  {
1500  global $objDefinition, $ilPluginAdmin, $ilUser;
1501 
1502  if (is_object($ilPluginAdmin))
1503  {
1504  // get user interface plugins
1505  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE, "UIComponent", "uihk");
1506 
1507  // search
1508  foreach ($pl_names as $pl)
1509  {
1510  $ui_plugin = ilPluginAdmin::getPluginObject(IL_COMP_SERVICE, "UIComponent", "uihk", $pl);
1511  $gui_class = $ui_plugin->getUIClassInstance();
1512  $resp = $gui_class->checkGotoHook($a_target);
1513  if ($resp["target"] !== false)
1514  {
1515  $a_target = $resp["target"];
1516  break;
1517  }
1518  }
1519  }
1520 
1521  if ($a_target == "")
1522  {
1523  return false;
1524  }
1525 
1526  $t_arr = explode("_", $a_target);
1527  $type = $t_arr[0];
1528 
1529  if ($type == "git")
1530  {
1531  $type = "glo";
1532  }
1533 
1534  if ($type == "pg" | $type == "st")
1535  {
1536  $type = "lm";
1537  }
1538 
1539  $class = $objDefinition->getClassName($type);
1540  if ($class == "")
1541  {
1542  return false;
1543  }
1544 
1545  $location = $objDefinition->getLocation($type);
1546  $full_class = "ilObj".$class."Access";
1547  include_once($location."/class.".$full_class.".php");
1548 
1549  $ret = call_user_func(array($full_class, "_checkGoto"), $a_target);
1550 
1551  // if no access and repository object => check for parent course/group
1552  if(!$ret &&
1553  !stristr($a_target, "_wsp") &&
1554  $ilUser->getId() != ANONYMOUS_USER_ID && // #10637
1555  !$objDefinition->isAdministrationObject($type) &&
1556  $objDefinition->isRBACObject($type) &&
1557  $t_arr[1])
1558  {
1559  global $tree, $rbacsystem, $ilAccess;
1560 
1561  // original type "pg" => pg_<page_id>[_<ref_id>]
1562  if($t_arr[0] == "pg")
1563  {
1564  if(isset($t_arr[2]))
1565  {
1566  $ref_id = $t_arr[2];
1567  }
1568  else
1569  {
1570  $lm_id = ilLMObject::_lookupContObjID($t_arr[1]);
1572  if($ref_id)
1573  {
1574  $ref_id = array_shift($ref_id);
1575  }
1576  }
1577  }
1578  else
1579  {
1580  $ref_id = $t_arr[1];
1581  }
1582 
1583  include_once "Services/Membership/classes/class.ilParticipants.php";
1584  $block_obj = array();
1585 
1586  // walk path to find parent container
1587  $path = $tree->getPathId($ref_id);
1588  array_pop($path);
1589  foreach($path as $path_ref_id)
1590  {
1591  $redirect_infopage = false;
1592  $add_member_role = false;
1593 
1594  $ptype = ilObject::_lookupType($path_ref_id, true);
1595  $pobj_id = ilObject::_lookupObjId($path_ref_id);
1596 
1597  // core checks: timings/object-specific
1598  if(!$ilAccess->doActivationCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype) ||
1599  !$ilAccess->doStatusCheck("read", "", $path_ref_id, $ilUser->getId(), $pobj_id, $ptype))
1600  {
1601  // object in path is inaccessible - aborting
1602  return false;
1603  }
1604  else if($ptype == "crs")
1605  {
1606  // check if already participant
1607  include_once "Modules/Course/classes/class.ilCourseParticipant.php";
1608  $participants = new ilCourseParticipant($pobj_id, $ilUser->getId());
1609  if(!$participants->isAssigned())
1610  {
1611  // subscription currently possible?
1612  include_once "Modules/Course/classes/class.ilObjCourse.php";
1613  if(ilObjCourse::_isActivated($pobj_id) &&
1615  {
1616  $block_obj[] = $path_ref_id;
1617  $add_member_role = true;
1618  }
1619  else
1620  {
1621  $redirect_infopage = true;
1622  }
1623  }
1624  }
1625  else if($ptype == "grp")
1626  {
1627  // check if already participant
1628  include_once "Modules/Group/classes/class.ilGroupParticipants.php";
1629  if(!ilGroupParticipants::_isParticipant($path_ref_id, $ilUser->getId()))
1630  {
1631  // subscription currently possible?
1632  include_once "Modules/Group/classes/class.ilObjGroup.php";
1633  $group_obj = new ilObjGroup($path_ref_id);
1634  if($group_obj->isRegistrationEnabled())
1635  {
1636  $block_obj[] = $path_ref_id;
1637  $add_member_role = true;
1638  }
1639  else
1640  {
1641  $redirect_infopage = true;
1642  }
1643  }
1644  }
1645 
1646  // add members roles for all "blocking" objects
1647  if($add_member_role)
1648  {
1649  // cannot join? goto will never work, so redirect to current object
1650  $rbacsystem->resetPACache($ilUser->getId(), $path_ref_id);
1651  if(!$rbacsystem->checkAccess("join", $path_ref_id))
1652  {
1653  $redirect_infopage = true;
1654  }
1655  else
1656  {
1657  $rbacsystem->addTemporaryRole($ilUser->getId(),
1658  ilParticipants::getDefaultMemberRole($path_ref_id));
1659  }
1660  }
1661 
1662  // redirect to infopage of 1st blocking object in path
1663  if($redirect_infopage)
1664  {
1665  if($rbacsystem->checkAccess("visible", $path_ref_id))
1666  {
1667  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
1668  "&ref_id=".$path_ref_id."&cmd=infoScreen");
1669  }
1670  else
1671  {
1672  return false;
1673  }
1674  }
1675  }
1676 
1677  // check if access will be possible with all (possible) member roles added
1678  $rbacsystem->resetPACache($ilUser->getId(), $ref_id);
1679  if($rbacsystem->checkAccess("read", $ref_id) && sizeof($block_obj)) // #12128
1680  {
1681  // this won't work with lm-pages (see above)
1682  // include_once "Services/Link/classes/class.ilLink.php";
1683  // $_SESSION["pending_goto"] = ilLink::_getStaticLink($ref_id, $type);
1684 
1685  // keep original target
1686  $_SESSION["pending_goto"] = "goto.php?target=".$a_target;
1687 
1688  // redirect to 1st non-member object in path
1689  ilUtil::redirect("ilias.php?baseClass=ilRepositoryGUI".
1690  "&ref_id=".array_shift($block_obj));
1691  }
1692  }
1693 
1694  return $ret;
1695  }
1696 
1697  public function confirmRegistration()
1698  {
1699  global $lng, $ilias, $ilLog;
1700 
1701  ilUtil::setCookie('iltest', 'cookie', false);
1702 
1703  if(!isset($_GET['rh']) || !strlen(trim($_GET['rh'])))
1704  {
1705  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_confirmation_hash_not_passed');
1706  }
1707 
1708  try
1709  {
1710  require_once 'Services/Registration/classes/class.ilRegistrationSettings.php';
1711  $oRegSettings = new ilRegistrationSettings();
1712 
1713  $usr_id = ilObjUser::_verifyRegistrationHash(trim($_GET['rh']));
1714  $oUser = ilObjectFactory::getInstanceByObjId($usr_id);
1715  $oUser->setActive(true);
1716  if($oRegSettings->passwordGenerationEnabled())
1717  {
1718  $passwd = ilUtil::generatePasswords(1);
1719  $password = $passwd[0];
1720  $oUser->setPasswd($password, IL_PASSWD_PLAIN);
1721  $oUser->setLastPasswordChangeTS( time() );
1722  }
1723  $oUser->update();
1724 
1725  $usr_lang = $oUser->getPref('language');
1726 
1727  if($lng->getLangKey() != $usr_lang)
1728  {
1729  $lng = new ilLanguage($usr_lang);
1730  }
1731 
1732  // send email
1733  // try individual account mail in user administration
1734  include_once("Services/Mail/classes/class.ilAccountMail.php");
1735  include_once './Services/User/classes/class.ilObjUserFolder.php';
1736  $amail = ilObjUserFolder::_lookupNewAccountMail($usr_lang);
1737  if (trim($amail["body"]) != "" && trim($amail["subject"]) != "")
1738  {
1739  $acc_mail = new ilAccountMail();
1740  $acc_mail->setUser($oUser);
1741  if($oRegSettings->passwordGenerationEnabled())
1742  {
1743  $acc_mail->setUserPassword($password);
1744  }
1745  $acc_mail->send();
1746  }
1747  else // do default mail
1748  {
1749  include_once 'Services/Mail/classes/class.ilMail.php';
1750  $mail_obj = new ilMail(ANONYMOUS_USER_ID);
1751 
1752  // mail subject
1753  $subject = $lng->txt("reg_mail_subject");
1754 
1755  // mail body
1756  $body = $lng->txt("reg_mail_body_salutation")." ".$oUser->getFullname().",\n\n".
1757  $lng->txt("reg_mail_body_text1")."\n\n".
1758  $lng->txt("reg_mail_body_text2")."\n".
1759  ILIAS_HTTP_PATH."/login.php?client_id=".CLIENT_ID."\n";
1760  $body .= $lng->txt("login").": ".$oUser->getLogin()."\n";
1761 
1762  if($oRegSettings->passwordGenerationEnabled())
1763  {
1764  $body.= $lng->txt("passwd").": ".$password."\n";
1765  }
1766 
1767  $body.= "\n";
1768  $body.= $lng->txt('reg_mail_body_forgot_password_info')."\n";
1769 
1770  $body.= "\n";
1771 
1772  $body .= ($lng->txt("reg_mail_body_text3")."\n\r");
1773  $body .= $oUser->getProfileAsString($lng);
1774  $mail_obj->enableSoap(false);
1775  $mail_obj->appendInstallationSignature(true);
1776  $mail_obj->sendMail($oUser->getEmail(), '', '',
1777  $subject,
1778  $body,
1779  array(), array('normal'));
1780  }
1781 
1782  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg=reg_account_confirmation_successful&lang='.$usr_lang);
1783  }
1784  catch(ilRegConfirmationLinkExpiredException $exception)
1785  {
1786  include_once 'Services/WebServices/SOAP/classes/class.ilSoapClient.php';
1787  $soap_client = new ilSoapClient();
1788  $soap_client->setResponseTimeout(1);
1789  $soap_client->enableWSDL(true);
1790  $soap_client->init();
1791 
1792  $ilLog->write(__METHOD__.': Triggered soap call (background process) for deletion of inactive user objects with expired confirmation hash values (dual opt in) ...');
1793 
1794  $soap_client->call
1795  (
1796  'deleteExpiredDualOptInUserObjects',
1797  array
1798  (
1799  $_COOKIE['PHPSESSID'].'::'.$_COOKIE['ilClientId'], // session id and client id, not used for checking access -> not possible for anonymous
1800  $exception->getCode() // user id
1801  )
1802  );
1803 
1804  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
1805  }
1806  catch(ilRegistrationHashNotFoundException $exception)
1807  {
1808  ilUtil::redirect('./login.php?cmd=force_login&reg_confirmation_msg='.$exception->getMessage()."&lang=".$usr_lang);
1809  }
1810  }
1811 
1816  protected function showOpenIdLoginForm($page_editor_html)
1817  {
1818  global $lng,$tpl;
1819 
1820  include_once './Services/OpenId/classes/class.ilOpenIdSettings.php';
1821  if(!ilOpenIdSettings::getInstance()->isActive())
1822  {
1823  return $page_editor_html;
1824  }
1825 
1826  $lng->loadLanguageModule('auth');
1827 
1828  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
1829  $form = new ilPropertyFormGUI();
1830  //$form->setTableWidth('500');
1831  $form->setShowTopButtons(false);
1832  $form->setFormAction($this->ctrl->getFormAction($this));
1833  $form->setTitle($lng->txt('login_to_ilias_via_openid'));
1834 
1835  $openid = new ilTextInputGUI($lng->txt('auth_openid_login'),'oid_username');
1836  $openid->setSize(18);
1837  $openid->setMaxLength(255);
1838  $openid->setRequired(true);
1839  $openid->setCssClass('ilOpenIDBox');
1840  $openid->setInfo($lng->txt('auth_openid_login_info_a'));
1841  $form->addItem($openid);
1842 
1843  include_once './Services/OpenId/classes/class.ilOpenIdProviders.php';
1844  $pro = new ilSelectInputGUI($lng->txt('auth_openid_provider'),'oid_provider');
1845  $pro->setOptions(ilOpenIdProviders::getInstance()->getProviderSelection());
1846  $pro->setValue(ilOpenIdProviders::getInstance()->getSelectedProvider());
1847  $form->addItem($pro);
1848  $form->addCommandButton("showLogin", $lng->txt("log_in"));
1849 
1850  return $this->substituteLoginPageElements(
1851  $tpl,
1852  $page_editor_html,
1853  $form->getHTML(),
1854  '[list-openid-login-form]',
1855  'OID_LOGIN_FORM'
1856  );
1857  }
1858 
1865  public static function initStartUpTemplate($a_tmpl, $a_show_back = false, $a_show_logout = false)
1866  {
1874  global $tpl, $lng, $ilCtrl, $ilSetting, $ilAccess;
1875 
1876  // #13574 - basic.js is included with ilTemplate, so jQuery is needed, too
1877  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1879 
1880  // framework is needed for language selection
1881  include_once("./Services/UICore/classes/class.ilUIFramework.php");
1883 
1884  $tpl->addBlockfile('CONTENT', 'content', 'tpl.startup_screen.html', 'Services/Init');
1885  $tpl->setVariable('HEADER_ICON', ilUtil::getImagePath('HeaderIcon.svg'));
1886 
1887  if($a_show_back)
1888  {
1889  // #13400
1890  $param = 'client_id=' . $_COOKIE['ilClientId'] . '&lang=' . $lng->getLangKey();
1891 
1892  $tpl->setCurrentBlock('link_item_bl');
1893  $tpl->setVariable('LINK_TXT', $lng->txt('login_to_ilias'));
1894  $tpl->setVariable('LINK_URL', 'login.php?cmd=force_login&'.$param);
1895  $tpl->parseCurrentBlock();
1896 
1897  if($ilSetting->get('pub_section') &&
1898  $ilAccess->checkAccessOfUser(ANONYMOUS_USER_ID, 'read', '', ROOT_FOLDER_ID))
1899  {
1900  $tpl->setVariable('LINK_URL', 'index.php?'.$param);
1901  $tpl->setVariable('LINK_TXT', $lng->txt('home'));
1902  $tpl->parseCurrentBlock();
1903  }
1904  }
1905  else if($a_show_logout)
1906  {
1907  $tpl->setCurrentBlock('link_item_bl');
1908  $tpl->setVariable('LINK_TXT', $lng->txt('logout'));
1909  $tpl->setVariable('LINK_URL', ILIAS_HTTP_PATH . '/logout.php');
1910  $tpl->parseCurrentBlock();
1911  }
1912 
1913  if(is_array($a_tmpl))
1914  {
1915  $template_file = $a_tmpl[0];
1916  $template_dir = $a_tmpl[1];
1917  }
1918  else
1919  {
1920  $template_file = $a_tmpl;
1921  $template_dir = 'Services/Init';
1922  }
1923 
1924  //Header Title
1925 
1926  include_once("./Modules/SystemFolder/classes/class.ilObjSystemFolder.php");
1927  $header_top_title = ilObjSystemFolder::_getHeaderTitle();
1928  if (trim($header_top_title) != "" && $tpl->blockExists("header_top_title"))
1929  {
1930  $tpl->setCurrentBlock("header_top_title");
1931  $tpl->setVariable("TXT_HEADER_TITLE", $header_top_title);
1932  $tpl->parseCurrentBlock();
1933  }
1934 
1935  // language selection
1936  $selection = self::getLanguageSelection();
1937  if($selection)
1938  {
1939  $tpl->setCurrentBlock("lang_select");
1940  $tpl->setVariable("TXT_LANGSELECT", $lng->txt("language"));
1941  $tpl->setVariable("LANG_SELECT", $selection);
1942  $tpl->parseCurrentBlock();
1943  }
1944 
1945  $tpl->addBlockFile('STARTUP_CONTENT', 'startup_content', $template_file, $template_dir);
1946  }
1947 
1952  protected static function getLanguageSelection()
1953  {
1954  include_once("./Services/MainMenu/classes/class.ilMainMenuGUI.php");
1956  }
1957 }