From: Nick J. <nje...@us...> - 2002-02-28 04:32:35
|
Update of /cvsroot/sandweb/sandweb/bin In directory usw-pr-cvs1:/tmp/cvs-serv9380/bin Modified Files: sandweb.cgi Log Message: * added repository deletion functionality. * changed all ERROR => $error to MESSAGE => $message and, set_error is now set_message, etc. etc. Index: sandweb.cgi =================================================================== RCS file: /cvsroot/sandweb/sandweb/bin/sandweb.cgi,v retrieving revision 1.228 retrieving revision 1.229 diff -U2 -r1.228 -r1.229 --- sandweb.cgi 28 Feb 2002 03:48:41 -0000 1.228 +++ sandweb.cgi 28 Feb 2002 04:32:33 -0000 1.229 @@ -27,5 +27,5 @@ # internal global vars -my $error = ''; +my $message = ''; # object creation, all objects global throughout CGI @@ -84,5 +84,5 @@ unless ($stat) { # unable to load user with auth cookie, or auth cookie expired - set_error("Please login first."); + set_message("Please login first."); $log->debug("unable to get valid authentication cookie: '$ck_auth'"); login_menu(); @@ -328,4 +328,5 @@ repo_root => $repo_root, new_repository => $new_repository, + submit => $submit, ); } else { @@ -347,5 +348,5 @@ my $msg = "Invalid page - $page!"; $log->error("$msg"); - set_error("$msg"); + set_message("$msg"); # load current menu (instead of going to new one) #no strict 'refs'; @@ -390,5 +391,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -422,5 +423,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -484,5 +485,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -653,5 +654,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -691,5 +692,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -749,5 +750,5 @@ if (!$valid) { # bad repository name - set_error("Invalid repository name: $repository_selected\n"); + set_message("Invalid repository name: $repository_selected\n"); $repository_selected = $new_string; $repo_name = ''; @@ -863,5 +864,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -904,5 +905,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -968,5 +969,5 @@ if ( $file->get_file_type() ne "Text" ) { $log->debug("User wants to view non-text file : $filename"); - set_error("This does not appear to be a text file."); + set_message("This does not appear to be a text file."); $file_content = ""; } else { @@ -1025,5 +1026,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -1074,5 +1075,5 @@ if ( $file->get_file_type() ne "Text" ) { $log->debug("User wants to edit non-text file : $filename"); - set_error("This does not appear to be a text file."); + set_message("This does not appear to be a text file."); view_file_menu( ck_auth => $ck_auth, @@ -1105,5 +1106,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -1149,5 +1150,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -1188,5 +1189,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -1227,5 +1228,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } @@ -1346,5 +1347,5 @@ unless (@filename) { $log->debug("no files selected for removal"); - set_error("Please select file(s) or folder(s) to delete."); + set_message("Please select file(s) or folder(s) to delete."); browse_module_menu( ck_auth => $ck_auth, @@ -1369,7 +1370,7 @@ } else { if ( $file->delete_file() ) { - set_error("$filename deleted."); + set_message("$filename deleted."); } else { - set_error("Cannot delete $filename."); + set_message("Cannot delete $filename."); } } @@ -1522,5 +1523,5 @@ ); } else { - set_error("Error: no file was received!"); + set_message("Error: no file was received!"); browse_module_menu( @@ -1686,5 +1687,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -1705,5 +1706,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -1741,8 +1742,8 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); } else { - set_error("VCS $vcs_command on @filename"); + set_message("VCS $vcs_command on @filename"); browse_module_menu( ck_auth => $ck_auth, @@ -1782,5 +1783,5 @@ FOOTER => '', CONTENT => $content, - ERROR => $error, + MESSAGE => $message, ); exit 0; @@ -1921,5 +1922,5 @@ # uh oh, problem occured $log->error("$msg"); - set_error("$msg"); + set_message("$msg"); preferences_menu( ck_auth => $ck_auth ); } @@ -1941,4 +1942,5 @@ my $repo_root = $args{'repo_root'}; my $new_repository = $args{'new_repository'} ? 1 : 0; + my $submit = $args{'submit'}; my $new_string = 'Add a new repository'; @@ -1946,33 +1948,49 @@ $log->debug("<pre>" . Dumper(\%args) . "</pre>"); - if (! $repo_name) { - # cannot commit without repository name - $log->error("cannot commit without repository name!\n"); - set_error("cannot commit without repository name!\n"); - repository_menu( ck_auth => $ck_auth ); - exit(0); - } - # commit data to file - if ($user->repository_exists(repo => $repo_name)) { - $log->debug("updating: username '$repo_username'\n"); - $user->update_repo( - name => $repo_name, - server => $repo_server, - username => $repo_username, - connection => $repo_connection, - type => $repo_type, - root => $repo_root, - ); - } else { - $user->create_repo( - name => $repo_name, - server => $repo_server, - username => $repo_username, - connection => $repo_connection, - type => $repo_type, - root => $repo_root, - ); + if ($submit eq 'Commit') { + # commit data to file + if (! $repo_name) { + # cannot commit without repository name + $log->error("cannot commit without repository name!\n"); + set_message("cannot commit without repository name!\n"); + repository_menu( ck_auth => $ck_auth ); + exit(0); + } + elsif ($user->repository_exists(repo => $repo_name)) { + $log->debug("updating: username '$repo_username'\n"); + $user->update_repo( + name => $repo_name, + server => $repo_server, + username => $repo_username, + connection => $repo_connection, + type => $repo_type, + root => $repo_root, + ); + } else { + $user->create_repo( + name => $repo_name, + server => $repo_server, + username => $repo_username, + connection => $repo_connection, + type => $repo_type, + root => $repo_root, + ); + } + } elsif ($submit eq 'Delete') { + # delete repository entry + $log->debug("deleting $repository_selected"); + if ((!$repository_selected) || ($repository_selected eq $new_string)) { + # cannot commit without repository name + $log->error("cannot delete without repository name!\n"); + set_message("cannot delete without repository name!\n"); + repository_menu( ck_auth => $ck_auth ); + exit(0); + } + $user->delete_repo( name => $repository_selected ); + $repo_name = ''; + set_message("$repository_selected deleted."); } + $log->debug("done $repository_selected '$submit'"); my $return = write_config(); @@ -2021,5 +2039,5 @@ # if $no_error is true, ignore this error msgs if (! $no_error) { - set_error("No config file cound for '$username', enter preferences."); + set_message("No config file cound for '$username', enter preferences."); } return 0; @@ -2057,5 +2075,5 @@ $log->debug("ERROR: $msg"); $log->error("$msg"); - set_error("$msg"); + set_message("$msg"); return 0; } @@ -2095,5 +2113,5 @@ else { $log->standard("Invalid login attempt, username: $username"); - set_error("Login incorrect, please try again."); + set_message("Login incorrect, please try again."); login_menu(); } @@ -2114,5 +2132,5 @@ } else { - set_error("Logout failed: $stat"); + set_message("Logout failed: $stat"); login_menu(); } @@ -2122,14 +2140,14 @@ # set error # -# assign error message to global $error IF it's not yet set. +# assign error message to global $msg IF it's not yet set. # # No args. ############################################################################### -sub set_error { - if (! $error) { - $error = shift; +sub set_message { + if (! $message) { + $message = shift; } else { - $log->debug("ERROR: shift"); + $log->debug("MESSAGE: " . shift); } return 1; |