示例#1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdministratorName);

            _theRoleName           = Body.GetQueryString("RoleName");
            _generalPermissionList = permissioins.PermissionList;

            if (!IsPostBack)
            {
                AdminManager.VerifyAdministratorPermissions(Body.AdministratorName, AppManager.Admin.Permission.AdminManagement);

                if (!string.IsNullOrEmpty(_theRoleName))
                {
                    TbRoleName.Text    = _theRoleName;
                    TbRoleName.Enabled = false;
                    TbDescription.Text = BaiRongDataProvider.RoleDao.GetRoleDescription(_theRoleName);

                    if (Body.GetQueryString("Return") == null)
                    {
                        var systemPermissionsInfoList = DataProvider.SystemPermissionsDao.GetSystemPermissionsInfoList(_theRoleName);
                        Session[SystemPermissionsInfoListKey] = systemPermissionsInfoList;
                    }
                }
                else
                {
                    if (Body.GetQueryString("Return") == null)
                    {
                        Session[SystemPermissionsInfoListKey] = new List <SystemPermissionsInfo>();
                    }
                }

                var cblPermissions = new CheckBoxList();

                var permissions = PermissionConfigManager.GetGeneralPermissionsOfProduct();
                if (permissions.Count > 0)
                {
                    foreach (PermissionConfig permission in permissions)
                    {
                        if (_generalPermissionList.Contains(permission.Name))
                        {
                            var listItem = new ListItem(permission.Text, permission.Name);
                            cblPermissions.Items.Add(listItem);
                        }
                    }

                    if (!string.IsNullOrEmpty(_theRoleName))
                    {
                        var permissionList = BaiRongDataProvider.PermissionsInRolesDao.GetGeneralPermissionList(new[] { _theRoleName });
                        if (permissionList != null && permissionList.Count > 0)
                        {
                            var permissionArray = new string[permissionList.Count];
                            permissionList.CopyTo(permissionArray);
                            ControlUtils.SelectListItems(cblPermissions, permissionArray);
                        }
                    }

                    var permissionBuilder = new StringBuilder();
                    permissionBuilder.Append(@"<table border=""0"" class=""table noborder""><tr>");
                    var i        = 1;
                    var cblIndex = 0;
                    foreach (ListItem listItem in cblPermissions.Items)
                    {
                        permissionBuilder.Append(
                            $@"<td><label class=""checkbox""><input type=""checkbox"" id=""cblPermissions{cblIndex++}"" name=""Permissions"" {(listItem
                                .Selected
                                ? "checked"
                                : string.Empty)} value=""{listItem.Value}"" /> {listItem.Text}</label></td>");
                        if (i++ % 5 == 0)
                        {
                            permissionBuilder.Append("</tr><tr>");
                        }
                    }
                    permissionBuilder.Append(@"</tr></table>");
                    LtlPermissions.Text = permissionBuilder.ToString();
                }

                PhPublishmentSystemPermissions.Visible = false;

                var psPermissionsInRolesInfoList = Session[SystemPermissionsInfoListKey] as List <SystemPermissionsInfo>;
                if (psPermissionsInRolesInfoList != null)
                {
                    var allPublishmentSystemIdArrayList = new ArrayList();
                    foreach (var itemForPsid in ProductPermissionsManager.Current.WebsitePermissionDict.Keys)
                    {
                        if (ProductPermissionsManager.Current.ChannelPermissionDict.ContainsKey(itemForPsid) && ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(itemForPsid))
                        {
                            var listOne = ProductPermissionsManager.Current.ChannelPermissionDict[itemForPsid];
                            var listTwo = ProductPermissionsManager.Current.WebsitePermissionDict[itemForPsid];
                            if ((listOne != null && listOne.Count > 0) || (listTwo != null && listTwo.Count > 0))
                            {
                                PhPublishmentSystemPermissions.Visible = true;
                                allPublishmentSystemIdArrayList.Add(itemForPsid);
                            }
                        }
                    }
                    var managedPublishmentSystemIdArrayList = new ArrayList();
                    foreach (var systemPermissionsInfo in psPermissionsInRolesInfoList)
                    {
                        managedPublishmentSystemIdArrayList.Add(systemPermissionsInfo.PublishmentSystemId);
                    }
                    LtlPublishmentSystems.Text = GetPublishmentSystemsHtml(allPublishmentSystemIdArrayList, managedPublishmentSystemIdArrayList);
                }
                else
                {
                    PageUtils.RedirectToErrorPage("页面超时,请重新进入。");
                }
            }
        }
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            var permissioins = PermissionsManager.GetPermissions(Body.AdministratorName);

            NodeTree.Text = GetNodeTreeHtml();

            if (IsPostBack)
            {
                return;
            }

            AdminManager.VerifyAdministratorPermissions(Body.AdministratorName, AppManager.Admin.Permission.AdminManagement);

            _appId = EPublishmentSystemTypeUtils.GetAppID(PublishmentSystemInfo.PublishmentSystemType);

            if (permissioins.IsSystemAdministrator)
            {
                var channelPermissions = PermissionConfigManager.GetChannelPermissionsOfApp(_appId);
                foreach (PermissionConfig permission in channelPermissions)
                {
                    if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel1)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 1)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel2)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 2)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel3)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 3)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel4)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 4)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (permission.Name == AppManager.Cms.Permission.Channel.ContentCheckLevel5)
                    {
                        if (PublishmentSystemInfo.IsCheckContentUseLevel)
                        {
                            if (PublishmentSystemInfo.CheckContentLevel < 5)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    var listItem = new ListItem(permission.Text, permission.Name);
                    ChannelPermissions.Items.Add(listItem);
                }
            }
            else
            {
                ChannelPermissionsPlaceHolder.Visible = false;
                if (ProductPermissionsManager.Current.ChannelPermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var channelPermissions = ProductPermissionsManager.Current.ChannelPermissionDict[PublishmentSystemId];
                    foreach (var channelPermission in channelPermissions)
                    {
                        foreach (PermissionConfig permission in PermissionConfigManager.Instance.ChannelPermissions)
                        {
                            if (permission.Name == channelPermission)
                            {
                                if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheck)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel1)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 1)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel2)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 2)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel3)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 3)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel4)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 4)
                                    {
                                        continue;
                                    }
                                }
                                else if (channelPermission == AppManager.Cms.Permission.Channel.ContentCheckLevel5)
                                {
                                    if (PublishmentSystemInfo.IsCheckContentUseLevel == false || PublishmentSystemInfo.CheckContentLevel < 5)
                                    {
                                        continue;
                                    }
                                }

                                ChannelPermissionsPlaceHolder.Visible = true;
                                var listItem = new ListItem(permission.Text, permission.Name);
                                ChannelPermissions.Items.Add(listItem);
                            }
                        }
                    }
                }
            }

            if (permissioins.IsSystemAdministrator)
            {
                var websitePermissions = PermissionConfigManager.GetWebsitePermissionsOfApp(_appId);
                foreach (PermissionConfig permission in websitePermissions)
                {
                    var listItem = new ListItem(permission.Text, permission.Name);
                    WebsitePermissions.Items.Add(listItem);
                }
            }
            else
            {
                WebsitePermissionsPlaceHolder.Visible = false;
                if (ProductPermissionsManager.Current.WebsitePermissionDict.ContainsKey(PublishmentSystemId))
                {
                    var websitePermissionList = ProductPermissionsManager.Current.WebsitePermissionDict[PublishmentSystemId];
                    foreach (var websitePermission in websitePermissionList)
                    {
                        foreach (PermissionConfig permission in PermissionConfigManager.Instance.WebsitePermissions)
                        {
                            if (permission.Name == websitePermission)
                            {
                                WebsitePermissionsPlaceHolder.Visible = true;
                                var listItem = new ListItem(permission.Text, permission.Name);
                                WebsitePermissions.Items.Add(listItem);
                            }
                        }
                    }
                }
            }

            var systemPermissionsInfoList = Session[PageRoleAdd.SystemPermissionsInfoListKey] as List <SystemPermissionsInfo>;

            if (systemPermissionsInfoList != null)
            {
                SystemPermissionsInfo systemPermissionsInfo = null;
                foreach (var publishmentSystemPermissionsInfo in systemPermissionsInfoList)
                {
                    if (publishmentSystemPermissionsInfo.PublishmentSystemId == PublishmentSystemId)
                    {
                        systemPermissionsInfo = publishmentSystemPermissionsInfo;
                        break;
                    }
                }
                if (systemPermissionsInfo == null)
                {
                    return;
                }

                foreach (ListItem item in ChannelPermissions.Items)
                {
                    item.Selected = CompareUtils.Contains(systemPermissionsInfo.ChannelPermissions, item.Value);
                }
                foreach (ListItem item in WebsitePermissions.Items)
                {
                    item.Selected = CompareUtils.Contains(systemPermissionsInfo.WebsitePermissions, item.Value);
                }
            }
        }