Improve code (#2071)
This commit is contained in:
parent
6b0d6b330b
commit
6996c79cab
|
@ -1,4 +1,4 @@
|
|||
.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
|
||||
.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
|
||||
.\"
|
||||
.\" Standard preamble:
|
||||
.\" ========================================================================
|
||||
|
@ -54,20 +54,16 @@
|
|||
.\" Avoid warning from groff about undefined register 'F'.
|
||||
.de IX
|
||||
..
|
||||
.nr rF 0
|
||||
.if \n(.g .if rF .nr rF 1
|
||||
.if (\n(rF:(\n(.g==0)) \{\
|
||||
. if \nF \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
.if !\nF .nr F 0
|
||||
.if \nF>0 \{\
|
||||
. de IX
|
||||
. tm Index:\\$1\t\\n%\t"\\$2"
|
||||
..
|
||||
. if !\nF==2 \{\
|
||||
. nr % 0
|
||||
. nr F 2
|
||||
. \}
|
||||
. if !\nF==2 \{\
|
||||
. nr % 0
|
||||
. nr F 2
|
||||
. \}
|
||||
.\}
|
||||
.rr rF
|
||||
.\"
|
||||
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
|
||||
.\" Fear. Run. Save yourself. No user-serviceable parts.
|
||||
|
@ -133,7 +129,7 @@
|
|||
.\" ========================================================================
|
||||
.\"
|
||||
.IX Title "llng-fastcgi-server 8"
|
||||
.TH llng-fastcgi-server 8 "2019-12-11" "perl v5.28.1" "User Contributed Perl Documentation"
|
||||
.TH llng-fastcgi-server 8 "2020-02-12" "perl v5.26.1" "User Contributed Perl Documentation"
|
||||
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
|
||||
.\" way too many mistakes in technical documents.
|
||||
.if n .ad l
|
||||
|
|
|
@ -108,7 +108,7 @@ sub portalConsts {
|
|||
}
|
||||
|
||||
# EXPORTER PARAMETERS
|
||||
our @EXPORT_OK = ('portalConsts');
|
||||
our @EXPORT_OK = ('portalConsts');
|
||||
our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK, 'import' ], );
|
||||
|
||||
1;
|
||||
|
|
|
@ -142,7 +142,7 @@ qr/^(?:(?:(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][-a-
|
|||
eval {
|
||||
do {
|
||||
qr/$_[0]/;
|
||||
}
|
||||
}
|
||||
};
|
||||
return $@ ? ( 0, "__badRegexp__: $@" ) : 1;
|
||||
}
|
||||
|
@ -223,8 +223,7 @@ m[^(?:(?:\-+\s*BEGIN\s+(?:PUBLIC\s+KEY|CERTIFICATE)\s*\-+\r?\n)?[a-zA-Z0-9/\+\r\
|
|||
},
|
||||
'select' => {
|
||||
'test' => sub {
|
||||
my $test =
|
||||
grep( { $_ eq $_[0]; }
|
||||
my $test = grep( { $_ eq $_[0]; }
|
||||
map( { $_->{'k'}; } @{ $_[2]{'select'}; } ) );
|
||||
return $test
|
||||
? 1
|
||||
|
@ -1695,7 +1694,7 @@ qr/^(?:\*\.)?(?:(?:(?:(?:[a-zA-Z0-9][-a-zA-Z0-9]*)?[a-zA-Z0-9])[.])*(?:[a-zA-Z][
|
|||
eval {
|
||||
do {
|
||||
qr/$_[0]/;
|
||||
}
|
||||
}
|
||||
};
|
||||
return $@ ? 0 : 1;
|
||||
},
|
||||
|
|
|
@ -169,18 +169,24 @@ sub myNotifs {
|
|||
if ($ref) {
|
||||
return $self->sendJSONresponse( $req, { error => 'Missing parameter' } )
|
||||
unless $req->param('epoch');
|
||||
|
||||
# Retrieve notification reference=$ref with epoch
|
||||
my $notif = $self->_viewNotif( $req, $ref, $req->param('epoch') );
|
||||
$notif =~ s/"checkbox"/"checkbox" checked disabled/g;
|
||||
|
||||
# Return HTML fragment
|
||||
return $self->sendJSONresponse( $req,
|
||||
{ notification => $notif, result => ( $notif ? 1 : 0 ) } );
|
||||
}
|
||||
|
||||
my $_notifications = $self->retrieveNotifs($req);
|
||||
my $msg = scalar @$_notifications ? 'myNotification' : 'noNotification';
|
||||
$msg .= 's' if ( @$_notifications > 1 );
|
||||
my $nbr = @$_notifications;
|
||||
my $msg = $nbr ? 'myNotification' : 'noNotification';
|
||||
$msg .= 's' if ( $nbr > 1 );
|
||||
|
||||
# Display form
|
||||
$self->logger->debug("$nbr accepted notification(s) found");
|
||||
|
||||
# Build template
|
||||
my $params = {
|
||||
PORTAL => $self->conf->{portal},
|
||||
MAIN_LOGO => $self->conf->{portalMainLogo},
|
||||
|
@ -189,7 +195,10 @@ sub myNotifs {
|
|||
NOTIFICATIONS => $_notifications,
|
||||
MSG => $msg
|
||||
};
|
||||
return $self->sendJSONresponse( $req, { %$params, result => $nbr } )
|
||||
if ( $req->wantJSON );
|
||||
|
||||
# Display template
|
||||
return $self->p->sendHtml( $req, 'notifications', params => $params );
|
||||
}
|
||||
|
||||
|
@ -197,25 +206,20 @@ sub retrieveNotifs {
|
|||
my ( $self, $req ) = @_;
|
||||
|
||||
# Retrieve user's accepted notifications
|
||||
my $_notifications = [
|
||||
my @_notifications = sort {
|
||||
$b->{epoch} <=> $a->{epoch}
|
||||
or $a->{reference} cmp $b->{reference}
|
||||
} (
|
||||
map {
|
||||
/^notification_(.+)$/
|
||||
? { reference => $1, epoch => $req->{userData}->{$_} }
|
||||
: ()
|
||||
}
|
||||
keys %{ $req->{userData} }
|
||||
];
|
||||
);
|
||||
splice @_notifications, $self->conf->{notificationsMaxRetrieve};
|
||||
|
||||
@$_notifications = sort {
|
||||
$b->{epoch} <=> $a->{epoch}
|
||||
or $a->{reference} cmp $b->{reference}
|
||||
} @$_notifications;
|
||||
splice @$_notifications, $self->conf->{notificationsMaxRetrieve};
|
||||
|
||||
$self->logger->debug(
|
||||
scalar @$_notifications . " accepted notifications found" );
|
||||
|
||||
return $_notifications;
|
||||
return \@_notifications;
|
||||
}
|
||||
|
||||
sub _viewNotif {
|
||||
|
@ -225,7 +229,7 @@ sub _viewNotif {
|
|||
$self->logger->error($@);
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return $notif;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue