Gossamer Forum
Home : Products : DBMan : Customization :

Need Field User viewable but only admin editable

Quote Reply
Need Field User viewable but only admin editable
I need some way to allow all users to view certain fields but only allow admin to edit them.

I know it is rather easy to hide fields from the user but make them available to anyone with admin permission. What I need is the ability to show a field to all users but only allow editing of this field by those with admin permissions.

For example... a field to show a members rating within an organization. I need field to be available for all to view and search for...... but only allow it to be modified by admin permission.

Is it possible to alter the modify sub to allow modifications to certain fields only by admin? Yet still allow global view?
Quote Reply
Re: [jeffa] Need Field User viewable but only admin editable In reply to
I think I have answered my own question thru experimentation. Inside html.pl I managed to do what I wanted by creating 2 different subs for html_record and html_record_form. Inside all of the Modify Subroutines, I called the second subs html_record2 and html_record_form2. For the fields I wanted to be viewable by all but only editable by admin, I modified these secondary subs so that the fields I was interested in doing this with would be hidden unless the user had admin permissions. This way, the values of the field would still be stored... but not seen. And... since all other subs such as the Search and View subs still used the original html_record_form and html_record, the fields I had set to only be modifyable by admin still displayed normally.
Quote Reply
Re: [jeffa] Need Field User viewable but only admin editable In reply to
There is a much easier way to do this within the html_record_form. You can make the field hidden to all but admin and still display the field normally in your html_record or html_record_long (short/long mod).

You could just use:

|;
if ($per admin){ print qq|
<TR><TD><$font>Rating</font></TD><TD><INPUT TYPE="text" NAME="Rating" SIZE="10" VALUE="$rec{'Rating'}" MAXLENGTH="40"></TD></TR>|;
}
else {
print qq|<TR><TD COLSPAN=2><INPUT TYPE="hidden" NAME="Rating" VALUE="$rec{'Rating'}"></TD></TR> |;
}

There are many tips and trick like this in the FAQ noted below :)

Unoffical DBMan FAQ

http://creativecomputingweb.com/dbman/index.shtml/
Quote Reply
Re: [LoisC] Need Field User viewable but only admin editable In reply to
Yes but would that not also hide it in the search form as well? Say that someone wanted to search for all with a particular rating?
Quote Reply
Re: [jeffa] Need Field User viewable but only admin editable In reply to
I don't think it would prevent the field from being searched on. Are you using a custom search form or a keyword searh?

The coding should only prevent it from being visible on the add form. The displays should work fine.

Unoffical DBMan FAQ

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