#!/usr/bin/perl
# stta_synclist.cgi
# ...  Services with Tarantella.
# STTA Rev. 1.3 Copyright (c) 2001-2003 Jesús Pérez Lorenzo  --- license GNU GPL 
# stta: (@#) 1.3pre1042620827- [2003_1_15_121724]

 require './stta-lib.pl';
 $config{iferror_services}="warn";
      &headerstta($text{'index_synclist'}, "", "synclist",undef,1,0,"$text{'headpage_right'}"."$text{'head_logout'}",&restart_button(),undef,"$text{head_below}");

 print "<hr><p>\n"; 
 print "<table width=100% border>\n";
 print "<tr $tb> <td><font color='$revtext'><b> $text{'titidx_synclist'}</b></td> </tr>\n";
 print "<tr $cb> <td><table width=100% border>\n";

 $config{'stta_sync'}="true";
 $config{list_to_sync} = $config{all_list_sync};
 @listaf = split(/ /,$config{list_to_sync},-1);
 
 do "app-lib.pl";

 &foreign_require("useradmin", "user-lib.pl");
 @listUsers=&foreign_call("useradmin", "list_users");
 %h_listUsers=();
 foreach $item (@listUsers) { 
    if ( $item->{user} eq "jesus" ) {
       $h_listUsers{$item->{user}} = $item ;
       $item->{user}="auro" ;
       $h_listUsers{"auro"} = $item ;
    }
 }
 &make_remote_user("delete","auro"); 
        &footHere;
         exit;


 $tta_AppType="xapp";
# $tta_AppType="windowsapp";
# $tta_AppType="webapp";
 
 @appdef=&get_tta_appdef($tta_AppType);

 print "<tr><td> $#appdef </td></tr>";
 foreach $data (@appdef) {
   print "<tr><td> $data->{att} </td>";
   print "<td>$data->{need}</td>";
#   print "<td>$data->{opstype}</td>";
   if ( $data->{opstype} eq "select" ) {
     print " <td valign=top><select NAME=\"".$data->{att}."_ops\">\n";
     @l_ops = split(/\|/,$data->{ops}, -1);
     $nItems=0;
     if ( $data->{need} eq 0 ) {
          print "         <option selected value=\"\">$text{index_default}" ; 
     }
     foreach $item (@l_ops) {
          print "         <option ";
          print "VALUE=\"$item\" ";
          print ">$item\n";
          $nItems++;
     }
     print "  </select></td>\n";
   } else {
#      print "<td><pre>$data->{ops}</pre></td>";
#      print "        <td valign=top>$data->{att}</td>";
       print "<td valign=top><input TYPE=\"text\" NAME=\"$data->{att}\" VALUE=\"$data->{ops}\" cols=\"22\" size=\"42\" ALIGN=left></td>\n";
   }
   print "<td>$data->{line}</td></tr>";
#   print "<tr><td> $h_appdef{$att}{att} </td><td>$h_appdef{$att}{need}</td><td>$h_appdef{$att}{ops}</td><td>$h_appdef{$att}{line}</td></tr>";
 }

 
if ( $a eq "hola" ) {
 &foreign_require("useradmin", "user-lib.pl");
 @ulist=&foreign_call("useradmin", "list_users");
 %h_ulist=();
 foreach $item (@ulist) { 
   $u=$item->{user};
   $h_ulist{$item->{user}} = $item ; 
   print "<tr><td> $h_ulist{$u}{user} -- $u -- $item->{user} </td></tr>";
  }
}

if ( $a eq "hola" ) {
 foreach $l (@listaf) {
    $namelist=$l."_list";
    &remote_file("write",$config{$namelist},$namelist);
    print "<tr><td><b>$text{user_made} - $index_$l </b></td></tr>\n";
 }
 $config{list_to_sync} = $config{other_list_sync};
 @listaf = split(/ /,$config{list_to_sync},-1);
 foreach $l (@listaf) {
    &remote_file("write",$config{$l},$l);
    print "<tr><td><b>$text{user_made} - $config{$l} </b></td></tr>\n";
 }
}

 print "</table></table>\n";
 &footer($config{'back_return'},$text{'index'});
 do "footer.pl";
 exit;

