Commit 8129d76d authored by Christophe Maudoux's avatar Christophe Maudoux 🐛
Browse files

Improve code

parent f1202909
......@@ -114,33 +114,20 @@ sub params {
$self->p->_sfEngine->display2fRegisters( $req, $req->userData );
$self->logger->debug("Display 2fRegisters link") if $res{sfaManager};
# Display ContextSwitching link only if allowed
my $cswPlugin = $self->p->loadedModules->{
'Lemonldap::NG::Portal::Plugins::ContextSwitching'};
$res{contextSwitching} =
$cswPlugin
? $cswPlugin->displaySwitchContext( $req, $req->userData )
: '';
$self->logger->debug("Display SwitchContext link -> $res{contextSwitching}")
if $res{contextSwitching};
# Display DecryptValue link if allowed
my $dvPlugin =
$self->p->loadedModules->{'Lemonldap::NG::Portal::Plugins::DecryptValue'};
$res{decryptValue} =
$dvPlugin
? $dvPlugin->displayLink( $req, $req->userData )
: '';
$self->logger->debug("Display DecryptValue link") if $res{decryptValue};
# Display NotifsExplorer link if allowed
my $notifsPlugin =
$self->p->loadedModules->{'Lemonldap::NG::Portal::Plugins::Notifications'};
$res{notifsExplorer} =
$notifsPlugin
? $notifsPlugin->displayLink( $req, $req->userData )
: '';
$self->logger->debug("Display NotifsExplorer link") if $res{notifsExplorer};
# Display menu links only if required
foreach (qw(ContextSwitching DecryptValue Notifications)) {
my $plugin =
$self->p->loadedModules->{"Lemonldap::NG::Portal::Plugins::$_"};
$res{$_} =
$plugin
? $plugin->displayLink( $req, $req->userData )
: '';
my $msg = "Display $_ link";
$msg .= " -> $res{ContextSwitching}"
if ( $_ eq 'ContextSwitching' && $res{$_} );
$self->logger->debug($msg) if $res{$_};
$plugin = undef;
}
return %res;
}
......
......@@ -282,7 +282,7 @@ sub _abortImpersonation {
return $req;
}
sub displaySwitchContext {
sub displayLink {
my ( $self, $req ) = @_;
return 'OFF'
if $req->userData->{"$self->{conf}->{impersonationPrefix}_session_id"};
......
......@@ -67,21 +67,21 @@
<span trspan="sfaManager">sfaManager</span>
</a></li>
</TMPL_IF>
<TMPL_IF NAME="contextSwitching">
<TMPL_IF NAME="ContextSwitching">
<li class="dropdown-item"><a href="/switchcontext" class="nav-link">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/switchcontext_<TMPL_VAR NAME="contextSwitching">.png" width="20" height="20" alt="switchContext" />
<span trspan="contextSwitching_<TMPL_VAR NAME="contextSwitching">">contextSwitching_<TMPL_VAR NAME="contextSwitching"></span>
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/switchcontext_<TMPL_VAR NAME="contextSwitching">.png" width="20" height="20" alt="ContentSwitching" />
<span trspan="contextSwitching_<TMPL_VAR NAME="contextSwitching">">contextSwitching_<TMPL_VAR NAME="ContextSwitching"></span>
</a></li>
</TMPL_IF>
<TMPL_IF NAME="decryptValue">
<TMPL_IF NAME="DecryptValue">
<li class="dropdown-item"><a href="/decryptvalue" class="nav-link">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/decryptValue.png" width="20" height="20" alt="decryptValue" />
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/decryptValue.png" width="20" height="20" alt="DecryptValue" />
<span trspan="decryptCipheredValue">decryptCipheredValue</span>
</a></li>
</TMPL_IF>
<TMPL_IF NAME="notifsExplorer">
<TMPL_IF NAME="Notifications">
<li class="dropdown-item"><a href="/mynotifications" class="nav-link">
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/notifsExplorer.png" width="20" height="20" alt="notificationsExplorer" />
<img src="<TMPL_VAR NAME="STATIC_PREFIX">common/icons/notifsExplorer.png" width="20" height="20" alt="NotificationsExplorer" />
<span trspan="notificationsExplorer">notificationsExplorer</span>
</a></li>
</TMPL_IF>
......
Markdown is supported
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