Skip to content

Commit

Permalink
WWSympa: viewlogs: selected type of action is not preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedas committed Sep 3, 2019
1 parent c34ea0d commit 416f949
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 40 deletions.
14 changes: 7 additions & 7 deletions default/web_tt2/viewlogs.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@
</th>
[% ELSE %]
<th>
<a href="[% 'viewlogs' | url_rel([list,1,size,'date']) %]" >
<a href="[% 'viewlogs' | url_rel([list,1,size,'date'],{type=>type}) %]" >
[%|loc%]Date[%END%]
</a>
</th>
[% END %]
<th>
<a href="[% 'viewlogs' | url_rel([list,1,size,'list']) %]">
<a href="[% 'viewlogs' | url_rel([list,1,size,'list'],{type=>type}) %]">
[%|loc%]List[%END%]
</a>
</th>
Expand All @@ -127,7 +127,7 @@
</th>
[% ELSE %]
<th>
<a href="[% 'viewlogs' | url_rel([list,1,size,'action']) %]">
<a href="[% 'viewlogs' | url_rel([list,1,size,'action'],{type=>type}) %]">
[%|loc%]Action[%END%]
</a>
</th>
Expand Down Expand Up @@ -155,7 +155,7 @@
</th>
[% ELSE %]
<th>
<a href="[% 'viewlogs' | url_rel([list,1,size,'user_email']) %]">
<a href="[% 'viewlogs' | url_rel([list,1,size,'user_email'],{type=>type}) %]">
[%|loc%]User Email[%END%]
</a>
</th>
Expand Down Expand Up @@ -200,7 +200,7 @@
</td>
<td>
[% IF l.msg_id %]
<a href="[% 'viewlogs' | url_rel([list,page,size,sortby],{type=>'all_actions',target_type=>'msg_id',target=>l.msg_id}) %]"
<a href="[% 'viewlogs' | url_rel([list,page,size,sortby],{type=>type,target_type=>'msg_id',target=>l.msg_id}) %]"
data-tooltip aria-haspopup="true"
title="[%|loc%]view other events related to this message id.[%END%]">
[%|loc%]Other events[%END%]
Expand Down Expand Up @@ -274,15 +274,15 @@
</form>
<br />
[% IF prev_page ~%]
<a href="[% 'viewlogs' | url_rel([list,prev_page,size,sortby]) %]">
<a href="[% 'viewlogs' | url_rel([list,prev_page,size,sortby],{type=>type}) %]">
<i class="fa fa-caret-left fa-lg" title="[%|loc%]Previous page[%END%]"></i>
</a>
[%~ END %]
[% IF page ~%]
[%|loc(page,total_page)%]page %1 / %2[%END%]
[%~ END %]
[% IF next_page ~%]
<a href="[% 'viewlogs' | url_rel([list,next_page,size,sortby]) %]">
<a href="[% 'viewlogs' | url_rel([list,next_page,size,sortby],{type=>type}) %]">
<i class="fa fa-caret-right fa-lg" title="[%|loc%]Next page[%END%]"></i>
</a>
[%~ END %]
Expand Down
49 changes: 16 additions & 33 deletions src/lib/Sympa/Log.pm
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,22 @@ sub get_first_db_log {
FROM logs_table
WHERE robot_logs = %s }, $sdm->quote($select->{'robot'});

#if a type of target and a target are specified
if (($select->{'target_type'}) && ($select->{'target_type'} ne 'none')) {
if ($select->{'target'}) {
$select->{'target_type'} = lc($select->{'target_type'});
$select->{'target'} = lc($select->{'target'});
$statement .= 'AND '
. $select->{'target_type'}
. '_logs = '
. $sdm->quote($select->{'target'}) . ' ';
}
if ( $select->{target_type}
and $select->{target_type} ne 'none'
and $select->{target_type} =~ /\A\w+\z/
and $select->{target}) {
# If a type of target and a target are specified:
$statement .= sprintf 'AND %s_logs = %s ',
lc $select->{target_type}, $sdm->quote(lc $select->{target});
} elsif ($select->{type}
and $select->{type} ne 'none'
and $select->{type} ne 'all_actions'
and $action_type{$select->{type}}) {
# If the search is on a precise type:
$statement .= sprintf 'AND (%s) ',
join ' OR ',
map { sprintf "logs_table.action_logs = '%s'", $_ }
@{$action_type{$select->{'type'}}};
}

#if the search is between two date
Expand All @@ -507,29 +513,6 @@ sub get_first_db_log {
}
}

#if the search is on a precise type
if ($select->{'type'}) {
if ( ($select->{'type'} ne 'none')
&& ($select->{'type'} ne 'all_actions')) {
my $first = 'false';
foreach my $type (@{$action_type{$select->{'type'}}}) {
if ($first eq 'false') {
#if it is the first action, put AND on the statement
$statement .=
sprintf "AND (logs_table.action_logs = '%s' ", $type;
$first = 'true';
}
#else, put OR
else {
$statement .= sprintf "OR logs_table.action_logs = '%s' ",
$type;
}
}
$statement .= ')';
}

}

# if the listmaster want to make a search by an IP address.
if ($select->{'ip'}) {
$statement .= sprintf ' AND client_logs = %s ',
Expand Down

0 comments on commit 416f949

Please sign in to comment.