예제 #1
0
        // 前台app权限
        private Boolean checkSiteAppPermission()
        {
            if (ctx.route.isAdmin)
            {
                return(true);
            }

            if (ctx.app == null)
            {
                return(true);
            }
            if (ctx.app.obj == null)
            {
                return(true);
            }
            IMemberApp app = ((AppContext)ctx.app).UserApp;

            if (app == null)
            {
                return(true);
            }

            Boolean hasPermission = AppRole.IsRoleInApp(((User)ctx.viewer.obj).RoleId, typeof(SiteRole).FullName, app.Id);

            if (!hasPermission)
            {
                echo(lang("exNoPermission"));
                return(false);
            }

            return(true);
        }
예제 #2
0
        private void bindRoleList(List <IRole> roles, IList apps)
        {
            IBlock roleBlock = getBlock("roles");

            foreach (IRole role in roles)
            {
                roleBlock.Set("role.Name", role.Name);

                IBlock appBlock = roleBlock.GetBlock("apps");

                foreach (IMemberApp app in apps)
                {
                    String strChecked = AppRole.IsRoleInApp(role.Role.Id, role.Role.GetType().FullName, app.Id) ? "checked=\"checked\"" : "";
                    appBlock.Set("checkedString", strChecked);
                    appBlock.Set("app.Id", app.Id);
                    appBlock.Set("role.Id", role.Role.Id);
                    appBlock.Set("role.Type", role.Role.GetType().FullName);

                    appBlock.Next();
                }

                roleBlock.Next();
            }
        }