kburnett
|
| Posted: 05/15/2002, 3:09 PM |
|
I want to chage a field type based on the user. The field (called "permission") is originally a select list. However, once a user has been assigned a low-level of security the do not have the authority to alter their user level.
I have read up on how to alter field types. But those solutions were only for text field vs. hidden. in my case i need to either show a select list or a hidden field.
So it seems the only option for alternating between a select list and hidden field is to have separate forms to display based on user.
Has anyone found a better way around this?
Thanks,
Kyle
|
|
|
 |
Nicole
|
| Posted: 05/16/2002, 2:34 AM |
|
Hello,
the workaround could be:
use Label type field (with selected 'HTML' flag of course) and assign it custom html code depending on user rights. If you need help with code let me know your programming language.
|
|
|
 |
kburnett
|
| Posted: 05/16/2002, 6:51 PM |
|
nicole - you are soooo helpful. since i see you name everyone on this board am i to assume you are with codecharge (or whatever it's parent company is)?
so here's my situation:
code: php
db: mysql
table: user
relevant fields: permission tinyint
possible permission values: 1 = general user, 2 = admin
what i done so far in codecharge:
1) created grid that links to the edit page
2) the edit page has permission as a "select list" with values 1;User;2;Admin
3) allowed insert, update, delete
all is well so far. every type of action works great.
but here what i need to do is on the "edit" page:
1) determine current user's permission
2) if permission == 1 then alter permission to not be a select list but rather be a label with a hidden form value
so from what i can tell, there is no smooth way to simply say:
if (get_session("UserRights") == 1)
{
$fldpermission="<input type=\"hidden\" name=\"permission\" value=\"".$fldpermission."\">".$fldpermission;
}
now this work just fine if permission is a label type with the html option turned on.
what works, sort of, is the ol' 2 form routine. but i would rather code then multiple my forms.
i hope this all made sense.
kyle
|
|
|
 |
kburnett
|
| Posted: 05/16/2002, 11:53 PM |
|
That second sentance should have read:
"since i see your name everywhere on this board..."
I really wish this BB had an edit feature as I am so sloppy.
kyle
|
|
|
 |
Nicole
|
| Posted: 05/17/2002, 2:48 AM |
|
Hello,
here is sample code that is to be placed in Before Show event to display listbox or label field (with hidden one of course) depending on user rights:
$show = $fldmember_level;
if (get_session("UserRights")>= 3)
{
$fldmember_level = "<select name=\"member_level\"><option value=\"\">Select Value</option>";
$LOV = split(";", "1;User;2;Admin");
if(sizeof($LOV)%2 != 0)
$array_length = sizeof($LOV) - 1;
else
$array_length = sizeof($LOV);
for($i = 0; $i < $array_length; $i = $i + 2)
{
if($LOV[$i] == $show)
$fldmember_level .="<option SELECTED value=\"" . $LOV[$i] . "\">" . $LOV[$i + 1];
else
$fldmember_level .="<option value=\"" . $LOV[$i] . "\">" . $LOV[$i + 1];
}
$member_level .="</select>";
}
else
{
$fldmember_level .= "<input type = \"hidden\" name = \"member_level\" value = ".$fldmember_level.">";
}
Just use real field names.
Also do jot forget to create Custom Action event in order to get passed "member_level" value and add it to sql statement. It is necessary because "member_level" is Label type on the form and non updatable fields aren't included into generated insert/update queries.
|
|
|
 |
|