gotocourse.php 2.5 KB

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