Index: ossp-pkg/tabea/tabea.cgi RCS File: /v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v rcsdiff -q -kk '-r1.15' '-r1.16' -u '/v/ossp/cvs/ossp-pkg/tabea/tabea.cgi,v' 2>/dev/null --- tabea.cgi 2002/05/14 14:06:21 1.15 +++ tabea.cgi 2002/05/14 15:34:02 1.16 @@ -42,6 +42,7 @@ my $configsdir = "./tabea.d"; #my $tabeauser = "tabea"; + # establish my configuration my $MY = {}; $MY->{PROGNAME} = ($0 =~ m|^.*?([^/]+?)(?:\.[^/.]+)?$|)[0]; @@ -247,6 +248,17 @@ # enter View form $page .= &view($cgi->param('templatelist')); } +elsif ($dialog eq 'New') { + $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)); + $page .= &new($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username); + $page .= $cgi->endform; +} +elsif ($dialog eq 'New_file') { + $page .= $cgi->startform( -method => "POST", -action => $cgi->url(-full => 1)); + $page .= &newfile($cfghash{'BaseDir'} . $cfghash{'ConfigDir'}, $username, $cgi->param('newfile'), $cgi->param('new_rights')); + $page .= $cgi->endform; +} + else { die "invalid dialog \"$dialog\""; } @@ -351,6 +363,92 @@ return $text; } ######################################################################################## + + +######################################################################################### +sub new { +######################################################################################## + my ( $dirname, $user ) = @_; + my $text; + + $text= "" . + "New File:

\n" . + "
" . + + "" . + " " . + " " . + " " . + " " . + " " . + "" . + "" . + " " . + " " . + "" . + " " . + "" . + " " . + " " . + "
New Filename: $dirname " . "/" . "$user" . "/" . "" . + $cgi->textfield( + -name => 'newfile', + -default => '', + -size => 20, + -maxlength => 30 + ) . + "

" . +# $cgi->checkbox_group( +# -name => 'new_rights', +# -values => ['private', 'protected', 'public'], +# -defaults => 'private', +# -linebreak => 'true' +# ) . + $cgi->scrolling_list( + -name => 'new_rights', + -value => ['private', 'protected', 'public'], + -size => 1 + ) . + "

" . + $cgi->submit(-name => 'dialog', -value => 'Back') . + $cgi->submit(-name => 'dialog', -value => 'New_file') . + "
"; + + return $text; +} +######################################################################################## +sub newfile { +######################################################################################## + my ( $dirname, $user, $newfilename, $newrights ) = @_; + my $text; + my $newpath = $dirname . "/" . $user . "/" . $newfilename; + my $filerights = ''; + + $text= "" . + "Creating New File:

" . + "



" ; + system("touch $newpath") && die "Cannot create new file"; + if ($newrights eq "private" ) { + $filerights = ''; + } elsif ($newrights eq "protected" ) { + $filerights = "r"; + } elsif ($newrights eq "public" ) { + $filerights = "rw"; + } else { + die "Unknown file rights"; + } + $text .= "Creating the new file $newpath

"; + system("touch $newpath") && die "Cannot create new file"; + $text .= "Setting new file rights for $newpath

"; + system("chmod u=rw $newpath") && die "Cannot set new file rights"; + system("chmod o=$filerights $newpath") && die "Cannot set new file rights"; + # Checking that file dont exist: TODO + $text .= "


" . + $cgi->submit(-name => 'dialog', -value => 'Back'); + + return $text; +} +######################################################################################## ########################################################################################