예제 #1
0
		/// <summary>
		/// Copies the elements of the specified <see cref="TabInfo">TabInfo</see> array to the end of the collection.
		/// </summary>
		/// <param name="value">An array of type <see cref="TabInfo">TabInfo</see> containing the Components to add to the collection.</param>
		public void AddRange(TabInfo[] value) 
		{
			for (int i = 0;	(i < value.Length); i = (i + 1)) 
			{
				this.Add(value[i]);
			}
		}
예제 #2
0
		/// <summary>
		/// 更新指定Tab信息
		/// </summary>
		/// <param name="tabInfo"></param>
		/// <returns></returns>
		public bool UpdateTab(TabInfo tabInfo)
		{
			IDataParameter[] parms =
			{
				DbHelper.MakeInParam("@tabid", (DbType)SqlDbType.Int, 4, tabInfo.TabID),
				DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4, tabInfo.UserID),
				DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, tabInfo.DisplayOrder),
				DbHelper.MakeInParam("@tabname", (DbType)SqlDbType.NVarChar, 50, tabInfo.TabName),
				DbHelper.MakeInParam("@iconfile", (DbType)SqlDbType.VarChar, 50, tabInfo.IconFile),
				DbHelper.MakeInParam("@template", (DbType)SqlDbType.VarChar, 50, tabInfo.Template)
			};

			string sql = string.Format(@"UPDATE [{0}spacetabs] SET [displayorder]=@displayorder, [tabname]=@tabname, [iconfile]=@iconfile, [template] = @template WHERE [tabid]=@tabid AND [uid]=@uid", BaseConfigs.GetTablePrefix);

			return RunExecuteSql(sql, parms);
		}
예제 #3
0
		/// <summary>
		/// 添加Tab信息至数据库
		/// </summary>
		/// <param name="tabInfo"></param>
		/// <returns></returns>
		public bool AddTab(TabInfo tabInfo)
		{
			IDataParameter[] parms =
			{
				DbHelper.MakeInParam("@tabid", (DbType)SqlDbType.Int, 4, tabInfo.TabID),
				DbHelper.MakeInParam("@uid", (DbType)SqlDbType.Int, 4, tabInfo.UserID),
				DbHelper.MakeInParam("@displayorder", (DbType)SqlDbType.Int, 4, tabInfo.DisplayOrder),
				DbHelper.MakeInParam("@tabname", (DbType)SqlDbType.NVarChar, 50, tabInfo.TabName),
				DbHelper.MakeInParam("@iconfile", (DbType)SqlDbType.VarChar, 50, tabInfo.IconFile),
				DbHelper.MakeInParam("@template", (DbType)SqlDbType.VarChar, 50, tabInfo.Template)
			};

			string sql = string.Format(@"INSERT INTO [{0}spacetabs]([tabid], [uid], [displayorder], [tabname], [iconfile], [template]) VALUES(@tabid, @uid, @displayorder, @tabname, @iconfile, @template)", BaseConfigs.GetTablePrefix);

			return RunExecuteSql(sql, parms);
		}
