Gossamer Forum
Home : Products : DBMan : Customization :

Skip Search to Modify/Delete 1 record

Quote Reply
Skip Search to Modify/Delete 1 record
Hello,

I know i have seen this but cannot find it searching forum; I would like a user to be able to view their record (they only have one) when clicking modify or delete - instead of going to a search form. They do not have permision to view - only add, modify and delete.

Sorry if this is a redundant question, any direction is appreciated.

BTW: I guess they could have more than one record but practically speaking they only add one - is there a way to limit it to one ?

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Here's a post that answers your question:

luthien
posted January 17, 1999 11:46 PM PST
what would be the best way to go about making the 'modify' option automatically bring up the user's profile, instead of making them search for it?

Alex
posted January 17, 1999 11:55 PM PST
Assuming you are using a Userid field:

<a href="$db_script_link_url&modify_form=1&Userid=$db_userid">Modify</a>

would do the trick!

Cheers,
Alex


Hope this helps Smile
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
 
Quote:
is there a way to limit it to one ?

Yep. In the Resource Center -> DBMan -> Modifications, look for

Limiting the number of records per user



------------------
JPD






Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Thank you Lois and JP, both worked just fine; one other question - I tested the above - created a user, added a record, went to modify (and delete) got the record and could not add a second record. Worked great.

Here is the question; when I delete a user their posting is still there - if another user signs up (with same UserID) they can't add a record, and modifying/deleting brings them to "old" user's record. Is'nt there a way that when I delete a user their record is also deleted ?

Thanks,

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
You don't come up with easy ones, do you? Smile

I think this will work -- be sure that you use non-vital data when you test this out!!!

In sub admin_display (in db.cgi) 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.";
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, 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);

unless ($data[$auth_user_field] eq $in{'username'} ) {
$output .= $line . "\n"
}
}

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;
}
else {
$message = "Unable to find userid: $in{'username'} in password file.";
}

Like I say, I'm not sure if this will work or not. But you can give it a shot!


------------------
JPD








[This message has been edited by JPDeni (edited April 27, 2000).]
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Well, that did not work, still would like it to, though.

Another thing has happened, related to my previous mod; now when the admin clicks modify or delete NO records are shown. Is there a way to still allow admin to get all records given the changes I (we) made with single record mod and modify link ?

Thanks again,

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
How didn't it work? Did it not delete the record? Or did it delete everything? Or did it delete something completely different? Or did you get a 500 Error?

One thing you might change in the code I gave you is, instead of

Code:
unless ($data[$db_key_pos] eq $in{'username'} ) {

use

Code:
unless ($data[$auth_user_field] eq $in{'username'} ) {


As for your other problem, try the mod at http://www.jpdeni.com/.../Mods/autosearch.txt . That takes admins into account.


------------------
JPD






Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
okay, i added the mod which solved the admin delete / modify issue (thanks!) - the change we made to db.cgi did not work and the error is that nothing of notice happens when deleting a user - the user is deleted as per usual but the records are not; there is no other apparent difference or errors shown.

I'll post what i have here:

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

unless ($data[$auth_user_field] eq $in{'username'} ) {
$output .= $line . "\n"
}
}

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;
}
else {
$message = "Unable to find userid: $in{'username'} in password file.";
}
last CASE;
};

Thanks, once again.

Jim

Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
I'm not sure what the problem is, then. Do you have the $auth_user_field set to the number of the userid field?


------------------
JPD






Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Yes, the $auth_user_field is set to the number of the userid field. I guess I am a bit confused; everything works fine except deleting one's records when deleting their user name.

I posted the files here:
http://www.takeyourshot.com/default_cfg.txt
http://www.takeyourshot.com/html_pl.txt
http://www.takeyourshot.com/db_cfg.txt
http://www.takeyourshot.com/db_cgi.txt


The program is here:
http://www.takeyourshot.com/cgi-bin/dbmancp/db.cgi

Thanks, again,

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
I'll need to create my own database and test this out. It may take a day or two.


------------------
JPD






Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Thanks, JP, I sincerely appreciate all the time you give to me and the forum, it has helped me tremendously.

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Oh. You are using the SQL version. I didn't realize that until I looked at your files.

I'm afraid I can't help you with that. I don't have access to SQL on my server, so I haven't been able to work with it.

The code I gave you does work with the regular version, though, at least on the database I made to test it.


------------------
JPD






Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
Actually, I am using the SQL version for my site at sysadminsrus.com - but this is not connected yet, simply using the flattext file, I started again from scratch using (I thought) the orginal downloadable scripts and some of your mods. Once I got things going then I will work in as SQL version -

Also, having read quite a bit in the forum (which helped me tremendously) I have quite a few mods on my SQL version - all were put in before moving to SQL and all worked flawlessly now - thanks to Alex.

Thanks,

Jim

Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
What I meant to say (though perhaps incoherently) - What I am working on now is not part of SQL - but I am still stuck.

Jim
Quote Reply
Re: Skip Search to Modify/Delete 1 record In reply to
The .cfg file I looked at was an SQL file. It is set up a little differently than the regular DBMan file. You'll need to use a non-sql DBMan .cfg file if you're not using SQL.


------------------
JPD