private bool HasPermission(StateAction stateAction)
{
if (this.Node.Id == 0)
{
//for new content, creator needs to have AddNew permission for the parent
if (!this.Node.Parent.Security.HasPermission(PermissionType.AddNew))
return false;
//if this is a list type, the user must have a manage container permission for the parent
if (!CheckManageListPermission(this.Node.NodeType, this.Node.Parent))
return false;
}
else
{
//otherwise the user needs to have Save permission for every action
if (!this.Node.Security.HasPermission(PermissionType.Save))
return false;
//if this is a list type, the user must have a manage container permission for the node
if (!CheckManageListPermission(this.Node.NodeType, this.Node))
return false;
}
switch (stateAction)
{
case StateAction.Save:
case StateAction.CheckOut:
case StateAction.SaveAndCheckIn:
case StateAction.CheckIn:
return !IsCheckedOutByAnotherUser(this.Node);
case StateAction.UndoCheckOut:
//force and 'normal' undo operations
return !IsCheckedOutByAnotherUser(this.Node) ||
HasForceUndoCheckOutRight(this.Node);
case StateAction.Publish:
return this.Node.Security.HasPermission(User.Current, PermissionType.Publish) &&
!IsCheckedOutByAnotherUser(this.Node);
case StateAction.Approve:
case StateAction.Reject:
return this.Node.Security.HasPermission(User.Current, PermissionType.Approve);
default:
throw new NotImplementedException("Unknown StateAction: " + stateAction);
}
}