# STTA Rev. 1.3 Copyright (c) 2001-2004 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.31051043346- [2004_01_29_102036]
# index_tabs.pl for STTA 
 
$current_cat=$in{cat};
if (!$current_cat )  { 
    if ( $config{'is_masterHost'} ne "true" ) {
                $current_cat="browsers";
    } else {
                $current_cat=$config{'default_cat'};
    }
}
$sub_cat=$in{sub};
@modules = split(/,/,$text{'modules'}, -1);
$out_titles=$config{'set_titles'};
        foreach $m (@modules) {
                next if ( $config{'is_masterHost'} ne "true"  && $m eq "monitor");     
                next if ( $config{'is_masterHost'} ne "true"  && $m eq "objects");     
                next if ( $config{'is_masterHost'} ne "true"  && $m eq "ldapcache");     
                next if ( $config{'is_masterHost'} ne "true"  && $m eq "password");     
                next if ( $config{'is_ldapcache'} ne "true"  && $m eq "ldapcache");     
                next if ( $config{'is_ldapcache'} eq "true"  && $m eq "ldapprofile");     
                next if ( $access{'admin'} ne 1  && $m eq "admin");     
                next if ( $access{'supervision'} ne 1  && $m eq "supervision");     
                next if ( $config{'has_monitor'} ne "true"  && $m eq "monitor");     
                if ( $ldap_ok ne true && $ldapcache_ok ne true ) {
                     next if ( $m eq "browsers");     
                }
                if ( $ldap_ok ne true ||  $tta_ok ne true ) {
                     next if ( $m eq "password");     
                }
                if ( $ldapcache_ok ne true ) {
                     next if ( $m eq "ldapcache");     
                }
                if ( $tta_ok ne true && $ldap_ok ne true &&  $tta_ok ne true ) {
                     next if ( $m eq "objects");     
                }
                $mod_name=$text{"category_$m"};
                if ( $mod_name eq "") { $mod_name=$m };
                push(@all_cats, { 'alias' => $m,
                              'name' => $mod_name,
                              'num' => scalar(@cats) });
        }
if ( $#all_cats < 0 ) {
      &footHere();
      exit;
}
        $sort_on=$config{'order_cat'};
        @cats = @all_cats;   
        if ( $sort_on eq "name" || $sort_on eq "alias" ) {
             @cats = sort {$a->{$sort_on} cmp $b->{$sort_on}} @all_cats;   
        }
        $per = $#cats ? 100.0 / $#cats : 100;

 print "<table border=0 cellpadding=0 cellspacing=0 height=20><tr>\n";
        
        $usercol = defined($gconfig{'cs_header'}) ||
                   defined($gconfig{'cs_table'}) ||
                   defined($gconfig{'cs_page'});
        foreach $c (@cats) {
                $t = $c->{name};
                $lnk = $c->{alias};
                if ($current_cat eq $c->{alias}) {
                        print "<td valign=top $cb>", $usercol ? "<br>" :
                          "<img src=/stta/images/lc2.gif alt=\"\">","</td>\n";
                        print "<td $cb>&nbsp;",
                              "<a class='menu1' href=/stta/?cat=$lnk><big>$t</big></a>&nbsp;</td>\n";
                        print "<td valign=top $cb>", $usercol ? "<br>" :
                          "<img src=/stta/images/rc2.gif alt=\"\">","</td>\n";
                        }
                else {
                        print "<td valign=top $tb>", $usercol ? "<br>" :
                          "<img src=/stta/images/lc1.gif alt=\"\">","</td>\n";
                        print "<td $tb>&nbsp;",
                              "<a class='menu2' href=/stta/?cat=$lnk><b>$t</b></a>&nbsp;</td>\n";
                        print "<td valign=top $tb>", $usercol ? "<br>" :
                          "<img src=/stta/images/rc1.gif alt=\"\">","</td>\n";
                        }
                print "<td width=10></td>\n";
                }
        print "</tr></table> <table border=1 cellpadding=0 cellspacing=0 width=100% $cb>\n";
        print "<tr><td><table width=100% cellpadding=5>\n";
 
        # Display the modules in this category
        $pos = 0;
        $cols = $gconfig{'nocols'} ? $gconfig{'nocols'} : 4;
        $per = 100.0 / $cols;
        foreach $m (@modules) {
                next if ($m ne $current_cat);
                if ($pos % $cols == 0) { print "<tr>\n"; }
                if ($sub_cat )  { 
		    $out_titles=1;
                    do "./index/$sub_cat.pl";
                } else {
                    do "./index/$m.pl";
                }
                if ($pos++ % $cols == $cols - 1) { print "</tr><tr>\n"; }

        }
        while($pos++ % $cols) {
                print "<td width=$per\%></td>\n";
        }
        print "</table></td></tr></table><p><hr>\n";
