* Admin: fix fatal error in admin >> bulk password reset

This commit is contained in:
Ralf Becker 2014-11-20 13:53:30 +00:00
parent 44595fe931
commit 89c02707e9
2 changed files with 18 additions and 17 deletions

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package admin * @package admin
* @copyright (c) 2011 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2011-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -105,6 +105,7 @@ class admin_passwordreset
} }
$change_pw = $content['random_pw'] || $content['hash'] && $content['hash'] != $current_hash; $change_pw = $content['random_pw'] || $content['hash'] && $content['hash'] != $current_hash;
$changed = array(); $changed = array();
$emailadmin = null;
foreach($content['users'] as $account_id) foreach($content['users'] as $account_id)
{ {
if (($account = $GLOBALS['egw']->accounts->read($account_id))) if (($account = $GLOBALS['egw']->accounts->read($account_id)))
@ -156,8 +157,12 @@ class admin_passwordreset
{ {
if (!isset($emailadmin)) if (!isset($emailadmin))
{ {
$emailadmin = new emailadmin_bo(); $emailadmin = emailadmin_account::get_default();
$domain = $GLOBALS['egw_info']['server']['mail_suffix']; if (!emailadmin_account::is_multiple($emailadmin))
{
$msg = lang('No default account found!');
break;
}
} }
if (($userData = $emailadmin->getUserData ($account_id))) if (($userData = $emailadmin->getUserData ($account_id)))
{ {
@ -171,11 +176,11 @@ class admin_passwordreset
} }
if (strpos($content['mail']['domain'], '.') !== false) if (strpos($content['mail']['domain'], '.') !== false)
{ {
$userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($domain).'$/', '@'.$content['mail']['domain'], $userData['mailLocalAddress']); $userData['mailLocalAddress'] = preg_replace('/@'.preg_quote($emailadmin->acc_domain).'$/', '@'.$content['mail']['domain'], $userData['mailLocalAddress']);
foreach($userData['mailAlternateAddress'] as &$alias) foreach($userData['mailAlternateAddress'] as &$alias)
{ {
$alias = preg_replace('/@'.preg_quote($domain).'$/', '@'.$content['mail']['domain'], $alias); $alias = preg_replace('/@'.preg_quote($emailadmin->acc_domain).'$/', '@'.$content['mail']['domain'], $alias);
} }
} }
$emailadmin->saveUserData($account_id, $userData); $emailadmin->saveUserData($account_id, $userData);
@ -215,6 +220,7 @@ class admin_passwordreset
} }
catch (phpmailerException $e) catch (phpmailerException $e)
{ {
unset ($e);
$msg .= lang('Notifying account "%1" %2 failed!',$account['account_lid'],$account['account_email']). $msg .= lang('Notifying account "%1" %2 failed!',$account['account_lid'],$account['account_email']).
': '.strip_tags(str_replace('<p>',"\n",$send->ErrorInfo))."\n"; ': '.strip_tags(str_replace('<p>',"\n",$send->ErrorInfo))."\n";
} }
@ -247,7 +253,7 @@ class admin_passwordreset
$GLOBALS['egw_info']['flags']['app_header'] = lang('Bulk password reset'); $GLOBALS['egw_info']['flags']['app_header'] = lang('Bulk password reset');
$tmpl = new etemplate('admin.passwordreset'); $tmpl = new etemplate_new('admin.passwordreset');
$tmpl->exec('admin.admin_passwordreset.index',$content,$sel_options,$readonlys,array( $tmpl->exec('admin.admin_passwordreset.index',$content,$sel_options,$readonlys,array(
'changed' => $changed, 'changed' => $changed,
)); ));

View File

@ -1,7 +1,7 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<!-- $Id$ --> <!-- $Id$ -->
<overlay> <overlay>
<template id="admin.passwordreset" template="" lang="" group="0" version="1.9.001"> <template id="admin.passwordreset" template="" lang="" group="0" version="14.1">
<grid> <grid>
<columns> <columns>
<column/> <column/>
@ -9,11 +9,6 @@
<column/> <column/>
</columns> </columns>
<rows> <rows>
<row disabled="!@msg">
<description id="msg" span="all" class="redItalic"/>
<description/>
<description/>
</row>
<row> <row>
<description value="Select users"/> <description value="Select users"/>
<description/> <description/>
@ -32,7 +27,7 @@
<menulist> <menulist>
<menupopup type="select-bool" label="Can change password" id="changepassword" onchange="var mustchange=document.getElementById(form::name('mustchangepassword')); if (this.value=='0' &amp;&amp; mustchange.value) mustchange.value='0';" options="Leave unchanged"/> <menupopup type="select-bool" label="Can change password" id="changepassword" onchange="var mustchange=document.getElementById(form::name('mustchangepassword')); if (this.value=='0' &amp;&amp; mustchange.value) mustchange.value='0';" options="Leave unchanged"/>
</menulist> </menulist>
<hbox options="0,0"> <hbox>
<menulist> <menulist>
<menupopup label="Change password hash to" id="hash" options="Leave unchanged"/> <menupopup label="Change password hash to" id="hash" options="Leave unchanged"/>
</menulist> </menulist>
@ -52,8 +47,8 @@
<row valign="top"> <row valign="top">
<groupbox> <groupbox>
<caption label="Notification mail"/> <caption label="Notification mail"/>
<textbox blur="Subject" id="subject" size="64"/> <textbox blur="Subject" id="subject" size="64" class="et2_fullWidth"/>
<textbox multiline="true" id="body" rows="15" cols="64"/> <textbox multiline="true" id="body" rows="15" cols="64" class="et2_fullWidth"/>
</groupbox> </groupbox>
<vbox> <vbox>
<description value="Available placeholders" class="gray"/> <description value="Available placeholders" class="gray"/>