예제 #4
0
		private void PassApply_Click(object sender, EventArgs e)
		{
			if (DNTRequest.GetString("uid") != "")
			{
				string uidlist = DNTRequest.GetString("uid");
				foreach(string uid in uidlist.Split(','))
				{
                    Discuz.Data.DatabaseProvider.GetInstance().UpdateUserSpaceId(Convert.ToInt32(uid));
					//string sql = "UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [spaceid]=ABS([spaceid]) WHERE [uid]=" + uid;
					//sql += ";SELECT [spaceid] FROM [" + BaseConfigs.GetTablePrefix + "users] WHERE [uid]=" + uid;
					//int spceid = (int)AdminDatabase.ExecuteScalar(sql);
                    int tabid = Spaces.GetNewTabId(Convert.ToInt32(uid));
                    TabInfo tab = new TabInfo();
                    tab.TabID = tabid;
                    tab.UserID = Convert.ToInt32(uid);
                    tab.DisplayOrder = 0;
                    tab.TabName = "首页";
                    tab.IconFile = "";
                    tab.Template = "template_25_75.htm";
                    Spaces.AddTab(tab);
                    //sql = "INSERT INTO [" + BaseConfigs.GetTablePrefix + "spacetabs] ([uid],[displayorder], [tabname], [iconfile],[template])  VALUES(" + uid + ",0,'默认','','template_25_75.htm');SELECT SCOPE_IDENTITY()";
                    //int tabid = Utils.StrToInt(AdminDatabase.ExecuteScalar(sql),0);
					Spaces.AddLocalModule("builtin_calendarmodule.xml",int.Parse(uid),tabid,1);
                    Spaces.AddLocalModule("builtin_statisticmodule.xml", int.Parse(uid), tabid, 1);
                    Spaces.AddLocalModule("builtin_postlistmodule.xml", int.Parse(uid), tabid, 2);

                    if (spaceConfig.Spacegreeting != string.Empty)
                    {
                        SpacePostInfo spacepostsinfo = new SpacePostInfo();
                        spacepostsinfo.Title = string.Format("欢迎使用 {0} {1}", config.Forumtitle, config.Spacename);
                        spacepostsinfo.Content = spaceConfig.Spacegreeting;
                        spacepostsinfo.Category = string.Empty;
                        spacepostsinfo.PostStatus = 1;
                        spacepostsinfo.CommentStatus = 0;
                        spacepostsinfo.Postdatetime = DateTime.Now;
                        spacepostsinfo.Author = username;
                        spacepostsinfo.Uid = Utils.StrToInt(uid, -1);
                        spacepostsinfo.PostUpDateTime = DateTime.Now;
                        spacepostsinfo.Commentcount = 0;

                        DbProvider.GetInstance().AddSpacePost(spacepostsinfo);
                    }
                    ///添加最新主题到日志
                    List<TopicInfo> list = Topics.GetTopicsByUserId(userid, 1, config.Topictoblog, 0, 0);
                    foreach (TopicInfo mytopic in list)
                    {
                        int pid = Posts.GetFirstPostId(mytopic.Tid);
                        PostInfo post = Posts.GetPostInfo(mytopic.Tid, pid);
                        if (post != null && post.Message.Trim() != string.Empty)
                        {
                            SpacePostInfo spacepost = new SpacePostInfo();
                            spacepost.Author = username;
                            string content = Posts.GetPostMessageHTML(post, new AttachmentInfo[0]);
                            spacepost.Category = "";
                            spacepost.Content = content;
                            spacepost.Postdatetime = DateTime.Now;
                            spacepost.PostStatus = 1;
                            spacepost.PostUpDateTime = DateTime.Now;
                            spacepost.Title = post.Title;
                            spacepost.Uid = Utils.StrToInt(uid, -1); ;

                            DbProvider.GetInstance().AddSpacePost(spacepost);
                        }
                    }

					//短信通知用户个人空间已经开通
                    PrivateMessageInfo privatemessageinfo = new PrivateMessageInfo();
                    ShortUserInfo userInfo = Users.GetShortUserInfo(Convert.ToInt32(uid));
                    privatemessageinfo.Msgto = userInfo == null ? "" : userInfo.Username;
                    privatemessageinfo.Msgtoid = Convert.ToInt32(uid);
                    privatemessageinfo.Postdatetime = Utils.GetDateTime();
                    privatemessageinfo.Message = "恭喜您,您的" + config.Spacename + "已经被管理员" + username + "开通!";
                    privatemessageinfo.Subject = "恭喜,您的" + config.Spacename + "已经开通";
                    privatemessageinfo.Msgfrom = username;
                    privatemessageinfo.Msgfromid = userid;
                    privatemessageinfo.New = 1;
                    privatemessageinfo.Folder = 0;
                    
                    PrivateMessages.CreatePrivateMessage(privatemessageinfo, 0);
					//AdminDatabase.ExecuteNonQuery("INSERT INTO [" + BaseConfigs.GetTablePrefix + "pms] (msgfrom,msgfromid,msgto,msgtoid,folder,new,subject,postdatetime,message) VALUES ('" + username + "','" + userid + "','" + msgto.Replace("'", "''") + "','" + uid + "','0','1','" + subject + "','" + curdatetime + "','" + message + "')");
					//AdminDatabase.ExecuteNonQuery("UPDATE [" + BaseConfigs.GetTablePrefix + "users] SET [newpmcount]=[newpmcount]+1  WHERE [uid] =" + uid);

				}
                base.RegisterStartupScript( "PAGE", "window.location.href='space_spaceapplymanage.aspx';");
			}
			else
			{
                base.RegisterStartupScript( "", "<script>alert('请选择要开通的空间!');window.location.href='space_spaceapplymanage.aspx';</script>");
			}
		}
