#################################### ### A R C H I V E R E C O R D S ### Modified 7 May 2000 ### Modified 31 May 2000 by LoisC ### Modified 8 March 2004 by shann123 for DBMan SQL version 1 ###################################### # You'll need to create a table for the archived records. You can do # that easily by doing an SQL command from phpmyadmin (if you have it) # or anything that will allow you to do sql queries. # Use this to create an exact copy: CREATE TABLE Items_archive SELECT * FROM Items; # NOTE: This will also copy all of the data to the new table. You'll need to empty that # table after it's created. (Sorry, not familiar enough with SQL to do it any other way) # This is assuming you have not changed your table name from the default "Items". ####################################### # In db.cfg, after # The table name to store user information $db_table_user = 'Items_users'; # add # Full Path and File name of the database file. $db_archive_name = 'Items_archive'; # ********** You must use a counter field for the $db_key! (ID field) **************** ########################################## # In db.cgi, sub main, after elsif ($in{'delete_records'}) { if ($per_del) { &delete_records; } else { &html_unauth; } } # add elsif ($in{'archive_search'}) { if ($per_admin) { &html_archive_search; } else { &html_unauth; } } elsif ($in{'archive_form'}) { if ($per_admin) { &html_archive_form; } else { &html_unauth; } } elsif ($in{'archive_records'}) { if ($per_admin) { &archive_records; } else { &html_unauth; } } elsif ($in{'unarchive_search'}) { if ($per_admin) { &html_unarchive_search; } else { &html_unauth; } } elsif ($in{'unarchive_form'}) { if ($per_admin) { &html_unarchive_form; } else { &html_unauth; } } elsif ($in{'unarchive_records'}) { if ($per_admin) { &unarchive_records; } else { &html_unauth; } } ############################################### # In db.cgi, add 3 new subroutines: sub archive_records { # -------------------------------------------------------- # archives a single or multiple records. First the routine goes thrrough the form input and makes sure there are some records to archive. It then goes # through the database deleting each entry and marking it archived. If there are any keys not archived, an error message will be returned saying which keys # were not found and not archived, otherwise the user will go to the success page. # This subroutine was re-wrote from the delete records subroutine. my (%archive_list, $rec_to_archive, $key, $key_q, $db_userid_q, $query, $rc, $errstr, $succstr, @lines, $line, @data, $output, $restricted); $rec_to_archive = 0; foreach $key (keys %in) { # Build a hash of keys to delete. if ($in{$key} eq "archive") { $archive_list{$key} = 1; $rec_to_archive = 1; } } if (!$rec_to_archive) { &html_archive_failure("no records specified."); } else { # Go through each key to archive and make an SQL query to archive it. Could also combine # the query into one by OR'ing the keys. foreach $key (keys %archive_list) { $db_is_int{$db_key} ? ($key_q = int($key)) : ($key_q = $DBH->quote($key)); # We add an extra check if the user is only allowed to # archive his own records. $userid_q = $DBH->quote($db_userid); ($auth_modify_own and !$per_admin) ? # Copies data from the Item table to the Item_archive table. ($query = qq! INSERT INTO $db_archive_name SELECT * FROM $db_table WHERE $db_key = $key_q AND $auth_user_field = $userid_q !) : ($query = qq! INSERT INTO $db_archive_name SELECT * FROM $db_table WHERE $db_key = $key_q !); $rc = $DBH->do($query); # Deletes original data from the Item table. $query = qq! DELETE FROM $db_table WHERE $db_key = $key_q !; $rc = $DBH->do($query); # We mark successful deletions by setting the value to 0. if ($rc) { $archive_list{$key} = 0; foreach (keys %db_indexed) { &archive_index ($key, $_); } } else { $output .= $line . "\n"; } } foreach $key (keys %archive_list) { if ($archive_list{$key}) { # Check to see if any items weren't deleted $errstr .= "$key,"; # that should have been. } else { $succstr .= "$key,"; # For logging, we'll remember the one's we } # deleted. } chop($succstr); # Remove trailing delimeter chop($errstr); # Remove trailing delimeter &auth_logging("archive records: $succstr", $DBH) if ($auth_logging); $errstr ? &html_archive_failure($errstr) : # If so, then let's report an error. &html_archive_success($succstr); # else, everything went fine. } } sub unarchive_records { # -------------------------------------------------------- # unarchives a single or multiple records. First the routine goes through the form input and makes sure there are some records to unarchive. It then goes # through the database deleting each entry and marking it unarchived. If there are any keys not unarchived, an error message will be returned saying which keys # were not found and not unarchived, otherwise the user will go to the success page. # This was easy to do since I already had it wrote for the archiving subroutine. It was just a matter of switching the tables around. my (%archive_list, $rec_to_archive, $key, $key_q, $db_userid_q, $query, $rc, $errstr, $succstr, @lines, $line, @data, $output, $restricted); $rec_to_archive = 0; foreach $key (keys %in) { # Build a hash of keys to delete. if ($in{$key} eq "unarchive") { $archive_list{$key} = 1; $rec_to_archive = 1; } } if (!$rec_to_archive) { &html_unarchive_failure("no records specified."); } else { # Go through each key to delete and make an SQL query to delete it. Could also combine # the query into one by OR'ing the keys. foreach $key (keys %archive_list) { $db_is_int{$db_key} ? ($key_q = int($key)) : ($key_q = $DBH->quote($key)); # We add an extra check if the user is only allowed to # delete his own records. $userid_q = $DBH->quote($db_userid); ($auth_modify_own and !$per_admin) ? ($query = qq! INSERT INTO $db_table SELECT * FROM $db_archive_name WHERE $db_key = $key_q AND $auth_user_field = $userid_q !) : ($query = qq! INSERT INTO $db_table SELECT * FROM $db_archive_name WHERE $db_key = $key_q !); $rc = $DBH->do($query); $query = qq! DELETE FROM $db_archive_name WHERE $db_key = $key_q !; $rc = $DBH->do($query); # We mark successful deletions by setting the value to 0. if ($rc) { $archive_list{$key} = 0; foreach (keys %db_indexed) { &archive_index ($key, $_); } } else { $output .= $line . "\n"; } } foreach $key (keys %archive_list) { if ($archive_list{$key}) { # Check to see if any items weren't deleted $errstr .= "$key,"; # that should have been. } else { $succstr .= "$key,"; # For logging, we'll remember the one's we } # deleted. } chop($succstr); # Remove trailing delimeter chop($errstr); # Remove trailing delimeter &auth_logging("unarchive records: $succstr", $DBH) if ($auth_logging); $errstr ? &html_unarchive_failure($errstr) : # If so, then let's report an error. &html_unarchive_success($succstr); # else, everything went fine. } } sub arc_query { # -------------------------------------------------------- # This routines does the actual search of the database. # After several hours of frustration, I realized that the unarchive query was using the original query subroutine. # I simply copied the old query subroutine and renamed it to sub arh_query and changed the table that it queries. my ($i, $column, @search_fields, @gt_fields, @lt_fields, $bool, $order, $sortby, $nh, $where, $offset, $field, $field_q, $query, $userid_q, $sth, @tmp, @hits, $count, $comp); # We pass in the type so we can check the userid. The type should either be 'mod', 'del', 'view'. # my ($type) = $_[0]; # Start by setting some options. Pick our boolean operator: OR or AND. Pick our sort order # and our sort by preferences as well. $in{'so'} ? ($order = $in{'so'}) : ($order = "ASC"); $in{'sb'} and ($sortby = "ORDER BY $in{'sb'} $order"); $in{'ma'} ? ($bool = "OR") : ($bool = "AND"); $in{'nh'} ? ($nh = $in{'nh'}) : ($nh = 1); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); $in{'ww'} ? ($comp = '=') : ($comp = 'LIKE'); # If this is a keyword search, we want to set every field in the database to the # search term. if ($in{'keyword'}) { $in{'ma'} = "on"; $bool = 'OR'; foreach $column (@db_cols) { next if ($db_lengths{$column} > 255); # Can't search on TEXT/BLOB fields. next if ($in{'keyword'} !~ /^\d+$/ and $db_is_int{$column}); push (@search_fields, $column); # Search every column $in{$column} = $in{'keyword'}; # Fill %in with keyword we are looking for. } } # Otherwise, we only add fields that have information to search on. else { foreach $column (@db_cols) { if ($in{$column} =~ /^\>(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'"); push (@gt_fields, $column); $in{"$column-gt"} = $1; next; } if ($in{$column} =~ /^\<(.+)$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($1) or return "Invalid date format: '$1'"); push (@lt_fields, $column); $in{"$column-lt"} = $1; next; } if ($in{$column} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{$column}) or return "Invalid date format: '$in{$column}'"); push (@search_fields, $column); next; } if ($in{"$column-gt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"}) or return "Invalid date format: '$in{$column}'"); push (@gt_fields, $column); } if ($in{"$column-lt"} !~ /^\s*$/) { ($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"}) or return "Invalid date format: '$in{$column}'"); push (@lt_fields, $column); } } } if (! $db_msql) { foreach (keys %db_indexed) { if ($in{$_}) { ($sth, $count) = &query_index ($_, $in{$_}, $nh, $maxhits, $bool, $in{'ww'}); defined $sth or return ("no matching results"); $index_search = 1; last; } } } if (! $index_search) { if (!@search_fields and !@gt_fields and !@lt_fields) { return ("no search terms specified."); # Make sure we are actually looking for } # something. # We quote each word for special characters, but the quote functions puts the enclosing # ' around the word. Since we want to add % before and after, we have to remove those. # MSQL: We use CLIKE instead of LIKE to do case insensitive searches. We also have to jump # some hoops so that msql doesn't complain when comparing integer values. foreach $field (@search_fields) { # We are looking at integers. if ($db_is_int{$field}) { if ($in{$field} eq "*") { # Special case as we can't use LIKE on int, we match >= 0 $where .= qq! $field >= 0 $bool!; } else { $field_q = int($in{$field}); next unless ($field_q =~ /^\d+$/); $where .= qq! $field = $field_q $bool!; } } else { # We are looking at strings. if ($in{$field} eq "*") { $where .= qq! $field $comp '%' $bool!; } else { $field_q = $DBH->quote ($in{$field}); $field_q =~ s/^'(.*)'$/'%$1%'/ unless $in{'ww'}; # Remove quotes ' so we can do % matchings. $where .= qq! $field $comp $field_q $bool!; } } } foreach $field (@lt_fields) { $db_is_int{$field} ? ($field_q = int($in{"$field-lt"})) : ($field_q = $DBH->quote($in{"$field-lt"})); $where .= qq! $field <= $field_q $bool!; } foreach $field (@gt_fields) { $db_is_int{$field} ? ($field_q = int($in{"$field-gt"})) : ($field_q = $DBH->quote($in{"$field-gt"})); $where .= qq! $field >= $field_q $bool!; } # Chop off the trailing AND or OR. chop ($where); chop ($where); chop ($where); # If we are only allowed to mod/del/view our own records let's make # sure we don't pull up anyone else's information. if ((($type eq 'mod' and $auth_modify_own) or ($type eq 'del' and $auth_modify_own) or ($type eq 'view' and $auth_view_own)) and (!$per_admin)) { $userid_q = $DBH->quote($db_userid); # $where .= qq! ($where) AND # $auth_user_field = $userid_q!; $where = qq! ($where) AND $auth_user_field = $userid_q!; } $where and ($where = "WHERE $where"); # Now let's work out the next url if there are more hits to be had and # if the database can use the LIMIT with offset function. $offset = ($nh - 1) * $maxhits; # Now let's pull up the relevant records. # MSQL: Does not support LIMIT OFFSET, HITS, so we have to get all the hits and # then throw away the ones we don't want. $count = $offset + $maxhits; $db_msql ? ($query = qq! SELECT ! . join(",", @db_cols) . qq! FROM $db_archive_name $where $sortby !): ($query = qq! SELECT ! . join(",", @db_cols) . qq! FROM $db_archive_name $where $sortby LIMIT $offset, $maxhits !); $sth = $DBH->prepare ($query) or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query"); $sth->execute or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query"); # If we can do a Next Hits link then let's find how many links there are. If # this is mSQL, we have just calculated the total using $count above. If it # is a db that supports count(*) then we can figure out the total using the # following: if (!$db_msql) { while (@tmp = $sth->fetchrow_array) { push (@hits, @tmp); } my $query2 = qq! SELECT COUNT(*) FROM $db_archive_name $where !; $sth = $DBH->prepare ($query2) or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query2"); $sth->execute or &cgierr("Unable to query database. Reason: $DBI::errstr. Query: $query2"); ($count) = $sth->fetchrow_array; } else { $count = 0; while (@tmp = $sth->fetchrow_array) { next if (($count++ < $offset) or ($count > $offset + $maxhits)); push (@hits, @tmp); } } } else { while (@tmp = $sth->fetchrow_array) { push (@hits, @tmp); } } # Set a global $db_total_hits to be used in the html. $db_total_hits = $count; # If we have to many hits, let's build the next toolbar, and return only the hits we want. if ($count > $maxhits) { my ($next_url, $next_hit, $prev_hit, $left, $right, $upper, $lower, $first, $last, $numhits); # Remove the nh= from the query string. $next_url = $ENV{'QUERY_STRING'}; $next_url =~ s/\&nh=\d+//; $next_hit = $nh + 1; $prev_hit = $nh - 1; $numhits = $count; # Build the next hits toolbar. It seems really complicated as we have to do # some number crunching to keep track of where we are on the toolbar, and so # that the toolbar stays centred. # First, set how many pages we have on the left and the right. $left = $nh; $right = int($numhits/$maxhits) - $nh; # Then work out what page number we can go above and below. ($left > 7) ? ($lower = $left - 7) : ($lower = 1); ($right > 7) ? ($upper = $nh + 7) : ($upper = int($numhits/$maxhits) + 1); # Finally, adjust those page numbers if we are near an endpoint. (7 - $nh >= 0) and ($upper = $upper + (8 - $nh)); ($nh > ($numhits/$maxhits - 7)) and ($lower = $lower - ($nh - int($numhits/$maxhits - 7) - 1)); $db_next_hits = ""; # Then let's go through the pages and build the HTML. ($nh > 1) and ($db_next_hits .= qq~[<<] ~); for ($i = 1; $i <= int($numhits/$maxhits) + 1; $i++) { if ($i < $lower) { $db_next_hits .= " ... "; $i = ($lower-1); next; } if ($i > $upper) { $db_next_hits .= " ... "; last; } ($i == $nh) ? ($db_next_hits .= qq~$i ~) : ($db_next_hits .= qq~$i ~); if ($i * $maxhits == $count) { $nh == $i and $next_hit = $i; last; } } $db_next_hits .= qq~[>>] ~ unless ($next_hit == $i); } # Bold the results if ($db_bold and $in{'view_records'}) { for $i (0 .. (($#hits+1) / ($#db_cols+1)) - 1) { $offset = $i * ($#db_cols+1); foreach $field (@search_fields) { $hits[$db_def{$field}[0] + $offset] =~ s,(<[^>]+>)|(\Q$in{$field}\E),defined($1) ? $1 : "$2",ge; } } } # Clean up! $sth->finish; return ("ok", @hits); } ############################################################## # In html.pl, sub footer, add print qq!| Archive Records ! if ($per_admin); print qq!| UnArchive Records ! if ($per_admin); ############################################################## ++++++++++++++++++++++ # If you are *NOT* using the "user-friendly html.pl" or "short/long display" mod, add the following to html.pl. #### Subroutines for "user-friendly html.pl" and "short/long display" are below. ########################################################## ## Archiving ## ########################################################## sub html_archive_search { # -------------------------------------------------------- # The page is displayed when a user wants to archive records. First the user has to search the database to pick which records to archive. That's handled by this form. # No changes from the original subroutine. &html_print_headers; print qq| $html_title: Search the Database for Deletion.
$html_title: Search the Database for Archiving

