Exemplo n.º 1
0
        //----------------------------------------------------------------------


        public static Boolean HasAction(User user, ISecurity objSecurity, ISecurityAction action, MvcContext ctx)
        {
            SecurityTool securityTool = ForumSecurityService.GetSecurityTool(objSecurity, ctx);

            Boolean hasAction = securityTool.HasAction(user.Role, action);

            if (hasAction)
            {
                return(true);
            }

            hasAction = securityTool.HasAction(user.Rank, action);
            if (hasAction)
            {
                return(true);
            }

            if (ctx.owner.obj.GetType() != typeof(Site))
            {
                IRole roleInOwner = ctx.owner.obj.GetUserRole(user);
                hasAction = securityTool.HasAction(roleInOwner, action);
                if (hasAction)
                {
                    return(true);
                }
            }

            if (new ModeratorService().IsModerator(objSecurity as ForumBoard, user))
            {
                hasAction = securityTool.HasAction(ForumRole.Moderator, action);
                if (hasAction)
                {
                    return(true);
                }
            }

            return(false);
        }