예제 #5
0
파일: Spaces.cs 프로젝트: khaliyo/DiscuzNT
        /// <summary>
        /// 添加Tab
        /// </summary>
        /// <param name="tabinfo">Tab对象</param>
		public static void AddTab(TabInfo tabinfo)
		{
			Space.Data.DbProvider.GetInstance().AddTab(tabinfo);
		}
예제 #6
0
파일: Spaces.cs 프로젝트: khaliyo/DiscuzNT
        /// <summary>
        /// 更新Tab
        /// </summary>
        /// <param name="tab">Tab对象</param>
		public static void UpdateTab(TabInfo tab)
		{
			Space.Data.DbProvider.GetInstance().UpdateTab(tab);
		}
예제 #7
0
		private void AddTabAction()
		{
			int tabcount = Spaces.GetTabCountByUserId(this.userid);
			int maxdisplayorder = DNTRequest.GetQueryInt("mo", 0);
			if (tabcount >= 5)
				return;
			TabInfo tabinfo = new TabInfo();
			tabinfo.TabID = Spaces.GetNewTabId(this.userid);
			tabinfo.DisplayOrder = maxdisplayorder;
			tabinfo.TabName = "新建页面";
			tabinfo.Template = "template_33_33_33.htm";
			tabinfo.UserID = this.userid;

			Spaces.AddTab(tabinfo);

			//清除config中的默认页面,交给spacepage去处理
			Spaces.ClearDefaultTab(this.userid);
		}
예제 #8
0
		/// <summary>
		/// Copies the collection Components to a one-dimensional <see cref="T:System.Array">Array</see> instance beginning at the specified index.
		/// </summary>
		/// <param name="array">The one-dimensional <see cref="T:System.Array">Array</see> that is the destination of the values copied from the collection.</param>
		/// <param name="index">The index of the array at which to begin inserting.</param>
		public void CopyTo(TabInfo[] array, int index) 
		{
			this.List.CopyTo(array, index);
		}
예제 #9
0
		/// <summary>
		/// Gets a value indicating whether the collection contains the specified <see cref="TabInfoCollection">TabInfoCollection</see>.
		/// </summary>
		/// <param name="value">The <see cref="TabInfoCollection">TabInfoCollection</see> to search for in the collection.</param>
		/// <returns><b>true</b> if the collection contains the specified object; otherwise, <b>false</b>.</returns>
		public bool Contains(TabInfo value) 
		{
			return this.List.Contains(value);
		}
예제 #10
0
		/// <summary>
		/// Initializes a new instance of the <see cref="TabInfoCollection">TabInfoCollection</see> class containing the specified array of <see cref="TabInfo">TabInfo</see> Components.
		/// </summary>
		/// <param name="value">An array of <see cref="TabInfo">TabInfo</see> Components with which to initialize the collection. </param>
		public TabInfoCollection(TabInfo[] value)
		{
			this.AddRange(value);
		}
예제 #11
0
		public int Add(TabInfo value) 
		{
			return this.List.Add(value);
		}
예제 #12
0
		public void Remove(TabInfo value) 
		{
			List.Remove(value);
		}
예제 #13
0
		public void Insert(int index, TabInfo value)	
		{
			List.Insert(index, value);
		}
예제 #14
0
		/// <summary>
		/// Gets the index in the collection of the specified <see cref="TabInfoCollection">TabInfoCollection</see>, if it exists in the collection.
		/// </summary>
		/// <param name="value">The <see cref="TabInfoCollection">TabInfoCollection</see> to locate in the collection.</param>
		/// <returns>The index in the collection of the specified object, if found; otherwise, -1.</returns>
		public int IndexOf(TabInfo value) 
		{
			return this.List.IndexOf(value);
		}
예제 #15
0
		private static TabInfo GetTabEntity(IDataReader reader)
		{
			TabInfo tab = new TabInfo();
			tab.TabID = TypeConverter.ObjectToInt(reader["tabid"]);
			tab.UserID = TypeConverter.ObjectToInt(reader["uid"]);
			tab.DisplayOrder = TypeConverter.ObjectToInt(reader["displayorder"]);
			tab.TabName = reader["tabname"].ToString();
			tab.IconFile = reader["iconfile"].ToString();
			tab.Template = reader["template"].ToString();
			return tab;
		}
