Ejemplo n.º 1
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            int typeID = OwnerType == "role" ? Constants.OwnerRole : Constants.OwnerAccount;

            string[] adds = null;
            //判断AddsTextBox.Text是否为空,其主要是由于前台JS所产生,为空则消除空;
            if (AddsTextBox.Text != "null" && AddsTextBox.Text != null && AddsTextBox.Text != string.Empty)
            {
                adds = AddsTextBox.Text.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
            }

            if (adds != null && adds.Length > 0)
            {
                for (int i = 0; i < adds.Length; i++)
                {
                    adds[i] = We7Helper.FormatToGUID(adds[i]);
                }
            }

            AccountHelper.DeletePermission(typeID, OwnerID, ObjectID);
            AccountHelper.AddPermission(typeID, OwnerID, ObjectID, adds);

            if (ApplyPermissionToSubChannelsCheckBox.Checked == true && ApplyPermissionToSubChannelsCheckBox.Visible)
            {
                List <Channel> subChannels = ChannelHelper.GetSubChannelList(ObjectID, true);

                foreach (Channel ch in subChannels)
                {
                    AccountHelper.DeletePermission(typeID, OwnerID, ch.ID);
                    AccountHelper.AddPermission(typeID, OwnerID, ch.ID, adds);
                }
            }

            if (OwnerType != "role")
            {
                Account act = AccountHelper.GetAccount(OwnerID, new string[] { "LoginName", "Email" });
                if (act != null)
                {
                    string userName = String.Format("{0}({1})", act.LoginName, act.Email);
                    string content  = string.Format("给用户“{0}设置权限”", userName);
                    AddLog("权限设置", content);
                }
            }
            else
            {
                Role role = AccountHelper.GetRole(OwnerID);
                if (role != null)
                {
                    string content = string.Format("给角色“{0}设置权限”", role.Name);
                    AddLog("权限设置", content);
                }
            }
            Messages.ShowMessage("权限设置成功!");
            Initialize();
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 保存角色/用户的权限
        /// </summary>
        /// <param name="objectGridView"></param>
        /// <param name="ownerType"></param>
        void SaveObjectPermissions(GridView objectGridView, string ownerType)
        {
            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 objectID = objIDHidden.Value;

                AccountHelper.DeletePermission(typeID, objectID, AdviceTypeID);
                ArrayList al = new ArrayList();
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceReadCheckBox")).Checked)
                {
                    al.Add("Advice.Read");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceAdminCheckbox")).Checked)
                {
                    al.Add("Advice.Admin");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceAcceptCheckbox")).Checked)
                {
                    al.Add("Advice.Accept");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceHandleCheckbox")).Checked)
                {
                    al.Add("Advice.Handle");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceFirstAuditCheckBox")).Checked)
                {
                    al.Add("Advice.FirstAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceSecondAuditCheckBox")).Checked)
                {
                    al.Add("Advice.SecondAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceThirdAuditCheckBox")).Checked)
                {
                    al.Add("Advice.ThirdAudit");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceRefuseCheckbox")).Checked)
                {
                    al.Add("Advice.Refuse");
                }
                if (((CheckBox)objectGridView.Rows[i].FindControl("AdviceTransferCheckBox")).Checked)
                {
                    al.Add("Advice.Transfer");
                }

                string[] adds = (string[])al.ToArray(typeof(string));
                AccountHelper.AddPermission(typeID, objectID, AdviceTypeID, adds);
            }
        }
Ejemplo n.º 4
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.AddPermission(Constants.OwnerAccount, acc.ID, AdviceTypeID, new string[] { "Advice.Read" });
                LoadUsers();
            }
        }
Ejemplo n.º 5
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();
            }
        }