<$font_title>Search the Database for Archiving

<$font>

Search the database for the records you wish to archive or list all:

|; &html_record_form(); &html_search_options; print qq|

|; &html_footer; print qq|
|; } sub html_archive_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now pick which records to archive from the records returned. This page should produce a checkbox with name=ID value=archive for each record. # We have to do a little work to convert the array @hits that contains the search results to a hash for printing. # No changes from the original subroutine. my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); &html_print_headers; print qq| $html_title: Archive Record(s).
$html_title: Archive Record(s)
|; if ($status ne "ok") { # There was an error searching! print qq|

Error: $status

|; } else { print qq|

<$font> Check which records you wish to archive and then press "Archive Records":
Your search returned $db_total_hits matches.|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } # Go through each hit and convert the array to hash and send to html_record for printing. Also add a checkbox with name=key and value=archive. print qq|

|; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
|; &html_record (%tmp); print qq|
\n|; } print qq|

|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } } &html_footer; print qq|

|; } sub html_archive_success { # -------------------------------------------------------- # This page let's the user know that the records were successfully archived. # No changes from the original subroutine. my $message = shift; &html_print_headers; print qq| $html_title: Record(s) Archived.
$html_title: Record(s) Archived.

<$font_title>Record(s) archived

<$font>The following records were archived: '$message'.

|; &html_footer; print qq|

|; } sub html_archive_failure { # -------------------------------------------------------- # This page let's the user know that some/all of the records were not archived (because they were not found in the database). # $errstr contains a list of records not archived. # No changes from the original subroutine. my ($errstr) = $_[0]; &html_print_headers; print qq| $html_title: Error: Record(s) Not Archived.
$html_title: Error: Record(s) Not Archived

<$font_title>Error: Record(s) Not archived

<$font>The records with the following keys were not found in the database: <$font_red>'$errstr'.

|; &html_footer; print qq|

|; } sub html_unarchive_search { # -------------------------------------------------------- # The page is displayed when a user wants to archive records. First the user has to search the database to pick which records to archive. # That's handled by this form. # No changes from the original subroutine. &html_print_headers; print qq| $html_title: Search the Database for Deletion.
$html_title: Search the Database for Archiving

<$font_title>Search the Database for Un-Archiving

<$font>

Search the database for the records you wish to un-archive or list all:

|; &html_record_form(); &html_search_options; print qq|

|; &html_footer; print qq|

|; } sub html_unarchive_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now pick which records to archive from the records returned. This page # should produce a checkbox with name=ID value=archive for each record. We have to do a little work to convert the array @hits that contains # the search results to a hash for printing. # Changed the original line: my ($status, @hits) = &query("mod"); to: my ($status, @hits) = &arh_query("mod"); # re-worded a few lines to read "Unarchived" rather than archived" my ($status, @hits) = &arh_query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); &html_print_headers; print qq| $html_title: UnArchive Record(s).
$html_title: UnArchive Record(s)
|; if ($status ne "ok") { # There was an error searching! print qq|

Error: $status

|; } else { print qq|

<$font>Check which records you wish to unarchive and then press "UnArchive Records":
Your search returned $db_total_hits matches.|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } # Go through each hit and convert the array to hash and send to html_record for printing. Also add a checkbox with name=key and value=unarchive. print qq|

|; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
|; &html_record (%tmp); print qq|
\n|; } print qq|

|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } } &html_footer; print qq|

|; } sub html_unarchive_success { # -------------------------------------------------------- # This page let's the user know that the records were successfully unarchived. my $message = shift; &html_print_headers; print qq| $html_title: Record(s) UnArchived.
$html_title: Record(s) UnArchived.

<$font_title>Record(s) Unarchived

<$font>The following records were unarchived: '$message'.

|; &html_footer; print qq|

|; } sub html_unarchive_failure { # -------------------------------------------------------- # This page let's the user know that some/all of the records were not unarchived (because they were not found in the database). # $errstr contains a list of records not unarchived. my ($errstr) = $_[0]; &html_print_headers; print qq| $html_title: Error: Record(s) Not UnArchived.
$html_title: Error: Record(s) Not UnArchived

<$font_title>Error: Record(s) Not unarchived

<$font>The records with the following keys were not found in the archive: <$font_red>'$errstr'.

|; &html_footer; print qq|

|; } ######################################### ## Archiving ## # USE THE SUBROUTINES BELOW IF YOU ARE USING THE "USER-FRIENDLY HTML.PL" OR "SHORT/LONG DISPLAY" MOD. ######################################### sub html_archive_search { # -------------------------------------------------------- # The page is displayed when a user wants to archive records. First the user has to search the database to pick which records to archive. That's handled by this form. $page_title = "Search the Database for Archiving"; &html_page_top; $submit_button = "Search"; $reset_button = "Reset Form"; print qq|<$font>

