blib/lib/Lemonldap/NG/Portal/Main/Plugin.pm

filter: Statementstmt 59.0% 39 / 66 Branchbran 25.0% 2 / 8 Conditioncond 20.0% 1 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 77.7% 14 / 18 Podpod 0.0% 0 / 10 totaltotal 50.9% 56 / 110 CC 8 SCAR 17.2
CC
8
Cov
53%
createNotification
20.0
addSessionDataToRemember
12.0
_addRoute
2.0
CRAP 5.6
« blib/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Auth.pm »
1 # Base package for LLNG portal plugins. It adds somme wrapper to
2 # Lemonldap::NG::Handler::PSGI::Try (base of portal)
3 package Lemonldap::NG::Portal::Main::Plugin;
4  
5 457 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 457 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 457 ▶use HTML::Template;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 457 ▶use Lemonldap::NG::Portal::Main::Constants qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 PE_OK
10 PE_INFO
11 PE_ERROR
12 457 );
13  
14 457 our $VERSION = '2.23.0';
15  
16 457 extends 'Lemonldap::NG::Common::Module';
17  
18 19 ▶sub sendError {
Subroutine sendError: called CC=1 SCAR=0.0
Pod undocumented
19 19 my $self = shift;
20 19 return $self->p->sendError(@_);
21 }
22  
23 10 ▶sub sendJSONresponse {
Subroutine sendJSONresponse: called CC=1 SCAR=0.0
Pod undocumented
24 10 my $self = shift;
25 10 return $self->p->sendJSONresponse(@_);
26 }
27  
28 6127 ▶sub addAuthRoute {
Subroutine addAuthRoute: called CC=1 SCAR=0.0
Pod undocumented
29 6127 my $self = shift;
30 6127 return $self->_addRoute( 'addAuthRoute', @_ );
31 }
32  
33 3134 ▶sub addUnauthRoute {
Subroutine addUnauthRoute: called CC=1 SCAR=0.0
Pod undocumented
34 3134 my $self = shift;
35 3134 return $self->_addRoute( 'addUnauthRoute', @_ );
36 }
37  
38 0 ▶sub addAuthRouteWithRedirect {
Subroutine addAuthRouteWithRedirect: not called CC=1 SCAR=6.9
Pod undocumented
39 0 my $self = shift;
40 0 return $self->_addRoute( 'addAuthRouteWithRedirect', @_ );
41 }
42  
43 9261 ▶sub _addRoute {
Subroutine _addRoute: called CC=2 SCAR=7.0
44 9261 my ( $self, $type, $word, $subName, $methods, $transform ) = @_;
45 12294 ▶ $transform //= sub {
Subroutine __ANON__: called CC=2 SCAR=6.9
46 12294 my ($sub) = @_;
47 12294 ▶ if ( ref $sub ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $sub) { } 140 12154 12294
48 85 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
49 85 shift;
50 85 return $sub->( $self, @_ );
51 }
52 140 }
53 else {
54 253 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
55 253 shift;
56 253 return $self->$sub(@_);
57 }
58 12154 }
59 9261 ▶ };
Condition33%1/3
$transform //= sub { my($sub) = @_; if (ref $sub) { return sub { shift(); return &$sub($self, @_); } ; } else { return sub { shift(); return $self->$sub(@_); } ; } ; }
l!l&&r!l&&!r
092610
MC/DC0%0/2
$transform //= sub { my($sub) = @_; if (ref $sub) { return sub { shift(); return &$sub($self, @_); } ; } else { return sub { shift(); return $self->$sub(@_); } ; } ; }
$transform sub { my($sub) = @_; if (ref $sub) { return sub { shift(); return &$sub($self, @_); } ; } else { return sub { shift(); return $self->$sub(@_); } ; } ; }
Truth table33%1/3
A //= B
A= $transformB= sub { my($sub) = @_; if (ref $sub) { return sub { shift(); return &$sub($self, @_); } ; } else { return sub { shift(); return $self->$sub(@_); } ; } ; }
ABresult
1X1
011
000
60 9261 $self->p->$type( $word, $subName, $methods, $transform );
61 9261 return $self;
62 }
63  
64 14 ▶sub loadTemplate {
Subroutine loadTemplate: called CC=1 SCAR=0.0
Pod undocumented
65 14 my $self = shift;
66 14 return $self->p->loadTemplate(@_);
67 }
68  
69 0 ▶sub displayTemplate {
Subroutine displayTemplate: not called CC=1 SCAR=6.9
Pod undocumented
70 0 my ( $self, $req, $template, $params ) = @_;
71 0 $self->logger->debug("Return $template template");
72 0 $req->info( $self->loadTemplate( $req, $template, params => $params ) );
73 0 return PE_INFO;
74 }
75  
76 0 ▶sub createNotification {
Subroutine createNotification: not called CC=4 SCAR=30.0
Pod undocumented
77 0 my ( $self, $req, $uid, $date, $ref, $title, $msg ) = @_;
78 my $notifEngine = $self->p->loadedModules->{
79 0 'Lemonldap::NG::Portal::Plugins::Notifications'};
80  
81 0 $self->logger->debug("Loading Notifications plugin...");
82 0 ▶ return PE_ERROR unless $notifEngine;
Branch: 1 branch
BranchTrueFalseTotal
unless $notifEngine 0 0 0
83  
84 # Prepare notification
85 my $content =
86 $self->conf->{oldNotifFormat}
87 0 ▶ ? '<?xml version="1.0" encoding="UTF-8"?><root><notification uid="_uid_" date="_date_" reference="_ref_"><title>_title_</title><text>_msg_</text></notification></root>'
Branch: 1 branch
BranchTrueFalseTotal
$self->conf->{'oldNotifFormat'} ? : 0 0 0
88 : '[{"uid":"_uid_","date":"_date_","title":"_title_","reference":"_ref_","text":"_msg_"}]';
89 0 $content =~ s/_uid_/$uid/;
90 0 $content =~ s/_date_/$date/;
91 0 $content =~ s/_ref_/$ref/;
92 0 $content =~ s/_title_/$title/;
93 0 $content =~ s/_msg_/$msg/;
94  
95 0 ▶ if ( $notifEngine->module->notifObject->newNotification($content) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($notifEngine->module->notifObject->newNotification($content)) { } 0 0 0
96 0 $self->logger->debug("Notification $ref successfully created");
97 0 $self->auditLog(
98 $req,
99 message =>
100 ("Notification $ref / $date successfully created for $uid"),
101 code => "NOTIFICATION_CREATED",
102 ref => $ref,
103 date => $date,
104 user => $uid,
105 );
106 0 return PE_OK;
107 }
108 else {
109 0 $self->logger->debug("Notification $ref NOT created!");
110 0 return PE_ERROR;
111 }
112 }
113  
114 0 ▶sub addSessionDataToRemember {
Subroutine addSessionDataToRemember: not called CC=3 SCAR=24.8
Pod undocumented
115 0 my ( $self, $newData ) = @_;
116 0 ▶ for my $sessionAttr ( keys %{ $newData || {} } ) {
Condition0%0/2
$newData || {}
l!l
00
MC/DC0%0/1
$newData || {}
$newData
Truth table0%0/2
A
A= $newData
Aresult
11
00
117 $self->p->pluginSessionDataToRemember->{$sessionAttr} =
118 0 $newData->{$sessionAttr};
119 }
120 0 return;
121 }
122  
123 2013 ▶sub addEntryPoint {
Subroutine addEntryPoint: called CC=1 SCAR=0.0
Pod undocumented
124 2013 my ( $self, %entryPointDescription ) = @_;
125 2013 return $self->p->_addPluginEntryPoint( %entryPointDescription,
126 _pkg => ref($self) );
127 }
128  
129 457 1;
130 __END__
« blib/lib/Lemonldap/NG/Portal/Plugins/AutoSignin.pm ↑ Summary blib/lib/Lemonldap/NG/Portal/Main/Auth.pm »