Skip to main content

Blog de Alejandro Avila

Go Search
Home
  

Blog de Alejandro Avila > Posts > ECQWP Context Menu limited entries by user permisssions
ECQWP Context Menu limited entries by user permisssions
When we use the ECQWP and a user of the "Viewers" group expand the context menu of one item. The option "Edit Item" appears. It's true that when the "viewer" clicks the "edit option" an error page appears saying that the user haven't got permissions to do that.
 
One of my tasks was delete the entries from the context menu where the user hasn't got permissions. It seems very dificult until I found the "Perm" option in the context menu table. This attribute of the table allows us to delete the not desired entries but this attribute only accept hexadecimal.
 
At this point the only complicated  is getting the permission mask of the user over the listitem selected... easy :)
 

public string PermMask

{

get

{

SPRoleDefinitionBindingCollection roles = ListItem.AllRolesForCurrentUser;

SPBasePermissions auxPerm = SPBasePermissions.EmptyMask;

foreach (SPRoleDefinition role in roles)

{

if ((auxPerm & role.BasePermissions) != role.BasePermissions)

{

auxPerm |= role.BasePermissions;

}

}

return "0x" + ((long)auxPerm).ToString("x");

}

}

So, I had to paste this property in the ListItemWrap.cs, then I had to create a new column in the ContentQueryWithContextMenus.cs called "PermMask" to pass the value to the ECQWPItems.xslt and add this value on the table attribute "Perm".

Comments

There are no comments yet for this post.