Search the database for the records you wish to archive or list all:

|; print qq| |; &html_record_form(); &html_search_options; print qq|

 

|; &html_footer; &html_page_bottom; } sub html_archive_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now pick which records to archive from the records returned. This page should produce a checkbox with name=ID value=archive for each record. We have to do a little work to convert the array @hits that contains the search results to a hash for printing. my ($status, @hits) = &query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); $page_title = "Archive Record(s)"; &html_page_top; $submit_button = "Archive Checked Record(s)"; $reset_button = "Reset Form"; if ($status ne "ok") { # There was an error searching! print qq|

<$font_error>Error: $status

|; &html_footer; &html_page_bottom; } else { print qq|

<$font>Check which records you wish to archive and then press "archive Records":
Your search returned $db_total_hits matches. |; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } print qq|

|; # Go through each hit and convert the array to hash and send to html_record for printing. Also add a checkbox with name=key and value=archive. print "

"; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
|; &html_record (%tmp); print qq|
\n|; } print qq|

 

|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } &html_footer; &html_page_bottom; } } sub html_archive_success { # -------------------------------------------------------- # This page let's the user know that the records were successfully archived. my $message = shift; $page_title = "Record(s) Archived"; &html_page_top; print qq| <$font>The following records were archived: '$message'.

|; &html_footer; &html_page_bottom; } sub html_archive_failure { # -------------------------------------------------------- # This page let's the user know that some/all of the records were not archived (because they were not found in the database). # $errstr contains a list of records not archived. my ($errstr) = $_[0]; $page_title = "Record(s) Not Archived"; &html_error_page_top; print qq| <$font>The records with the following keys were not found in the database: <$error_color>'$errstr'.

|; &html_footer; &html_page_bottom; } sub html_unarchive_search { # -------------------------------------------------------- # The page is displayed when a user wants to unarchive records. First the user has to search the database to pick which records to unarchive. That's handled by this form. $page_title = "Search the Database for UnArchiving"; &html_page_top; $submit_button = "Search"; $reset_button = "Reset Form"; print qq| <$font>

Search the database for the records you wish to unarchive or list all:

|; print qq|
|; &html_record_form(); &html_search_options; print qq|

 

|; &html_footer; &html_page_bottom; } sub html_unarchive_form { # -------------------------------------------------------- # The user has searched the database for deletion and must now pick which records to unarchive from the records returned. This page should produce a checkbox with name=ID value=unarchive for each record. We have to do a little work to convert the array @hits that contains the search results to a hash for printing. # changed the "&query("mod") to &arh_query("mod") my ($status, @hits) = &arc_query("mod"); my ($numhits) = ($#hits+1) / ($#db_cols+1); my ($maxhits); $in{'mh'} ? ($maxhits = $in{'mh'}) : ($maxhits = $db_max_hits); my (%tmp); $page_title = "unarchive Record(s)"; &html_page_top; $submit_button = "Unarchive Checked Record(s)"; $reset_button = "Reset Form"; if ($status ne "ok") { # There was an error searching! print qq|

<$font_error>Error: $status

|; &html_footer; &html_page_bottom; } else { print qq|

<$font>Check which records you wish to unarchive and then press "unarchive Records":
Your search returned $db_total_hits matches. |; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } print qq|

|; # Go through each hit and convert the array to hash and send to html_record for printing. Also add a checkbox with name=key and value=unarchive. print "

"; for (0 .. $numhits - 1) { %tmp = &array_to_hash($_, @hits); print qq|
|; &html_record (%tmp); print qq|
\n|; } print qq|

 

|; if ($db_next_hits) { print "
<$font>Pages: $db_next_hits"; } &html_footer; &html_page_bottom; } } sub html_unarchive_success { # -------------------------------------------------------- # This page let's the user know that the records were successfully unarchived. my $message = shift; $page_title = "Record(s) unarchived"; &html_page_top; print qq| <$font>The following records were unarchived: '$message'.

|; &html_footer; &html_page_bottom; } sub html_unarchive_failure { # -------------------------------------------------------- # This page let's the user know that some/all of the records were not unarchived (because they were not found in the database). # $errstr contains a list of records not unarchived. my ($errstr) = $_[0]; $page_title = "Record(s) Not unarchived"; &html_error_page_top; print qq| <$font>The records with the following keys were not found in the database: <$error_color>'$errstr'.

|; &html_footer; &html_page_bottom; }