OSSP CVS Repository

ossp - Check-in [2132]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 2132
Date: 2002-May-14 16:06:21 (local)
2002-May-14 14:06:21 (UTC)
User:ps
Branch:
Comment: Changed view of main window. Changed read in of template and config files
Tickets:
Inspections:
Files:
ossp-pkg/tabea/tabea.cgi      1.14 -> 1.15     131 inserted, 24 deleted

ossp-pkg/tabea/tabea.cgi 1.14 -> 1.15

--- tabea.cgi    2002/05/13 16:28:28     1.14
+++ tabea.cgi    2002/05/14 14:06:21     1.15
@@ -140,18 +140,30 @@
     
     &validpassword($username, $password, $cfghash{'BaseDir'}.$cfghash{'PasswdFile'}) || print STDOUT $cgi->redirect(-uri => $cgi->url(-full => 1), -type => "text/html");
 
-    my $templatesfiles = &readdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} ."/".$cfghash{'TabeaUser'});
-    my $configsfiles = &readdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} ."/".$username);
+     
+#    my $templatesfiles = &readdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} ."/".$cfghash{'TabeaUser'});
+#    my $configsfiles = &readdir($cfghash{'BaseDir'} . $cfghash{'ConfigDir'} ."/".$username);
 
+    my $templatesfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 4);
+    my $configsfiles = &get_name_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, 6);
+
+    $configsfiles .= &get_own_files($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username);
+
+    $templatesfiles = &strsort($templatesfiles);
+    $configsfiles = &strsort($configsfiles);
+    
     my @templatesarray = split(/ /,$templatesfiles);
     my @configsarray = split(/ /,$configsfiles);
-
+    
+    
 #
      $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
         $cgi->hidden(-name => 'form', -default => ['']) .
 # Begin with templates part         
+        "<font size=+1>" .
         "<br> Active User: $username<br><br>\n" .
-#        "Templates:   <br><br>\n" . 
+        "</font>" .
+        "<table> <caption>Templates</caption>" .
         "  <td>" . 
         "    <td>" .
         $cgi->scrolling_list(
@@ -165,7 +177,7 @@
         "   <td>" .
         "   <tr>" .
         "     <td>" .
-        $cgi->submit(-name => 'dialog', -value => 'Copy') .
+        $cgi->submit(-name => 'dialog', -value => 'Copy_Temp') .
         "     </td>" .
         "   </tr>" .
         "   <tr>" .
@@ -181,7 +193,8 @@
         "</table>" .
 
 # Now the configuration part         
-        $page .=  "<table> <caption>Configuration</caption>" .
+        "<br><br>" .
+        "<table> <caption>Configuration</caption>" .
         "<td>" .
         "    <td>" .
         $cgi->scrolling_list(
@@ -198,7 +211,7 @@
         "      </td></tr>" .
 
         "      <tr><td>" .
-        $cgi->submit(-name => 'dialog', -value => 'Copy') .
+        $cgi->submit(-name => 'dialog', -value => 'Copy_Conf') .
         "      </td></tr>" .
 
         "      <tr><td>" .
@@ -233,7 +246,8 @@
 elsif ($dialog eq 'View') {
     #   enter View form
     $page .= &view($cgi->param('templatelist'));
-} else {
+}
+else {
     die "invalid dialog \"$dialog\"";
 }
 
@@ -251,19 +265,68 @@
 
 
 ########################################################################################
+sub get_name_files {
+########################################################################################
+    my ($dirname, $user, $rights) = @_;
+    my $filel = '';
+    my @filelarray;
+    my $filelist = '';
+    my $subdir = '';
+    my $filemode = '';
+    my $entry = '';
+
+    my $dirlist = &readsubdir($dirname . "/" );    
+    my @dirarray =  split (/ /, $dirlist);
+
+    DIR: foreach $subdir (@dirarray)  {
+        next DIR if $subdir eq $user;
+        $filel = &readdir($dirname . "/" . $subdir . "/") ;
+        @filelarray = split (/ /, $filel);
+        FILE: foreach $entry (@filelarray) {
+            my $path = $dirname . "/" . $subdir . "/" . $entry;
+            next FILE if  (((stat($dirname . "/" . $subdir . "/" . $entry))[2]) & 07)  !=  $rights;
+            $filelist .= $subdir . "/" . $entry . " ";
+        }
+   }
+
+    
+    return $filelist;
+}
+########################################################################################
+
+########################################################################################
+sub get_own_files {
+########################################################################################
+    my ($dirname, $user) = @_;
+    my $filelist = '';
+    my $entry = '';
+
+    my $flist = &readdir($dirname . "/" . $user . "/");
+    my @flistarray = split (/ /,$flist);
+
+    foreach $entry (@flistarray) {
+        $filelist .= $user . "/" . $entry . " ";
+    }
+
+    return $filelist;
+}
+########################################################################################
+
+
+########################################################################################
 sub edit {
 ########################################################################################
     my ($file) = @_;
     my $text;
     #   enter Edit form
     if($file) {
-    my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $username . "/" . $file;
-    &editconfig($filename, 'w', $username);
+        my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $file;
+        &editconfig($filename, 'w', $username);
     } else {
-    $text = $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
-    "<font color=red>Missing filename<br><br>\n" .
-    $cgi->submit(-name => 'dialog', -value => 'Back') .
-    $cgi->endform;
+        $text = $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+        "<font color=red>Missing filename<br><br>\n" .
+        $cgi->submit(-name => 'dialog', -value => 'Back') .
+        $cgi->endform;
     }
     return $text;
 }
@@ -275,22 +338,21 @@
 ########################################################################################
     my ($file) = @_; 
     my $text;
-    #   enter View form
+    
     if ($file) {
-    my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cfghash{'TabeaUser'} . "/" . $cgi->param('templatelist');
-    &editconfig($filename, 'r', $username);
+        my $filename = $cfghash{'BaseDir'} . $cfghash{'ConfigDir'} . "/" . $cgi->param('templatelist');
+        &editconfig($filename, 'r', $username);
     } else {
-    $text .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
-    "<font color=red>Missing filename<br><br>\n" .
-    $cgi->submit(-name => 'dialog', -value => 'Back') .
-    $cgi->endform;
+        $text .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)) .
+        "<font color=red>Missing filename<br><br>\n" .
+        $cgi->submit(-name => 'dialog', -value => 'Back') .
+        $cgi->endform;
     }
     return $text;
 }
 ########################################################################################
 
 
