コード例 #1
0
        /// <summary>
        /// 保存角色/用户的权限
        /// </summary>
        /// <param name="objectGridView"></param>
        /// <param name="ownerType"></param>
        void SaveObjectPermissions(GridView objectGridView, string ownerType)
        {
            if (DemoSiteMessage)
            {
                return;
            }

            int typeID = ownerType == "role" ? Constants.OwnerRole : Constants.OwnerAccount;

            for (int i = 0; i < objectGridView.Rows.Count; i++)
            {
                System.Web.UI.HtmlControls.HtmlInputHidden objIDHidden = (System.Web.UI.HtmlControls.HtmlInputHidden)objectGridView.Rows[i].FindControl("IDHidden");
                string ownerID = objIDHidden.Value;

                AccountHelper.DeletePermission(typeID, ownerID, ChannelID);
                ArrayList al = new ArrayList();
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelReadCheckbox")).Checked)
                {
                    al.Add("Channel.Read");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelInputCheckbox")).Checked)
                {
                    al.Add("Channel.Input");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelArticleCheckbox")).Checked)
                {
                    al.Add("Channel.Article");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelFirstAuditCheckbox")).Checked)
                {
                    al.Add("Channel.FirstAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelSecondAuditCheckbox")).Checked)
                {
                    al.Add("Channel.SecondAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelThirdAuditCheckbox")).Checked)
                {
                    al.Add("Channel.ThirdAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("ChannelAdminCheckbox")).Checked)
                {
                    al.Add("Channel.Admin");
                }

                string[] adds = (string[])al.ToArray(typeof(string));
                AccountHelper.DeletePermission(typeID, ownerID, ChannelID);
                AccountHelper.AddPermission(typeID, ownerID, ChannelID, adds);

                //处理子栏目的权限信息
                ChannelHelper.DeleteChildrenPermission(typeID, ownerID, ChannelID);
                ChannelHelper.AddChildrenPermission(typeID, ownerID, ChannelID, adds);
            }
        }
コード例 #2
0
        protected void userAddSubmit_ServerClick(object sender, EventArgs e)
        {
            Account acc = AccountHelper.GetAccountByLoginName(userNameInput.Value);

            if (acc == null)
            {
                Messages.ShowError(string.Format("没有找到用户“{0}”,请输入正确的用户登录名再试。", userNameInput.Value));
            }
            else
            {
                AccountHelper.DeletePermission(Constants.OwnerAccount, acc.ID, ChannelID, new string[] { "Channel.Read" });
                AccountHelper.AddPermission(Constants.OwnerAccount, acc.ID, ChannelID, new string[] { "Channel.Read" });

                //处理子栏目的权限信息
                ChannelHelper.DeleteChildrenPermission(Constants.OwnerAccount, acc.ID, ChannelID, new string[] { "Channel.Read" });
                ChannelHelper.AddChildrenPermission(Constants.OwnerAccount, acc.ID, ChannelID, new string[] { "Channel.Read" });
                LoadUsers();
            }
        }