Exemple #1
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (!Page.IsPostBack || !Page.IsValid)
            {
                return;
            }

            var systemPermissionsInfoList = Session[PageAdminRoleAdd.SystemPermissionsInfoListKey] as List <SitePermissionsInfo>;

            if (systemPermissionsInfoList != null)
            {
                var systemPermissionlist = new List <SitePermissionsInfo>();
                foreach (var systemPermissionsInfo in systemPermissionsInfoList)
                {
                    if (systemPermissionsInfo.SiteId == SiteId)
                    {
                        continue;
                    }
                    systemPermissionlist.Add(systemPermissionsInfo);
                }

                var channelIdList = TranslateUtils.StringCollectionToStringList(Request.Form["ChannelIdCollection"]);
                if (channelIdList.Count > 0 && CblChannelPermissions.SelectedItem != null ||
                    CblWebsiteSysPermissions.SelectedItem != null || CblWebsitePluginPermissions.SelectedItem != null)
                {
                    var websiteSysPermissions =
                        ControlUtils.SelectedItemsValueToStringCollection(CblWebsiteSysPermissions.Items);
                    var websitePluginPermissions =
                        ControlUtils.SelectedItemsValueToStringCollection(CblWebsitePluginPermissions.Items);
                    var systemPermissionsInfo = new SitePermissionsInfo
                    {
                        SiteId = SiteId,
                        ChannelIdCollection = TranslateUtils.ObjectCollectionToString(channelIdList),
                        ChannelPermissions  =
                            ControlUtils.SelectedItemsValueToStringCollection(CblChannelPermissions.Items),
                        WebsitePermissions =
                            websiteSysPermissions + (string.IsNullOrEmpty(websitePluginPermissions) ? string.Empty : "," + websitePluginPermissions)
                    };

                    systemPermissionlist.Add(systemPermissionsInfo);
                }

                Session[PageAdminRoleAdd.SystemPermissionsInfoListKey] = systemPermissionlist;
            }

            PageUtils.Redirect(PageAdminRoleAdd.GetReturnRedirectUrl(AuthRequest.GetQueryString("RoleName")));
        }
Exemple #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (Body.IsQueryExists("Delete"))
            {
                var roleName = Body.GetQueryString("RoleName");
                try
                {
                    DataProvider.PermissionsInRolesDao.Delete(roleName);
                    DataProvider.RoleDao.DeleteRole(roleName);

                    Body.AddAdminLog("删除管理员角色", $"角色名称:{roleName}");

                    SuccessDeleteMessage();
                }
                catch (Exception ex)
                {
                    FailDeleteMessage(ex);
                }
            }

            if (IsPostBack)
            {
                return;
            }

            VerifyAdministratorPermissions(ConfigManager.Permissions.Settings.Admin);

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

            RptContents.DataSource = permissioins.IsConsoleAdministrator
                ? DataProvider.RoleDao.GetAllRoles()
                : DataProvider.RoleDao.GetAllRolesByCreatorUserName(Body.AdminName);
            RptContents.ItemDataBound += RptContents_ItemDataBound;
            RptContents.DataBind();

            BtnAdd.Attributes.Add("onclick", $"location.href = '{PageAdminRoleAdd.GetRedirectUrl()}';return false;");
        }
Exemple #3
0
        private static void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var roleName = (string)e.Item.DataItem;

            e.Item.Visible = !EPredefinedRoleUtils.IsPredefinedRole(roleName);

            var ltlRoleName    = (Literal)e.Item.FindControl("ltlRoleName");
            var ltlDescription = (Literal)e.Item.FindControl("ltlDescription");
            var ltlEdit        = (Literal)e.Item.FindControl("ltlEdit");
            var ltlDelete      = (Literal)e.Item.FindControl("ltlDelete");

            ltlRoleName.Text    = roleName;
            ltlDescription.Text = DataProvider.RoleDao.GetRoleDescription(roleName);
            ltlEdit.Text        = $@"<a href=""{PageAdminRoleAdd.GetRedirectUrl(roleName)}"">修改</a>";
            ltlDelete.Text      = $@"<a href=""javascript:;"" onClick=""{AlertUtils.ConfirmDelete("删除角色", $"此操作将会删除角色“{roleName}”,确认吗?", $"{GetRedirectUrl()}?Delete={true}&RoleName={roleName}")}"">删除</a>";
        }
Exemple #4
0
 public void Return_OnClick(object sender, EventArgs e)
 {
     PageUtils.Redirect(PageAdminRoleAdd.GetReturnRedirectUrl(AuthRequest.GetQueryString("RoleName")));
 }