Gossamer Forum
Home : Products : DBMan : Customization :

Personal and Public Viewing

Quote Reply
Personal and Public Viewing
In my application, I would like to have the ability to enable users to select "private" or "public" viewing. I've created a database object call view_type(Private,Public) which they choose in the add record function

However, my challenge is to find out how to set this selection in the view screen so that those will private record can find them and all public records are reality available.

if view_type=public then view all can view
if view_type=private must enter "userid" view your record.

Any thoughts would be appreciated.
Quote Reply
Re: Personal and Public Viewing In reply to
I'm afraid you lost me with the words "I've created a database object." Possibly someone else will understand.

------------------
JPD





Quote Reply
Re: Personal and Public Viewing In reply to
By database object, I mean a
%db_select_field.
Quote Reply
Re: Personal and Public Viewing In reply to
Oh, okay. Sorry. I'm just a little dense today. Smile

Do you want logged in users to be able to view the private records, or only the person who entered it?

If you want all logged in users to be able to view the private records, make the change in bold to html_view_search and html_view_failure:

Code:
<form action="$db_script_url" method="GET">
<input type=hidden name="db" value="$db_setup">
<input type=hidden name="uid" value="$db_uid">|;
if ($db_userid eq "default") {
print qq|<input type=hidden name="view_type" value="Public">|;
}
print qq|


You'll also want to take out the "Match Any" option in sub html_search_options, or this won't work.

I'm not sure how you would go about setting up an optional "view own" records.


------------------
JPD





Quote Reply
Re: Personal and Public Viewing In reply to
Thanks we are getting close, but actually I want only the individual who create a "private" record will be able to view. However, if someone creates a "public" record, all should be able to view. Thanks
Quote Reply
Re: Personal and Public Viewing In reply to
I don't know if this would work, but it's a possibility.

Find the line

next LINE if ($restricted and ($db_userid ne $values[$auth_user_field]));

in db.cgi, sub query

Change it to

next LINE if (($values[#] eq "Private") and ($db_userid ne $values[$auth_user_field]));

Replace # with the field number of the "view_type" field.

One thing that you need to be careful of. Words are case-sensitive in Perl. In your first message in this thread you mentioned

view_type(Private,Public)

and then later

if view_type=public then view all can view
if view_type=private must enter "userid" view your record.

You must be consistent with the values. If your select field is defined as

view_type => 'Private,Public'

the above code will be fine. However, if it's

view_type => 'private,public'

you'll need to change the code above to match.

I don't know if this will work or not.

------------------
JPD