Gossamer Forum
Home : Products : DBMan : Customization :

Delete user does not delete record?

Quote Reply
Delete user does not delete record?
I am curious to know if dbman is supposed to delete the users record when admin deletes the user? My database is not doing this.

If so where might be the problem?

thanks !

Denny

VWPowered
www.vwpowered.com
Quote Reply
Re: Delete user does not delete record? In reply to
It's not an "out of the box" feature, but it is something which can be added in.

Check out LoisC's DBMan FAQ for more information:
http://webmagic.hypermart.net/dbman/

Good luck!

- Mark


Astro-Boy!!
http://www.zip.com.au/~astroboy/
Quote Reply
Re: Delete user does not delete record? In reply to
Thanks Astroboy, always a mod eh !

denny

VWPowered
www.vwpowered.com
Quote Reply
Re: [AstroBoy] Delete user does not delete record? In reply to
Hi.
I'm looking for this mod now and I don't found yet.
Can you help me?
Thank's.
Quote Reply
Re: [pepee] Delete user does not delete record? In reply to
Can anyone help me?
I'm thinking now, it's will be nice if the admin display it had a checkbox for choosing delete or not the records together.
huh?
Quote Reply
Re: [pepee] Delete user does not delete record? In reply to
I was hoping that Lois would see this and tell us if she had a mod in her database like this. I seem to have lost the correct URL for it.

Add a checkbox to sub html_admin_display would be easy enough to do. Call it "del_user_records" or something. Then, in sub admin_display (db.cgi), in the

Code:

$in{'delete'} and do {

section, after the username is deleted from the password file, you would add the routine to delete records.

I would change

Code:

$found ?
($message = "User: $in{'username'} deleted.") :
($message = "Unable to find userid: $in{'username'} in password file.");


to
Code:

if ($found)
{
$message = "User: $in{'username'} deleted."
if ($in{'del_user_records'})
{
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); }
@lines = <DB>;
close DB;

LINE: foreach $line (@lines) {
if ($line =~ /^$/) { next LINE; }
if ($line =~ /^#/) { $output .= $line; next LINE; }
chomp ($line);
@data = &split_decode($line);
($output .= "$line\n" and next LINE) if ($in{'username'} ne $data[$auth_user_field]);
}
open (DB, ">$db_file_name") or &cgierr("error in admin_display. unable to open db file: $db_file_name.\nReason: $!");
if ($db_use_flock) {
flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_file_name.\nReason: $!");
}
print DB $output;
close DB; # automatically removes file lock
}
}
else
{
$message = "Unable to find userid: $in{'username'} in password file.";
}


I haven't tested this at all. I just copied bits of db.cgi. Please make a backup of your database before you try this. I'd hate for you to lose things you don't want to lose because I've made an error some place. It seems like the logical way to do it, but better safe than sorry. :)


JPD
----------------------------------------------------
JPDeni's DBMan-ual
How to ask questions the smart way.
Quote Reply
Re: [JPDeni] Delete user does not delete record? In reply to
Yes, it's working!
I just had corrected these two lines in the routine, to be like the original version:
($message = "User: $in{'username'} deleted.");
($message = "Unable to find userid: $in{'username'} in password file.");

About html_admin_display, I put this tag:

<input type=checkbox name="del_user_records" value="1"><$font>Delete records.</font>

Thank you again.