Gossamer Forum
Home : Products : DBMan : Customization :

$auth_modify_own

Quote Reply
$auth_modify_own
I am converting an existing DBMan (single user/admin) to one where visitors can signup for their own account.

The signup works OK, but when adding a record I need to add their signup username to the database so DBMan knows who the record belongs to. How do I do that or should I use $uid instead?

i.e. change default.cfg:
Owner => [10,'alpha', 64, 64, 1, '', '']

to:
uid => [10,'alpha', 64, 64, 1, '', '']

Best regards, Brian
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
In your .cfg file you can setup a field for your userid (calling it whatever you choose)

'UserID' => [ 0,'alpha',10,8,1,'',''],

Then be sure to setup your:

$auth_user_field = 0;

to match the field number for your userid.

Then in your html.pl file you will need to this field to your html_record_form either as a visible or hidden field.

If you want the userid automatically filled in when they enter new records you can setup the script to do so. There was a recent thread with the instructions.

Check out this thread:

http://www.gossamer-threads.com/perl/gforum/gforum.cgi?post=193903

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] $auth_modify_own In reply to
Thanks for the reply. I am trying a hidden value in the add form but don't know what to put as the value. I have tried:

<input type=hidden name=Owner value=$uid>
$uid is obviously unique to that particular users's logon i.e. username.random_number, so that doesn't work

<input type=hidden name=Owner value=$userid>
Value = ""

<input type=hidden name="Owner" value="$in{'userid'}">
Value=""

Am I over simplifying matters?

I have done a search for any posts for userid, but so far haven't found one relevant to this...

Best regards, Brian
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
Think I have it with:
<input type=hidden name="Owner" value="$db_userid">
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
Nope - only half way there...

If I add a record as a signed-up user the Success page returns blank fields. However the record is added correctly to the database file with my userid!

If I deliberately omit a required field on adding, the error page correctly returns the exisiting field values.

Searching for modification/deletion (and list all) shows "no matching records" Unimpressed

Logging in as admin I can view, modify and delete the 'user' records without problem.

Can anyone help?
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
You should put the hidden field in your html_record_form like this:

<input type="hidden" name="Owner" VALUE="$rec{'Owner'}">

For your others problems could you make a text copy of your .cfg file and post the url to access it.

Have you by any change visited JPDeni's DBMan tutorial site? She has a configurator which really helps setting up your basic database and provides you with your .cfg file and also the coding for your html_record_form and html_record.

Then you only need to modify the html coding to suit your display needs. http://www.jpdeni.com/dbman/

If you want to continue to work with what you already have, we will be happy to help.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] $auth_modify_own In reply to
Hello Lois - thanks for your time on this.

OK I have added:
<input type="hidden" name="Owner" VALUE="$db_userid">

to sub html_record_form and removed it from the add/modify routines - but same problem (results do not show on the success page and a user search to mod/del gives "no records")

The cfg is at www.omegadm.co.uk/demos/default.cfg

I am supposed to be quite familar with the DBMan code as an experienced user Blush but I haven't looked at the code for over a year...


Thanks, Brian
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
<input type="hidden" name="Owner" VALUE="$db_userid">

is not correct it should be:

<input type="hidden" name="Owner" VALUE="$rec{'Owner'}">


Your field numbers are not in consecutive order. Notice you are missing #2. They must be 0 to 9 in your cfg file.
This could be causing your problems.

Also unless you are using autogenerate the -2 functions will not work.

Change to:

ID => [ 0, 'numer', -2, 8, 1, '', ''],
Reference => [ 1, 'alpha', 8, 8, 1, '', ''],
Price => [ 2, 'numer', 64, 64, 1, '', ''],
Resort => [ 3, 'alpha', 64, 64, 1, '', ''],
Bedrooms => [ 4, 'numer', 8, 8, 1, '', ''],
Description => [ 5, 'alpha', 1024, 1024,1, '', ''],
Filename => [ 6, 'alpha', 64, 64, 0, '', ''],
Graphic => [ 7, 'alpha', 0, 3, 0, '', 'Yes'],
DateOfEntry => [ 8, 'date', -2, 15, 1, '&get_date', ''],
Owner => [ 9,'alpha', 64, 64, 1, '', '']

and then set:

$auth_user_field = 9;

If you are using Bedrooms as a select field it would look like this:

Bedrooms => [5, 'alpa', 0,8,1,'',''],

Your graphic field is setup to be a checkbox option?
then you will want to use:

%db_checkbox_fields = ( 'Graphic' => 'Yes' );

You might also want to set up your description field as a textarea as a text field should only be 255 max.

Description => [ 5,'alpha','50x10',1024,0,'',''],

and then define it with your html_record_form as:

<TEXTAREA name="Description" ROWS="10" COLS="50" WRAP="VIRTUAL" MAXLENGTH="1024">$rec{'Description'}</TEXTAREA>

Hope this helps

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] $auth_modify_own In reply to
OK sorted - the problem was with the cfg file as you correctly pointed out.

BTW, <input type="hidden" name="Owner" VALUE="$db_userid"> is the correct field to use.

If I use <input type="hidden" name="Owner" VALUE="$rec{'Owner'}"> the value will always be blank for adding records...

Thanks again for your wisdom. Now for further mods...

Brian
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
Yes, the field will be blank uless you add additional coding to your script to have it automatically fill in the userid when adding records.

Visit the FAQ under the section Admin for a thread called "Set userid to the logged in user (except if admin)"
for the codes to add. Record ID 114.

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] $auth_modify_own In reply to
I have gotten further with the crashing issue - the /auth dir is filling up with hundreds (if not thousands) of temp files until it crashes! Each temp file is empty apart from ":". The last thing I did was mod 166 and 114.

166 still works - log failed logging attempts.

auth_check_password is the place where the /auth/temp files are created, but this has not been modified.

Getting that sinking feeling Unsure...

Best regards, Brian

Quote Reply
Re: [omegadm] $auth_modify_own In reply to
OK, back on track - I had left in sub auth_logging from mod 166:

# I ADDED THIS TO GET $status, I'M SURE IT COULD''VE BEEN DONE BETTER
($status, $uid, $per_view, $per_add, $per_del, $per_mod, $per_admin ) = &auth_check_password;

when it wasn't needed (see JPDeni's comments on that mod). Can't see why that would create an inifite number of /auth temp files but that was all I could find when I did a file compare with my test server...

For mod 144 (Set userid for logged in user - accept admin), I now see why the hidden field needs to be:

<input type="hidden" name="Owner" VALUE="$rec{'Owner'}">

and not $db_userid!! At last I hear you say Smile...

It just wasn't clear that mod 144 is also required to acheive my original post - I thought they were separate issues - the text of mod 144 only mentions "modifying".

Probably a case of me trying to do too manythings at once.

Thanks for being there...
Still a great program :))))
Quote Reply
Re: [omegadm] $auth_modify_own In reply to
Glad things are working for you. And yes reading and following the instructions carefully for all the mods is very important :)

I find it useful when installing any mods to find all related threads so I would learn all I could about any further changes, problems, or tweaks.

That's how the FAQ came about, reading threads and taking notes about anything I thought would become useful in the future. So many interesting things within the threads it turned into the unofficial FAQ so others could easily find solutions.

Unoffical DBMan FAQ

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