Gossamer Forum
Home : Products : Links 2.0 : Discussions :

Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete

Quote Reply
Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete In reply to
Well, I was incorrect when I said they were stored in delete.db. The actual file name they are stored in is linksdel.db.

In db.pl, sub delete-records, I changed this code:

Code:
# Search the database for a record to delete.
open (DB, "<$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);

$delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
($output .= "$_\n"); # otherwise print it.
}
close DB;

To read:

Code:
# Search the database for a record to delete.
open (DB, "<$db_file_name") or &cgierr("error in delete_records. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) { flock(DB, 1); }
LINE: while (<DB> ) {
(/^#/) and ($output .= $_ and next LINE);
(/^\s*$/) and next LINE;
chomp;
@data = &split_decode($_);

# If this is the ID of a record to delete, mark it as deleted and store
# it in the linksdel.db database for possible future reactivation. Do not
# print it to the links.db database. If it is not the ID of a record to
# delete, then include the record in $output for writing to links.db.
if ($delete_list{$data[$db_key_pos]}) {
$delete_list{$data[$db_key_pos]} = 0;
open (DELDB, ">>$db_script_path/data/linksdel.db")
or &cgierr("Unable to open $db_script_path/data/linksdel.db.\nReason: $!");
print DELDB "$_\n";
close DELDB;
}
else { $output .= "$_\n"; }

# $delete_list{$data[$db_key_pos]} ? # if this id is one we want to delete
# ($delete_list{$data[$db_key_pos]} = 0) : # then mark it deleted and don't print it to the new database.
# ($output .= "$_\n"); # otherwise print it.
}
close DB;

You could do something similar for the sub validate_records routine in db.pl.

I hope this helps.

[This message has been edited by Bobsie (edited August 08, 1999).]
Subject Author Views Date
Thread Modify Link - "Modify" "Delete" - what if I don't want to modify or delete Troy 2327 Aug 5, 1999, 12:13 PM
Post Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete
Brad Richardson 2236 Aug 6, 1999, 7:02 AM
Post Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete
Bobsie 2237 Aug 7, 1999, 1:28 AM
Post Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete
chmod 2239 Aug 7, 1999, 4:40 AM
Post Re: Modify Link - "Modify" "Delete" - what if I don't want to modify or delete
Bobsie 2236 Aug 8, 1999, 8:59 AM