#!/usr/bin/perl
# tta_moddgrphosts.cgi
# Mod Hosts Groups
# STTA Rev. 1.3 Copyright (c) 2001-2002 Jesús Pérez Lorenzo  --- license GNU GPL 

require './stta-lib.pl';
&foreign_require("proc", "proc-lib.pl");
if ( $config{'is_ldapcache'} eq "true" ) { 
   do "ldap-lib.pl";
}

&ReadParse();

 $aliasgrphosts=$in{usergrphosts};
 if (!$aliasgrphosts) { &redirect("tta_selgrphosts.cgi?form=modgrphosts"); }
 $postform = $in{postform};
 &headerstta($text{'index_modgrphosts'}, "","modgrphosts",undef,1,1,$text{headpage_rigth} );
 $ttacmd="edit";
 # Cleaning and reset values ...
 $descrip="";
 $maxsess="";
 $grphostsname="";
 $dn_grphosts="";
 $ens_grphosts="";
 $alias="";
 %h_grphosts=&list_grphosts();
 if  ( $h_grphosts{$aliasgrphosts}->{'alias'} ne $aliasgrphosts ) {
       $err_msg=$text{'list_errno'};
       &footHere;
       exit;
 }
 $dn_grphosts=$h_grphosts{$aliasgrphosts}->{'obj'};
 $ens_grphosts=$h_grphosts{$aliasgrphosts}->{'ens'};
 $grphostsname=$h_grphosts{$aliasgrphosts}->{'name'};
 $descrip=$h_grphosts{$aliasgrphosts}->{'descrip'};
 $alias=$h_grphosts{$aliasgrphosts}->{'alias'};
 $maxsess=$h_grphosts{$aliasgrphosts}->{'maxsess'};

if ( $config{'is_ldapcache'} eq "true" ) { 
   $dn_cache="cn=$config{ldapcache_defaultobj},$dn_grphosts,".$config{ldapcache_base};  
   $ldapcache_server=$in{ldapcacheserver} || "1";
   &connect_cache();
   # loading variables
   &load_tta3tier_vars($dn_cache);
}
 print "<hr><p>\n";
 print "<SCRIPT SRC=\"global.js\">\n"; 
 print "</SCRIPT>\n"; 
 print "<SCRIPT LANGUAGE=\"JavaScript\">\n"; 
 print "<!--\n"; 
 print "/*  Strings for locales  */\n"; 
 print "var msg0=\"".$text{'msg_0'},"\";\n";
 print "var msg1=\"".$text{'msg_1'},"\";\n";
 print "var msg2=\"".$text{'msg_2'},"\";\n";
 print "var msg3=\"".$text{'msg_3'},"\";\n";
 print "var msg4=\"".$text{'msg_4'},"\";\n";
 print "var msg5=\"".$text{'msg_5'},"\";\n";
 print "var msg6=\"".$text{'msg_6'},"\";\n";
 print "var msg7=\"".$text{'msg_7'},"\";\n";
 print "var ask_confadmin=true;\n"; 
 print "\n"; 
 &htmlCheckAlias("grphosts");
if ( $config{'is_ldapcache'} eq "true" ) { &htmlCacheaShowPassw }
 print "/******************************************************************\n"; 
 print "   Chek_fields(obj)\n"; 
 print "*******************************************************************/\n"; 
 print "function Chek_fields(obj) {\n"; 
 print "     nro=parseInt(obj.maxsess.value);\n";
 print "     if ( nro+1 > 0) { \n";
 print "          obj.maxsess.value=nro;\n";
 print "     } else {;\n";
 print "          alert(obj.maxsess.name+\":\"+msg1+\"->\"+obj.maxsess.value+\"<-\");\n";
 print "          obj.maxsess.focus();\n";
 print "          return false;\n";
 print "     };\n";
 if ( $config{'is_ldapcache'} eq "true" ) { &script_cache_chek; }; 
 print "     if ( get_value(\"select\",obj.usergrphosts) != \"none\" ) {\n"; 
 print "          return confirm(obj.grphostsname.value+msg7+get_value('select',obj.usergrphosts));\n"; 
 print "     }         \n"; 
 print "\n"; 
 print "     return true;\n"; 
 print "}\n"; 
 print "//-->\n"; 
 print "</SCRIPT>\n"; 
 print " $str_cmds\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_adgrphosts'}</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<form METHOD=POST name=modgrphosts ACTION=\"modgrphosts.cgi\" onSubmit=\"return Chek_fields(this)\">\n"; 
 print "	<input TYPE=\"hidden\" NAME=\"ttacmd\" VALUE=\"",$ttacmd,"\">\n"; 
 print "	<input TYPE=\"hidden\" NAME=\"aliasgrphosts\" VALUE=\"",$aliasgrphosts,"\">\n"; 
 print "	<input TYPE=\"hidden\" NAME=\"grphostsname\" VALUE=\"",$grphostsname,"\">\n"; 
 print "	<tr><td valign=top>",&hlink("<b>$text{'f_aliasgrphosts'}</b>","faliasgrphosts"),"&nbsp;</td>\n";
 print "         <td valign=top><b>$aliasgrphosts</b>&nbsp;</td></tr>\n";     
 print "	<tr><td valign=top>",&hlink("<b>$text{'f_grphostname'}</b>","fgrphostsname"),"&nbsp;</td>\n";
 print "         <td valign=top><b>$grphostsname</b>&nbsp;</td></tr>\n";     
 print "        <tr><td valign=top>",&hlink("<b>$text{'f_descrip'}</b>","fdescrip"),"</td>\n";
 print "        <td valign=top><input TYPE=\"text\" NAME=\"descrip\" VALUE=\"$descrip\" cols=\"40\" size=\"40\" ALIGN=left></td></tr>\n";
 print "        <tr><td valign=top>",&hlink("<b>$text{'f_maxsess'}</b>","fmaxsess"),"&nbsp;</td>\n";
 print "        <td valign=top><input TYPE=\"text\" NAME=\"maxsess\" VALUE=\"$maxsess\" cols=\"5\" size=\"5\" ALIGN=left onChange=\"isNroThis(this)\">\n";
if ( $config{'is_ldapcache'} eq "true" ) { $formObj="modgrphosts";$msgObj=$text{'default_obj'};&htmlCacheapp(msgObj) }
 print "        <tr><td valign=top><input TYPE=\"submit\" NAME=\"",$text{'f_sendreq'},"\" VALUE=\"",$text{'f_sendreq'},"\">\n";
 print "        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
 print "        <td valign=top><input TYPE=\"reset\" NAME=\"",$text{'f_cancelreq'},"\" VALUE=\"",$text{'f_cancelreq'},"\"></td></tr>\n";
 print "	</form>\n"; 
 print "<tr><tr></table></table><hr><p>\n"; 
 &footer($config{'back_return'},$text{'index'}); 
 print "<p><p><p>\n";
 do "footer.pl";
 exit;



