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