There used to be a property in v4 on the DynamicNode that you could check called HasAccess, which you'd do just like you check IsVisible. Since it looks like this property no longer exists on the IPublishedContent I'm not sure what exactly the recommended practice is now, but I do see after a quick glance at the codebase something on the UmbracoHelper which looks like might do what you want:
public bool MemberHasAccess(int nodeId, string path);
So maybe something like if (Umbraco.MemberHasAccess(item.Id, "/whatever/")) { ... } ??? (Not sure why you would need path if you are giving it the node ID...) But hopefully this is enough to get you started and know what further you need to search on/experiment with.
Yes its possible to do this in umbraco but you will also need to set up some roles under the Member section where you will have to create a Member Group.
Based on those Group you will give public access to the nodes you want a member to have access to.
Here is an example of how your razor
List<DynamicNode> nodes = @Model.AncestorOrSelf(1).Descendants("docType").Where("Visible && HasAccess").ToList; @foreach(var n in nodes){ @n.Name }
Hi Guys,
I have a requirement where I would like to do reverse of what you are doing. I need to do a for loop through all memebrs and check which memebers have access to a particular node/document. I tried couple of options but nothing is working. My code block is attached. Can any one guide me through.
Show only nodes to which user has Access
I need to show only nodes to which user has access.
Same question is there:
http://our.umbraco.org/forum/developers/extending-umbraco/4001-Display-only-the-pages-that-members-have-access-to-
but can I do it in code?
Example:
1) Get root:
DynamicNode root = new DynamicNode(new Node(-1));
2) Get all visiable children:
var menuItems = root.Children.Where(n => n.Visible == true).First().Children.Where(n => n.Visible == true);
3) In cycle I want to checking if user has access to node:
check if the user belongs to the member group to which this page is available.
@foreach (var item in menuItems)
{
if(CHECK)
}
Is it posible?
Thanks.
There used to be a property in v4 on the DynamicNode that you could check called
HasAccess
, which you'd do just like you checkIsVisible
. Since it looks like this property no longer exists on the IPublishedContent I'm not sure what exactly the recommended practice is now, but I do see after a quick glance at the codebase something on the UmbracoHelper which looks like might do what you want:public bool MemberHasAccess(int nodeId, string path);
So maybe something like
if (Umbraco.MemberHasAccess(item.Id, "/whatever/")) { ... }
??? (Not sure why you would need path if you are giving it the node ID...) But hopefully this is enough to get you started and know what further you need to search on/experiment with.Good luck!
Hi Taras,
Yes its possible to do this in umbraco but you will also need to set up some roles under the Member section where you will have to create a Member Group.
Based on those Group you will give public access to the nodes you want a member to have access to.
Here is an example of how your razor
Hope this helps
//Fuji
In my case best solution is:
if (Umbraco.MemberHasAccess(item.Id, item.Path))
thank you Funka! & Fuji Kusaka.
Hi Guys, I have a requirement where I would like to do reverse of what you are doing. I need to do a for loop through all memebrs and check which memebers have access to a particular node/document. I tried couple of options but nothing is working. My code block is attached. Can any one guide me through.
try { string _emailD = string.Empty; string _emailBody = string.Empty; string _docsHit = string.Empty; string _docsDetails = string.Empty; string _memID = string.Empty;
Hi Balvvant
Did you ever find a solution to your problem? I am having a simular problem right now :-)
is working on a reply...