Welcome Guest Search | Active Topics | Sign In | Register

How to allow ALL roles to see a menu item? Options
RocketDawg
Posted: Saturday, February 2, 2008 4:12:03 PM
Rank: Newbie
Groups: Member

Joined: 2/2/2008
Posts: 5
I know how to allow specific roles to see a menu item, but how do you allow all roles to see it? In other words, if a user is logged on, it's visible, else, no.

Thanks for any help.
Code: Visual Basic.NET
eo_support
Posted: Saturday, February 2, 2008 5:43:00 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

You can set AlloweRoles to "*" to do that. These are all valid values:

1. Leave it empty. All visitors, regardless logged in or not, are allowed;
2. "*" (without quotation marks), only logged in users are allowed. This is your case;
3. "?" (without quotation marks), only anonymous users are allowed;
4. A list of real roles;

Thanks
RocketDawg
Posted: Saturday, February 2, 2008 5:51:06 PM
Rank: Newbie
Groups: Member

Joined: 2/2/2008
Posts: 5
I have tried the *, with no success. It still allows all viewing, even if not logged in.
I am using V3.1.11.2 if it makes a difference.

Any idea on what may be the problem?
eo_support
Posted: Saturday, February 2, 2008 6:10:54 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

That appears to be a bug. We will see if we can get it fixed as soon as possible.

Thanks
RocketDawg
Posted: Saturday, February 2, 2008 6:16:58 PM
Rank: Newbie
Groups: Member

Joined: 2/2/2008
Posts: 5
Thank you for your quick replies!

Will you post when you get the bug fixed? Or how does that work?
eo_support
Posted: Saturday, February 2, 2008 6:39:55 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Yes. We will reply in the forum and also provide you the download location of the new build. You MAY need a new license for the new build though because it would be for the current release, which is 2007.2. If you do not have a license for the current release, you can use the following code:

Code: Visual Basic.NET
Private Sub Page_Load( _
    ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim isAnonymous As Boolean = _
            Not (HttpContext.Current.User Is Nothing) And _
            Not (HttpContext.Current.User.Identity Is Nothing) And _
            Not HttpContext.Current.User.Identity.IsAuthenticated
        DisableItems(Menu1.Items, isAnonymous)
End Sub

Private Sub DisableItems( _
    ByVal items As EO.Web.MenuItemCollection, _
    ByVal isAnonymous As Boolean)

    Dim item As EO.Web.MenuItem
    For Each item In items
        If item.AllowRoles = "*" And isAnonymous Then
            item.Disabled = True
        End If

        DisableItems(item.SubMenu.Items, isAnonymous)
    Next
End Sub


Thanks
RocketDawg
Posted: Saturday, February 2, 2008 6:49:10 PM
Rank: Newbie
Groups: Member

Joined: 2/2/2008
Posts: 5
EXCELLENT!!!

I must say a huge thank you, as well as how much I appreciate the prompt, and helpful support.

WELL DONE!

The code that you supplies works as a patch until the new build comes out.

Thanks again,
RocketDawg.
eo_support
Posted: Monday, February 4, 2008 9:43:32 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi,

We have posted a new build that fixed this issue. Please see your private messages for download location.

Thanks!
Justin
Posted: Friday, February 8, 2008 3:55:08 AM
Rank: Newbie
Groups: Member

Joined: 2/8/2008
Posts: 1
If I set AllowRoles="" then all users can see the menu item
If I set AllowRoles="?" no users can see the menu item
If I set AllowRoles="Administrator" only admin users can see the menu item

I need to set a menu item that only anonymous users can see it, am I missing something in my web.config?

I have it working find for Set Roles in dedicated sub directories, but now I want only anonymous users to see a menu item and page for a specific file in the root.
eo_support
Posted: Friday, February 8, 2008 5:13:50 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,095
Hi Justin,

In your case, you would set all the items who you do not want anonymous users to see as "*", and leave other items blank. You can then use the sample code provided in the previous post to translate AllowRoles into MenuItem.Enabled/Visible.

Thanks


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.