Tests whether a given user has the specified role.
Class Name |
|
---|---|
Component |
|
Required Input Parameters
function
The function property of the relative role held by the user.
userId
The ID of the user whose functional role to check. For example:
<dsp:param name="userid" beanvalue="/atg/userprofiling/Profile.id"/>
Optional Input Parameters
organizationId
An organization name. If set, the servlet bean returns true only if the user is assigned the function in this organization.
Open Parameters
true
This parameter and the tags nested within it are rendered when an item matches the conditions defined by the input parameters.
false
This parameter and the tags nested within it are rendered when no item matches the conditions defined by the input parameters.
error
Rendered if there is an error when the query executes.
Usage Notes
HasFunction determines whether a given user has a certain functional role and renders certain content based on the result. You can limit the query further by specifying an organization, meaning that a result of true is returned only if the user has the specified role in a particular organization.
Be sure to set the userDirectory
property to the relevant User Directory component.
Example
In this example, HasFunction determines if the active user is an admin
for the org1001
organization, and when he/she is, displays a link to a page for creating user accounts. Otherwise, a link to the profile page displays.
<dsp:droplet name="/atg/userdirectory/droplet/HasFunction"> <dsp:param name="function" value="admin"/> <dsp:param name="userId" beanvalue="/atg/userprofiling/Profile.id"/> <dsp:param name="organizationId" value="org1001"/> <dsp:oparam name="true"> <dsp:a href="UserAccountForms.jsp">Set up new user accounts</dsp:a> </dsp:oparam> <dsp:oparam name="false"> <dsp:a href="UserAccountInfo.jsp">Edit your profile</dsp:a> </dsp:oparam> </dsp:droplet>