gotocourse.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. *
  5. * Allow the user to login to a course after reaching a course URL
  6. * (e.g. http://chamilo.chamilo.org/courses/MYCOURSE/?id_session=0 )
  7. * See https://support.chamilo.org/issues/6768
  8. *
  9. * Author : hubert.borderiou@grenet.fr
  10. *
  11. */
  12. require_once __DIR__.'/../inc/global.inc.php';
  13. require_once api_get_path(SYS_PATH).'main/auth/cas/authcas.php';
  14. $msg = null;
  15. if (isset($_GET['firstpage'])) {
  16. $firstpage = $_GET['firstpage'];
  17. // if course is public, go to course without auth
  18. $tab_course_info = api_get_course_info($firstpage);
  19. api_set_firstpage_parameter($firstpage);
  20. $tpl = new Template(null, 1, 1);
  21. $action = api_get_self().'?'.Security::remove_XSS($_SERVER['QUERY_STRING']);
  22. $action = str_replace('&amp;', '&', $action);
  23. $form = new FormValidator('formLogin', 'post', $action, null, array('class'=>'form-stacked'));
  24. $form->addElement(
  25. 'text',
  26. 'login',
  27. null,
  28. array('placeholder' => get_lang('UserName'), 'autocapitalize' => 'none')
  29. );
  30. $form->addElement(
  31. 'password',
  32. 'password',
  33. null,
  34. array('placeholder' => get_lang('Password'), 'autocapitalize' => 'none')
  35. );
  36. $form->addButtonNext(get_lang('LoginEnter'), 'submitAuth');
  37. // see same text in main_api.lib.php function api_not_allowed
  38. if (api_is_cas_activated()) {
  39. $msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false);
  40. $msg .= Display::div("<br/><a href='".get_cas_direct_URL(api_get_course_id())."'>".getCASLogoHTML()." ".sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution"))."</a><br/><br/>", array('align'=>'center'));
  41. $msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount'));
  42. $msg .= "<p style='text-align:center'><a href='#' onclick='$(this).parent().next().toggle()'>".get_lang('LoginWithExternalAccount')."</a></p>";
  43. $msg .= "<div style='display:none;'>";
  44. }
  45. $msg .= '<div class="well_login">';
  46. $msg .= $form->returnForm();
  47. $msg .= '</div>';
  48. if (api_is_cas_activated()) {
  49. $msg .= "</div>";
  50. }
  51. $msg .= '<hr/><p style="text-align:center"><a href="'.api_get_path(WEB_PATH).'">'.get_lang('ReturnToCourseHomepage').'</a></p>';
  52. $tpl->assign('content', '<h4>'.get_lang('LoginToGoToThisCourse').'</h4>'.$msg);
  53. $tpl->display_one_col_template();
  54. } else {
  55. api_delete_firstpage_parameter();
  56. header('Location: '.api_get_path(WEB_PATH).'index.php');
  57. exit;
  58. }