public void InsertForum(string parentid, string layer, string parentidlist, string subforumcount, string systemdisplayorder) { #region 添加新论坛 forumInfo.Parentid = Convert.ToInt32(parentid); forumInfo.Layer = Convert.ToInt32(layer); forumInfo.Parentidlist = parentidlist; forumInfo.Subforumcount = Convert.ToInt32(subforumcount); forumInfo.Name = name.Text.Trim(); forumInfo.Status = Convert.ToInt16(status.SelectedValue); forumInfo.Displayorder = Convert.ToInt32(systemdisplayorder); forumInfo.Templateid = Convert.ToInt32(templateid.SelectedValue); forumInfo.Allowsmilies = BoolToInt(setting.Items[0].Selected); forumInfo.Allowrss = BoolToInt(setting.Items[1].Selected); forumInfo.Allowhtml = 0; forumInfo.Allowbbcode = BoolToInt(setting.Items[2].Selected); forumInfo.Allowimgcode = BoolToInt(setting.Items[3].Selected); forumInfo.Allowblog = 0; forumInfo.Istrade = 0; forumInfo.Alloweditrules = 0; forumInfo.Recyclebin = BoolToInt(setting.Items[4].Selected); forumInfo.Modnewposts = BoolToInt(setting.Items[5].Selected); forumInfo.Modnewtopics = BoolToInt(setting.Items[6].Selected); forumInfo.Jammer = BoolToInt(setting.Items[7].Selected); forumInfo.Disablewatermark = BoolToInt(setting.Items[8].Selected); forumInfo.Inheritedmod = BoolToInt(setting.Items[9].Selected); forumInfo.Allowthumbnail = BoolToInt(setting.Items[10].Selected); forumInfo.Allowtag = BoolToInt(setting.Items[11].Selected); forumInfo.Istrade = 0; int temppostspecial = 0; temppostspecial = setting.Items[12].Selected ? temppostspecial | 1 : temppostspecial & ~1; temppostspecial = setting.Items[13].Selected ? temppostspecial | 16 : temppostspecial & ~16; temppostspecial = setting.Items[14].Selected ? temppostspecial | 4 : temppostspecial & ~4; forumInfo.Allowpostspecial = temppostspecial; forumInfo.Alloweditrules = BoolToInt(setting.Items[15].Selected); forumInfo.Allowspecialonly = Convert.ToInt16(allowspecialonly.SelectedValue); forumInfo.Autoclose = autocloseoption.SelectedValue == "0" ? 0 : Convert.ToInt32(autocloseday.Text); forumInfo.Description = description.Text; forumInfo.Password = password.Text; forumInfo.Icon = icon.Text; forumInfo.Postcredits = ""; forumInfo.Replycredits = ""; forumInfo.Redirect = redirect.Text; forumInfo.Attachextensions = attachextensions.GetSelectString(","); forumInfo.Moderators = moderators.Text; forumInfo.Rules = rules.Text; forumInfo.Seokeywords = seokeywords.Text.Trim(); forumInfo.Seodescription = seodescription.Text.Trim(); forumInfo.Rewritename = rewritename.Text.Trim(); forumInfo.Topictypes = topictypes.Text; forumInfo.Colcount = colcount.SelectedValue == "1" ? 1 : Convert.ToInt16(colcountnumber.Text); //传统模式[默认] forumInfo.Viewperm = Request.Form["viewperm"]; forumInfo.Postperm = Request.Form["postperm"]; forumInfo.Replyperm = Request.Form["replyperm"]; forumInfo.Getattachperm = Request.Form["getattachperm"]; forumInfo.Postattachperm = Request.Form["postattachperm"]; string result; int fid = AdminForums.CreateForums(forumInfo, out result, userid, username, usergroupid, grouptitle, ip); //如果有上传版块图片的操作 if (HttpContext.Current.Request.Files.Count > 0 && !string.IsNullOrEmpty(HttpContext.Current.Request.Files[0].FileName)) { forumInfo = Forums.GetForumInfo(fid); forumInfo.Icon = AdminForums.UploadForumIcon(forumInfo.Fid); AdminForums.UpdateForumInfo(forumInfo).Replace("'", "’"); ForumOperator.RefreshForumCache(); GeneralConfigInfo configInfo = GeneralConfigs.GetConfig(); configInfo.Specifytemplate = Forums.GetSpecifyForumTemplateCount() > 0 ? 1 : 0; GeneralConfigs.Serialiaze(configInfo, Server.MapPath("../../config/general.config")); } if (string.IsNullOrEmpty(result)) { base.RegisterStartupScript("PAGE", "self.location.href='forum_ForumsTree.aspx';"); } else { base.RegisterStartupScript("PAGE", "alert('用户:" + result + "不存在,因为无法设为版主');self.location.href='forum_ForumsTree.aspx';"); } #endregion }
public void InsertForum(Int32 parentid, Int32 systemdisplayorder) { //需要初始化 forumInfo forumInfo = new XForum(); this.forumInfo.ParentID = parentid; //this.forumInfo.Layer = layer.ToInt(); //this.forumInfo.Parentidlist = parentidlist; //this.forumInfo.SubforumCount = subforumcount.ToInt(); this.forumInfo.Name = this.name.Text.Trim(); this.forumInfo.Status = this.status.SelectedValue.ToInt(); this.forumInfo.DisplayOrder = systemdisplayorder; this.forumInfo.TemplateID = this.templateid.SelectedValue.ToInt(); this.forumInfo.AllowSmilies = this.setting.Items[0].Selected; this.forumInfo.AllowRss = this.setting.Items[1].Selected; //this.forumInfo.AllowHtml = 0; this.forumInfo.AllowBbCode = this.setting.Items[2].Selected; this.forumInfo.AllowImgCode = this.setting.Items[3].Selected; //this.forumInfo.AllowBlog = 0; //this.forumInfo.IsTrade = 0; //this.forumInfo.AllowEditRules = 0; this.forumInfo.Recyclebin = this.BoolToInt(this.setting.Items[4].Selected); this.forumInfo.Modnewposts = this.BoolToInt(this.setting.Items[5].Selected); this.forumInfo.Modnewtopics = this.BoolToInt(this.setting.Items[6].Selected); this.forumInfo.Jammer = this.BoolToInt(this.setting.Items[7].Selected); this.forumInfo.DisableWatermark = this.setting.Items[8].Selected; this.forumInfo.Inheritedmod = this.BoolToInt(this.setting.Items[9].Selected); this.forumInfo.AllowThumbnail = this.setting.Items[10].Selected; this.forumInfo.AllowTag = this.setting.Items[11].Selected; //this.forumInfo.IsTrade = 0; int num = 0; num = (this.setting.Items[12].Selected ? (num | 1) : (num & -2)); num = (this.setting.Items[13].Selected ? (num | 16) : (num & -17)); num = (this.setting.Items[14].Selected ? (num | 4) : (num & -5)); this.forumInfo.AllowPostSpecial = num; this.forumInfo.AllowEditRules = this.setting.Items[15].Selected; this.forumInfo.AllowSpecialOnly = (int)Convert.ToInt16(this.allowspecialonly.SelectedValue) != 0; this.forumInfo.AutoClose = ((this.autocloseoption.SelectedValue == "0") ? 0 : this.autocloseday.Text.ToInt()); this.forumInfo.Description = this.description.Text; this.forumInfo.Password = this.password.Text; this.forumInfo.Icon = this.icon.Text; //this.forumInfo.PostcrEdits = ""; //this.forumInfo.ReplycrEdits = ""; this.forumInfo.Redirect = this.redirect.Text; this.forumInfo.Attachextensions = this.attachextensions.GetSelectString(","); this.forumInfo.Moderators = this.moderators.Text; this.forumInfo.Rules = this.rules.Text; this.forumInfo.Seokeywords = this.seokeywords.Text.Trim(); this.forumInfo.Seodescription = this.seodescription.Text.Trim(); this.forumInfo.RewriteName = this.rewritename.Text.Trim(); this.forumInfo.TopicTypes = this.topictypes.Text; this.forumInfo.ColCount = colcount.SelectedValue == "1" ? 1 : colcountnumber.Text.ToInt(); this.forumInfo.ViewPerm = base.Request.Form["viewperm"]; this.forumInfo.PostPerm = base.Request.Form["postperm"]; this.forumInfo.ReplyPerm = base.Request.Form["replyperm"]; this.forumInfo.GetattachPerm = base.Request.Form["getattachperm"]; this.forumInfo.PostattachPerm = base.Request.Form["postattachperm"]; string text; int fid = AdminForums.CreateForums(this.forumInfo, out text, this.userid, this.username, this.usergroupid, this.grouptitle, this.ip); if (HttpContext.Current.Request.Files.Count > 0 && !string.IsNullOrEmpty(HttpContext.Current.Request.Files[0].FileName)) { this.forumInfo = Forums.GetForumInfo(fid); this.forumInfo.Icon = AdminForums.UploadForumIcon(this.forumInfo.ID); AdminForums.UpdateForumInfo(this.forumInfo).Replace("'", "’"); ForumOperator.RefreshForumCache(); GeneralConfigInfo config = GeneralConfigInfo.Current; config.Specifytemplate = ((Forums.GetSpecifyForumTemplateCount() > 0) ? 1 : 0); config.Save(); //config.Save();; } if (string.IsNullOrEmpty(text)) { base.RegisterStartupScript("PAGE", "self.location.href='forum_ForumsTree.aspx';"); return; } base.RegisterStartupScript("PAGE", "alert('用户:" + text + "不存在,因为无法设为版主');self.location.href='forum_ForumsTree.aspx';"); }
private void SubmitInfo_Click(object sender, EventArgs e) { #region 提交同级版块 if (this.CheckCookie()) { if (DNTRequest.GetString("fid") != "") { forumInfo = Forums.GetForumInfo(DNTRequest.GetInt("fid", 0)); forumInfo.Name = name.Text.Trim(); forumInfo.Displayorder = Convert.ToInt32(displayorder.Text); forumInfo.Status = Convert.ToInt16(status.SelectedValue); if (colcount.SelectedValue == "1") //传统模式[默认] { forumInfo.Colcount = 1; } else { if (Convert.ToInt16(colcountnumber.Text) < 1 || Convert.ToInt16(colcountnumber.Text) > 9) { colcountnumber.Text = ""; base.RegisterStartupScript("", "<script>alert('列值必须在2~9范围内');</script>"); return; } forumInfo.Colcount = Convert.ToInt16(colcountnumber.Text); } if (rewritename.Text.Trim() != oldrewritename.Value && rewritename.Text.Trim() != "" && Discuz.Forum.Forums.CheckRewriteNameInvalid(rewritename.Text.Trim())) { rewritename.Text = ""; base.RegisterStartupScript("", "<script>alert('URL重写非法!');</script>"); return; } //forumInfo.Templateid为0表示绑定到默认模板 forumInfo.Templateid = (Convert.ToInt32(templateid.SelectedValue) == config.Templateid ? 0 : Convert.ToInt32(templateid.SelectedValue)); forumInfo.Allowhtml = 0; forumInfo.Allowblog = 0; forumInfo.Istrade = 0; forumInfo.Alloweditrules = 0; forumInfo.Allowsmilies = BoolToInt(setting.Items[0].Selected); forumInfo.Allowrss = BoolToInt(setting.Items[1].Selected); forumInfo.Allowbbcode = BoolToInt(setting.Items[2].Selected); forumInfo.Allowimgcode = BoolToInt(setting.Items[3].Selected); forumInfo.Recyclebin = BoolToInt(setting.Items[4].Selected); forumInfo.Modnewposts = BoolToInt(setting.Items[5].Selected); forumInfo.Modnewtopics = BoolToInt(setting.Items[6].Selected); forumInfo.Jammer = BoolToInt(setting.Items[7].Selected); forumInfo.Disablewatermark = BoolToInt(setting.Items[8].Selected); forumInfo.Inheritedmod = BoolToInt(setting.Items[9].Selected); forumInfo.Allowthumbnail = BoolToInt(setting.Items[10].Selected); forumInfo.Allowtag = BoolToInt(setting.Items[11].Selected); int temppostspecial = 0; temppostspecial = setting.Items[12].Selected ? temppostspecial | 1 : temppostspecial & ~1; temppostspecial = setting.Items[13].Selected ? temppostspecial | 16 : temppostspecial & ~16; temppostspecial = setting.Items[14].Selected ? temppostspecial | 4 : temppostspecial & ~4; forumInfo.Allowpostspecial = temppostspecial; forumInfo.Alloweditrules = BoolToInt(setting.Items[15].Selected); forumInfo.Allowspecialonly = Convert.ToInt16(allowspecialonly.SelectedValue); if (autocloseoption.SelectedValue == "0") { forumInfo.Autoclose = 0; } else { forumInfo.Autoclose = Convert.ToInt32(autocloseday.Text); } forumInfo.Description = description.Text; forumInfo.Password = password.Text; //如果有上传的图片被提交上来,则执行文件保存操作,并返回保存后的文件路径,否则将icon.text控件中的值保存 forumInfo.Icon = HttpContext.Current.Request.Files.Count > 0 && !string.IsNullOrEmpty(HttpContext.Current.Request.Files[0].FileName) ? AdminForums.UploadForumIcon(forumInfo.Fid) : icon.Text; forumInfo.Redirect = redirect.Text; forumInfo.Attachextensions = attachextensions.GetSelectString(","); AdminForums.CompareOldAndNewModerator(forumInfo.Moderators, moderators.Text.Replace("\r\n", ","), DNTRequest.GetInt("fid", 0)); forumInfo.Moderators = moderators.Text.Replace("\r\n", ","); forumInfo.Rules = rules.Text.Trim(); forumInfo.Seokeywords = seokeywords.Text.Trim(); forumInfo.Seodescription = seodescription.Text.Trim(); forumInfo.Rewritename = rewritename.Text.Trim(); forumInfo.Viewperm = Request.Form["viewperm"]; forumInfo.Postperm = Request.Form["postperm"]; forumInfo.Replyperm = Request.Form["replyperm"]; forumInfo.Getattachperm = Request.Form["getattachperm"]; forumInfo.Postattachperm = Request.Form["postattachperm"]; forumInfo.Applytopictype = Convert.ToInt32(applytopictype.SelectedValue); forumInfo.Postbytopictype = Convert.ToInt32(postbytopictype.SelectedValue); forumInfo.Viewbytopictype = Convert.ToInt32(viewbytopictype.SelectedValue); forumInfo.Topictypeprefix = Convert.ToInt32(topictypeprefix.SelectedValue); forumInfo.Topictypes = GetTopicType(); forumInfo.Permuserlist = GetPermuserlist(); Discuz.Aggregation.AggregationFacade.ForumAggregation.ClearDataBind(); string result = AdminForums.UpdateForumInfo(forumInfo).Replace("'", "’"); if (childForumApplyTemplate.Checked)//批量设置子版块的模板信息 { AdminForums.UpdateForumTemplateID(forumInfo); } ForumOperator.RefreshForumCache(); AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "编辑论坛版块", "编辑论坛版块,名称为:" + name.Text.Trim()); GeneralConfigInfo configInfo = GeneralConfigs.GetConfig(); configInfo.Specifytemplate = Forums.GetSpecifyForumTemplateCount() > 0 ? 1 : 0; GeneralConfigs.Serialiaze(configInfo, Server.MapPath("../../config/general.config")); if (result == "") { Response.Redirect("forum_ForumsTree.aspx"); } else { Response.Write("<script>alert('用户:" + result + "不存在或因为它们所属组为\"游客\",\"等待验证会员\",因为无法设为版主');window.location.href='forum_ForumsTree.aspx';</script>"); Response.End(); } } } #endregion }
private void SubmitInfo_Click(object sender, EventArgs e) { var fid = Request["fid"].ToInt(); if (base.CheckCookie() && fid > 0) { //this.forumInfo = Forums.GetForumInfo(DNTRequest.GetInt("fid", 0)); var f = XForum.FindByID(fid); this.forumInfo = f as IXForum; this.forumInfo.Name = this.name.Text.Trim(); this.forumInfo.DisplayOrder = displayorder.Text.ToInt(); this.forumInfo.Status = status.SelectedValue.ToInt(); if (this.colcount.SelectedValue == "1") { this.forumInfo.ColCount = 1; } else { var count = colcountnumber.Text.ToInt(); if (count < 1 || count > 9) { this.colcountnumber.Text = ""; base.RegisterStartupScript("", "<script>alert('列值必须在2~9范围内');</script>"); return; } this.forumInfo.ColCount = count; } if (this.rewritename.Text.Trim() != this.oldrewritename.Value && !this.rewritename.Text.IsNullOrEmpty() && XForum.CheckRewriteNameInvalid(this.rewritename.Text.Trim())) { this.rewritename.Text = ""; base.RegisterStartupScript("", "<script>alert('URL重写非法!');</script>"); return; } this.forumInfo.TemplateID = ((this.templateid.SelectedValue.ToInt() == this.config.Templateid) ? 0 : this.templateid.SelectedValue.ToInt()); //this.forumInfo.AllowHtml = 0; //this.forumInfo.AllowBlog = 0; //this.forumInfo.IsTrade = 0; //this.forumInfo.AllowEditRules = 0; this.forumInfo.AllowSmilies = this.setting.Items[0].Selected; this.forumInfo.AllowRss = this.setting.Items[1].Selected; this.forumInfo.AllowBbCode = this.setting.Items[2].Selected; this.forumInfo.AllowImgCode = this.setting.Items[3].Selected; this.forumInfo.Recyclebin = this.BoolToInt(this.setting.Items[4].Selected); this.forumInfo.Modnewposts = this.BoolToInt(this.setting.Items[5].Selected); this.forumInfo.Modnewtopics = this.BoolToInt(this.setting.Items[6].Selected); this.forumInfo.Jammer = this.BoolToInt(this.setting.Items[7].Selected); this.forumInfo.DisableWatermark = this.setting.Items[8].Selected; this.forumInfo.Inheritedmod = this.BoolToInt(this.setting.Items[9].Selected); this.forumInfo.AllowThumbnail = this.setting.Items[10].Selected; this.forumInfo.AllowTag = this.setting.Items[11].Selected; int num = 0; num = (this.setting.Items[12].Selected ? (num | 1) : (num & -2)); num = (this.setting.Items[13].Selected ? (num | 16) : (num & -17)); num = (this.setting.Items[14].Selected ? (num | 4) : (num & -5)); this.forumInfo.AllowPostSpecial = num; this.forumInfo.AllowEditRules = this.setting.Items[15].Selected; this.forumInfo.AllowSpecialOnly = (int)Convert.ToInt16(this.allowspecialonly.SelectedValue) != 0; if (this.autocloseoption.SelectedValue == "0") { this.forumInfo.AutoClose = 0; } else { this.forumInfo.AutoClose = this.autocloseday.Text.ToInt(); } this.forumInfo.Description = this.description.Text; this.forumInfo.Password = this.password.Text; this.forumInfo.Icon = ((HttpContext.Current.Request.Files.Count > 0 && !string.IsNullOrEmpty(HttpContext.Current.Request.Files[0].FileName)) ? AdminForums.UploadForumIcon(this.forumInfo.ID) : this.icon.Text); this.forumInfo.Redirect = this.redirect.Text; this.forumInfo.Attachextensions = this.attachextensions.GetSelectString(","); AdminForums.CompareOldAndNewModerator(this.forumInfo.Moderators, this.moderators.Text.Replace("\r\n", ","), DNTRequest.GetInt("fid", 0)); this.forumInfo.Moderators = this.moderators.Text.Replace("\r\n", ","); this.forumInfo.Rules = this.rules.Text.Trim(); this.forumInfo.Seokeywords = this.seokeywords.Text.Trim(); this.forumInfo.Seodescription = this.seodescription.Text.Trim(); this.forumInfo.RewriteName = this.rewritename.Text.Trim(); this.forumInfo.ViewPerm = base.Request.Form["viewperm"]; this.forumInfo.PostPerm = base.Request.Form["postperm"]; this.forumInfo.ReplyPerm = base.Request.Form["replyperm"]; this.forumInfo.GetattachPerm = base.Request.Form["getattachperm"]; this.forumInfo.PostattachPerm = base.Request.Form["postattachperm"]; this.forumInfo.ApplytopicType = Convert.ToSByte(this.applytopictype.SelectedValue); this.forumInfo.PostbytopicType = Convert.ToSByte(this.postbytopictype.SelectedValue); this.forumInfo.ViewbytopicType = Convert.ToSByte(this.viewbytopictype.SelectedValue); this.forumInfo.Topictypeprefix = Convert.ToSByte(this.topictypeprefix.SelectedValue); this.forumInfo.TopicTypes = this.GetTopicType(); this.forumInfo.Permuserlist = this.GetPermuserlist(); //AggregationFacade.ForumAggregation.ClearDataBind(); string text = AdminForums.UpdateForumInfo(this.forumInfo).Replace("'", "’"); if (this.childForumApplyTemplate.Checked) { // 子孙采用相同的模板 //AdminForums.UpdateForumTemplateID(this.forumInfo); foreach (var item in f.AllChilds) { item.TemplateID = f.TemplateID; item.Update(); } } ForumOperator.RefreshForumCache(); AdminVisitLog.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "编辑论坛版块", "编辑论坛版块,名称为:" + this.name.Text.Trim()); var config = GeneralConfigInfo.Current; config.Specifytemplate = ((Forums.GetSpecifyForumTemplateCount() > 0) ? 1 : 0); config.Save(); //config.Save();; if (String.IsNullOrEmpty(text)) { //base.Response.Redirect("forum_ForumsTree.aspx"); base.RegisterStartupScript("PAGE", "self.location.href='forum_ForumsTree.aspx';"); return; } base.Response.Write("<script>alert('用户:" + text + "不存在或因为它们所属组为\"游客\",\"等待验证会员\",因为无法设为版主');window.location.href='forum_ForumsTree.aspx';</script>"); base.Response.End(); } }