From: Rob H. <for...@us...> - 2002-02-24 05:46:08
|
Update of /cvsroot/sandweb/sandweb/bin In directory usw-pr-cvs1:/tmp/cvs-serv31831/bin Modified Files: sandweb.cgi Log Message: moved delete out into delete_file_commit subroutine Index: sandweb.cgi =================================================================== RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v retrieving revision 1.209 retrieving revision 1.210 diff -U2 -r1.209 -r1.210 --- sandweb.cgi 24 Feb 2002 05:28:02 -0000 1.209 +++ sandweb.cgi 24 Feb 2002 05:46:05 -0000 1.210 @@ -235,5 +235,4 @@ elsif ( $action eq 'view_file' ) { # called file viewer - view_file_menu( ck_auth => $ck_auth, @@ -246,5 +245,4 @@ elsif ( $action eq 'edit_file' ) { # called file editor - if ($submit) { edit_file_commit( @@ -265,4 +263,15 @@ } } + elsif ( $action eq 'delete_file' ) { + # called file deleter + my @filename = CGI::param('filename'); + delete_file_commit( + ck_auth => $ck_auth, + filename => \@filename, + module_name => $module_name, + repo_name => $repo_name, + location => CGI::param('location'), + ); + } elsif ( $action eq 'repository' ) { if ($submit) { @@ -917,4 +926,18 @@ } +############################################################################### +# edit file menu +# +# edit a file, with the option to save. +# +# A File object is created and used. +# +# args: +# ck_auth - the sessions cookie +# file_command - name of the File object method to be invoked +# filename - name of the file(s) that the File object should +# be invoked with. NOTE: this is an array +# location - system path to the file(s) specified by filename +############################################################################### sub edit_file_menu { my %args = @_; @@ -982,4 +1005,5 @@ + ############################################################################### ############################################################################### @@ -1038,48 +1062,4 @@ my $vcsroot; - # Remove a file - if ( $file_command eq 'delete' ) { - unless (@filename) { - $log->debug("no files selected for removal"); - set_error("Please select file(s) or folder(s) to delete."); - browse_module_menu( - ck_auth => $ck_auth, - location => $location, - module_name => $module_name, - repo_name => $repo_name, - ); - } - - foreach my $entry (@filename) { - - $log->debug("creating File object"); - my $file = SandWeb::File->new( - 'log_obj' => $log, - 'filename' => $entry, - 'location' => "$users_dir/$username/$module_name$location", - ); - - $log->debug("removing file"); - if ($file) { - if ( $file->get_file_type() eq 'Directory' ) { - $file->delete_folder(); - } else { - if ( $file->delete_file() ) { - set_error("$filename deleted."); - } else { - set_error("Cannot delete $filename."); - } - } - } - } - - browse_module_menu( - ck_auth => $ck_auth, - location => $location, - module_name => $module_name, - repo_name => $repo_name, - ); - } - # CVS parses network CVSROOTs and local CVSROOTs # differently @@ -1226,4 +1206,17 @@ } +############################################################################### +# edit_file_commit is called by edit_file_menu to save edited data +# +# A File object is created and used. +# +# args: +# ck_auth - the sessions cookie +# file_command - name of the File object method to be invoked +# filename - name of the file(s) that the File object should +# be invoked with. NOTE: this is an array +# location - system path to the file(s) specified by filename +############################################################################### + sub edit_file_commit { my %args = @_; @@ -1272,4 +1265,80 @@ repo_name => $repo_name, location => CGI::param('location'), + ); +} + +sub delete_file_commit { + # delete a file + my %args = @_; + + my $ck_auth = $args{'ck_auth'}; + if (! load_config()) { + # no existing user config, forward to prefs menu + preferences_menu( ck_auth => $ck_auth ); + } + + my $location = $args{'location'}; + my $message = CGI::param('message'); + my $username = $auth->get_username(); + my $template_dir = $config->{'paths'}->{'template_dir'}; + my $users_dir = $config->{'paths'}->{'users_dir'}; + my $repo_name = $args{'repo_name'}; + my $module_name = $args{'module_name'}; + my @filename = (); + my $count = 0; + while ( $args{'filename'}->[$count] ) { + push (@filename, $args{'filename'}->[$count]); + $count++; + } + my $filename = "@filename"; + + $log->debug("viewing file : $filename"); + + $log->debug("creating File object: $filename"); + my $file = SandWeb::File->new( + 'config_obj' => $config, + 'log_obj' => $log, + 'filename' => $filename, + 'location' => "$users_dir/$username/$module_name$location", + ); + + unless (@filename) { + $log->debug("no files selected for removal"); + set_error("Please select file(s) or folder(s) to delete."); + browse_module_menu( + ck_auth => $ck_auth, + location => $location, + module_name => $module_name, + repo_name => $repo_name, + ); + } + + foreach my $entry (@filename) { + $log->debug("creating File object"); + my $file = SandWeb::File->new( + 'log_obj' => $log, + 'filename' => $entry, + 'location' => "$users_dir/$username/$module_name$location", + ); + + $log->debug("removing file"); + if ($file) { + if ( $file->get_file_type() eq 'Directory' ) { + $file->delete_folder(); + } else { + if ( $file->delete_file() ) { + set_error("$filename deleted."); + } else { + set_error("Cannot delete $filename."); + } + } + } + } + + browse_module_menu( + ck_auth => $ck_auth, + location => $location, + module_name => $module_name, + repo_name => $repo_name, ); } |