Skip to content

Commit

Permalink
Register and lost password tpl added. #10102
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jul 17, 2015
1 parent 2b809b7 commit a893afb
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 44 deletions.
29 changes: 16 additions & 13 deletions main/auth/inscription.php
Expand Up @@ -738,12 +738,13 @@
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
Expand Down Expand Up @@ -775,16 +776,18 @@
}

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);
}
}
43 changes: 29 additions & 14 deletions main/auth/lostPassword.php
Expand Up @@ -14,9 +14,7 @@
*
* @package chamilo.auth
*/
/**
* Code
*/

require_once '../inc/global.inc.php';

// Custom pages
Expand Down Expand Up @@ -63,20 +61,24 @@
}

$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 .= '<a href="'.api_get_path(WEB_CODE_PATH).'auth/lostPassword.php" class="btn btn-back" >'.get_lang('Back').'</a>';
echo $message;
Display::addFlash($message);
} else {
$form = new FormValidator('lost_password');
$form->addElement('header', $tool_name);
Expand All @@ -96,16 +98,29 @@
$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);
7 changes: 4 additions & 3 deletions main/inc/lib/login.lib.php
Expand Up @@ -124,7 +124,8 @@ public static function send_password_to_user($user, $by_username = false)
*
* @author Olivier Cauberghe <olivier.cauberghe@UGent.be>, 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
Expand All @@ -147,7 +148,7 @@ public static function handle_encrypted_password($user, $by_username = false) {
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')));
Expand All @@ -156,7 +157,7 @@ public static function handle_encrypted_password($user, $by_username = false) {
if (CustomPages::enabled()) {
return $message;
} else {
Display::display_error_message($message, false);
return Display::return_message($message, 'error');
}
}
}
Expand Down
33 changes: 19 additions & 14 deletions main/inc/lib/template.lib.php
Expand Up @@ -60,10 +60,10 @@ public function __construct(
$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
Expand All @@ -83,20 +83,25 @@ public function __construct(
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
);
}

Expand Down
10 changes: 10 additions & 0 deletions 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 %}
7 changes: 7 additions & 0 deletions main/template/default/auth/lost_password.tpl
@@ -0,0 +1,7 @@
{% extends template ~ "/layout/layout_1_col.tpl" %}

{% block content %}

{{ form }}

{% endblock %}

0 comments on commit a893afb

Please sign in to comment.