Commit 502b7e17 authored by IKEDA Soji's avatar IKEDA Soji
Browse files

sympa.pl --change_user_email no longer working with 6.2.34 #389

parent b9f2e1a9
......@@ -791,8 +791,26 @@ Warning: this message may already have been sent by one of the list's moderators
[%~ ELSIF report_entry == 'change_member_email_failed_deleting' ~%]
[%|loc(report_param.email,report_param.listname)%]Failed to delete member email '%1' in list '%2'.[%END%]
[%~ ELSIF report_entry == 'change_admin_email_failed' ~%]
[% IF report_param.role == 'owner' ~%]
[%|loc(report_param.email,report_param.listname)%]Failed to update owner email '%1' in list '%2'.[%END%]
[%~ ELSE ~%]
[%|loc(report_param.email,report_param.listname)%]Failed to update moderator email '%1' in list '%2'.[%END%]
[%~ END %]
[%~ ELSIF report_entry == 'change_admin_email_failed_included' ~%]
[%|loc(report_param.listname)%]Failed to update admin email in list '%1', list owner has been notified.[%END%]
[% IF report_param.role == 'owner' ~%]
[%|loc(report_param.listname)%]Failed to update owner email in list '%1', listmaster has been notified.[%END%]
[%~ ELSE ~%]
[%|loc(report_param.listname)%]Failed to update moderator email in list '%1', listmaster has been notified.[%END%]
[%~ END %]
[%~ ELSIF report_entry == 'change_admin_email_failed_deleting' ~%]
[% IF report_param.role == 'owner' ~%]
[%|loc(report_param.email,report_param.listname)%]Failed to delete owner email '%1' in list '%2'.[%END%]
[%~ ELSE ~%]
[%|loc(report_param.email,report_param.listname)%]Failed to delete moderator email '%1' in list '%2'.[%END%]
[%~ END %]
[%~ ELSIF report_entry == 'no_email_changed' ~%]
[%|loc%]Address was not changed.[%END%]
......
......@@ -149,23 +149,27 @@ sub _twist {
Sympa::List::get_which($current_email, $robot_id, $role)) {
# Check if admin is included via an external datasource.
my ($admin_user) =
@{$list->get_admins($role,
filter => [email => $current_email])};
grep { $_->{role} eq $role and $_->{email} eq $current_email }
@{$list->get_current_admins || []};
if ($admin_user and $admin_user->{'included'}) {
# Notify listmaster.
Sympa::send_notify_to_listmaster(
$list,
'failed_to_change_included_admin',
{ 'current_email' => $current_email,
'new_email' => $email,
'datasource' =>
{ current_email => $current_email,
new_email => $email,
role => $role,
datasource =>
$list->get_datasource_name($admin_user->{'id'})
}
);
$self->add_stash(
$request, 'user',
'change_admin_email_failed_included',
{email => $current_email, listname => $list->{'name'}}
{ email => $current_email,
listname => $list->{'name'},
role => $role
}
);
$log->syslog(
'err',
......@@ -178,19 +182,46 @@ sub _twist {
next;
}
# Go through owners/editors of the list.
foreach my $admin (@{$list->{'admin'}{$role}}) {
next
unless lc $admin->{'email'} eq lc $current_email;
# Update entry with new email address.
$admin->{'email'} = $email;
$updated_lists{$list->{'name'}}++;
# Check if user is already user of the list with their new address
# then we just need to remove the old address.
if (grep { $_->{role} eq $role and $_->{email} eq $email }
@{$list->get_current_admins || []}) {
unless ($list->delete_list_admin($role, $current_email)) {
$self->add_stash(
$request, 'user',
'change_admin_email_failed_deleting',
{ email => $current_email,
listname => $list->{'name'},
role => $role
}
);
$log->syslog('info',
'Could not remove email %s from list %s',
$current_email, $list);
next;
}
} else {
unless (
$list->update_list_admin(
$current_email, $role,
{email => $email, update_date => time}
)
) {
$self->add_stash(
$request, 'user',
'change_admin_email_failed',
{ email => $current_email,
listname => $list->{'name'},
role => $role
}
);
$log->syslog('err',
'Could not change email %s for list %s to %s',
$current_email, $list, $email);
next;
}
}
# Update database cache for the list.
$list->sync_include_admin();
$list->save_config();
$updated_lists{$list->{'name'}} = 1;
}
}
# Notify listmasters that list owners/moderators email have changed.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment