skip to Main Content

I’m creating an SEO Helper module for DNN. It basically adds a note on the page to Page Editors to correct certain items on the page to help with SEO. However, I obviously don’t need/want to show this information on internal pages where Google and other search engines can’t access.

What’s the best way to determine if “All Users” has view access to the Current Tab?

2

Answers


  1. Chosen as BEST ANSWER

    Here's a one-liner:

    var allCanSee = TabPermissionController.GetTabPermissions(TabId, PortalId)
       .ToList().Any(pi => pi.RoleID == -1);
    

  2. This will help

    //get the TabPermission for the current tab and cast from Collection to List<TabPermissionInfo>
    List<DotNetNuke.Security.Permissions.TabPermissionInfo> tabPermissionInfo = DotNetNuke.Security.Permissions.TabPermissionController.GetTabPermissions(TabId, PortalId).Cast<DotNetNuke.Security.Permissions.TabPermissionInfo>().ToList();
    
    //loop all the permissionInfo objects and check for RoleId -1 (= all users)
    bool allUsers = false;
    foreach (TabPermissionInfo permissionInfo in tabPermissionInfo)
    {
        if (permissionInfo.RoleID == -1)
        {
            allUsers = true;
        }
    
        //for visualization of all roles and id's for current tab
        Label1.Text += permissionInfo.RoleName + " - " + permissionInfo.RoleID + "<br>";
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search