Commit 1524e6fb authored by IKEDA Soji's avatar IKEDA Soji
Browse files

WWSympa: sync_include: Add a button to synchronize owners / moderators in Web interface (#857)

parent 5d19b9ba
......@@ -408,10 +408,16 @@
[%~ ELSIF report_entry == 'no_msg_document' ~%]
[%|loc(report_param.list)%]No message and no document to moderate for list %1[%END%]
[%~ ELSIF report_entry == 'subscribers_updated' ~%]
[%|loc%]The list of list members have been built/updated.[%END%]
[%~ ELSIF report_entry == 'member_updated' ~%]
[%|loc%]The list of list subscribers have been built/updated.[%END%]
[%~ ELSIF report_entry == 'subscribers_updated_soon' ~%]
[%~ ELSIF report_entry == 'owner_updated' ~%]
[%|loc%]The list of list owners have been built/updated.[%END%]
[%~ ELSIF report_entry == 'editor_updated' ~%]
[%|loc%]The list of list moderators have been built/updated.[%END%]
[%~ ELSIF report_entry == 'subscribers_updated_soon' # No longer used ~%]
[%|loc%]The list of list members will be built/updated soon (a few minutes).[%END%]
[%~ ELSIF report_entry == 'subscribers_noticed_deleted_topics' ~%]
......
......@@ -55,12 +55,13 @@
</a>
<br />
[% IF may_sync %]
[% IF may_include.member %]
<br />
<form name="synchronize_list_members" action="[% path_cgi %]" method="post">
<input class="MainMenuLinks heavyWork" type="submit" name="action_sync_include"
value="[%|loc%]Synchronize members with data sources[%END%]" />
<input type="hidden" name="list" value="[% list %]"/>
<input type="hidden" name="role" value="member"/>
</form>
[% END %]
<hr>
......@@ -456,6 +457,21 @@
</fieldset>
</form>
[% IF may_include.$role ~%]
<br />
<form name="sync_include" action="[% path_cgi %]" method="post">
<input class="MainMenuLinks heavyWork" type="submit"
name="action_sync_include"
value="[% IF role == 'owner' ~%]
[%|loc%]Synchronize owners with data sources[%END%]
[%~ ELSE ~%]
[%|loc%]Synchronize moderators with data sources[%END%]
[%~ END %]" />
<input type="hidden" name="list" value="[% list %]"/>
<input type="hidden" name="role" value="[% role %]"/>
</form>
[%~ END %]
[%# AJAX modal dialog ~%]
<div id="edit" class="reveal medium" data-reveal role="dialog"
aria-labelledby="[%|loc%]View user[%END%]" aria-hidden="true">
......
......@@ -2859,10 +2859,21 @@ sub check_param_out {
$param->{'may_post_reason'} = $reason;
}
 
if ( $list->has_include_data_sources()
&& $param->{'is_owner'}) {
$param->{'may_sync'} = 1;
}
$param->{'may_include'} = {
member => (
$param->{'is_owner'} and $list->has_data_sources('member')
),
owner => (
$param->{'is_privileged_owner'}
and $list->has_data_sources('owner')
),
editor => (
$param->{'is_privileged_owner'}
and $list->has_data_sources('editor')
),
};
# Compat.<=6.2.54
$param->{'may_sync'} = $param->{'may_include'}{'member'};
}
 
## Should Not be used anymore ##
......@@ -4806,18 +4817,14 @@ sub _review_member {
my @additional_fields = split ',',
$Conf::Conf{'db_additional_subscriber_fields'};
 
## Members list synchronization if list has included data sources.
if ($list->has_include_data_sources()) {
my $sync_result = $list->on_the_fly_sync_include(use_ttl => 1);
unless (defined $sync_result) {
Sympa::WWW::Report::reject_report_web('intern',
'sync_include_failed',
{}, $param->{'action'}, $list, $param->{'user'}{'email'},
$robot);
} elsif ($sync_result) {
Sympa::WWW::Report::notice_report_web('subscribers_updated', {},
$param->{'action'});
}
# Members list synchronization if list has included data sources.
my $sync_result = $list->on_the_fly_sync_include(use_ttl => 1);
unless (defined $sync_result) {
Sympa::WWW::Report::reject_report_web('intern', 'sync_include_failed',
{}, $param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
} elsif ($sync_result) {
Sympa::WWW::Report::notice_report_web('member_updated', {},
$param->{'action'});
}
 
# Members list
......@@ -10620,20 +10627,22 @@ sub do_edit_list {
## If list has included data sources, update them and delete sync_include
## task.
if ($data_source_updated) {
if ($list->on_the_fly_sync_include('use_ttl' => 0)) {
Sympa::WWW::Report::notice_report_web('subscribers_updated', {},
$param->{'action'});
} else {
my $sync_result = $list->on_the_fly_sync_include(use_ttl => 0);
unless (defined $sync_result) {
Sympa::WWW::Report::reject_report_web('intern',
'sync_include_failed',
{}, $param->{'action'}, $list, $param->{'user'}{'email'},
$robot);
} elsif ($sync_result) {
Sympa::WWW::Report::notice_report_web('member_updated', {},
$param->{'action'});
}
}
 
# Call sync_include_admin if there are changes about owners or editors.
# Call sync_include() if there are changes about owners or editors.
#FIXME:Update only when owner or editor was updated.
unless (defined $list->sync_include_admin) {
unless (defined $list->sync_include('owner')
and defined $list->sync_include('editor')) {
Sympa::WWW::Report::reject_report_web('intern',
'sync_include_admin_failed', {}, $param->{'action'}, $list,
$param->{'user'}{'email'}, $robot);
......@@ -16512,16 +16521,30 @@ sub do_wsdl {
 
## Synchronize list members with data sources
sub do_sync_include {
wwslog('info', '(%s)', $in{'list'});
wwslog('info', '(%s, %s)', $in{'list'}, $in{'role'});
 
unless ($list->sync_include()) {
my $role = $in{'role'} || 'member'; # Compat.<=6.2.52.
$in{'page'} = $role unless $role eq 'member';
$param->{'list'} = $list->{'name'};
$param->{'role'} = $role;
$param->{'page'} = $role unless $role eq 'member';
unless (defined $list->sync_include($role)) {
Sympa::WWW::Report::reject_report_web('intern',
'sync_include_failed', {},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
return undef;
}
Sympa::WWW::Report::notice_report_web('subscribers_updated', {},
$param->{'action'});
Sympa::WWW::Report::notice_report_web(
{ member => 'member_updated',
owner => 'owner_updated',
editor => 'editor_updated',
}->{$role},
{},
$param->{'action'}
);
return 'review';
}
 
......
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