/// <summary> /// 向版块列表中插入新的版块信息 /// </summary> /// <param name="foruminfo"></param> /// <param name="moderatorsInfo">版主信息</param> /// <param name="adminUid">管理员Id</param> /// <param name="adminUserName">管理员用户名</param> /// <param name="adminUserGruopId">管理员用户组Id</param> /// <param name="adminUserGroupTitle">管理员用户组名称</param> /// <param name="adminIp">管理员IP</param> /// <returns></returns> public static int CreateForums(ForumInfo forumInfo, out string moderatorsInfo, int adminUid, string adminUserName, int adminUserGruopId, string adminUserGroupTitle, string adminIp) { int fid = Data.DataProvider.Forums.CreateForumInfo(forumInfo); SetForumsPathList(); //moderatorsInfo = SetForumsModerators(fid.ToString(), forumInfo.Moderators, forumInfo.Inheritedmod).Replace("'", "’"); moderatorsInfo = ""; SASCache.GetCacheService().RemoveObject("/SAS/UI/ForumListBoxOptions"); SASCache.GetCacheService().RemoveObject("/SAS/ForumList"); SASCache.GetCacheService().RemoveObject("/Aggregation/HotForumList"); SASCache.GetCacheService().RemoveObject("/Aggregation/ForumHotTopicList"); SASCache.GetCacheService().RemoveObject("/Aggregation/ForumNewTopicList"); SASCache.GetCacheService().RemoveObject("/SAS/DropdownOptions"); SASCache.GetCacheService().RemoveObject("/SAS/ForumListMenuDiv"); AdminVistLogs.InsertLog(adminUid, adminUserName, adminUserGruopId, adminUserGroupTitle, adminIp, "添加论坛版块", "添加论坛版块,名称为:" + forumInfo.Name); return fid; }
/// <summary> /// 得到用户可以上传的文件类型 /// </summary> /// <param name="usergroupinfo">当前用户所属用户组信息</param> /// <param name="forum">所在版块</param> /// <returns></returns> public static string GetAllowAttachmentType(UserGroupInfo usergroupinfo, ForumInfo forum) { //得到用户可以上传的文件类型 StringBuilder sbAttachmentTypeSelect = new StringBuilder(); if (!usergroupinfo.ug_attachextensions.Trim().Equals("")) { sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(usergroupinfo.ug_attachextensions); sbAttachmentTypeSelect.Append(")"); } if (!forum.Attachextensions.Equals("")) { if (sbAttachmentTypeSelect.Length > 0) sbAttachmentTypeSelect.Append(" AND "); sbAttachmentTypeSelect.Append("[id] in ("); sbAttachmentTypeSelect.Append(forum.Attachextensions); sbAttachmentTypeSelect.Append(")"); } return sbAttachmentTypeSelect.ToString(); }
/// <summary> /// 发帖(主题)是否需要审核 /// </summary> /// <param name="forum"></param> /// <param name="useradminid"></param> /// <param name="topicInfo"></param> /// <param name="userid"></param> /// <param name="disablepost"></param> /// <returns></returns> public static bool NeedAudit(ForumInfo forum, int useradminid, TopicInfo topicInfo, int userid, int disablepost) { bool needaudit = false; //是否需要审核 if (BetweenTime(GeneralConfigs.GetConfig().Postmodperiods)) { needaudit = true; } else { if (forum.Modnewposts == 1 && useradminid != 1) { if (useradminid > 1) { if (disablepost == 1 && topicInfo.Displayorder != -2) { if (useradminid == 3) needaudit = true; } else needaudit = true; } else needaudit = true; } else if (useradminid != 1 && topicInfo.Displayorder == -2) needaudit = true; } return needaudit; }
/// <summary> /// 上传附件权限控制 /// </summary> /// <param name="forum">版块信息</param> /// <param name="usergroupinfo">当前用户的用户组信息</param> /// <param name="userId">当前用户Id</param> /// <returns></returns> public static bool PostAttachAuthority(ForumInfo forum, UserGroupInfo userGroupInfo, int userId, ref string msg) { if (!Forums.AllowPostAttachByUserID(forum.Permuserlist, userId)) { if (!Forums.AllowPostAttach(forum.Postattachperm, userGroupInfo.ug_id)) { msg = "您没有在该版块上传附件的权限"; return false; } else if (userGroupInfo.Allowpostattach != 1) { msg = string.Format("您当前的身份 \"{0}\" 没有上传附件的权限", userGroupInfo.ug_name); return false; } } return true; }
public static bool NeedAudit(ForumInfo forum, int useradminid, int userid) { bool needaudit = false; //是否需要审核 if (useradminid == 1) return false; if (BetweenTime(GeneralConfigs.GetConfig().Postmodperiods)) { needaudit = true; } else { if (forum.Modnewposts == 1) { needaudit = true; } } return needaudit; }
private void SubmitInfo_Click(object sender, EventArgs e) { #region 提交同级版块 if (this.CheckCookie()) { if (SASRequest.GetString("fid") != "") { forumInfo = Forums.GetForumInfo(SASRequest.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() != "" && SAS.Logic.Forums.CheckRewriteNameInvalid(rewritename.Text.Trim())) { rewritename.Text = ""; base.RegisterStartupScript("", "<script>alert('URL重写非法!');</script>"); return; } 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.Jammer = BoolToInt(setting.Items[6].Selected); forumInfo.Disablewatermark = BoolToInt(setting.Items[7].Selected); forumInfo.Inheritedmod = BoolToInt(setting.Items[8].Selected); forumInfo.Allowthumbnail = BoolToInt(setting.Items[9].Selected); forumInfo.Allowtag = BoolToInt(setting.Items[10].Selected); int temppostspecial = 0; temppostspecial = setting.Items[11].Selected ? temppostspecial | 1 : temppostspecial & ~1; temppostspecial = setting.Items[12].Selected ? temppostspecial | 16 : temppostspecial & ~16; temppostspecial = setting.Items[13].Selected ? temppostspecial | 4 : temppostspecial & ~4; ////forumInfo.Allowpostspecial = temppostspecial; forumInfo.Alloweditrules = BoolToInt(setting.Items[14].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; forumInfo.Icon = icon.Text; forumInfo.Redirect = redirect.Text; forumInfo.Attachextensions = attachextensions.GetSelectString(","); ////AdminForums.CompareOldAndNewModerator(forumInfo.Moderators, moderators.Text.Replace("\r\n", ","), SASRequest.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.Topictypes = topictypes.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(); ////SAS.Aggregation.AggregationFacade.ForumAggregation.ClearDataBind(); string result = AdminForums.UpdateForumInfo(forumInfo).Replace("'", "’"); 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 RunForumStatic_Click(object sender, EventArgs e) { #region 运行论坛统计 if (this.CheckCookie()) { forumsstatic.Text = ViewState["forumsstatic"].ToString(); int fid = SASRequest.GetInt("fid", -1); if (fid > 0) { forumInfo = Forums.GetForumInfo(fid); } else { return; } int topiccount = 0; int postcount = 0; int lasttid = 0; string lasttitle = ""; string lastpost = ""; int lastposterid = 0; string lastposter = ""; int replypost = 0; AdminForumStats.ReSetFourmTopicAPost(fid, out topiccount, out postcount, out lasttid, out lasttitle, out lastpost, out lastposterid, out lastposter, out replypost); runforumsstatic = string.Format("<br /><br />运行结果<hr style=\"height:1px; width:600; color:#CCCCCC; background:#CCCCCC; border: 0; \" align=\"left\" />主题总数:{0}<br />帖子总数:{1}<br />今日回帖数总数:{2}<br />最后提交日期:{3}", topiccount, postcount, replypost, lastpost); if ((forumInfo.Topics == topiccount) && (forumInfo.Posts == postcount) && (forumInfo.Todayposts == replypost) && (forumInfo.Lastpost.Trim() == lastpost)) { runforumsstatic += "<br /><br /><br />结果一致"; } else { runforumsstatic += "<br /><br /><br />比较<hr style=\"height:1px; width:600; color:#CCCCCC; background:#CCCCCC; border: 0; \" align=\"left\" />"; if (forumInfo.Topics != topiccount) { runforumsstatic += "主题总数有差异<br />"; } if (forumInfo.Posts != postcount) { runforumsstatic += "帖子总数有差异<br />"; } if (forumInfo.Todayposts != replypost) { runforumsstatic += "今日回帖数总数有差异<br />"; } if (forumInfo.Lastpost != lastpost) { runforumsstatic += "最后提交日期有差异<br />"; } } } this.TabControl1.SelectedIndex = 5; DataGridBind(""); BindTopicType(); #endregion }
public void LoadCurrentForumInfo(int fid) { #region 加载相关信息 if (fid <= 0) return; forumInfo = Forums.GetForumInfo(fid); if (forumInfo == null) return; if (forumInfo.Layer > 0) { tabPage2.Visible = true; tabPage6.Visible = true; } else { //删除掉"高级设置"属性页 TabControl1.Items.Remove(tabPage2); tabPage2.Visible = false; //删除掉"特殊用户"属性页 TabControl1.Items.Remove(tabPage4); tabPage4.Visible = false; //删除掉"主题分类"属性页 TabControl1.Items.Remove(tabPage5); tabPage5.Visible = false; //删除掉"统计信息"属性页 TabControl1.Items.Remove(tabPage6); tabPage6.Visible = false; templatestyle.Visible = false; } forumname.Text = forumInfo.Name.Trim(); name.Text = forumInfo.Name.Trim(); displayorder.Text = forumInfo.Displayorder.ToString(); status.SelectedValue = forumInfo.Status.ToString(); ////if (forumInfo.Colcount == 1) ////{ //// showcolnum.Attributes.Add("style", "display:none"); //// colcount.SelectedIndex = 0; ////} ////else ////{ //// showcolnum.Attributes.Add("style", "display:block"); //// colcount.SelectedIndex = 1; ////} ////colcount.Attributes.Add("onclick", "javascript:document.getElementById('" + showcolnum.ClientID + "').style.display= (document.getElementById('TabControl1_tabPage1_colcount_0').checked ? 'none' : 'block');"); ////colcountnumber.Text = forumInfo.Colcount.ToString(); templateid.SelectedValue = forumInfo.Templateid.ToString(); forumsstatic.Text = string.Format("主题总数:{0}<br />帖子总数:{1}<br />今日回帖数总数:{2}<br />最后提交日期:{3}", forumInfo.Topics.ToString(), forumInfo.Posts.ToString(), forumInfo.Todayposts.ToString(), forumInfo.Lastpost.ToString()); ViewState["forumsstatic"] = forumsstatic.Text; if (forumInfo.Allowsmilies == 1) setting.Items[0].Selected = true; if (forumInfo.Allowrss == 1) setting.Items[1].Selected = true; if (forumInfo.Allowbbcode == 1) setting.Items[2].Selected = true; if (forumInfo.Allowimgcode == 1) setting.Items[3].Selected = true; if (forumInfo.Recyclebin == 1) setting.Items[4].Selected = true; if (forumInfo.Modnewposts == 1) setting.Items[5].Selected = true; if (forumInfo.Jammer == 1) setting.Items[6].Selected = true; if (forumInfo.Disablewatermark == 1) setting.Items[7].Selected = true; if (forumInfo.Inheritedmod == 1) setting.Items[8].Selected = true; if (forumInfo.Allowthumbnail == 1) setting.Items[9].Selected = true; if (forumInfo.Allowtag == 1) setting.Items[10].Selected = true; //if (__foruminfo.Istrade == 1) setting.Items[11].Selected = true; ////if ((forumInfo.Allowpostspecial & 1) != 0) setting.Items[11].Selected = true; ////if ((forumInfo.Allowpostspecial & 16) != 0) setting.Items[12].Selected = true; ////if ((forumInfo.Allowpostspecial & 4) != 0) setting.Items[13].Selected = true; if ((forumInfo.Alloweditrules == 1)) setting.Items[14].Selected = true; ////allowspecialonly.SelectedValue = forumInfo.Allowspecialonly.ToString(); if (forumInfo.Autoclose == 0) { showclose.Attributes.Add("style", "display:none"); autocloseoption.SelectedIndex = 0; } else { autocloseoption.SelectedIndex = 1; } autocloseoption.Attributes.Add("onclick", "javascript:document.getElementById('" + showclose.ClientID + "').style.display= (document.getElementById('TabControl1_tabPage2_autocloseoption_0').checked ? 'none' : 'block');"); autocloseday.Text = forumInfo.Autoclose.ToString(); //提取高级信息 description.Text = forumInfo.Description.Trim(); password.Text = forumInfo.Password.Trim(); icon.Text = forumInfo.Icon.Trim(); redirect.Text = forumInfo.Redirect.Trim(); moderators.Text = forumInfo.Moderators.Trim(); ////inheritmoderators.Text = Users.GetModerators(fid); rules.Text = forumInfo.Rules.Trim(); seokeywords.Text = forumInfo.Seokeywords == null ? "" : forumInfo.Seokeywords.Trim(); seodescription.Text = forumInfo.Seodescription == null ? "" : forumInfo.Seodescription.Trim(); rewritename.Text = forumInfo.Rewritename == null ? "" : forumInfo.Rewritename.Trim(); oldrewritename.Value = rewritename.Text; topictypes.Text = forumInfo.Topictypes.Trim(); DataTable dt = UserGroups.GetUserGroupForDataTable(); int i = 1; foreach (DataRow dr in dt.Rows) { HtmlTableRow tr = new HtmlTableRow(); HtmlTableCell td = new HtmlTableCell("td"); //if (i % 2 == 1) // td.Attributes.Add("class", "td_alternating_item1"); //else // td.Attributes.Add("class", "td_alternating_item2"); td.Controls.Add(new LiteralControl("<input type='checkbox' id='r" + i + "' onclick='selectRow(" + i + ",this.checked)'>")); tr.Cells.Add(td); td = new HtmlTableCell("td"); //if (i % 2 == 1) // td.Attributes.Add("class", "td_alternating_item1"); //else // td.Attributes.Add("class", "td_alternating_item2"); td.Controls.Add(new LiteralControl("<label for='r" + i + "'>" + dr["ug_name"].ToString() + "</lable>")); tr.Cells.Add(td); tr.Cells.Add(GetTD("viewperm", forumInfo.Viewperm.Trim(), dr["ug_id"].ToString(), i)); tr.Cells.Add(GetTD("postperm", forumInfo.Postperm.Trim(), dr["ug_id"].ToString(), i)); tr.Cells.Add(GetTD("replyperm", forumInfo.Replyperm.Trim(), dr["ug_id"].ToString(), i)); tr.Cells.Add(GetTD("getattachperm", forumInfo.Getattachperm.Trim(), dr["ug_id"].ToString(), i)); tr.Cells.Add(GetTD("postattachperm", forumInfo.Postattachperm.Trim(), dr["ug_id"].ToString(), i)); powerset.Rows.Add(tr); i++; } dt = Attachments.GetAttachmentType(); attachextensions.SetSelectByID(forumInfo.Attachextensions.Trim()); if (fid > 0) { forumInfo = Forums.GetForumInfo(fid); } else { return; } applytopictype.SelectedValue = forumInfo.Applytopictype.ToString(); postbytopictype.SelectedValue = forumInfo.Postbytopictype.ToString(); viewbytopictype.SelectedValue = forumInfo.Viewbytopictype.ToString(); topictypeprefix.SelectedValue = forumInfo.Topictypeprefix.ToString(); #endregion }
/// <summary> /// 返回全部版块列表并缓存 /// </summary> /// <returns>板块信息数组</returns> public static List<ForumInfo> GetForumList() { List<ForumInfo> forumlist = new List<ForumInfo>(); DataTable dt = GetForumListForDataTable(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { ForumInfo forum = new ForumInfo(); forum.Fid = TypeConverter.StrToInt(dr["fid"].ToString(), 0); forum.Parentid = TypeConverter.StrToInt(dr["parentid"].ToString(), 0); forum.Layer = TypeConverter.StrToInt(dr["layer"].ToString(), 0); forum.Pathlist = dr["pathlist"].ToString(); forum.Parentidlist = dr["parentidlist"].ToString(); forum.Subforumcount = TypeConverter.StrToInt(dr["subforumcount"].ToString(), 0); forum.Name = dr["name"].ToString(); forum.Status = TypeConverter.StrToInt(dr["status"].ToString(), 0); //forum.Colcount = TypeConverter.StrToInt(dr["colcount"].ToString(), 0); forum.Displayorder = TypeConverter.StrToInt(dr["displayorder"].ToString(), 0); forum.Templateid = TypeConverter.StrToInt(dr["templateid"].ToString(), 0); forum.Topics = TypeConverter.StrToInt(dr["topics"].ToString(), 0); forum.CurrentTopics = TypeConverter.StrToInt(dr["curtopics"].ToString(), 0); forum.Posts = TypeConverter.StrToInt(dr["posts"].ToString(), 0); //当前版块的最后发帖日期为空,则表示今日发帖数为0 if (Utils.StrIsNullOrEmpty(dr["lastpost"].ToString())) dr["todayposts"] = 0; else { //当系统日期与最发发帖日期不同时,则表示今日发帖数为0 if (Convert.ToDateTime(dr["lastpost"]).ToString("yyyy-MM-dd") != DateTime.Now.ToString("yyyy-MM-dd")) dr["todayposts"] = 0; } forum.Todayposts = TypeConverter.StrToInt(dr["todayposts"].ToString(), 0); forum.Lasttid = TypeConverter.StrToInt(dr["lasttid"].ToString(), 0); forum.Lasttitle = dr["lasttitle"].ToString(); forum.Lastpost = dr["lastpost"].ToString(); forum.Lastposterid = TypeConverter.StrToInt(dr["lastposterid"].ToString(), 0); forum.Lastposter = dr["lastposter"].ToString(); forum.Allowsmilies = TypeConverter.StrToInt(dr["allowsmilies"].ToString(), 0); forum.Allowrss = TypeConverter.StrToInt(dr["allowrss"].ToString(), 0); forum.Allowhtml = TypeConverter.StrToInt(dr["allowhtml"].ToString(), 0); forum.Allowbbcode = TypeConverter.StrToInt(dr["allowbbcode"].ToString(), 0); forum.Allowimgcode = TypeConverter.StrToInt(dr["allowimgcode"].ToString(), 0); ////forum.Allowblog = TypeConverter.StrToInt(dr["allowblog"].ToString(), 0); ////forum.Istrade = TypeConverter.StrToInt(dr["istrade"].ToString(), 0); ////forum.Allowpostspecial = TypeConverter.StrToInt(dr["allowpostspecial"].ToString(), 0); ////forum.Allowspecialonly = TypeConverter.StrToInt(dr["allowspecialonly"].ToString(), 0); forum.Alloweditrules = TypeConverter.StrToInt(dr["alloweditrules"].ToString(), 0); forum.Allowthumbnail = TypeConverter.StrToInt(dr["allowthumbnail"].ToString(), 0); forum.Allowtag = TypeConverter.StrToInt(dr["allowtag"].ToString(), 0); forum.Recyclebin = TypeConverter.StrToInt(dr["recyclebin"].ToString(), 0); forum.Modnewposts = TypeConverter.StrToInt(dr["modnewposts"].ToString(), 0); forum.Jammer = TypeConverter.StrToInt(dr["jammer"].ToString(), 0); forum.Disablewatermark = TypeConverter.StrToInt(dr["disablewatermark"].ToString(), 0); forum.Inheritedmod = TypeConverter.StrToInt(dr["inheritedmod"].ToString(), 0); forum.Autoclose = TypeConverter.StrToInt(dr["autoclose"].ToString(), 0); forum.Password = dr["password"].ToString(); forum.Icon = dr["icon"].ToString(); ////forum.Postcredits = dr["postcredits"].ToString(); ////forum.Replycredits = dr["replycredits"].ToString(); forum.Redirect = dr["redirect"].ToString(); forum.Attachextensions = dr["attachextensions"].ToString(); forum.Rules = dr["rules"].ToString(); forum.Topictypes = dr["topictypes"].ToString(); forum.Viewperm = dr["viewperm"].ToString(); forum.Postperm = dr["postperm"].ToString(); forum.Replyperm = dr["replyperm"].ToString(); forum.Getattachperm = dr["getattachperm"].ToString(); forum.Postattachperm = dr["postattachperm"].ToString(); forum.Moderators = dr["moderators"].ToString(); forum.Description = dr["description"].ToString(); forum.Applytopictype = TypeConverter.StrToInt(dr["applytopictype"] == DBNull.Value ? "0" : dr["applytopictype"].ToString(), 0); forum.Postbytopictype = TypeConverter.StrToInt(dr["postbytopictype"] == DBNull.Value ? "0" : dr["postbytopictype"].ToString(), 0); forum.Viewbytopictype = TypeConverter.StrToInt(dr["viewbytopictype"] == DBNull.Value ? "0" : dr["viewbytopictype"].ToString(), 0); forum.Topictypeprefix = TypeConverter.StrToInt(dr["topictypeprefix"] == DBNull.Value ? "0" : dr["topictypeprefix"].ToString(), 0); forum.Permuserlist = dr["permuserlist"].ToString(); forum.Seokeywords = dr["seokeywords"].ToString(); forum.Seodescription = dr["seodescription"].ToString(); forum.Rewritename = dr["rewritename"].ToString(); forumlist.Add(forum); } } return forumlist; }
/// <summary> /// 创建版块 /// </summary> /// <param name="forumInfo">版块信息</param> /// <returns>新建版块Fid</returns> public static int CreateForumInfo(ForumInfo forumInfo) { return DatabaseProvider.GetInstance().InsertForumsInf(forumInfo); }
/// <summary> /// 更新版块信息 /// </summary> /// <param name="forumInfo">版块信息</param> public static void UpdateForumInfo(ForumInfo forumInfo) { DatabaseProvider.GetInstance().SaveForumsInfo(forumInfo); }
protected override void ShowPage() { if (oluserinfo.Ol_ug_id == 4) { AddErrLine("你所在的用户组,为禁止发言"); return; } if (userid > 0) { userinfo = Users.GetShortUserInfo(userid); } #region 获取并检查版块信息 forumid = 2; forum = Forums.GetForumInfo(forumid); if (forum == null || forum.Layer == 0) { forum = new ForumInfo();//如果不初始化对象,则会报错 allowposttopic = false; AddErrLine("错误的论坛ID"); return; } pagetitle = Utils.RemoveHtml(forum.Name); enabletag = (config.Enabletag & forum.Allowtag) == 1; if (forum.Applytopictype == 1) //启用主题分类 topictypeselectoptions = Forums.GetCurrentTopicTypesOption(forum.Fid, forum.Topictypes); if (forum.Password != "" && Utils.MD5(forum.Password) != LogicUtils.GetCookie("forum" + forumid + "password")) { AddErrLine("本版块被管理员设置了密码"); SetBackLink(base.ShowForumAspxRewrite(forumid, 0)); return; } needaudit = UserAuthority.NeedAudit(forum, useradminid, userid); smileyoff = 1 - forum.Allowsmilies; bbcodeoff = (forum.Allowbbcode == 1 && usergroupinfo.Ug_allowcusbbcode == 1) ? 0 : 1; allowimg = forum.Allowimgcode; #endregion #region 附件信息绑定 //得到用户可以上传的文件类型 string attachmentTypeSelect = Attachments.GetAllowAttachmentType(usergroupinfo, forum); attachextensions = Attachments.GetAttachmentTypeArray(attachmentTypeSelect); attachextensionsnosize = Attachments.GetAttachmentTypeString(attachmentTypeSelect); //得到今天允许用户上传的附件总大小(字节) int MaxTodaySize = (userid > 0 ? MaxTodaySize = Attachments.GetUploadFileSizeByuserid(userid) : 0); attachsize = usergroupinfo.Ug_maxsizeperday - MaxTodaySize;//今天可上传得大小 //是否有上传附件的权限 canpostattach = UserAuthority.PostAttachAuthority(forum, usergroupinfo, userid, ref msg); if (canpostattach && (userinfo != null && userinfo.Ps_id > 0) && apb != null && config.Enablealbum == 1 && (UserGroups.GetUserGroupInfo(userinfo.Ps_ug_id).ug_maxspacephotosize - apb.GetPhotoSizeByUserid(userid) > 0)) { caninsertalbum = true; albumlist = apb.GetSpaceAlbumByUserId(userid); } #endregion if (ispost) { } else //非提交操作 AddLinkCss(BaseConfigs.GetSitePath + "templates/" + templatepath + "/editor.css", "css"); }
/// <summary> /// 更新论坛版块(分类)的相关信息 /// </summary> /// <param name="forumInfo"></param> /// <returns></returns> public static string UpdateForumInfo(ForumInfo forumInfo) { Data.DataProvider.Forums.UpdateForumInfo(forumInfo); SASCache.GetCacheService().RemoveObject("/SAS/ForumList"); SetForumsPathList(); //string result = SetForumsModerators(forumInfo.Fid.ToString(), forumInfo.Moderators, forumInfo.Inheritedmod); string result = ""; SASCache.GetCacheService().RemoveObject("/SAS/UI/ForumListBoxOptions"); SASCache.GetCacheService().RemoveObject("/SAS/ForumList"); SASCache.GetCacheService().RemoveObject("/SAS/TopicTypesOption" + forumInfo.Fid); SASCache.GetCacheService().RemoveObject("/SAS/TopicTypesLink" + forumInfo.Fid); SASCache.GetCacheService().RemoveObject("/Aggregation/HotForumList"); SASCache.GetCacheService().RemoveObject("/Aggregation/ForumHotTopicList"); SASCache.GetCacheService().RemoveObject("/Aggregation/ForumNewTopicList"); return result; }
/// <summary> /// 保存板块信息 /// </summary> /// <param name="forumInfo">版块信息</param> public void SaveForumsInfo(ForumInfo forumInfo) { SqlConnection conn = new SqlConnection(DbHelper.ConnectionString); conn.Open(); using (SqlTransaction trans = conn.BeginTransaction()) { try { DbParameter[] parms = { DbHelper.MakeInParam("@parentid", (DbType)SqlDbType.SmallInt, 2, forumInfo.Parentid), DbHelper.MakeInParam("@layer", (DbType)SqlDbType.Int, 4, forumInfo.Layer), DbHelper.MakeInParam("@pathlist", (DbType)SqlDbType.NChar, 3000, Utils.StrIsNullOrEmpty(forumInfo.Pathlist) ? " " : forumInfo.Pathlist), DbHelper.MakeInParam("@parentidlist", (DbType)SqlDbType.NChar, 300, Utils.StrIsNullOrEmpty(forumInfo.Parentidlist) ? " " : forumInfo.Parentidlist), DbHelper.MakeInParam("@subforumcount", (DbType)SqlDbType.Int, 4, forumInfo.Subforumcount), DbHelper.MakeInParam("@name", (DbType)SqlDbType.NChar, 50, forumInfo.Name), DbHelper.MakeInParam("@status", (DbType)SqlDbType.Int, 4, forumInfo.Status), //DbHelper.MakeInParam("@colcount", (DbType)SqlDbType.SmallInt, 4, forumInfo.Colcount), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, forumInfo.Displayorder), DbHelper.MakeInParam("@templateid", (DbType)SqlDbType.SmallInt, 2, forumInfo.Templateid), DbHelper.MakeInParam("@topics", (DbType)SqlDbType.Int, 4, forumInfo.Topics), DbHelper.MakeInParam("@curtopics", (DbType)SqlDbType.Int, 4, forumInfo.CurrentTopics), DbHelper.MakeInParam("@posts", (DbType)SqlDbType.Int, 4, forumInfo.Posts), DbHelper.MakeInParam("@todayposts", (DbType)SqlDbType.Int, 4, forumInfo.Todayposts), DbHelper.MakeInParam("@lasttid", (DbType)SqlDbType.Int, 4, forumInfo.Lasttid), DbHelper.MakeInParam("@lasttitle", (DbType)SqlDbType.NChar, 60, forumInfo.Lasttitle), DbHelper.MakeInParam("@lastpost", (DbType)SqlDbType.DateTime, 8, forumInfo.Lastpost), DbHelper.MakeInParam("@lastposterid", (DbType)SqlDbType.Int, 4, forumInfo.Lastposterid), DbHelper.MakeInParam("@lastposter", (DbType)SqlDbType.NChar, 20, forumInfo.Lastposter), DbHelper.MakeInParam("@allowsmilies", (DbType)SqlDbType.Int, 4, forumInfo.Allowsmilies), DbHelper.MakeInParam("@allowrss", (DbType)SqlDbType.Int, 6, forumInfo.Allowrss), DbHelper.MakeInParam("@allowhtml", (DbType)SqlDbType.Int, 4, forumInfo.Allowhtml), DbHelper.MakeInParam("@allowbbcode", (DbType)SqlDbType.Int, 4, forumInfo.Allowbbcode), DbHelper.MakeInParam("@allowimgcode", (DbType)SqlDbType.Int, 4, forumInfo.Allowimgcode), //DbHelper.MakeInParam("@allowblog", (DbType)SqlDbType.Int, 4, forumInfo.Allowblog), //DbHelper.MakeInParam("@istrade", (DbType)SqlDbType.Int, 4, forumInfo.Istrade), //DbHelper.MakeInParam("@allowpostspecial",(DbType)SqlDbType.Int,4,forumInfo.Allowpostspecial), //DbHelper.MakeInParam("@allowspecialonly",(DbType)SqlDbType.Int,4,forumInfo.Allowspecialonly), DbHelper.MakeInParam("@alloweditrules", (DbType)SqlDbType.Int, 4, forumInfo.Alloweditrules), DbHelper.MakeInParam("@allowthumbnail", (DbType)SqlDbType.Int, 4, forumInfo.Allowthumbnail), DbHelper.MakeInParam("@allowtag",(DbType)SqlDbType.Int,4,forumInfo.Allowtag), DbHelper.MakeInParam("@recyclebin", (DbType)SqlDbType.Int, 4, forumInfo.Recyclebin), DbHelper.MakeInParam("@modnewposts", (DbType)SqlDbType.Int, 4, forumInfo.Modnewposts), DbHelper.MakeInParam("@jammer", (DbType)SqlDbType.Int, 4, forumInfo.Jammer), DbHelper.MakeInParam("@disablewatermark", (DbType)SqlDbType.Int, 4, forumInfo.Disablewatermark), DbHelper.MakeInParam("@inheritedmod", (DbType)SqlDbType.Int, 4, forumInfo.Inheritedmod), DbHelper.MakeInParam("@autoclose", (DbType)SqlDbType.SmallInt, 2, forumInfo.Autoclose), DbHelper.MakeInParam("@fid", (DbType)SqlDbType.Int, 4, forumInfo.Fid) }; string commandText = string.Format("UPDATE [{0}forums] SET [parentid]=@parentid, [layer]=@layer, [pathlist]=@pathlist, " + "[parentidlist]=@parentidlist, [subforumcount]=@subforumcount, [name]=@name, [status]=@status," + "[displayorder]=@displayorder,[templateid]=@templateid,[topics]=@topics," + "[curtopics]=@curtopics,[posts]=@posts,[todayposts]=@todayposts,[lasttid]=@lasttid,[lasttitle]=@lasttitle," + "[lastpost]=@lastpost,[lastposterid]=@lastposterid,[lastposter]=@lastposter," + "[allowsmilies]=@allowsmilies ,[allowrss]=@allowrss, [allowhtml]=@allowhtml, [allowbbcode]=@allowbbcode, [allowimgcode]=@allowimgcode, " //+ "[allowblog]=@allowblog,[istrade]=@istrade,[allowpostspecial]=@allowpostspecial,[allowspecialonly]=@allowspecialonly," + "[alloweditrules]=@alloweditrules ,[allowthumbnail]=@allowthumbnail ,[allowtag]=@allowtag," + "[recyclebin]=@recyclebin, [modnewposts]=@modnewposts,[jammer]=@jammer,[disablewatermark]=@disablewatermark,[inheritedmod]=@inheritedmod," + "[autoclose]=@autoclose WHERE [fid]=@fid", BaseConfigs.GetTablePrefix); DbHelper.ExecuteNonQuery(trans, CommandType.Text, commandText, parms); DbParameter[] prams1 = { DbHelper.MakeInParam("@password", (DbType)SqlDbType.NVarChar, 16, forumInfo.Password), DbHelper.MakeInParam("@icon", (DbType)SqlDbType.VarChar, 255, forumInfo.Icon), //DbHelper.MakeInParam("@postcredits", (DbType)SqlDbType.VarChar, 255, forumInfo.Postcredits), //DbHelper.MakeInParam("@replycredits", (DbType)SqlDbType.VarChar, 255, forumInfo.Replycredits), DbHelper.MakeInParam("@redirect", (DbType)SqlDbType.VarChar, 255, forumInfo.Redirect), DbHelper.MakeInParam("@attachextensions", (DbType)SqlDbType.VarChar, 255, forumInfo.Attachextensions), DbHelper.MakeInParam("@rules", (DbType)SqlDbType.NText, 0, forumInfo.Rules), DbHelper.MakeInParam("@topictypes", (DbType)SqlDbType.Text, 0, forumInfo.Topictypes), DbHelper.MakeInParam("@viewperm", (DbType)SqlDbType.Text, 0, forumInfo.Viewperm), DbHelper.MakeInParam("@postperm", (DbType)SqlDbType.Text, 0, forumInfo.Postperm), DbHelper.MakeInParam("@replyperm", (DbType)SqlDbType.Text, 0, forumInfo.Replyperm), DbHelper.MakeInParam("@getattachperm", (DbType)SqlDbType.Text, 0, forumInfo.Getattachperm), DbHelper.MakeInParam("@postattachperm", (DbType)SqlDbType.Text, 0, forumInfo.Postattachperm), DbHelper.MakeInParam("@moderators", (DbType)SqlDbType.Text, 0, forumInfo.Moderators), DbHelper.MakeInParam("@description", (DbType)SqlDbType.NText, 0, forumInfo.Description), DbHelper.MakeInParam("@applytopictype", (DbType)SqlDbType.TinyInt, 1, forumInfo.Applytopictype), DbHelper.MakeInParam("@postbytopictype", (DbType)SqlDbType.TinyInt, 1, forumInfo.Postbytopictype), DbHelper.MakeInParam("@viewbytopictype", (DbType)SqlDbType.TinyInt, 1, forumInfo.Viewbytopictype), DbHelper.MakeInParam("@topictypeprefix", (DbType)SqlDbType.TinyInt, 1, forumInfo.Topictypeprefix), DbHelper.MakeInParam("@permuserlist", (DbType)SqlDbType.NText, 0, forumInfo.Permuserlist), DbHelper.MakeInParam("@seokeywords", (DbType)SqlDbType.NVarChar, 500, forumInfo.Seokeywords), DbHelper.MakeInParam("@seodescription", (DbType)SqlDbType.NVarChar, 500, forumInfo.Seodescription), DbHelper.MakeInParam("@rewritename", (DbType)SqlDbType.NVarChar, 20, forumInfo.Rewritename), DbHelper.MakeInParam("@fid", (DbType)SqlDbType.Int, 4, forumInfo.Fid) }; commandText = string.Format("UPDATE [{0}forumfields] SET [password]=@password,[icon]=@icon," + "[redirect]=@redirect,[attachextensions]=@attachextensions,[rules]=@rules,[topictypes]=@topictypes," + "[viewperm]=@viewperm,[postperm]=@postperm,[replyperm]=@replyperm,[getattachperm]=@getattachperm,[postattachperm]=@postattachperm," + "[moderators]=@moderators,[description]=@description,[applytopictype]=@applytopictype,[postbytopictype]=@postbytopictype," + "[viewbytopictype]=@viewbytopictype,[topictypeprefix]=@topictypeprefix,[permuserlist]=@permuserlist,[seokeywords]=@seokeywords," + "[seodescription]=@seodescription,[rewritename]=@rewritename WHERE [fid]=@fid", BaseConfigs.GetTablePrefix); DbHelper.ExecuteNonQuery(trans, CommandType.Text, commandText, prams1); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } conn.Close(); }
public int InsertForumsInf(ForumInfo forumInfo) { DbParameter[] parms = { DbHelper.MakeInParam("@parentid", (DbType)SqlDbType.SmallInt, 2, forumInfo.Parentid), DbHelper.MakeInParam("@layer", (DbType)SqlDbType.Int, 4, forumInfo.Layer), DbHelper.MakeInParam("@pathlist", (DbType)SqlDbType.NChar, 3000, Utils.StrIsNullOrEmpty(forumInfo.Pathlist) ? " " : forumInfo.Pathlist), DbHelper.MakeInParam("@parentidlist", (DbType)SqlDbType.NChar, 300, Utils.StrIsNullOrEmpty(forumInfo.Parentidlist) ? " " : forumInfo.Parentidlist), DbHelper.MakeInParam("@subforumcount", (DbType)SqlDbType.Int, 4, forumInfo.Subforumcount), DbHelper.MakeInParam("@name", (DbType)SqlDbType.NChar, 50, forumInfo.Name), DbHelper.MakeInParam("@status", (DbType)SqlDbType.Int, 4, forumInfo.Status), ////DbHelper.MakeInParam("@colcount", (DbType)SqlDbType.SmallInt, 4, forumInfo.Colcount), DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, forumInfo.Displayorder), DbHelper.MakeInParam("@templateid", (DbType)SqlDbType.SmallInt, 2, forumInfo.Templateid), DbHelper.MakeInParam("@allowsmilies", (DbType)SqlDbType.Int, 4, forumInfo.Allowsmilies), DbHelper.MakeInParam("@allowrss", (DbType)SqlDbType.Int, 6, forumInfo.Allowrss), DbHelper.MakeInParam("@allowhtml", (DbType)SqlDbType.Int, 4, forumInfo.Allowhtml), DbHelper.MakeInParam("@allowbbcode", (DbType)SqlDbType.Int, 4, forumInfo.Allowbbcode), DbHelper.MakeInParam("@allowimgcode", (DbType)SqlDbType.Int, 4, forumInfo.Allowimgcode), ////DbHelper.MakeInParam("@allowblog", (DbType)SqlDbType.Int, 4, forumInfo.Allowblog), ////DbHelper.MakeInParam("@istrade", (DbType)SqlDbType.Int, 4, forumInfo.Istrade), DbHelper.MakeInParam("@alloweditrules", (DbType)SqlDbType.Int, 4, forumInfo.Alloweditrules), DbHelper.MakeInParam("@allowthumbnail", (DbType)SqlDbType.Int, 4, forumInfo.Allowthumbnail), DbHelper.MakeInParam("@allowtag",(DbType)SqlDbType.Int,4,forumInfo.Allowtag), DbHelper.MakeInParam("@recyclebin", (DbType)SqlDbType.Int, 4, forumInfo.Recyclebin), DbHelper.MakeInParam("@modnewposts", (DbType)SqlDbType.Int, 4, forumInfo.Modnewposts), DbHelper.MakeInParam("@jammer", (DbType)SqlDbType.Int, 4, forumInfo.Jammer), DbHelper.MakeInParam("@disablewatermark", (DbType)SqlDbType.Int, 4, forumInfo.Disablewatermark), DbHelper.MakeInParam("@inheritedmod", (DbType)SqlDbType.Int, 4, forumInfo.Inheritedmod), DbHelper.MakeInParam("@autoclose", (DbType)SqlDbType.SmallInt, 2, forumInfo.Autoclose), ////DbHelper.MakeInParam("@allowpostspecial",(DbType)SqlDbType.Int,4,forumInfo.Allowpostspecial), ////DbHelper.MakeInParam("@allowspecialonly",(DbType)SqlDbType.Int,4,forumInfo.Allowspecialonly), }; string commandText = string.Format("INSERT INTO [{0}forums] ([parentid],[layer],[pathlist],[parentidlist],[subforumcount],[name]," + "[status],[displayorder],[templateid],[allowsmilies],[allowrss],[allowhtml],[allowbbcode],[allowimgcode]," + "[alloweditrules],[recyclebin],[modnewposts],[jammer],[disablewatermark],[inheritedmod],[autoclose],[allowthumbnail]," + "[allowtag]) VALUES (@parentid,@layer,@pathlist,@parentidlist,@subforumcount,@name,@status, @displayorder," + "@templateid,@allowsmilies,@allowrss,@allowhtml,@allowbbcode,@allowimgcode,@alloweditrules,@recyclebin," + "@modnewposts,@jammer,@disablewatermark,@inheritedmod,@autoclose,@allowthumbnail,@allowtag)", BaseConfigs.GetTablePrefix); DbHelper.ExecuteNonQuery(CommandType.Text, commandText, parms); int fid = GetMaxForumId(); DbParameter[] prams1 = { DbHelper.MakeInParam("@fid", (DbType)SqlDbType.Int, 4, fid), DbHelper.MakeInParam("@description", (DbType)SqlDbType.NText, 0, forumInfo.Description), DbHelper.MakeInParam("@password", (DbType)SqlDbType.VarChar, 16, forumInfo.Password), DbHelper.MakeInParam("@icon", (DbType)SqlDbType.VarChar, 255, forumInfo.Icon), ////DbHelper.MakeInParam("@postcredits", (DbType)SqlDbType.VarChar, 255, forumInfo.Postcredits), ////DbHelper.MakeInParam("@replycredits", (DbType)SqlDbType.VarChar, 255, forumInfo.Replycredits), DbHelper.MakeInParam("@redirect", (DbType)SqlDbType.VarChar, 255, forumInfo.Redirect), DbHelper.MakeInParam("@attachextensions", (DbType)SqlDbType.VarChar, 255, forumInfo.Attachextensions), DbHelper.MakeInParam("@moderators", (DbType)SqlDbType.Text, 0, forumInfo.Moderators), DbHelper.MakeInParam("@rules", (DbType)SqlDbType.NText, 0, forumInfo.Rules), DbHelper.MakeInParam("@topictypes", (DbType)SqlDbType.Text, 0, forumInfo.Topictypes), DbHelper.MakeInParam("@viewperm", (DbType)SqlDbType.Text, 0, forumInfo.Viewperm), DbHelper.MakeInParam("@postperm", (DbType)SqlDbType.Text, 0, forumInfo.Postperm), DbHelper.MakeInParam("@replyperm", (DbType)SqlDbType.Text, 0, forumInfo.Replyperm), DbHelper.MakeInParam("@getattachperm", (DbType)SqlDbType.Text, 0, forumInfo.Getattachperm), DbHelper.MakeInParam("@postattachperm", (DbType)SqlDbType.Text, 0, forumInfo.Postattachperm), DbHelper.MakeInParam("@seokeywords", (DbType)SqlDbType.NVarChar, 500, forumInfo.Seokeywords), DbHelper.MakeInParam("@seodescription", (DbType)SqlDbType.NVarChar, 500, forumInfo.Seodescription), DbHelper.MakeInParam("@rewritename", (DbType)SqlDbType.NVarChar, 20, forumInfo.Rewritename) }; commandText = string.Format("INSERT INTO [{0}forumfields] ([fid],[description],[password],[icon],[redirect]," + "[attachextensions],[moderators],[rules],[topictypes],[viewperm],[postperm],[replyperm],[getattachperm],[postattachperm],[seokeywords],[seodescription],[rewritename]) " + "VALUES (@fid,@description,@password,@icon,@redirect,@attachextensions,@moderators,@rules,@topictypes,@viewperm," + "@postperm,@replyperm,@getattachperm,@postattachperm,@seokeywords,@seodescription,@rewritename)", BaseConfigs.GetTablePrefix); DbHelper.ExecuteDataset(CommandType.Text, commandText, prams1); return fid; }