Ask a Question related to Macromedia ColdFusion, Design and Development.
-
jlavetan #1
Selecting users that are in multiple groups
I am very new to ColdFusion and am having a light issue trying to select users
that are in multiple groups...
Basically, I want the sales people that are in the Sales group and the
Customer group to have access to a webmail link. Users in the Customers group
won't have the link displayed.
<!--- only show the reports and ecom links to the customers group --->
<!--- <cfif ListFind(ValueList(getGroups.groupID), 4)> --->
<cfif getGroups.groupID gte 4>
<a href="http://LINK_HERE/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
<!--- only show the webmail link to the sales group --->
<cfelseif getGroups.groupID gte 3>
<a href="http://WEBMAIL_LINK/"><b>CBW Webmail</b></a><br>
</cfif>
jlavetan Guest
-
Selecting objects within groups
Help! I'm using CS2 to produce an advertisement for an auto dealer. It consists of a 7x7 grid of 49 vehicles. Each vehicle space consists of a photo... -
[Carbon] how do i get a list of users and groups??
hey all, i've been struggling to figure out how to get a list of users and groups like the finder's get info window displays in its ownership &... -
selecting ordered groups out of a table
Rainer Gauweiler wrote: with recent_orders as ( select customer, invoice-nr, date, row_number() over (partition by customer, order by date... -
adding users to different groups
Hi group, I need to add a user (myself) to a group he doesn't belong to by default. On most unices I do edit the group file and voila. On the... -
local users and groups
When I try to access the Local Users and Groups, as the local administrator, there's an X, and I get an error message stating, Unable to access the... -
mxstu #2
Re: Selecting users that are in multiple groups
If I'm understanding you correctly, you have a list of groups that the current
user is a member of. If the current user belongs to both the "sales" and
"customer" group, you to want to display a "web mail" link. Otherwise, you want
to display nothing.
If so, one method would be to use the ListFind() method:
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<cfset memberOfGroups = "1,3,4">
<!--- Link is displayed because user belongs to both sales and customer groups
--->
<cfif ListFind(memberOfGroups, salesGroupID) GT 0 AND
ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://WEBMAIL_LINK/"><b>CBW Webmail</b></a><br>
<cfelse>
The current user has no access to Webmail
</cfif>
mxstu Guest
-
jlavetan #3
Re: Selecting users that are in multiple groups
Ok, that works... except that both groups have access to the webmail link...
How can I make it so:
If user is a member of both customer and sales group then display Link 1
If user is a member of customer group only then display Link 2
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<cfset memberOfGroups = "1,3,4">
<!--- only show the reports and ecom links to the customers group --->
<cfif ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://LINK.com/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
</cfif>
<!--- Link is displayed because user belongs to both sales and customer
groups --->
<cfif ListFind(memberOfGroups, salesGroupID) GT 0 AND
ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
<cfelse>
The current user has no access to Webmail
</cfif>
jlavetan Guest
-
mxstu #4
Re: Selecting users that are in multiple groups
<cfif ListFind(memberOfGroups, customerGroupID) GT 0>
<cfif ListFind(memberOfGroups, salesGroupID) GT 0>
Member of "customer" and "sales" group - Display Link 1
<cfelse>
Member of "customer" group only - Display Link 2
</cfif>
</cfif>
mxstu Guest
-
jlavetan #5
Re: Selecting users that are in multiple groups
My test user who is in the Customer group only can still see the link...
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<cfset memberOfGroups = "1,3,4">
<cfif ListFind(memberOfGroups, salesGroupID) GT 0>
<cfif ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
<a href="http://208.17.69.11:8080/"><b>CBW Webmail</b></a><br>
<cfelse>
<a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
</cfif>
</cfif>
jlavetan Guest
-
mxstu #6
Re: Selecting users that are in multiple groups
If this is your test code, the user would see the link because they are a
member of both groups (3 and 4):
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<cfset memberOfGroups = "1,3,4">
I think you switched the example code around and reversed the logic. Try
attached.
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<!--- This user is ONLY a member of customer group --->
<cfset memberOfGroups = "4">
<!--- user IS a member of customer group --->
<cfif ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
<!--- user IS also a member of sales group --->
<cfif ListFind(memberOfGroups, salesGroupID) GT 0>
<a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
</cfif>
</cfif>
mxstu Guest
-
jlavetan #7
Re: Selecting users that are in multiple groups
First, I want to say thanks for helping me out... :-)
With the latest code... neither user can see the link...
user test is in group 4
user sales_test is in group 3 and 4
jlavetan Guest
-
mxstu #8
Re: Selecting users that are in multiple groups
Not a problem. The code worked fine for me when I tested each of the different
possibilities. A few things you should check:
1) Did you output all of the variables to make sure they contain the correct
values?
2) Are there any spaces in between the list values? You may need to remove
them first. Use Replace() function
3) ListFind() assumes that the list delimiter is a comma, so if you're using a
different delimiter, you need to specify it.
mxstu Guest
-
jlavetan #9
Re: Selecting users that are in multiple groups
Dumb question, but would it matter that group IDs are in the database (MS Access)? so, doing the cfset command is causing the problem
jlavetan Guest
-
mxstu #10
Re: Selecting users that are in multiple groups
I'm not sure which CFSET statement you're referring to, but the sample code was
just an example. You need to replace this line:
<cfset memberOfGroups = "1,3,4">
with whatever code you're using to create the actual list, such as:
<cfset memberOfGroups = ValueList(getGroups.groupID)>
mxstu Guest
-
jlavetan #11
Re: Selecting users that are in multiple groups
Solved :-)
Thanks again for your help :-)
Ok, here is the final working code...
<cfset salesGroupID = 3>
<cfset customerGroupID = 4>
<!--- This user is ONLY a member of customer group --->
<cfset memberOfGroups = ValueList(getGroups.groupID)>
<!--- user IS a member of customer group --->
<cfif ListFind(memberOfGroups, customerGroupID) GT 0>
<a href="http://ecom.cooperbooth.com/"><b>Food-Ecom Login</b></a><br>
<a href="/secure/requests.cfm"><b>Report Requests</b></a><br>
<a href="/links.cfm"><b>Useful Links</b></a><br>
<!--- user IS also a member of sales group --->
<cfif ListFind(memberOfGroups, salesGroupID) GT 0>
<a href="http://WEBMAIL LINK/"><b>CBW Webmail</b></a><br>
</cfif>
</cfif>
jlavetan Guest



Reply With Quote

