Gossamer Forum
Home : Products : DBMan : Customization :

Viewing admin only fields.

Quote Reply
Viewing admin only fields.
I have a database setup that is going to be used (hopefully) to issue and track document numbers. There are 8 fields in each record, 4 of which are admin only (-2) because I only want the admin to be able to modify these fields. However, I need them to be viewable (and searchable) by everyone. It seems that the admin fields don't show up unless your logged in as the admin (How is that any different than hidden fields?).

Maybe there is another way to set this up or somebody has a workaround for this?

Thanks

Daniel Alexander
Quote Reply
Re: Viewing admin only fields. In reply to
Dan,

In your sub html_record_form area, all your admin only fields must look something like this:

if ($per_admin) {
print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="150" bgcolor="#dcdcdc"><$font_color>whatever:</FONT></TD>
<TD VALIGN="TOP" WIDTH="475"> <INPUT TYPE="TEXT" NAME="whatever" SIZE="25" VALUE="$rec{'whatever'}" MAXLENGTH="30"></TD></TR>
|;
}
else {
print qq|
<input type="hidden" NAME="whatever" VALUE="$rec{'whatever'}">
|;
}

This will only affect the fields shown when you log into your add form, so you can specify who can add what. When it comes time to view whatever, just do it as a normal field in sub html_record:

print qq|
<TR><TD ALIGN="Right" VALIGN="TOP" WIDTH="20%"><$font_color>Whatever:</FONT></TD>
<TD WIDTH="80%"> <$font>$rec{'Whatever'}</Font></TD></TR> |;

That should do it for you
Good Luck!

Mike

Quote Reply
Re: Viewing admin only fields. In reply to
mrmeat,

I looked thru the routines that you mentioned (specifically the build_html_record) and commented out the "nextif" line that checks for -2 fields. This works like a charm and displays the admin fields in the search results for normal users.

However, I havn't found where the search form code is that checks for the admin fields so I can make those show up for normal users too. I want any user to be able to search within these admin fields as well as sort by them in the searchs.

Any idea where I can change that?

Thanks for the help,

Daniel Alexander
Quote Reply
Re: Viewing admin only fields. In reply to
Dan,

As long as you are allowing those with view permissions to see all fields, it should carry over to your search fields. I'm not quite sure why it wouldn't.

Is there a way I could take a look at the url and see what the search is showing? it would be a great help.

Hope I can Help,
Mike
Quote Reply
Re: Viewing admin only fields. In reply to
Dan,

As long as you are allowing those with view permissions to see all fields, it should carry over to your search fields. I'm not quite sure why it wouldn't.

Is there a way I could take a look at the url and see what the search is showing? it would be a great help.

Hope I can Help,
Mike
Quote Reply
Re: Viewing admin only fields. In reply to
It's all running on my PC right now which is behind the firewall. Frown

I've looked pretty hard and can only find one place that checks for -2 fields and converts them to hidden input fields and thats in sub build_html_record_form. I'm not sure, but this must be used for not only the ADD form but the search form as well. This would explain why the only form fields a normal user sees when he goes to the search page are the same ones he sees when he goes to the add form. This would also make it not possible to do what I am wanting because if I comment out the part that checks for -2 fields, it will then show them in the normal users add form and let them add that information (not what I want). My guess is that this same subroutine is used in every instance that a form is needed (add, view, modify, delete). This just makes sense from a programming standpoint (but not from a flexibility standpoint).

If anybody has any ideas on a way to work around that, I'm all ears. Smile


Thanks,

Daniel Alexander
Quote Reply
Re: Viewing admin only fields. In reply to
FYI. I worked around it by creating a duplicate of sub build_html_record_form called build_html_addrecord_form to use specifically for the adding of records which does not show the admin fields. All others use the old sub build_html_record_form which shows the admin fields for searches. Since my normal users don't have "Modify" permissions this worked just fine. I suppose you could create a duplicate subroutine for every instance that the form is needed if you wanted.

Thanks for hangin in there with me. Smile

(P.S. Not bad for somebody who doesn't know a lick of perl eh?)

Daniel Alexander

[This message has been edited by vewdew (edited December 02, 1999).]