package RelationEdit; # ## # SPDX-License-Identifier: AGPL-3.0-or-later # Copyright (c) Rainer Gümpelein, TeilRad GmbH # use strict; use warnings; use CGI; use CGI::Carp qw(fatalsToBrowser); use CGI ':standard'; use Lib::Config; use Mod::Buttons; use Mod::Libenz; use Mod::Libenzdb; sub new { my $class = shift; my $self = {}; bless($self,$class); return $self; } #Template sub tpl(){ my $node_meta = shift; my $users_dms = shift; my $u_group = shift; my $return = shift; my $q = new CGI; my @keywords = $q->param; my $cf = new Config; my $lb = new Libenz; my $db = new Libenzdb; my $but = new Buttons; my %ib = $but->ibuttons(); my $script = $q->script_name(); my %varenv = $cf->envonline(); my $path_info = $q->path_info(); my $path = $path_info; #with meta_host, if("$varenv{metahost}"){ $path = "$script" . "$path_info"; $script=""; } my $lang = "de"; my $ctn; if($R::rel_id){ $ctn = $db->collect_rel4nodes("",$node_meta->{content_id},$node_meta->{template_id}); }else{ return "failure::Fehler bei der Auswahluebergabe"; } my $bg_color = "gray"; my $table = "content"; my $relate_key; $relate_key = "move_content" if($R::rel_edit =~ /move_/); $relate_key = "relate_content" if($R::rel_edit =~ /relate_/); $relate_key = "copy_content" if($R::rel_edit =~ /copy_/); if($node_meta->{ct_table} eq "contentadr"){ $table = "contentadr"; $relate_key = "move_contentadr" if($R::rel_edit =~ /move_/); $relate_key = "relate_contentadr" if($R::rel_edit =~ /relate_/); } if($node_meta->{ct_table} eq "contenttrans"){ $table = "contenttrans"; $relate_key = "move_conttrans" if($R::rel_edit =~ /move_/); $relate_key = "relate_contenttrans" if($R::rel_edit =~ /relate_/); } if($node_meta->{ct_table} eq "contenttver"){ $table = "contenttver"; $relate_key = "move_contenttver" if($R::rel_edit =~ /move_/); $relate_key = "relate_contenttver" if($R::rel_edit =~ /relate_/); } if($node_meta->{ct_table} eq "contentnel"){ $table = "contentnel"; $relate_key = "move_contentnel" if($R::rel_edit =~ /move_/); $relate_key = "relate_contentnel" if($R::rel_edit =~ /relate_/); } #print "$table,$node_meta->{main_id},$lang,$R::rel_id, xxxxxxxxxxxxxx"; my $ctrel = $db->get_ctrel($table,"",$lang,$R::rel_id); my $node = $db->get_node4multi($node_meta->{main_id},$lang); $ctrel->{mtime} = $lb->time4de($ctrel->{mtime},"1") if($ctrel->{mtime}); $ctrel->{rel_id} = 0 if(!$ctrel->{rel_id}); my $ct_users; $ct_users = $db->collect_users("users") if($u_group eq "manager");#users map #we mean roots for sub-NodePath selection my @viewsel = split /\//,$1 if($path =~ /^\/(.*)/); my $depth = scalar(@viewsel); my $view_root = $viewsel[0] || "root"; my $selector = "this_is_no_selection"; $selector = $1 if($path =~ /\/(Waren|Kunden|Veranstaltung|Nachrichten)/); #collect recursive nodes my $selsize="200px"; #nodes with relation would be better my $nodes = $db->collect_node4all("","","","100000"); my @_menu_rel; foreach my $id (sort { lc($nodes->{$a}->{node_name}) cmp lc($nodes->{$b}->{node_name}) } keys (%$nodes)){ my @viewsel; my $depth=0; my $j=0; my ($m_id,$uri) = $lb->make_uri5($nodes->{$id}->{main_id},$nodes); if(($uri =~ /\w\/\w/) && ($uri !~ /000 root/)){ @viewsel = split(/\//,$uri) if($uri =~ /^\/(.*)/); $depth = scalar(@viewsel); if($varenv{orga} eq "dms"){ #sharee-copri workaround to get only bike menue if($selector && ($path =~ /\/$selector/) && ($uri =~ /$selector/) && ($node_meta->{template_id} == 205)){#Waren bikes if($depth >= 2){ my $rel = $db->get_relation($nodes->{$id}->{main_id},$lang,""); push (@_menu_rel, "$m_id:$uri") if($rel->{template_id} == 205); } } } } } my $mcount = scalar(@_menu_rel); # #collect content my $content = $db->collect_content(); my @_content; foreach my $id (sort { lc($content->{$a}->{ct_name}) cmp lc($content->{$b}->{ct_name}) } keys (%$content)){ push (@_content, "$id:$content->{$id}->{ct_name}") if($content->{$id}->{ct_name}); } # print "