public string SaveNodePermissions(int userID, string nodes, string permissions, bool replaceChild) { Authorize(); UserPermissions uPermissions = new UserPermissions(BusinessLogic.User.GetUser(userID)); List<IAction> actions = umbraco.BusinessLogic.Actions.Action.FromString(permissions); uPermissions.SaveNewPermissions(toIntArray(nodes), actions, replaceChild); return GetNodePermissions(userID, nodes); }
public string SaveNodePermissions(int userID, string nodes, string permissions, bool replaceChild) { Authorize(); UserPermissions uPermissions = new UserPermissions(BusinessLogic.User.GetUser(userID)); List <IAction> actions = umbraco.BusinessLogic.Actions.Action.FromString(permissions); uPermissions.SaveNewPermissions(toIntArray(nodes), actions, replaceChild); return(GetNodePermissions(userID, nodes)); }
public override void DataBind() { base.DataBind(); if (m_umbracoUser == null) { throw new ArgumentNullException("No User specified"); } //get the logged in user's permissions UserPermissions currUserPermissions = new UserPermissions(UmbracoEnsuredPage.CurrentUser); //lookup permissions for last node selected int selectedNodeId = m_nodeID[m_nodeID.Length - 1]; List <IAction> lstCurrUserActions = currUserPermissions.GetExistingNodePermission(selectedNodeId); List <IAction> lstLookupUserActions = m_userPermissions.GetExistingNodePermission(selectedNodeId); List <IAction> lstAllActions = umbraco.BusinessLogic.Actions.Action.GetPermissionAssignable(); //no node is selected, disable the check boxes if (m_nodeID[0] == -1) { ShowMessage("No node selected"); return; } //ensure the current user has access to assign permissions. //if their actions list is null then it means that the node is not published. if (lstCurrUserActions == null || lstCurrUserActions.Contains(ActionRights.Instance)) { BindExistingPermissions(lstAllActions, lstLookupUserActions); } else { ShowMessage("You do not have access to assign permissions to this node"); } string names = ""; foreach (int id in m_nodeID) { if (id > 0) { names += new cms.businesslogic.web.Document(id).Text + ", "; } } lt_names.Text = names.Trim().Trim(','); }
public override void DataBind() { base.DataBind(); if (m_umbracoUser == null) throw new ArgumentNullException("No User specified"); //get the logged in user's permissions UserPermissions currUserPermissions = new UserPermissions(UmbracoEnsuredPage.CurrentUser); //lookup permissions for last node selected int selectedNodeId = m_nodeID[m_nodeID.Length - 1]; List<IAction> lstCurrUserActions = currUserPermissions.GetExistingNodePermission(selectedNodeId); List<IAction> lstLookupUserActions = m_userPermissions.GetExistingNodePermission(selectedNodeId); List<IAction> lstAllActions = umbraco.BusinessLogic.Actions.Action.GetPermissionAssignable(); //no node is selected, disable the check boxes if (m_nodeID[0] == -1) { ShowMessage("No node selected"); return; } //ensure the current user has access to assign permissions. //if their actions list is null then it means that the node is not published. if (lstCurrUserActions == null || lstCurrUserActions.Contains(ActionRights.Instance)) BindExistingPermissions(lstAllActions, lstLookupUserActions); else ShowMessage("You do not have access to assign permissions to this node"); string names = ""; foreach (int id in m_nodeID) { if(id > 0) names += new cms.businesslogic.web.Document(id).Text + ", "; } lt_names.Text = names.Trim().Trim(','); }
/// <summary> /// Checks if the current user has permissions to execute this action against this node /// </summary> /// <param name="node"></param> /// <param name="currentAction"></param> /// <returns></returns> /// <remarks> /// This used to do a recursive check for all descendent nodes but this is not required and is a massive CPU hog. /// See: http://issues.umbraco.org/issue/U4-2632, https://groups.google.com/forum/?fromgroups=#!topic/umbraco-dev/L1D4LwVSP2Y /// </remarks> private bool CheckPermissions(IContentBase node, IAction currentAction) { var currUserPermissions = new UserPermissions(CurrentUser); var lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id); return lstCurrUserActions.Contains(currentAction); }
private bool CheckPermissions(CMSNode node, IAction currentAction) { var currUserPermissions = new UserPermissions(CurrentUser); var lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id); if (lstCurrUserActions.Contains(currentAction) == false) return false; if (node.HasChildren) { foreach (CMSNode child in node.Children) if (CheckPermissions(child, currentAction) == false) return false; } return true; }
private bool CheckPermissions(CMSNode node, IAction currentAction, char actionLetter) { UserPermissions currUserPermissions = new UserPermissions(UmbracoEnsuredPage.CurrentUser); List<IAction> lstCurrUserActions = currUserPermissions.GetExistingNodePermission(node.Id); if (!lstCurrUserActions.Contains(currentAction)) return false; if (node.HasChildren) { foreach (CMSNode c in node.Children) if (!CheckPermissions(c,currentAction,actionLetter)) return false; } return true; }