Gossamer Forum
Home : Products : DBMan : Installation :

Need Help with authorisation modification

Quote Reply
Need Help with authorisation modification
My name is David and I recently stumbled upon your program as I was looking for a membership database script to help me manage my non-profit organisation's membership on the website. Your dbman seems to come highly recommended in the cgi-resource website. As such, I'm very tempted to try it and evaluate it myself. For your information, I'm still new to CGI/Perl but have bought O-Reilly's book to help bring me up to speed on this wonderful language.

The challenge that I have is as follows:

I would like to set up a database where individual members are able to submit their particulars into the website's database. These members are only able to modify and delete their own records although they may view all others. When they submit their records, not all fields will be made available to the public (which excludes themselves and the administrator) for viewing. This is because some of the information are considered private and to be available only to the administrator.

The closest solution which is available on your dbman script is the '-2' option for form_length in your %db_def array. The only problem with this option is that it will make this field only available to the administrator of the database. The individual member will not be able to put in their information here.

In short, how do I set up a database which will allow the member to key in their public and private information without having the private information made available for viewing by the public other then themselves and the administrator????


Besides the above problem, I would like to seek clarification on several questions.

1. How do I change the URL to a similar field which accepts e-mail addresses? (This field in contained in the %db_def array) dbman.

2. What is the use of the 'hidden' setting (i.e. -1) for the form_length field?

3. When I autogenerate the html, does it update the html.pl file with the latest variables??

4. The readme file says that the valid_expr is used to enter regular expressions to validate the input. What does this mean and what 'regular expressions' does it refer to?

If you could help me solve the main problem with authorisation, it would be fantastic. Love to hear from you all soon.

Thanks in advance
David Tan
Quote Reply
Re: Need Help with authorisation modification In reply to
You won't be able to do what you want if you use the auto-generate feature. You will have to build html_record and html_record_form in the html.pl file.

Code:
if ($per_admin or ($rec{'UserID'} eq $db_userid )) {
print qq|
[display private fields]
|;
}

A couple of things to watch out for. Before the "if" statement, close off the previous print command with a |; (pipe, semicolon). After the "if" statement, start up with print qq| to continue the rest of the display.

Remember to keep your field names consistent. They must be *exactly* like they are defined in the .cfg file.

Code:
Email => [ 4, 'alpha', 40, 255, 1, '', '.+\@.+\..+'],

(replacing the "4" with your own field number). When you display the email address, if you'd like it to be a clickable link, use

Code:
<a href="mailto:$rec{'Email'}">$rec{'Email'}</a>

This prints the email address and makes it a clickable link. If you'd rather have some other field the text for the link, replace the field name in the bolded section above.

Code:
^http://

The ^ means that the contents of the field must begin with the characters that follow.

There are entire books (well, one anyway) on regular expressions. I'm sure that you will be able to get help here if you have something you want to construct.

Welcome to the world of DBMan! Smile You will find it fascinating and frustrating at the same time, but there's lots of helpful folks here who will do their best to find answers for you.



------------------
JPD
Quote Reply
Re: Need Help with authorisation modification In reply to
Hi JPD!

Thanks again for your more then adequate explanation. I will try to reconfigure this setup on my website and see whether I can get it up successfully. There goes another sleepless night :-)

With much thanks,
David Tan
Quote Reply
Re: Need Help with authorisation modification In reply to
When I tried the clickable e-mail you suggested below I got an error after email on line 61. This in reference to:

Code:
<a href="mailto:$rec{'Email'}">$rec{'Email'}</a>

Any suggestions? Oh I put this in the last set of ''