-
 ########################################################################################
 sub read_config {
 ########################################################################################
@@ -360,12 +422,39 @@
 
 
 ########################################################################################
+sub readsubdir {
+########################################################################################
+    my ( $dir ) = @_;
+    my $filestring = "";
+    my $direntry = "";
+
+
+
+    opendir(DIR, "$dir");       # Open dir for scanning
+    
+    foreach $direntry (readdir(DIR)) {
+        next if $direntry eq ".";
+        next if $direntry eq "..";
+        if (-d "$dir/$direntry") {
+            $filestring .= $direntry. " ";
+        }
+    }
+    closedir(DIR);
+    return $filestring;
+}
+
+
+
+
+########################################################################################
 sub readdir {
 ########################################################################################
     my ( $dir ) = @_;
     my $filestring = "";
     my $direntry = "";
 
+
+
     opendir(DIR, "$dir");       # Open dir for scanning
     
     foreach $direntry (readdir(DIR)) {
@@ -382,6 +471,24 @@
 
 
 ########################################################################################
+sub strsort {
+########################################################################################
+    my ( $sortstr ) = @_;
+
+    my @sortarray = split (/ /, $sortstr);
+     
+    @sortarray = reverse sort {$b cmp $a} @sortarray;
+    $sortstr = join(" ", @sortarray);
+
+    return $sortstr;
+}
+########################################################################################
+
+
+
+
+
+########################################################################################
 sub editconfig {
 ########################################################################################
     my ($file, $mode, $user) = @_;
@@ -413,9 +520,9 @@
     "<font size=+2>" .
     $titletext . ":   <br><br>\n" .
     "</font>" .
-    "Username: $username<br><br>\n" .
+    "<font size=+1>" .
     "File: $file<br><br>\n" .
-    "Mode: $mode<br><br>\n" .
+    "</font>" .
     $cgi->textarea($textahash).
     "<br><br>\n" .
     "<table>" .

CVSTrac 2.0.1