Gossamer Forum
Home : Products : DBMan : Customization :

How do I set diff UID when logged in as Admin?

Quote Reply
How do I set diff UID when logged in as Admin?
I want only admin to be able to create entries, but want to be able to set a specific UID that can view it. eg admin enters the data and specifies a UID of "smith" (separate UID)
I have the following sections of code in the respective files:
default.cfg:
---------------
%db_def = {
'UID' => [1, 'alpha', -2, 10, 0, '', '' ],

$auth_user_field = 1 (correct field in DB)
----------------

html.pl:

under "sub html_record_form", I have the following:
------------------
if ($per_admin) {
print qq|
<TR><TD><$font>User ID:</FONT></TD>
<TD INPUT TYPE="text" NAME="UID" VALUE="$rec{'UID'}"></TD></TR>|;
}
else {
print qq|<INPUT TYPE="hidden" NAME="UID" VALUE="$rec{'UID'}">|;
}
...

This brings up a text field on the form, but whatever is written here is replaced by "admin" for the UID.

How can I get this to keep and use the text I enter as the UID?



Quote Reply
Re: How do I set diff UID when logged in as Admin? In reply to
 
Make the following change to 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 ($per_admin) {
($auth_user_field >= 0) and ($in{$db_cols[$auth_user_field]} = $db_userid);
}


This will prevent the script from defaulting to admin when you are adding or modifying a record.

Hope this helps

Unoffical DBMan FAQ
http://webmagic.hypermart.net/dbman/
Quote Reply
Re: How do I set diff UID when logged in as Admin? In reply to
Thanks - that worked perfectly.