예제 #16
0
        protected override void ShowPage()
        {
            pagetitle = string.Format("激活{0}", config.Spacename);

            if (userid == -1)
            {
                AddErrLine("你尚未登录");
                return;
            }

            UserInfo user = Users.GetUserInfo(userid);

            if (config.Enablespace != 1)
            {
                AddErrLine(string.Format("{0}功能已被关闭", config.Spacename));
                return;
            }

            bool isactivespace = false;
            bool isallowapply = true;
            if (user.Spaceid > 0)
                isactivespace = true;
            else
            {
                if (user.Spaceid < 0)
                    isallowapply = false;
                else
                {
                    if (spaceactiveconfig.AllowPostcount == "1" || spaceactiveconfig.AllowDigestcount == "1" ||
                        spaceactiveconfig.AllowScore == "1" || spaceactiveconfig.AllowUsergroups == "1")
                    {
                        if (spaceactiveconfig.AllowPostcount == "1")
                            isallowapply = isallowapply && (Convert.ToInt32(spaceactiveconfig.Postcount) <= user.Posts);
                        if (spaceactiveconfig.AllowDigestcount == "1")
                            isallowapply = isallowapply &&
                                           (Convert.ToInt32(spaceactiveconfig.Digestcount) <= user.Digestposts);
                        if (spaceactiveconfig.AllowScore == "1")
                            isallowapply = isallowapply && (Convert.ToInt32(spaceactiveconfig.Score) <= user.Credits);
                        if (spaceactiveconfig.AllowUsergroups == "1")
                            isallowapply = isallowapply &&
                                           (("," + spaceactiveconfig.Usergroups + ",").IndexOf("," + user.Groupid + ",") !=
                                            -1);
                    }
                    else
                        isallowapply = false;
                }
            }

            if (isactivespace)
            {
                AddErrLine("您已经申请过个人空间!");
                return;
            }
            if (!isallowapply)
            {
                AddErrLine("您未被允许申请个人空间!");
                return;
            }

            if (DNTRequest.IsPost())
            {
                if (ForumUtils.IsCrossSitePost())
                {
                    AddErrLine("您的请求来路不正确,无法提交。如果您安装了某种默认屏蔽来路信息的个人防火墙软件(如 Norton Internet Security),请设置其不要禁止来路信息后再试。");
                    return;
                }
                if (DNTRequest.GetString("spacetitle").Length > 100)
                {
                    AddErrLine("个人空间标题不得超过100个字符");
                    return;
                }
                if (DNTRequest.GetString("description").Length > 200)
                {
                    AddErrLine("个人空间描述不得超过200个字符");
                    return;
                }
                if (DNTRequest.GetInt("bpp", 0) == 0)
                {
                    AddErrLine("显示日志篇数必需是一个大于0的数字");
                    return;
                }

                if (page_err == 0)
                {
                    DataRow dr = DbProvider.GetInstance().GetThemes();
                    spaceconfiginfo = new SpaceConfigInfo();
                    spaceconfiginfo.UserID = userid;
                    spaceconfiginfo.Spacetitle = DNTRequest.GetHtmlEncodeString("spacetitle");
                    spaceconfiginfo.Description = DNTRequest.GetHtmlEncodeString("description");
                    spaceconfiginfo.BlogDispMode = DNTRequest.GetInt("blogdispmode", 0);
                    spaceconfiginfo.Bpp = DNTRequest.GetInt("bpp", 0);
                    spaceconfiginfo.Commentpref = DNTRequest.GetInt("commentpref", 0);
                    spaceconfiginfo.MessagePref = DNTRequest.GetInt("messagepref", 0);
                    spaceconfiginfo.UpdateDateTime = spaceconfiginfo.CreateDateTime = DateTime.Now;
                    string rewritename = DNTRequest.GetFormString("rewritename").Trim();
                    if (rewritename != string.Empty)
                    {
                        if (Globals.CheckSpaceRewriteNameAvailable(rewritename) == 0)
                            spaceconfiginfo.Rewritename = rewritename;
                        else
                        {
                            AddErrLine("您输入的 个性域名 不可用或含有非法字符");
                            return;
                        }
                    }
                    else
                        spaceconfiginfo.Rewritename = "";

                    spaceconfiginfo.ThemeID = int.Parse(dr["themeid"].ToString());
                    spaceconfiginfo.ThemePath = dr["directory"].ToString();
                    spaceconfiginfo.PostCount = 0;
                    spaceconfiginfo.CommentCount = 0;
                    spaceconfiginfo.VisitedTimes = 0;
                    spaceconfiginfo.DefaultTab = 0;

                    string errorinfo = "";
                    int blogid = DbProvider.GetInstance().AddSpaceConfigData(spaceconfiginfo);
                    Users.UpdateUserSpaceId(-blogid, userid);

                    SpaceActiveConfigInfo _spaceconfiginfo = SpaceActiveConfigs.GetConfig();
                    if (_spaceconfiginfo.ActiveType == "0")
                    {
                        if (errorinfo == "")
                        {
                            SetUrl("index.aspx");
                            SetMetaRefresh();
                            SetShowBackLink(true);
                            AddMsgLine("您的申请已经提交,请等待管理员开通您的个人空间");
                        }
                        else
                        {
                            AddErrLine(errorinfo);
                            return;
                        }
                    }
                    else
                    {
                        Discuz.Data.DatabaseProvider.GetInstance().UpdateUserSpaceId(userid);
                        int tabid = Spaces.GetNewTabId(userid);
                        TabInfo tab = new TabInfo();
                        tab.TabID = tabid;
                        tab.UserID = userid;
                        tab.DisplayOrder = 0;
                        tab.TabName = "首页";
                        tab.IconFile = "";
                        tab.Template = "template_25_75.htm";
                        Spaces.AddTab(tab);
                        Spaces.AddLocalModule("builtin_calendarmodule.xml", userid, tabid, 1);
                        Spaces.AddLocalModule("builtin_statisticmodule.xml", userid, tabid, 1);
                        Spaces.AddLocalModule("builtin_postlistmodule.xml", userid, tabid, 2);
                        if (SpaceActiveConfigs.GetConfig().Spacegreeting != string.Empty)
                        {
                            SpacePostInfo spacepostsinfo = new SpacePostInfo();
                            spacepostsinfo.Title = string.Format("欢迎使用 {0} 个人空间", config.Forumtitle);
                            spacepostsinfo.Content = SpaceActiveConfigs.GetConfig().Spacegreeting;
                            spacepostsinfo.Category = string.Empty;
                            spacepostsinfo.PostStatus = 1;
                            spacepostsinfo.CommentStatus = 0;
                            spacepostsinfo.Postdatetime = DateTime.Now;
                            spacepostsinfo.Author = username;
                            spacepostsinfo.Uid = userid;
                            spacepostsinfo.PostUpDateTime = DateTime.Now;
                            spacepostsinfo.Commentcount = 0;
                            DbProvider.GetInstance().AddSpacePost(spacepostsinfo);
                        }
                        
                        ///添加最新主题到日志
                        List<TopicInfo> list = Topics.GetTopicsByUserId(userid, 1, config.Topictoblog, 0, 0);
                        foreach (TopicInfo mytopic in list)
                        {
                            int pid = Posts.GetFirstPostId(mytopic.Tid);
                            PostInfo post = Posts.GetPostInfo(mytopic.Tid, pid);
                            if (post != null && post.Message.Trim() != string.Empty)
                            {
                                SpacePostInfo spacepost = new SpacePostInfo();
                                spacepost.Author = username;
                                string content = Posts.GetPostMessageHTML(post, new AttachmentInfo[0]);
                                spacepost.Category = "";
                                spacepost.Content = content;
                                spacepost.Postdatetime = DateTime.Now;
                                spacepost.PostStatus = 1;
                                spacepost.PostUpDateTime = DateTime.Now;
                                spacepost.Title = post.Title;
                                spacepost.Uid = userid;
                                DbProvider.GetInstance().AddSpacePost(spacepost);
                            }
                        }
						SetUrl("space/");
						SetMetaRefresh();
						SetShowBackLink(true);
						AddMsgLine("恭喜您,您的个人空间已经被开通");
					}
				}
			}
			else
				spaceconfiginfo = BlogProvider.GetSpaceConfigInfo(userid);
		}