Port the change password dialog to et2

This commit is contained in:
Hadi Nategh 2015-03-12 17:02:10 +00:00
commit 69b5797745
4 changed files with 114 additions and 74 deletions

View File

@ -15,49 +15,43 @@ class preferences_password
'change' => True
);
function change()
/**
* Change password function
* process change password form
*
* @param type $content
*/
function change($content = null)
{
//_debug_array($GLOBALS['egw_info']['user']);
$n_passwd = $_POST['n_passwd'];
$n_passwd_2 = $_POST['n_passwd_2'];
$o_passwd_2 = $_POST['o_passwd_2'];
if (isset($_GET['message'])) $message = str_replace("<br />"," ",html::purify($_GET['message']));
if($GLOBALS['egw']->acl->check('nopasswordchange', 1) || $_POST['cancel'])
if ($GLOBALS['egw']->acl->check('nopasswordchange', 1))
{
egw_framework::window_close();
egw_framework::window_close('There was no password change!');
}
$GLOBALS['egw']->template->set_file(array(
'form' => 'changepassword.tpl'
));
$GLOBALS['egw']->template->set_var('lang_enter_password',lang('Enter your new password'));
$GLOBALS['egw']->template->set_var('lang_reenter_password',lang('Re-enter your password'));
$GLOBALS['egw']->template->set_var('lang_enter_old_password',lang('Enter your old password'));
$GLOBALS['egw']->template->set_var('lang_change',lang('Change password'));
$GLOBALS['egw']->template->set_var('lang_cancel',lang('Cancel'));
$GLOBALS['egw']->template->set_var('form_action',egw::link('/index.php','menuaction=preferences.preferences_password.change'));
$errors = array();
if($_POST['change'])
if (!is_array($content))
{
$content= array();
}
else
{
if ($content['button']['change'])
{
$o_passwd = $GLOBALS['egw_info']['user']['passwd'];
if($o_passwd != $o_passwd_2)
if($o_passwd != $content['o_passwd_2'])
{
$errors[] = lang('The old password is not correct');
}
if($n_passwd != $n_passwd_2)
if($content['n_passwd'] != $content['n_passwd_2'])
{
$errors[] = lang('The two passwords are not the same');
}
if($o_passwd == $n_passwd)
if($o_passwd == $content['n_passwd'])
{
$errors[] = lang('Old password and new password are the same. This is invalid. You must enter a new password');
}
if(!$n_passwd)
if(!$content['n_passwd'])
{
$errors[] = lang('You must enter a password');
}
@ -66,7 +60,7 @@ class preferences_password
if (!$errors)
{
try {
$passwd_changed = $GLOBALS['egw']->auth->change_password($o_passwd, $n_passwd,
$passwd_changed = $GLOBALS['egw']->auth->change_password($o_passwd, $content['n_passwd'],
$GLOBALS['egw_info']['user']['account_id']);
}
catch (Exception $e) {
@ -80,22 +74,20 @@ class preferences_password
$errors[] = lang('Failed to change password.');
}
egw_framework::message(implode("\n", $errors), 'error');
common::egw_header();
echo parse_navbar();
$GLOBALS['egw']->template->pfp('out','form');
common::egw_exit(True);
$content = array();
}
else
{
egw_framework::refresh_opener(lang('Password changed'), 'preferences');
egw_framework::window_close();
}
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Change your password');
common::egw_header();
echo parse_navbar();
$GLOBALS['egw']->template->pfp('out','form');
common::egw_footer();
}
}
$GLOBALS['egw_info']['flags']['app_header'] = lang('Change your password');
$tmpl = new etemplate_new('preferences.password');
$tmpl->exec('preferences.preferences_password.change', $content,array(),array(),array(),2);
}
}

View File

@ -49,3 +49,6 @@ tr.prefRow:hover .prefHelp {
margin-top: 10px;
margin-right: 5px;
}
#preferences-password .dialogHeader td {
text-align: center;
}

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE overlay PUBLIC "-//Stylite AG//eTemplate 2//EN" "http://www.egroupware.org/etemplate2.dtd">
<!-- $Id$ -->
<overlay>
<template id="preferences.password" template="" lang="" group="0" version="14.2">
<grid resize_ratio="0.25" >
<columns>
<column width="35%"/>
<column width="65%"/>
</columns>
<rows>
<row class="dialogHeader">
<description value="Change password" class="et2_fullWidth"/>
</row>
<row>
<description value="Enter your old password"/>
<passwd id="o_passwd_2" class="et2_fullWidth" needed="true"/>
</row>
<row>
<description value="Enter your new password"/>
<passwd id="n_passwd" class="et2_fullWidth" needed="true"/>
</row>
<row>
<description value="Re-enter your password"/>
<passwd id="n_passwd_2" class="et2_fullWidth" needed="true"/>
</row>
</rows>
</grid>
<!-- the empty resizable grid make sure that the toolbar stays always at the bottom after window gets resized -->
<grid resize_ratio="0.75">
<columns>
<column/>
</columns>
<rows>
<row></row>
</rows>
</grid>
<hbox class="dialogFooterToolbar">
<button label="Change" id="button[change]"/>
<button label="Cancel" id="button[cancel]" onclick="window.close();"/>
</hbox>
</template>
</overlay>

View File

@ -66,6 +66,9 @@ textarea.prefValue {
margin-top: 10px;
margin-right: 5px;
}
#preferences-password .dialogHeader td {
text-align: center;
}
/* #############################################################################
// iframe
// Rahmen + padding**/
@ -100,7 +103,7 @@ tr.prefRow > td {
/* otherwise help will cover bigger prefValue */
}
.prefHelp {
position: fixed;
position: absolute;
background-color: #e6e6e6;
/*border-radius: 10px;*/
-webkit-box-shadow: 1px 2px 1px rgba(0, 0, 0, 0.5);
@ -188,7 +191,6 @@ div#preferences-settings {
}
div#preferences-settings div.dialogHeader {
height: 50px;
font-size: 100% !important;
}
div#preferences-settings div.dialogHeader select#preferences-settings_appname {
min-width: 47%;