Exemple #1
0
		public bool BatchSetForumInf(ForumInfo foruminfo, BatchSetParams bsp, string fidlist)
		{
			StringBuilder forums = new StringBuilder();
			StringBuilder forumfields = new StringBuilder();

			forums.Append("UPDATE [" + BaseConfigs.GetTablePrefix + "forums] SET ");
			if (bsp.SetSetting)
			{
				forums.Append("[Allowsmilies]='" + foruminfo.Allowsmilies + "' ,");
				forums.Append("[Allowrss]='" + foruminfo.Allowrss + "' ,");
				forums.Append("[Allowhtml]='" + foruminfo.Allowhtml + "' ,");
				forums.Append("[Allowbbcode]='" + foruminfo.Allowbbcode + "' ,");
				forums.Append("[Allowimgcode]='" + foruminfo.Allowimgcode + "' ,");
				forums.Append("[Allowblog]='" + foruminfo.Allowblog + "' ,");
				forums.Append("[Allowtrade]='" + foruminfo.Allowtrade + "' ,");
				forums.Append("[Alloweditrules]='" + foruminfo.Alloweditrules + "' ,");
				forums.Append("[allowthumbnail]='" + foruminfo.Allowthumbnail + "' ,");
				forums.Append("[Recyclebin]='" + foruminfo.Recyclebin + "' ,");
				forums.Append("[Modnewposts]='" + foruminfo.Modnewposts + "' ,");
				forums.Append("[Jammer]='" + foruminfo.Jammer + "' ,");
				forums.Append("[Disablewatermark]='" + foruminfo.Disablewatermark + "' ,");
				forums.Append("[Inheritedmod]='" + foruminfo.Inheritedmod + "' ,");
			}
			if (forums.ToString().EndsWith(","))
			{
				forums.Remove(forums.Length - 1, 1);
			}
			forums.Append("WHERE [fid] IN(" + fidlist + ")");


			forumfields.Append("UPDATE [" + BaseConfigs.GetTablePrefix + "forumfields] SET ");

			if (bsp.SetPassWord)
			{
				forumfields.Append("[password]='" + foruminfo.Password + "' ,");
			}

			if (bsp.SetAttachExtensions)
			{
				forumfields.Append("[attachextensions]='" + foruminfo.Attachextensions + "' ,");
			}

			if (bsp.SetPostCredits)
			{
				forumfields.Append("[postcredits]='" + foruminfo.Postcredits + "' ,");
			}

			if (bsp.SetReplyCredits)
			{
				forumfields.Append("[replycredits]='" + foruminfo.Replycredits + "' ,");
			}


			if (bsp.SetViewperm)
			{
				forumfields.Append("[Viewperm]='" + foruminfo.Viewperm + "' ,");
			}

			if (bsp.SetPostperm)
			{
				forumfields.Append("[Postperm]='" + foruminfo.Postperm + "' ,");
			}

			if (bsp.SetReplyperm)
			{
				forumfields.Append("[Replyperm]='" + foruminfo.Replyperm + "' ,");
			}

			if (bsp.SetGetattachperm)
			{
				forumfields.Append("[Getattachperm]='" + foruminfo.Getattachperm + "' ,");
			}

			if (bsp.SetPostattachperm)
			{
				forumfields.Append("[Postattachperm]='" + foruminfo.Postattachperm + "' ,");
			}

			if (forumfields.ToString().EndsWith(","))
			{
				forumfields.Remove(forumfields.Length - 1, 1);
			}

			forumfields.Append("WHERE [fid] IN(" + fidlist + ")");


			SqlConnection conn = new SqlConnection(DbHelper.ConnectionString);
			conn.Open();
			using (SqlTransaction trans = conn.BeginTransaction())
			{
				try
				{
					if (forums.ToString().IndexOf("SET WHERE") < 0)
					{
						DbHelper.ExecuteNonQuery(trans, CommandType.Text, forums.ToString());
					}

					if (forumfields.ToString().IndexOf("SET WHERE") < 0)
					{
						DbHelper.ExecuteNonQuery(trans, CommandType.Text, forumfields.ToString());
					}
					trans.Commit();
				}
				catch
				{
					trans.Rollback();
					return false;
				}
			}
			return true;
		}
        private void SubmitBatchSet_Click(object sender, EventArgs e)
        {
            #region 写入批量论坛设置信息

            string targetlist = DNTRequest.GetString("Forumtree1");

            if ((targetlist == "") || (targetlist == ",") || (targetlist == "0"))
            {
                base.RegisterStartupScript( "", "<script>alert('您未选中任何版块, 系统无法提交! ');</script>");
                return;
            }

            __foruminfo = AdminForums.GetForumInfomation(DNTRequest.GetInt("fid", -1));
            __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.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.Password = password.Text;
            __foruminfo.Attachextensions = attachextensions.GetSelectString(",");
            __foruminfo.Viewperm = viewperm.GetSelectString(",");
            __foruminfo.Postperm = postperm.GetSelectString(",");
            __foruminfo.Replyperm = replyperm.GetSelectString(",");
            __foruminfo.Getattachperm = getattachperm.GetSelectString(",");
            __foruminfo.Postattachperm = postattachperm.GetSelectString(",");

            BatchSetParams bsp = new BatchSetParams();
            bsp.SetPassWord = setpassword.Checked;
            bsp.SetAttachExtensions = setattachextensions.Checked;
            bsp.SetPostCredits = setpostcredits.Checked;
            bsp.SetReplyCredits = setreplycredits.Checked;
            bsp.SetSetting = setsetting.Checked;
            bsp.SetViewperm = setviewperm.Checked;
            bsp.SetPostperm = setpostperm.Checked;
            bsp.SetReplyperm = setreplyperm.Checked;
            bsp.SetGetattachperm = setgetattachperm.Checked;
            bsp.SetPostattachperm = setpostattachperm.Checked;

            if (AdminForums.BatchSetForumInf(__foruminfo, bsp, targetlist))
            {
                base.RegisterStartupScript( "PAGE", "window.location.href='forum_ForumsTree.aspx';");
            }
            else
            {
                base.RegisterStartupScript( "", "<script>alert('提交不成功!');window.location.href='forum_ForumsTree.aspx';</script>");
            }

            #endregion
        }
 /// <summary>
 /// 批理设置论坛信息
 /// </summary>
 /// <param name="__foruminfo">复制的论坛信息</param>
 /// <param name="bsp">是否要批量设置的信息字段</param>
 /// <param name="fidlist">目标论坛(fid)串</param>
 /// <returns></returns>
 public static bool BatchSetForumInf(ForumInfo forumInfo, BatchSetParams bsp, string fidlist)
 {
     return Discuz.Data.Forums.BatchSetForumInf(forumInfo, bsp, fidlist);
 }
Exemple #4
0
 /// <summary>
 /// 批理设置论坛信息
 /// </summary>
 /// <param name="__foruminfo">复制的论坛信息</param>
 /// <param name="bsp">是否要批量设置的信息字段</param>
 /// <param name="fidlist">目标论坛(fid)串</param>
 /// <returns></returns>
 public static bool BatchSetForumInf(ForumInfo __foruminfo, BatchSetParams bsp, string fidlist)
 {
     return DatabaseProvider.GetInstance().BatchSetForumInf(__foruminfo, bsp, fidlist);
 }
        private void SubmitBatchSet_Click(object sender, EventArgs e)
        {
            #region 写入批量论坛设置信息

            string targetlist = DNTRequest.GetString("Forumtree1");

            if ((targetlist == "") || (targetlist == ",") || (targetlist == "0"))
            {
                base.RegisterStartupScript( "", "<script>alert('您未选中任何版块, 系统无法提交! ');</script>");
                return;
            }

            forumInfo = Forums.GetForumInfo(DNTRequest.GetInt("fid", -1));
            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.Password = password.Text;
            forumInfo.Attachextensions = attachextensions.GetSelectString(",");
            forumInfo.Viewperm = viewperm.GetSelectString(",");
            forumInfo.Postperm = postperm.GetSelectString(",");
            forumInfo.Replyperm = replyperm.GetSelectString(",");
            forumInfo.Getattachperm = getattachperm.GetSelectString(",");
            forumInfo.Postattachperm = postattachperm.GetSelectString(",");

            BatchSetParams bsp = new BatchSetParams();
            bsp.SetPassWord = setpassword.Checked;
            bsp.SetAttachExtensions = setattachextensions.Checked;
            bsp.SetPostCredits = setpostcredits.Checked;
            bsp.SetReplyCredits = setreplycredits.Checked;
            bsp.SetSetting = setsetting.Checked;
            bsp.SetViewperm = setviewperm.Checked;
            bsp.SetPostperm = setpostperm.Checked;
            bsp.SetReplyperm = setreplyperm.Checked;
            bsp.SetGetattachperm = setgetattachperm.Checked;
            bsp.SetPostattachperm = setpostattachperm.Checked;

            if (AdminForums.BatchSetForumInf(forumInfo, bsp, targetlist))
            {
                ForumOperator.RefreshForumCache();
                AdminVistLogs.InsertLog(this.userid, this.username, this.usergroupid, this.grouptitle, this.ip, "复制版块设置", "编辑论坛版块列表为:" + targetlist.Trim());
                base.RegisterStartupScript( "PAGE", "window.location.href='forum_ForumsTree.aspx';");
            }
            else
            {
                base.RegisterStartupScript( "", "<script>alert('提交不成功!');window.location.href='forum_ForumsTree.aspx';</script>");
            }

            #endregion
        }
