mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-07 16:44:20 +01:00
Port the change password dialog to et2
This commit is contained in:
parent
047ee13253
commit
87ee549921
@ -15,87 +15,79 @@ 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))
|
||||
{
|
||||
$o_passwd = $GLOBALS['egw_info']['user']['passwd'];
|
||||
|
||||
if($o_passwd != $o_passwd_2)
|
||||
$content= array();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($content['button']['change'])
|
||||
{
|
||||
$errors[] = lang('The old password is not correct');
|
||||
}
|
||||
|
||||
if($n_passwd != $n_passwd_2)
|
||||
{
|
||||
$errors[] = lang('The two passwords are not the same');
|
||||
}
|
||||
|
||||
if($o_passwd == $n_passwd)
|
||||
{
|
||||
$errors[] = lang('Old password and new password are the same. This is invalid. You must enter a new password');
|
||||
}
|
||||
|
||||
if(!$n_passwd)
|
||||
{
|
||||
$errors[] = lang('You must enter a password');
|
||||
}
|
||||
|
||||
// allow auth backends or configured password strenght to throw exceptions and display there message
|
||||
if (!$errors)
|
||||
{
|
||||
try {
|
||||
$passwd_changed = $GLOBALS['egw']->auth->change_password($o_passwd, $n_passwd,
|
||||
$GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
if(!$passwd_changed)
|
||||
{
|
||||
if (!$errors) // if we have no specific error, add general message
|
||||
$o_passwd = $GLOBALS['egw_info']['user']['passwd'];
|
||||
if($o_passwd != $content['o_passwd_2'])
|
||||
{
|
||||
$errors[] = lang('Failed to change password.');
|
||||
$errors[] = lang('The old password is not correct');
|
||||
}
|
||||
egw_framework::message(implode("\n", $errors), 'error');
|
||||
common::egw_header();
|
||||
echo parse_navbar();
|
||||
$GLOBALS['egw']->template->pfp('out','form');
|
||||
common::egw_exit(True);
|
||||
}
|
||||
else
|
||||
{
|
||||
egw_framework::refresh_opener(lang('Password changed'), 'preferences');
|
||||
egw_framework::window_close();
|
||||
if($content['n_passwd'] != $content['n_passwd_2'])
|
||||
{
|
||||
$errors[] = lang('The two passwords are not the same');
|
||||
}
|
||||
|
||||
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(!$content['n_passwd'])
|
||||
{
|
||||
$errors[] = lang('You must enter a password');
|
||||
}
|
||||
|
||||
// allow auth backends or configured password strenght to throw exceptions and display there message
|
||||
if (!$errors)
|
||||
{
|
||||
try {
|
||||
$passwd_changed = $GLOBALS['egw']->auth->change_password($o_passwd, $content['n_passwd'],
|
||||
$GLOBALS['egw_info']['user']['account_id']);
|
||||
}
|
||||
catch (Exception $e) {
|
||||
$errors[] = $e->getMessage();
|
||||
}
|
||||
}
|
||||
if(!$passwd_changed)
|
||||
{
|
||||
if (!$errors) // if we have no specific error, add general message
|
||||
{
|
||||
$errors[] = lang('Failed to change password.');
|
||||
}
|
||||
egw_framework::message(implode("\n", $errors), 'error');
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
@ -48,4 +48,7 @@ tr.prefRow:hover .prefHelp {
|
||||
font-size: 150%;
|
||||
margin-top: 10px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
#preferences-password .dialogHeader td {
|
||||
text-align: center;
|
||||
}
|
43
preferences/templates/default/password.xet
Normal file
43
preferences/templates/default/password.xet
Normal 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>
|
@ -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%;
|
||||
|
Loading…
Reference in New Issue
Block a user