gotocourse.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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 '../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('text', 'login', null, array('placeholder' => get_lang('UserName'), 'class' => 'autocapitalize_off')); //new
  25. $form->addElement('password', 'password', null, array('placeholder' => get_lang('Password'))); //new
  26. $form->addButtonNext(get_lang('LoginEnter'), 'submitAuth');
  27. // see same text in main_api.lib.php function api_not_allowed
  28. if (api_is_cas_activated()) {
  29. $msg .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false);
  30. $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'));
  31. $msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount'));
  32. $msg .= "<p style='text-align:center'><a href='#' onclick='$(this).parent().next().toggle()'>".get_lang('LoginWithExternalAccount')."</a></p>";
  33. $msg .= "<div style='display:none;'>";
  34. }
  35. $msg .= '<div class="well_login">';
  36. $msg .= $form->return_form();
  37. $msg .='</div>';
  38. if (api_is_cas_activated()) {
  39. $msg .= "</div>";
  40. }
  41. $msg .= '<hr/><p style="text-align:center"><a href="'.api_get_path(WEB_PATH).'">'.get_lang('ReturnToCourseHomepage').'</a></p>';
  42. $tpl->assign('content', '<h4>'.get_lang('LoginToGoToThisCourse').'</h4>'.$msg);
  43. $tpl->display_one_col_template();
  44. } else {
  45. api_delete_firstpage_parameter();
  46. header('Location: '.api_get_path(WEB_PATH).'index.php');
  47. exit;
  48. }