Skip to content

Commit

Permalink
WWSympa: sync_include: Add a button to synchronize owners / moderator…
Browse files Browse the repository at this point in the history
…s in Web interface (sympa-community#857)
  • Loading branch information
ikedas committed Feb 29, 2020
1 parent 5d19b9b commit 1524e6f
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 30 deletions.
12 changes: 9 additions & 3 deletions default/mail_tt2/report.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -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' ~%]
Expand Down
18 changes: 17 additions & 1 deletion default/web_tt2/review.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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">
Expand Down
75 changes: 49 additions & 26 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 ##
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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';
}

Expand Down

0 comments on commit 1524e6f

Please sign in to comment.