Gossamer Forum
Home : Products : DBMan : Customization :

Help with dbkey and admin access

Quote Reply
Help with dbkey and admin access
My database is setup with the dbkey being the username. This is to allow each user only one record, and also they can only change their own record.

I need for the admin user to be able to change the info in someone's record without the dbkey changing to the admin's username.

Can this be done?
Quote Reply
Re: [cap1tan] Help with dbkey and admin access In reply to
You sure can make the following change in sub add_record in db.cgi:

Change code:

# Set the userid to the logged in user.
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);

to code:

# Set the userid to the logged in user unless admin
unless ($per_admin) {
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);
}

Then if you or when you add records you would have to manually add your userid.

This and other tips can be found in the FAQ noted below.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Help with dbkey and admin access In reply to
That's great!

I also have the userid field as a hidden field. What would the code look like to have the userid field visible only for admin's?
Quote Reply
Re: [cap1tan] Help with dbkey and admin access In reply to
Try

if ($per_admin) {
print qq! $rec{'Userid'} !;
}


chmod
Quote Reply
Re: [cap1tan] Help with dbkey and admin access In reply to
I think I answered my own question:
Code:
print qq|<input type=|;

if ($per_admin) { print qq|"text"|;
}
else {
print qq|"hidden"|;
}

print qq| name="UserID" value="$rec{'UserID'}" size="30" maxlength="30">