2016-04-13 07:32:10 +02:00
|
|
|
##@file
|
|
|
|
# menu for lemonldap::ng portal
|
|
|
|
package Lemonldap::NG::Portal::Main::Menu;
|
|
|
|
|
|
|
|
use strict;
|
2016-04-20 18:36:30 +02:00
|
|
|
use utf8;
|
2016-04-13 07:32:10 +02:00
|
|
|
use Mouse;
|
|
|
|
use Clone 'clone';
|
|
|
|
|
2017-02-28 21:53:19 +01:00
|
|
|
our $VERSION = '2.0.0';
|
|
|
|
|
2016-06-02 23:20:36 +02:00
|
|
|
extends 'Lemonldap::NG::Common::Module';
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2016-06-09 20:40:20 +02:00
|
|
|
# PROPERTIES
|
|
|
|
|
2016-04-13 13:56:19 +02:00
|
|
|
has menuModules => (
|
|
|
|
is => 'rw',
|
2017-03-27 18:51:18 +02:00
|
|
|
lazy => 1,
|
2016-04-13 13:56:19 +02:00
|
|
|
builder => sub {
|
2017-09-19 09:24:43 +02:00
|
|
|
my $conf = $_[0]->{conf};
|
2016-04-14 20:42:59 +02:00
|
|
|
my @res;
|
2017-09-15 12:32:15 +02:00
|
|
|
foreach (qw(Appslist ChangePassword LoginHistory Logout OidcConsents)) {
|
2016-04-13 13:56:19 +02:00
|
|
|
my $cond = $conf->{"portalDisplay$_"} // 1;
|
2017-02-15 07:41:50 +01:00
|
|
|
$_[0]->p->logger->debug("Evaluate condition $cond for module $_");
|
2016-04-13 23:06:04 +02:00
|
|
|
my $tmp =
|
2017-03-27 22:45:17 +02:00
|
|
|
$_[0]->{p}
|
|
|
|
->HANDLER->buildSub( $_[0]->{p}->HANDLER->substitute($cond) );
|
2016-04-29 09:27:26 +02:00
|
|
|
push @res, [ $_, $tmp ] if ($tmp);
|
2016-04-13 13:56:19 +02:00
|
|
|
}
|
2016-04-14 20:42:59 +02:00
|
|
|
return \@res;
|
2016-04-13 13:56:19 +02:00
|
|
|
}
|
|
|
|
);
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2017-11-01 09:03:03 +01:00
|
|
|
has specific => ( is => 'rw', default => sub { {} } );
|
|
|
|
|
2016-04-13 13:56:19 +02:00
|
|
|
has imgPath => (
|
|
|
|
is => 'rw',
|
2017-03-27 18:51:18 +02:00
|
|
|
lazy => 1,
|
2016-04-13 13:56:19 +02:00
|
|
|
builder => sub {
|
2017-02-15 07:41:50 +01:00
|
|
|
return $_[0]->{conf}->{impgPath}
|
|
|
|
|| $_[0]->{conf}->{staticPrefix} . '/logos';
|
2016-04-13 13:56:19 +02:00
|
|
|
}
|
|
|
|
);
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2016-06-28 22:56:38 +02:00
|
|
|
# INITIALIZATION
|
|
|
|
|
|
|
|
sub init {
|
|
|
|
1;
|
|
|
|
}
|
|
|
|
|
2016-06-09 20:40:20 +02:00
|
|
|
# RUNNING METHODS
|
|
|
|
|
2016-04-13 07:32:10 +02:00
|
|
|
# Prepare menu template elements
|
|
|
|
# Returns hash (=list) containing :
|
|
|
|
# - DISPLAY_MODULES
|
|
|
|
# - DISPLAY_TAB
|
|
|
|
# - AUTH_ERROR
|
|
|
|
# - AUTH_ERROR_TYPE
|
|
|
|
sub params {
|
2016-04-13 13:56:19 +02:00
|
|
|
my ( $self, $req ) = @_;
|
2016-12-30 08:03:48 +01:00
|
|
|
$self->{conf}->{imgPath} ||= $self->{staticPrefix};
|
2016-04-13 13:56:19 +02:00
|
|
|
my %res;
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# Tab to display
|
|
|
|
# Get the tab URL parameter
|
|
|
|
|
|
|
|
# Force password tab in case of password error
|
2016-04-13 13:56:19 +02:00
|
|
|
if (
|
2016-05-23 18:55:16 +02:00
|
|
|
$req->menuError
|
|
|
|
and scalar(
|
|
|
|
grep { $_ == $req->menuError } (
|
|
|
|
25, #PE_PP_CHANGE_AFTER_RESET
|
|
|
|
26, #PE_PP_PASSWORD_MOD_NOT_ALLOWED
|
|
|
|
27, #PE_PP_MUST_SUPPLY_OLD_PASSWORD
|
|
|
|
28, #PE_PP_INSUFFICIENT_PASSWORD_QUALITY
|
|
|
|
29, #PE_PP_PASSWORD_TOO_SHORT
|
|
|
|
30, #PE_PP_PASSWORD_TOO_YOUNG
|
|
|
|
31, #PE_PP_PASSWORD_IN_HISTORY
|
|
|
|
32, #PE_PP_GRACE
|
|
|
|
33, #PE_PP_EXP_WARNING
|
|
|
|
34, #PE_PASSWORD_MISMATCH
|
|
|
|
39, #PE_BADOLDPASSWORD
|
|
|
|
74, #PE_MUST_SUPPLY_OLD_PASSWORD
|
2016-04-13 07:32:10 +02:00
|
|
|
)
|
|
|
|
)
|
2016-04-13 13:56:19 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
$res{DISPLAY_TAB} = "password";
|
|
|
|
}
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2016-04-13 13:56:19 +02:00
|
|
|
# else calculate modules to display
|
|
|
|
else {
|
2016-05-23 18:55:16 +02:00
|
|
|
$res{DISPLAY_TAB} = scalar( grep /^(password|logout|loginHistory)$/,
|
|
|
|
$req->param("tab") // '' )
|
2016-04-13 23:06:04 +02:00
|
|
|
|| "applist";
|
2016-04-13 07:32:10 +02:00
|
|
|
}
|
2016-04-13 23:06:04 +02:00
|
|
|
$res{DISPLAY_MODULES} = $self->displayModules($req);
|
2016-04-13 13:56:19 +02:00
|
|
|
$res{AUTH_ERROR_TYPE} =
|
|
|
|
$req->error_type( $res{AUTH_ERROR} = $req->menuError );
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2016-04-13 23:06:04 +02:00
|
|
|
return %res;
|
2016-04-13 07:32:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
## @method arrayref displayModules()
|
|
|
|
# List modules that can be displayed in Menu
|
|
|
|
# @return modules list
|
|
|
|
sub displayModules {
|
2016-04-13 13:56:19 +02:00
|
|
|
my ( $self, $req ) = @_;
|
2016-04-13 07:32:10 +02:00
|
|
|
my $displayModules = [];
|
|
|
|
|
|
|
|
# Foreach module, eval condition
|
|
|
|
# Store module in result if condition is valid
|
2016-04-14 20:42:59 +02:00
|
|
|
foreach my $module ( @{ $self->menuModules } ) {
|
2017-02-15 07:41:50 +01:00
|
|
|
$self->logger->debug("Check if $module->[0] has to be displayed");
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2017-03-28 23:07:49 +02:00
|
|
|
if ( $module->[1]->( $req, $req->sessionInfo ) ) {
|
2016-04-14 20:42:59 +02:00
|
|
|
my $moduleHash = { $module->[0] => 1 };
|
|
|
|
if ( $module->[0] eq 'Appslist' ) {
|
2016-04-13 13:56:19 +02:00
|
|
|
$moduleHash->{'APPSLIST_LOOP'} = $self->appslist($req);
|
|
|
|
}
|
2016-04-14 20:42:59 +02:00
|
|
|
elsif ( $module->[0] eq 'LoginHistory' ) {
|
2016-04-13 07:32:10 +02:00
|
|
|
$moduleHash->{'SUCCESS_LOGIN'} =
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->p->mkSessionArray(
|
2017-03-21 22:00:37 +01:00
|
|
|
$req->{sessionInfo}->{_loginHistory}->{successLogin},
|
2016-04-13 07:32:10 +02:00
|
|
|
"", 0, 0 );
|
|
|
|
$moduleHash->{'FAILED_LOGIN'} =
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->p->mkSessionArray(
|
2017-03-21 22:00:37 +01:00
|
|
|
$req->{sessionInfo}->{_loginHistory}->{failedLogin},
|
2016-04-13 07:32:10 +02:00
|
|
|
"", 0, 1 );
|
|
|
|
}
|
2017-09-15 14:31:42 +02:00
|
|
|
elsif ( $module->[0] eq 'OidcConsents' ) {
|
|
|
|
$moduleHash->{'OIDC_CONSENTS'} =
|
|
|
|
$self->p->mkOidcConsent( $req->sessionInfo );
|
|
|
|
}
|
2016-04-13 07:32:10 +02:00
|
|
|
push @$displayModules, $moduleHash;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $displayModules;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method arrayref appslist()
|
|
|
|
# Returns categories and applications list as HTML::Template loop
|
|
|
|
# @return categories and applications list
|
|
|
|
sub appslist {
|
2016-04-13 13:56:19 +02:00
|
|
|
my ( $self, $req ) = @_;
|
2016-04-13 07:32:10 +02:00
|
|
|
my $appslist = [];
|
|
|
|
|
2016-04-13 13:56:19 +02:00
|
|
|
return $appslist unless defined $self->conf->{applicationList};
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# Reset level
|
|
|
|
my $catlevel = 0;
|
|
|
|
|
2016-04-13 13:56:19 +02:00
|
|
|
my $applicationList = clone( $self->conf->{applicationList} );
|
|
|
|
my $filteredList = $self->_filter( $req, $applicationList );
|
|
|
|
push @$appslist,
|
|
|
|
$self->_buildCategoryHash( $req, "", $filteredList, $catlevel );
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# We must return an ARRAY ref
|
|
|
|
return ( ref $appslist->[0]->{categories} eq "ARRAY" )
|
|
|
|
? $appslist->[0]->{categories}
|
|
|
|
: [];
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method private hashref _buildCategoryHash(string catname,hashref cathash, int catlevel)
|
|
|
|
# Build hash for a category
|
|
|
|
# @param catname Category name
|
|
|
|
# @param cathash Hash of category elements
|
|
|
|
# @param catlevel Category level
|
|
|
|
# @return Category Hash
|
|
|
|
sub _buildCategoryHash {
|
2016-04-13 13:56:19 +02:00
|
|
|
my ( $self, $req, $catid, $cathash, $catlevel ) = @_;
|
2016-04-13 07:32:10 +02:00
|
|
|
my $catname = $cathash->{catname} || $catid;
|
2016-04-20 18:36:30 +02:00
|
|
|
utf8::decode($catname);
|
2016-04-13 07:32:10 +02:00
|
|
|
my $applications;
|
|
|
|
my $categories;
|
|
|
|
|
|
|
|
# Extract applications from hash
|
|
|
|
my $apphash;
|
|
|
|
foreach my $catkey ( sort keys %$cathash ) {
|
|
|
|
next if $catkey =~ /(type|options|catname)/;
|
|
|
|
if ( $cathash->{$catkey}->{type} eq "application" ) {
|
|
|
|
$apphash->{$catkey} = $cathash->{$catkey};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Display applications first
|
|
|
|
if ( scalar keys %$apphash > 0 ) {
|
|
|
|
foreach my $appkey ( sort keys %$apphash ) {
|
|
|
|
push @$applications,
|
|
|
|
$self->_buildApplicationHash( $appkey, $apphash->{$appkey} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Display subcategories
|
|
|
|
foreach my $catkey ( sort keys %$cathash ) {
|
|
|
|
next if $catkey =~ /(type|options|catname)/;
|
|
|
|
if ( $cathash->{$catkey}->{type} eq "category" ) {
|
|
|
|
push @$categories,
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->_buildCategoryHash( $req, $catkey, $cathash->{$catkey},
|
2016-04-13 07:32:10 +02:00
|
|
|
$catlevel + 1 );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $categoryHash = {
|
|
|
|
category => 1,
|
|
|
|
catname => $catname,
|
|
|
|
catid => $catid,
|
|
|
|
catlevel => $catlevel
|
|
|
|
};
|
|
|
|
$categoryHash->{applications} = $applications if $applications;
|
|
|
|
$categoryHash->{categories} = $categories if $categories;
|
|
|
|
return $categoryHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method private hashref _buildApplicationHash(string appid, hashref apphash)
|
|
|
|
# Build hash for an application
|
|
|
|
# @param $appid Application ID
|
|
|
|
# @param $apphash Hash of application elements
|
|
|
|
# @return Application Hash
|
|
|
|
sub _buildApplicationHash {
|
|
|
|
my ( $self, $appid, $apphash ) = @_;
|
|
|
|
my $applications;
|
|
|
|
|
|
|
|
# Get application items
|
|
|
|
my $appname = $apphash->{options}->{name} || $appid;
|
|
|
|
my $appuri = $apphash->{options}->{uri} || "";
|
|
|
|
my $appdesc = $apphash->{options}->{description};
|
|
|
|
my $applogo = $apphash->{options}->{logo};
|
2016-04-20 18:36:30 +02:00
|
|
|
utf8::decode($appname);
|
|
|
|
utf8::decode($appdesc) if $appdesc;
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# Detect sub applications
|
|
|
|
my $subapphash;
|
|
|
|
foreach my $key ( sort keys %$apphash ) {
|
|
|
|
next if $key =~ /(type|options|catname)/;
|
|
|
|
if ( $apphash->{$key}->{type} eq "application" ) {
|
|
|
|
$subapphash->{$key} = $apphash->{$key};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Display sub applications
|
|
|
|
if ( scalar keys %$subapphash > 0 ) {
|
|
|
|
foreach my $appkey ( sort keys %$subapphash ) {
|
|
|
|
push @$applications,
|
|
|
|
$self->_buildApplicationHash( $appkey, $subapphash->{$appkey} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $applicationHash = {
|
|
|
|
application => 1,
|
|
|
|
appname => $appname,
|
|
|
|
appuri => $appuri,
|
|
|
|
appdesc => $appdesc,
|
|
|
|
applogo => $applogo,
|
|
|
|
appid => $appid,
|
|
|
|
};
|
|
|
|
$applicationHash->{applications} = $applications if $applications;
|
|
|
|
return $applicationHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method private string _filter(hashref apphash)
|
|
|
|
# Duplicate hash reference
|
|
|
|
# Remove unauthorized menu elements
|
|
|
|
# Hide empty categories
|
|
|
|
# @param $apphash Menu elements
|
|
|
|
# @return filtered hash
|
|
|
|
sub _filter {
|
2016-04-13 13:56:19 +02:00
|
|
|
my ( $self, $req, $apphash ) = @_;
|
2016-04-13 07:32:10 +02:00
|
|
|
my $filteredHash;
|
|
|
|
my $key;
|
|
|
|
|
|
|
|
# Copy hash reference into a new hash
|
|
|
|
foreach $key ( keys %$apphash ) {
|
|
|
|
$filteredHash->{$key} = $apphash->{$key};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Filter hash
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->_filterHash( $req, $filteredHash );
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# Hide empty categories
|
|
|
|
$self->_isCategoryEmpty($filteredHash);
|
|
|
|
|
|
|
|
return $filteredHash;
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method private string _filterHash(hashref apphash)
|
|
|
|
# Remove unauthorized menu elements
|
|
|
|
# @param $apphash Menu elements
|
|
|
|
# @return filtered hash
|
|
|
|
sub _filterHash {
|
2016-04-13 23:06:04 +02:00
|
|
|
my ( $self, $req, $apphash ) = @_;
|
2016-04-13 07:32:10 +02:00
|
|
|
|
2016-04-13 23:06:04 +02:00
|
|
|
foreach my $key ( keys %$apphash ) {
|
2016-04-13 07:32:10 +02:00
|
|
|
next if $key =~ /(type|options|catname)/;
|
|
|
|
if ( $apphash->{$key}->{type}
|
|
|
|
and $apphash->{$key}->{type} eq "category" )
|
|
|
|
{
|
|
|
|
|
|
|
|
# Filter the category
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->_filterHash( $req, $apphash->{$key} );
|
2016-04-13 07:32:10 +02:00
|
|
|
}
|
|
|
|
if ( $apphash->{$key}->{type}
|
|
|
|
and $apphash->{$key}->{type} eq "application" )
|
|
|
|
{
|
|
|
|
|
|
|
|
# Find sub applications and filter them
|
2016-04-13 23:06:04 +02:00
|
|
|
foreach my $appkey ( keys %{ $apphash->{$key} } ) {
|
2016-04-13 07:32:10 +02:00
|
|
|
next if $appkey =~ /(type|options|catname)/;
|
|
|
|
|
|
|
|
# We have sub elements, so we filter them
|
2016-04-13 23:06:04 +02:00
|
|
|
$self->_filterHash( $req, $apphash->{$key} );
|
2016-04-13 07:32:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Check rights
|
|
|
|
my $appdisplay = $apphash->{$key}->{options}->{display}
|
|
|
|
|| "auto";
|
2016-04-13 23:06:04 +02:00
|
|
|
my ( $vhost, $appuri ) =
|
|
|
|
$apphash->{$key}->{options}->{uri} =~ m#^https?://([^/]*)(.*)#;
|
|
|
|
$vhost =~ s/:\d+$//;
|
2017-10-24 12:56:21 +02:00
|
|
|
$vhost = $self->p->HANDLER->resolveAlias($vhost);
|
2016-04-13 23:06:04 +02:00
|
|
|
$appuri ||= '/';
|
2016-04-13 07:32:10 +02:00
|
|
|
|
|
|
|
# Remove if display is "no" or "off"
|
|
|
|
delete $apphash->{$key} and next if ( $appdisplay =~ /^(no|off)$/ );
|
|
|
|
|
|
|
|
# Keep node if display is "yes" or "on"
|
|
|
|
next if ( $appdisplay =~ /^(yes|on)$/ );
|
|
|
|
|
2017-07-17 16:03:45 +02:00
|
|
|
my $cond = undef;
|
2017-11-01 09:03:03 +01:00
|
|
|
|
2017-11-11 17:39:24 +01:00
|
|
|
# Handle partner rules (SAML, CAS or OIDC)
|
2017-11-12 07:34:45 +01:00
|
|
|
if ( $appdisplay =~ /^sp:\s*(.*)$/ ) {
|
2017-11-11 17:39:24 +01:00
|
|
|
my $p = $1;
|
2017-11-11 21:16:52 +01:00
|
|
|
if ( my $sub = $self->p->spRules->{$p} ) {
|
2017-11-11 17:39:24 +01:00
|
|
|
eval {
|
|
|
|
delete $apphash->{$key}
|
2017-11-11 21:16:52 +01:00
|
|
|
unless ( $sub->( $req, $req->sessionInfo ) );
|
2017-11-11 17:39:24 +01:00
|
|
|
};
|
|
|
|
if ($@) {
|
|
|
|
$self->logger->error("Partner rule $p returns: $@");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2017-11-01 09:03:03 +01:00
|
|
|
# If a specific rule exists, get it from cache or compile it
|
2017-07-17 16:03:45 +02:00
|
|
|
if ( $appdisplay !~ /^auto$/i ) {
|
2017-11-01 09:03:03 +01:00
|
|
|
if ( $self->specific->{$appuri} ) {
|
|
|
|
$cond = $self->specific->{$appuri};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$cond = $self->specific->{$appuri} =
|
|
|
|
$self->p->HANDLER->buildSub(
|
|
|
|
$self->p->HANDLER->substitute($appdisplay) );
|
|
|
|
}
|
2017-07-17 16:03:45 +02:00
|
|
|
}
|
|
|
|
|
2016-04-13 07:32:10 +02:00
|
|
|
# Check grant function if display is "auto" (this is the default)
|
2016-04-13 23:06:04 +02:00
|
|
|
delete $apphash->{$key}
|
2016-08-03 09:31:36 +02:00
|
|
|
unless (
|
|
|
|
$self->p->HANDLER->grant(
|
2017-07-17 16:03:45 +02:00
|
|
|
$req, $req->sessionInfo, $appuri, $cond, $vhost
|
2016-08-03 09:31:36 +02:00
|
|
|
)
|
|
|
|
);
|
2016-04-13 07:32:10 +02:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
## @method private void _isCategoryEmpty(hashref apphash)
|
|
|
|
# Check if a category is empty
|
|
|
|
# @param $apphash Menu elements
|
|
|
|
# @return boolean
|
|
|
|
sub _isCategoryEmpty {
|
|
|
|
my $self = shift;
|
|
|
|
my ($apphash) = @_;
|
|
|
|
my $key;
|
|
|
|
|
|
|
|
# Test sub categories
|
|
|
|
foreach $key ( keys %$apphash ) {
|
|
|
|
next if $key =~ /(type|options|catname)/;
|
|
|
|
if ( $apphash->{$key}->{type}
|
|
|
|
and $apphash->{$key}->{type} eq "category" )
|
|
|
|
{
|
|
|
|
delete $apphash->{$key}
|
|
|
|
if $self->_isCategoryEmpty( $apphash->{$key} );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test this category
|
|
|
|
if ( $apphash->{type} and $apphash->{type} eq "category" ) {
|
|
|
|
|
|
|
|
# Temporary store 'options'
|
|
|
|
my $tmp_options = $apphash->{options};
|
|
|
|
my $tmp_catname = $apphash->{catname};
|
|
|
|
|
|
|
|
delete $apphash->{type};
|
|
|
|
delete $apphash->{options};
|
|
|
|
delete $apphash->{catname};
|
|
|
|
|
|
|
|
if ( scalar( keys %$apphash ) ) {
|
|
|
|
|
|
|
|
# There are sub categories or sub applications
|
|
|
|
# Restore type and options
|
|
|
|
$apphash->{type} = "category";
|
|
|
|
$apphash->{options} = $tmp_options;
|
|
|
|
$apphash->{catname} = $tmp_catname;
|
|
|
|
|
|
|
|
# Return false
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
# Return true
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|