diff --git a/main/auth/inscription.php b/main/auth/inscription.php index 5284bfe55d..bd02b47ce0 100755 --- a/main/auth/inscription.php +++ b/main/auth/inscription.php @@ -738,12 +738,13 @@ if ($form->validate()) { array('info' => $text_after_registration) ); } else { - Display:: display_header($tool_name); - echo Display::page_header($tool_name); - echo $content; - echo $text_after_registration; - Display:: display_footer(); + $tpl = new Template($tool_name); + + $tpl->assign('inscription_content', $content); + $tpl->assign('text_after_registration', $text_after_registration); + $inscription = $tpl->get_template('auth/inscription.tpl'); + $tpl->display($inscription); } } else { // Custom pages @@ -775,16 +776,18 @@ if ($form->validate()) { } if ($hideHeaders) { - Display:: display_no_header(); + $showHeader = false; } else { - Display:: display_header($tool_name); + $showHeader = true; } - echo Display::page_header($tool_name); - echo $content; - $form->display(); - if ($hideHeaders == false) { - Display:: display_footer(); - } + $tpl = new Template($tool_name, $showHeader, $showHeader); + + $tpl->assign('inscription_header', Display::page_header($tool_name)); + $tpl->assign('inscription_content', $content); + $tpl->assign('form', $form->returnForm()); + + $inscription = $tpl->get_template('auth/inscription.tpl'); + $tpl->display($inscription); } } diff --git a/main/auth/lostPassword.php b/main/auth/lostPassword.php index 7b0f627e93..3c410f2562 100755 --- a/main/auth/lostPassword.php +++ b/main/auth/lostPassword.php @@ -14,9 +14,7 @@ * * @package chamilo.auth */ -/** - * Code - */ + require_once '../inc/global.inc.php'; // Custom pages @@ -63,20 +61,24 @@ if (CustomPages::enabled()) { } $tool_name = get_lang('LostPassword'); -Display :: display_header($tool_name); -$this_section = SECTION_CAMPUS; -$tool_name = get_lang('LostPass'); +$this_section = SECTION_CAMPUS; +$tool_name = get_lang('LostPass'); // Forbidden to retrieve the lost password if (api_get_setting('allow_lostpassword') == 'false') { - api_not_allowed(); + api_not_allowed(true); } +$formToString = ''; if (isset($_GET['reset']) && isset($_GET['id'])) { - $message = Display::return_message(Login::reset_password($_GET["reset"], $_GET["id"], true), 'normal', false); + $message = Display::return_message( + Login::reset_password($_GET["reset"], $_GET["id"], true), + 'normal', + false + ); $message .= ''.get_lang('Back').''; - echo $message; + Display::addFlash($message); } else { $form = new FormValidator('lost_password'); $form->addElement('header', $tool_name); @@ -96,16 +98,29 @@ if (isset($_GET['reset']) && isset($_GET['id'])) { $by_username = true; foreach ($users_related_to_username as $user) { if ($_configuration['password_encryption'] != 'none') { - Login::handle_encrypted_password($user, $by_username); + $message = Login::handle_encrypted_password($user, $by_username); } else { - Login::send_password_to_user($user, $by_username); + $message = Login::send_password_to_user($user, $by_username); } + Display::addFlash($message); } } else { - Display::display_warning_message(get_lang('NoUserAccountWithThisEmailAddress')); + Display::addFlash( + Display::return_message( + get_lang('NoUserAccountWithThisEmailAddress'), + 'warning' + ) + ); } } else { - $form->display(); + $formToString = $form->returnForm(); } } -Display::display_footer(); + + +$tpl = new Template($tool_name); + +$tpl->assign('form', $formToString); + +$template = $tpl->get_template('auth/lost_password.tpl'); +$tpl->display($template); diff --git a/main/inc/lib/login.lib.php b/main/inc/lib/login.lib.php index 1d3efe4d47..9431ea2408 100755 --- a/main/inc/lib/login.lib.php +++ b/main/inc/lib/login.lib.php @@ -124,7 +124,8 @@ class Login * * @author Olivier Cauberghe , Ghent University */ - public static function handle_encrypted_password($user, $by_username = false) { + public static function handle_encrypted_password($user, $by_username = false) + { $email_subject = "[" . api_get_setting('siteName') . "] " . get_lang('LoginRequest'); // SUBJECT if ($by_username) { // Show only for lost password @@ -147,7 +148,7 @@ class Login if (CustomPages::enabled()) { return get_lang('YourPasswordHasBeenEmailed'); } else { - Display::display_confirmation_message(get_lang('YourPasswordHasBeenEmailed')); + return Display::return_message(get_lang('YourPasswordHasBeenEmailed')); } } else { $admin_email = Display :: encrypted_mailto_link(api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'))); @@ -156,7 +157,7 @@ class Login if (CustomPages::enabled()) { return $message; } else { - Display::display_error_message($message, false); + return Display::return_message($message, 'error'); } } } diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 395cc95186..fc70575ef8 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -60,10 +60,10 @@ class Template $load_plugins = true ) { // Page title - $this->title = $title; - $this->show_learnpath = $show_learnpath; + $this->title = $title; + $this->show_learnpath = $show_learnpath; $this->hide_global_chat = $hide_global_chat; - $this->load_plugins = $load_plugins; + $this->load_plugins = $load_plugins; $template_paths = array( api_get_path(SYS_CODE_PATH) . 'template/overrides', // user defined templates @@ -83,20 +83,25 @@ class Template if (api_get_setting('server_type') == 'test') { $options = array( //'cache' => api_get_path(SYS_ARCHIVE_PATH), //path to the cache folder - 'autoescape' => false, - 'debug' => true, - 'auto_reload' => true, - 'optimizations' => 0, // turn on optimizations with -1 - 'strict_variables' => false, //If set to false, Twig will silently ignore invalid variables + 'autoescape' => false, + 'debug' => true, + 'auto_reload' => true, + 'optimizations' => 0, + // turn on optimizations with -1 + 'strict_variables' => false, + //If set to false, Twig will silently ignore invalid variables ); } else { $options = array( - 'cache' => $cache_folder, //path to the cache folder - 'autoescape' => false, - 'debug' => false, - 'auto_reload' => false, - 'optimizations' => -1, // turn on optimizations with -1 - 'strict_variables' => false //If set to false, Twig will silently ignore invalid variables + 'cache' => $cache_folder, + //path to the cache folder + 'autoescape' => false, + 'debug' => false, + 'auto_reload' => false, + 'optimizations' => -1, + // turn on optimizations with -1 + 'strict_variables' => false + //If set to false, Twig will silently ignore invalid variables ); } diff --git a/main/template/default/auth/inscription.tpl b/main/template/default/auth/inscription.tpl new file mode 100644 index 0000000000..9067d1a3c9 --- /dev/null +++ b/main/template/default/auth/inscription.tpl @@ -0,0 +1,10 @@ +{% extends template ~ "/layout/layout_1_col.tpl" %} + +{% block content %} + +{{ inscription_header }} +{{ inscription_content }} +{{ form }} +{{ text_after_registration }} + +{% endblock %} diff --git a/main/template/default/auth/lost_password.tpl b/main/template/default/auth/lost_password.tpl new file mode 100644 index 0000000000..8199816a74 --- /dev/null +++ b/main/template/default/auth/lost_password.tpl @@ -0,0 +1,7 @@ +{% extends template ~ "/layout/layout_1_col.tpl" %} + +{% block content %} + +{{ form }} + +{% endblock %}