#!/usr/bin/perl
# tta_delhostsuser.cgi
# Delete Hosts Group Users from Services with Tarantella
# 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");
do "ldap-lib.pl";
&ReadParse();

 $hostsusername=$in{hostsusername};
 &headerstta($text{'index_delhostsuser'}, "", "delhostsuser",undef,1,1,$text{headpage_rigth} ); 
 print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><b>$text{'titidx_delhostsuser'} $hostusername </b></td> </tr>\n";
 print "<tr $cb> <td><table width=100%>\n";
 print "<center>\n";

if ($hostsusername ) {
    print "<tr></tr><tr></tr>\n";
    print "</pre><tr><p><b>$text{'user_delete'}... Tarantella </b></tr>\n";
    %h_hostsuser=&list_hostsuser();
    &webmin_log($config{'hostsuser_list'}, "hostsuser", "delete",$h_hostsuser{$hostsusername});
    delete $h_hostsuser{$hostsusername};
    foreach $item (keys (%h_hostsuser)) { push (@listhostusers,$h_hostsuser{$item}); }
    @list_hostusers = sort {$a->{'name'} cmp $b->{'name'}} @listhostusers;
    &lock_file($config{'hostsuser_list'});
    open(FILEHOSTSUSER, ">$config{'hostsuser_list'}");
    foreach $hostsuser (@list_hostusers) {
             $lin_hostsuser=$hostsuser->{'username'}."::".
                            $hostsuser->{'passwd'}."::".
                            $hostsuser->{'name'}."::\n";
             print FILEHOSTSUSER "$lin_hostsuser";
    }
    close (FILEHOSTSUSER);
    $str=$text{'user_delete'}.$hostsusername;
    &additional_log('delhostsuser.cgi', "hostsuser", $str);
    &webmin_log($config{'hostsuser_list'}, "hostsuser", "delete");
    &unlock_file($config{'hostsuser_list'});
    print "</tr></td></pre>\n";
 }
 print "<tr><tr></table></table><hr><p>\n";
 &footer($config{'back_return'},$text{'index'});
 print "<p><p><p>\n";
 do "footer.pl";
 exit;
