Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jun 11, 2010 @ 16:44
    Matt Brailsford
    0

    Creating a context aware Member Picker Data Type

    Hi Guys,

    Does anybody know if it's possible to create a context aware Data Type? What I'd like is to create a Member Picker control that filters itself based upong the permissions within that section of the site. ie

    Members
    Bob
    Bill
    Barry

    Tree
    Home
    - Section < Only Bob and Bill have access
      - Page 1 < This page has a Member Picker Data Type on only showing Bob and Bill

    Matt

  • Richard Soeteman 3875 posts 12037 karma points MVP
    Jun 11, 2010 @ 17:02
    Richard Soeteman
    0

    This is what I see happening in the source code of the Protectpage.aspx, it loops over all Roles and then checks if the role is allowed for the document. You can use that also I think, just use the following line to check if the document is protected by a certain role

    Access.IsProtectedByMembershipRole(int.Parse(helper.Request("id")), role)

    When you have all the selected roles use Roles.GetUsersInRole("Your RoleName") to get the users assigned to that role.

     Below the source code in Umbraco, hope the formattings stays okay after submit

     

    // Load up membergrouops

    _memberGroups.ID =

    "Membergroups";

    _memberGroups.Width = 175;

     

    string selectedGroups = "";

     

    string[] _roles = Roles.GetAllRoles();

     

    if (_roles.Length > 0)

    {

     

    foreach (string role in _roles)

    {

     

    ListItem li = new ListItem(role, role);

     

    if (!IsPostBack)

    {

     

    if (cms.businesslogic.web.Access.IsProtectedByMembershipRole(int.Parse(helper.Request("nodeid")), role))

    selectedGroups += role +

    ",";

    }

    _memberGroups.Items.Add(li);

    }

    }

     

    else

    {

    p_noGroupsFound.Visible =

    true;

    rb_advanced.Enabled =

    false;

    }

    _memberGroups.Value = selectedGroups;

    groupsSelector.Controls.Add(_memberGroups);

     Cheers,

    Richard

  • Matt Brailsford 2958 posts 15629 karma points MVP 7x c-trib
    Jun 11, 2010 @ 17:14
    Matt Brailsford
    0

    Sweet, that should do the trick =)

    Matt

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies