package ONO::FW::Edu::Apps::ToolBox;
################################################################################
# COPYRIGHT / LICENSE #
################################################################################
#
# This file is part of the ONO Software Project.
#
# Copyright (C) 2022-2026 Jos Kirps and The Joopita Project [ASBL]
# Copyright (C) 2011-2022 Jos Kirps and Joopita Research ASBL
# Copyright (C) 2006-2011 Jos Kirps and The Joopita Project
# Copyright (C) 2001-2006 Jos Kirps and The WobbleWolf Project
#
# This file, as well as many other parts of the ONO Software Project or
# related elements, are FREE SOFTWARE available under the ARTISTIC LICENSE 2.0.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# For the full license, see /ono/osr/license/LICENSE.txt, or write to
# jos_AT_kirps_DOT_com or contact_AT_joopita_DOT_com.
#
################################################################################
# END OF COPYRIGHT / LICENSE, HERE COMES THE CODE ... #
################################################################################
use strict;
use ONO::IO;
use ONO::Lib::Web::LocateIP;
#: This is the Morzino front end application module TooBox.
###############################################################################
# ONO
###############################################################################
use ONO::FW::Edu::Apps::Variation;
my $VARIATION = ONO::FW::Edu::Apps::Variation->variation();
###############################################################################
# ONO
###############################################################################
sub apps_gate {
#: This makes sure that Morzino applications will only be available to
#: the right visitors.
my (
$self,
$WEB,
$vars_ref,
) = @_;
my %vars = %$vars_ref;
my $community = ONO::IO->community();
if (ONO::IO->devstation) {
# $vars{'username'} = "";
}
my ($valid_username,$valid_oli_in_lux);
if ($vars{'username'}) {
$valid_username = 1;
}
if (!$valid_username) {
if ($community eq "school") {
if (ONO::Lib::Web::LocateIP->locate_country_lu(ONO::Lib::Web::Client->ip(),1)) {
$valid_oli_in_lux = 1;
}
}
}
if ($community eq "morzino") {
$valid_oli_in_lux = 1;
}
if ($valid_username || $valid_oli_in_lux) {
# successfully display the app
} else {
# login and/or location blocking
my @txt = (
"Login",
"You must be logged in to use this app.",
"login now",
);
if ($vars{'app_lang'} eq "de") {
@txt = (
"Login",
"Du musst eingeloggt sein, um diese App nutzen zu können.",
"jetzt einloggen",
);
}
if ($vars{'app_lang'} eq "lu") {
@txt = (
"Login",
"Du muss ageloggt sinn fir dës App ze benotzen.",
"elo aloggen",
);
}
if ($vars{'app_lang'} eq "fr") {
@txt = (
"Login",
"Vous devez être connecté pour utiliser cette application.",
"se connecter",
);
}
my $LOGIN = "/account/";
if ($community eq "school") {
$LOGIN = &saml_login();
}
$WEB =~ s~\<form~\<form_disabled~gi;
$WEB =~ s~\<\/form~\<\/form_disabled~gi;
my $DIMS = "width:920px;height:480px";
my $TRANS = "trans40";
if ($ENV{'SCRIPT_NAME'} =~ /index_(worksheet|bookmaker)/) {
$DIMS = "width:100%;height:100%;z-index:999";
$TRANS = "trans60";
}
$WEB .= qq~<div class="abs overhide" style="$DIMS;top:0px;left:0px">
<div class="bg_paper abs $TRANS" style="$DIMS;top:0px;left:0px"></div>
<div class="abs" style="$DIMS;top:160px;left:0px">
<div class="inline auto w40">
<div class="box_blue">
<h3 class="cole">$txt[0]</h3>
<div class="box_paper">
<div class="large col6">$txt[1]</div>
<div class="inline"><a href="$LOGIN" class="button_green button_big mt10" target="_parent">$txt[2]</a></div>
</div>
</div>
</div>
</div>
</div>
~;
}
return $WEB;
}
sub saml_login {
#: Login linker for platforms using SAML authentication.
my $lang = "lu";
if (length $_[1] == 2) {
$lang = $_[1];
}
my $SERVER = $ENV{'SERVER_NAME'};
if ($SERVER =~ /^172\./) {
$SERVER = "ssl.education.lu";
}
return "https://$SERVER/oli/$lang/cgi-bin/local/perl/school/cgie/login.pl";
}
###############################################################################
# end of script
###############################################################################
1;
__END__