#!/usr/local/bin/perl # Show the left-side menu of Virtualmin domains, plus modules use strict; use warnings; # Globals our %in; our %text; our $base_remote_user; our %miniserv; our %gaccess; our $session_id; our $trust_unknown_referers = 1; require "gray-theme/gray-theme-lib.pl"; require "gray-theme/theme.pl"; ReadParse(); popup_header("Virtualmin"); print "\n"; my $is_master; # Is this user root? if (foreign_available("virtual-server")) { foreign_require("virtual-server"); $is_master = virtual_server::master_admin(); } elsif (foreign_available("server-manager")) { foreign_require("server-manager"); $is_master = server_manager::can_action(undef, "global"); } # Find all left-side items from Webmin my $sects = get_right_frame_sections(); my @leftitems = list_combined_webmin_menu($sects, \%in); my @lefttitles = grep { $_->{'type'} eq 'title' } @leftitems; # Work out what mode selector contains my @has = ( ); my %modmenu; foreach my $title (@lefttitles) { push(@has, { 'id' => $title->{'module'}, 'desc' => $title->{'desc'}, 'icon' => $title->{'icon'} }); $modmenu{$title->{'module'}}++; } my $nw = $sects->{'nowebmin'} || 0; if ($nw == 0 || $nw == 2 && $is_master) { my $p = get_product_name(); push(@has, { 'id' => 'modules', 'desc' => $text{'has_'.$p}, 'icon' => '/images/'.$p.'-small.png' }); } # Default left-side mode my $mode = $in{'mode'} ? $in{'mode'} : $sects->{'tab'} =~ /vm2/ ? "server-manager" : $sects->{'tab'} =~ /virtualmin/ ? "virtual-server" : $sects->{'tab'} =~ /mail/ ? "mailboxes" : @leftitems ? $has[0]->{'id'} : "modules"; # Show mode selector if (indexof($mode, (map { $_->{'id'} } @has)) < 0) { $mode = $has[0]->{'id'}; } if (@has > 1) { print "
| \n"; my $selwidth = (get_left_frame_width() - 70)."px"; if ($mode eq "modules") { # Only showing Webmin modules @leftitems = &list_modules_webmin_menu(); foreach my $l (@leftitems) { $l->{'members'} = [ grep { !$modmenu{$_->{'id'}} } @{$l->{'members'}} ]; } push(@leftitems, { 'type' => 'hr' }); } else { # Only show items under some title OR items that have no title my ($lefttitle) = grep { $_->{'id'} eq $mode } @lefttitles; my %titlemods = map { $_->{'module'}, $_ } @lefttitles; @leftitems = grep { $_->{'module'} eq $mode || !$titlemods{$_->{'module'}} } @leftitems; } # Show system information link push(@leftitems, { 'type' => 'item', 'id' => 'home', 'desc' => $text{'left_home'}, 'link' => '/right.cgi', 'icon' => '/images/gohome.png' }); # Show refresh modules link if ($mode eq "modules" && foreign_available("webmin")) { push(@leftitems, { 'type' => 'item', 'id' => 'refresh', 'desc' => $text{'main_refreshmods'}, 'link' => '/webmin/refresh_modules.cgi', 'icon' => '/images/reload.png' }); } # Show logout link get_miniserv_config(\%miniserv); if ($miniserv{'logout'} && !$ENV{'SSL_USER'} && !$ENV{'LOCAL_USER'} && $ENV{'HTTP_USER_AGENT'} !~ /webmin/i) { my $logout = { 'type' => 'item', 'id' => 'logout', 'target' => 'window', 'icon' => '/images/stock_quit.png' }; if ($main::session_id) { $logout->{'desc'} = $text{'main_logout'}; $logout->{'link'} = '/session_login.cgi?logout=1'; } else { $logout->{'desc'} = $text{'main_switch'}; $logout->{'link'} = '/switch_user.cgi'; } push(@leftitems, $logout); } # Show link back to original Webmin server if ($ENV{'HTTP_WEBMIN_SERVERS'}) { push(@leftitems, { 'type' => 'item', 'desc' => $text{'header_servers'}, 'link' => $ENV{'HTTP_WEBMIN_SERVERS'}, 'icon' => '/images/webmin-small.gif', 'target' => 'window' }); } # Show Webmin search form my $cansearch = ($gaccess{'webminsearch'} || '') ne '0' && !$sects->{'nosearch'}; if ($mode eq "modules" && $cansearch) { push(@leftitems, { 'type' => 'input', 'desc' => $text{'left_search'}, 'name' => 'search', 'cgi' => '/webmin_search.cgi', }); } show_menu_items_list(\@leftitems, 0); print " |