sharee.bike/copri4/shareeweb-project/src/Lib/Mlogic.pm

185 lines
6.2 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
package Mlogic;
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI ':standard';
use Mod::Buttons;
use Mod::Libenzdb;
use Mod::DBtank;
use Data::Dumper;
my $q = new CGI;
my $db = new Libenzdb;
my $dbt = new DBtank;
my $but = new Buttons;
sub new {
my $class = shift;
my $self = {};
bless($self,$class);
return $self;
}
#Template
sub tpl(){
my $self = shift;
my ($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return) = @_;
my $lang = "de";
my $debug = 0;
$debug = 1;
my $dbh = "";
my $session="";
my $session_and="";
if($R::sessionid && length($R::sessionid) > 20 && !$q->cookie(-name=>'domcookie')){
$session = "?sessionid=$R::sessionid";
$session_and = "&sessionid=$R::sessionid";
}
my $bgcolor1 = "yellow";
my $parent_node = "app";
my $node = {};
my $rows = 0;
$bgcolor1 = $dbt->{website}->{$varenv->{syshost}}->{bgcolor1};
$parent_node = $dbt->{website}->{$varenv->{syshost}}->{parent_node};
($node,$rows) = $dbt->collect_noderel($dbh,$dbt->{website}->{$varenv->{syshost}}->{parent_id});
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2" && ($users_sharee->{c_id} eq $varenv->{superu_id} || $dbt->{copri_conf}->{stage} eq "test")){
my $coo = $q->cookie('domcookie') || $q->param('sessionid') || "";
print $q->div({-style=>'float:right;text-align:right;height:25px;padding:6px 15px;background-color:white'},$q->a({-style=>"color:#$bgcolor1;", -href=>"$varenv->{metahost}/src/scripts/tests/index.pl?sessionid=$coo", -target=>'_blank'}," [ booking-test ] ")),"\n";
}
if($users_sharee->{c_id} && $R::sharee_edit ne "delete_account2"){
print $q->div({-style=>'text-align:right;height:25px;padding:6px 15px 6px 0px;background-color:white'},"$users_sharee->{txt08}",$q->a({-style=>"color:#$bgcolor1;", -href=>"logout_sharee$session"},"logout")),"\n";
}
if(1==1){
print "<style>
ul#TopNavi {
margin:20px 0;
padding:0;
vertical-align:top;
border: 0px solid white;
}
ul#TopNavi li {
list-style: none;
display: inline;
margin: 0 4px 0 0;
}
ul#TopNavi li a {
transition: all 0.3s ease;
margin: 0;
padding: 1em 3%;
width:100px;
background-color: #$bgcolor1;
text-decoration: none;
font-weight: normal;
color: white;
}
ul#TopNavi a:hover {
color: black;
background-color: white;
}
ul#TopNavi a:active {
color: white;
background-color: gray;
}
</style>";
my $lmenu0 = "";
foreach my $id (sort {$node->{$a}->{n_sort} <=> $node->{$b}->{n_sort}} keys (%$node)){
#if($node->{$id}->{main_id} && $node->{$id}->{node_name} =~ /$dbt->{shareeapp_conf}->{mod_active}/){
$node->{$id}->{node_path} = $node->{$id}->{node_name} if(!$node->{$id}->{node_path});
my $mstyle = "";
#print "$node->{$id}->{main_id} eq $node_meta->{main_id}|$node_meta->{parent_id}|$node_meta->{template_id}|$node->{$id}->{node_name} - $node_meta->{node_name}<br />\n" if($debug);
if($node->{$id}->{main_id} == $node_meta->{main_id} || $node->{$id}->{main_id} == $node_meta->{parent_id}){
$mstyle = "background-color:silver;color:black;";
}
if($node->{$id}->{node_name} eq "Anmelden" && $node_meta->{parent_id} == 200010){
$mstyle = "background-color:silver;color:black;";
}
if($node->{$id}->{node_name} eq "Anmelden" && $users_sharee->{c_id}){
$lmenu0 .= $but->lia_button("/$parent_node/$varenv->{profile}$session","Mein Profil",$node->{$id}->{main_id},"","$mstyle",$users_dms->{u_id});
}else{
$lmenu0 .= $but->lia_button("/$parent_node/$node->{$id}->{node_path}",$node->{$id}->{node_name},$node->{$id}->{main_id},"","$mstyle",$users_dms->{u_id});
}
}
#}
#print "<div class='container' style='border:0px dotted black;'>\n";
print $q->div({-style=>'text-align:left;border:0px dotted black;'},$q->ul({-id=>'TopNavi'},$lmenu0)),"\n";
#print "</div>\n";
#end Topmenue
if(($node_meta->{tpl_id} == 1 || $node_meta->{tpl_id} == 3) && $node_meta->{main_id} == 200017){
require "Tpl/Karte.pm";
&Karte::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}else{
# print "<div class='container'>\n";
print "<div id='Contenttxt' style='margin:40px 5px 40px 0;border:0px dotted black;'>\n";
$self->tplselect($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
print "</div>\n";
#print "</div>\n";
}
}
}
#2021-05-05 changed to Mlogic
sub tplselect(){
my $self = shift;
my $node_meta = shift;
my $users_dms = shift || "";
my $mode = shift || "";
my $varenv = shift;
my $users_sharee = shift || "";
my $return = shift || "";
my $u_id = $users_dms->{u_id} || "";
my $lang = "de";
my $tpl_id = $node_meta->{tpl_id};
if($node_meta->{main_id}){
if($tpl_id == 2){
require "Tpl/Anmelden.pm";
&Anmelden::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}elsif($tpl_id == 302 || $tpl_id == 302008 || $tpl_id == 302004){#Adresse
require "Tpl/FormEdit.pm";
&FormEdit::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}elsif($tpl_id == 308){
require "Tpl/PayoneSelect.pm";
&PayoneSelect::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}elsif($tpl_id == 197){
require "Tpl/Contact.pm";
&Contact::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}elsif($tpl_id == 1 || $tpl_id == 3){
require "Tpl/Listing.pm";
&Listing::tpl($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
#require "Tpl/ModalboxDialog.pm";
#&ModalboxDialog::mobox2($node_meta,$users_dms,$mode,$varenv,$users_sharee,$return);
}
}
print "<script type='text/javascript' src='$varenv->{metahost}/js/iframeResizer.contentWindow.min.js'></script>\n";
my $debug_footer = "Mlogic --> (syshost: $varenv->{syshost} | users_sharee->{c_id}: $users_sharee->{c_id} | ct_table: $node_meta->{ct_table} | parent_id: $node_meta->{parent_id} | main_id: $node_meta->{main_id} | tpl_id: $node_meta->{tpl_id} | u_id: $u_id | mode: $mode)";
print $q->div({-style=>'position:fixed;bottom:0%;right:2%;z-index:10;font-size:13px;'},"$debug_footer"),"\n" if($users_sharee->{c_id} eq $varenv->{superu_id});
if($return && $return =~ /failure/){
require "Mod/Failure.pm";
&Failure::tpl("",$u_id,"","","","",$return);
}
}
1;