Exemple #6
0
        public bool BatchSetForumInf(ForumInfo forumInfo, BatchSetParams bsp, string fidList)
        {
            StringBuilder forums = new StringBuilder();
            StringBuilder forumfields = new StringBuilder();

            forums.AppendFormat("UPDATE [{0}forums] SET ", BaseConfigs.GetTablePrefix);
            if (bsp.SetSetting)
            {
                forums.AppendFormat("[Allowsmilies]='{0}' ,", forumInfo.Allowsmilies);
                forums.AppendFormat("[Allowrss]='{0}' ,", forumInfo.Allowrss);
                forums.AppendFormat("[Allowhtml]='{0}' ,", forumInfo.Allowhtml);
                forums.AppendFormat("[Allowbbcode]='{0}' ,", forumInfo.Allowbbcode);
                forums.AppendFormat("[Allowimgcode]='{0}' ,", forumInfo.Allowimgcode);
                forums.AppendFormat("[Allowblog]='{0}' ,", forumInfo.Allowblog);
                forums.AppendFormat("[istrade]='{0}' ,", forumInfo.Istrade);
                forums.AppendFormat("[allowpostspecial]='{0}' ,", forumInfo.Allowpostspecial);
                forums.AppendFormat("[allowspecialonly]='{0}' ,", forumInfo.Allowspecialonly);
                forums.AppendFormat("[Alloweditrules]='{0}' ,", forumInfo.Alloweditrules);
                forums.AppendFormat("[allowthumbnail]='{0}' ,", forumInfo.Allowthumbnail);
                forums.AppendFormat("[Recyclebin]='{0}' ,", forumInfo.Recyclebin);
                forums.AppendFormat("[Modnewposts]='{0}' ,", forumInfo.Modnewposts);
                forums.AppendFormat("[Modnewtopics]='{0}' ,", forumInfo.Modnewtopics);
                forums.AppendFormat("[Jammer]='{0}' ,", forumInfo.Jammer);
                forums.AppendFormat("[Disablewatermark]='{0}' ,", forumInfo.Disablewatermark);
                forums.AppendFormat("[Inheritedmod]='{0}' ,", forumInfo.Inheritedmod);
                forums.AppendFormat("[allowtag]='{0}' ,", forumInfo.Allowtag);
            }
            if (forums.ToString().EndsWith(","))
                forums.Remove(forums.Length - 1, 1);

            forums.AppendFormat("WHERE [fid] IN ({0})", fidList);

            forumfields.AppendFormat("UPDATE [{0}forumfields] SET ", BaseConfigs.GetTablePrefix);
            if (bsp.SetPassWord)
                forumfields.AppendFormat("[password]='{0}' ,", forumInfo.Password);

            if (bsp.SetAttachExtensions)
                forumfields.AppendFormat("[attachextensions]='{0}' ,", forumInfo.Attachextensions);

            if (bsp.SetPostCredits)
                forumfields.AppendFormat("[postcredits]='{0}' ,", forumInfo.Postcredits);

            if (bsp.SetReplyCredits)
                forumfields.AppendFormat("[replycredits]='{0}' ,", forumInfo.Replycredits);

            if (bsp.SetViewperm)
                forumfields.AppendFormat("[Viewperm]='{0}' ,", forumInfo.Viewperm);

            if (bsp.SetPostperm)
                forumfields.AppendFormat("[Postperm]='{0}' ,", forumInfo.Postperm);

            if (bsp.SetReplyperm)
                forumfields.AppendFormat("[Replyperm]='{0}' ,", forumInfo.Replyperm);

            if (bsp.SetGetattachperm)
                forumfields.AppendFormat("[Getattachperm]='{0}' ,", forumInfo.Getattachperm);

            if (bsp.SetPostattachperm)
                forumfields.AppendFormat("[Postattachperm]='{0}' ,", forumInfo.Postattachperm);

            if (forumfields.ToString().EndsWith(","))
                forumfields.Remove(forumfields.Length - 1, 1);

            forumfields.AppendFormat("WHERE [fid] IN ({0})", fidList);

            SqlConnection conn = new SqlConnection(DbHelper.ConnectionString);
            conn.Open();
            using (SqlTransaction trans = conn.BeginTransaction())
            {
                try
                {
                    if (forums.ToString().IndexOf("SET WHERE") < 0)
                        DbHelper.ExecuteNonQuery(trans, CommandType.Text, forums.ToString());

                    if (forumfields.ToString().IndexOf("SET WHERE") < 0)
                        DbHelper.ExecuteNonQuery(trans, CommandType.Text, forumfields.ToString());

                    trans.Commit();
                }
                catch
                {
                    trans.Rollback();
                    return false;
                }
            }
            return true;
        }