Gossamer Forum
Home : Products : DBMan : Customization :

ADMIN add new record for registered user

Quote Reply
ADMIN add new record for registered user
This was answered somewhat before but the examples are not in the thread and the FAQ does not have any info listed about this anymore that i could find:



just want it brokedown how ADMIN can ADD record for REGISTERED USER so USER can then view/modify since i have them restricted to doing this to their own records.... many thanks in advance. booboo
Quote Reply
Re: [booboo] ADMIN add new record for registered user In reply to
Let me see if I understand the problem.

When the ADMIN creates the record, the ADMIN is the owner, thus the user cannot see the record.

If this is the problem, I had a similar problem and if was answered. I recall that I had to put an if statement around the line in the sub html_add_form that stopped the

<input type=hidden name="uid" value="$db_uid">

from assigning the ADMIN as the uid.
Quote Reply
Re: [booboo] ADMIN add new record for registered user In reply to
This is referenced in the FAQ under a few different thread, but here is the solution:

Add userid automatically when adding records:

In sub get_defaults replace:

foreach $field (keys %db_defaults) {
$default{$field} = $db_defaults{$field};
}

with:

foreach $field (keys %db_defaults) {
$default{$field} = $db_defaults{$field};
####### add userid in add form ###########
unless ($per_admin) { ($auth_user_field >=0) and ($db_defaults{$db_cols[$auth_user_field]} = $db_userid); }
}


In sub add_record instead of:

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

use:

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

This will allow you as admin to manually enter the userid so the record owner can then modify his/her record.

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/