protected string GetThreadSubject(BasicThread thread, int subjectLength) { string subject; if (thread.ThreadType == ThreadType.Move || thread.ThreadType == ThreadType.Join) { int index = thread.SubjectText.IndexOf(","); if (index > 0) { string threadIDStr = thread.SubjectText.Substring(0, index); int id; if (int.TryParse(threadIDStr, out id)) { subject = thread.SubjectText.Substring(index + 1); } else { subject = thread.SubjectText; } } else { subject = thread.SubjectText; } } else { subject = thread.SubjectText; } //subject = subject.Replace("'", "‘").Replace("\\", "\"); subject = StringUtil.CutString(subject, subjectLength); return(subject); }
protected bool IsShowCheckBox(BasicThread thread) { if (ForumID == thread.ForumID && (//Forum.IsModerator(MyUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsRecycled, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.MoveThreads, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsLock, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.Action.SetThreadsSubjectStyle) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsStick, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsGlobalStick, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.Action.SetThreadsUp) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadNotUpdateSortOrder, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsValued, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.UpdateThreadCatalog, thread.PostUserID) || ForumManagePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.JudgementThreads, thread.PostUserID)) ) { return(true); } else { return(false); } }
protected void Page_Load(object sender, EventArgs e) { int threadID = _Request.Get <int>("threadID", Method.Get, 0); if (threadID < 1) { ShowError(new InvalidParamError("threadID").Message); } thread = PostBOV5.Instance.GetThread(threadID); if (thread == null) { ShowError("该主题不存在或者已被删除!"); } ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID); if (thread.PostUserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents))) { if (!thread.IsBuyed(My)) { ShowError("您还没有购买此主题,不能查看购买记录!"); } } TradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID); int pageNumber = _Request.Get <int>("page", Method.Get, 1); ExchangeList = PostBOV5.Instance.GetThreadExchanges(threadID, pageNumber, pageSize, out totalCount, out totalMoney); WaitForFillSimpleUsers <ThreadExchange>(ExchangeList); SetPager("list", null, pageNumber, pageSize, totalCount); }
public override PropResult Apply(HttpRequest request, int threadID, string param) { List <int> forumIDs = StringUtil.Split2 <int>(param, ','); BasicThread thread = PostBOV5.Instance.GetThread(threadID); if (thread == null) { return(Error("指定主题不存在")); } else if (thread.PostUserID != User.Current.UserID) { return(Error("本道具只能用于您本人发表的主题")); } else if (forumIDs.Contains(-1) == false && forumIDs.Contains(thread.ForumID) == false) { return(Error("目标主题所属版块不在本道具有效范围中")); } if (PostBOV5.Instance.SetThreadsUp(User.Current, thread.ForumID, new int[] { threadID }, true, true, false, string.Empty) == false) { return(Error("发生了未知的错误,请联系管理员")); } PropResult result = Succeed(); result.LogForUser = string.Format("您用道具对主题《{0}》进行了提升", thread.SubjectText); return(result); }
protected string GetThreadSubject(BasicThread thread, int subjectLength) { string subject; if (thread.ThreadType == ThreadType.Move || thread.ThreadType == ThreadType.Join) { int index = thread.SubjectText.IndexOf(","); if (index > 0) { string threadIDStr = thread.SubjectText.Substring(0, index); int id; if (int.TryParse(threadIDStr, out id)) { subject = thread.SubjectText.Substring(index + 1); } else subject = thread.SubjectText; } else subject = thread.SubjectText; } else subject = thread.SubjectText; //subject = subject.Replace("'", "‘").Replace("\\", "\"); subject = StringUtil.CutString(subject, subjectLength); return subject; }
protected string GetThreadUrl(BasicThread thread, bool isLastPage) { if (isLastPage) return BbsUrlHelper.GetThreadUrl(thread.Forum.CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, PageNumber); else return BbsUrlHelper.GetThreadUrl(thread.Forum.CodeName, thread.RedirectThreadID, thread.ThreadTypeString, 1, PageNumber); }
protected void Page_Load(object sender, EventArgs e) { int threadID = _Request.Get<int>("threadID", Method.Get, 0); if (threadID < 1) ShowError(new InvalidParamError("threadID").Message); thread = PostBOV5.Instance.GetThread(threadID); if (thread == null) ShowError("该主题不存在或者已被删除!"); ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID); if (thread.PostUserID != MyUserID && (!permission.Can(My, ForumPermissionSetNode.Action.AlwaysViewContents))) { if (!thread.IsBuyed(My)) { ShowError("您还没有购买此主题,不能查看购买记录!"); } } TradePoint = ForumPointAction.Instance.GetUserPoint(thread.PostUserID, ForumPointValueType.SellThread, thread.ForumID); int pageNumber = _Request.Get<int>("page",Method.Get,1); ExchangeList = PostBOV5.Instance.GetThreadExchanges(threadID, pageNumber, pageSize, out totalCount, out totalMoney); WaitForFillSimpleUsers<ThreadExchange>(ExchangeList); SetPager("list", null, pageNumber, pageSize, totalCount); }
protected bool CanViewValuedThread(PostV5 post) { if (post.PostType != PostType.ThreadContent) { return(true); } bool can; if (canViewValueThreads.TryGetValue(post.ForumID, out can) == false) { BasicThread thread = searchThreads.GetValue(post.ThreadID); if (thread.IsValued == false) { can = true; } else { can = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID).Can(My, ForumPermissionSetNode.Action.ViewValuedThread); } canViewValueThreads.Add(post.ForumID, can); } return(can); }
/* * private static BasicThread GetThreadFromCache(int threadID) * { * string cacheKey = string.Format(CacheKey_Thread, threadID); * return CacheUtil.Get<BasicThread>(cacheKey); * } * * private static void RemoveThreadCache(int threadID) * { * string cacheKey = string.Format(CacheKey_Thread, threadID); * CacheUtil.Remove(cacheKey); * } * */ /// <summary> /// 更新缓存的主题olThread 为newThread ,只更新BasicThreadV5中的属性,没有更新子类的属性 不更新点击数 /// </summary> /// <param name="olThread"></param> /// <param name="newThread"></param> public static void UpdateThreadCache(BasicThread olThread, BasicThread newThread) { int totalView = olThread.TotalViews; olThread.CopyFrom(newThread); olThread.TotalViews = totalView; }
private static void UpdateAllCachedThreadsRemoveThread(BasicThread thread, int?forumID, ThreadOrderType?excludeOrderType, string excludeCacheKey) { ThreadCollectionV5 threads = new ThreadCollectionV5(); threads.Add(thread); UpdateAllCachedThreadsRemoveThreads(threads, forumID, excludeOrderType, excludeCacheKey); }
protected bool IsOverSellThreadDays(BasicThread thread) { if (SellThreadDays == 0) { return(false); } return(thread.CreateDate.AddSeconds(SellThreadDays) <= DateTimeUtil.Now); }
protected bool CanDeleteTopic(BasicThread thread) { if (thread == null) { return(true); } return(AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(thread.ForumID).Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads, thread.PostUserID)); }
private static void UpdateAllCachedThreadsAddThreads(BasicThread thread) { ThreadCollectionV5 threads = new ThreadCollectionV5(); threads.Add(thread); UpdateAllCachedThreadsAddThreads(threads); }
protected string GetThreadUrl(BasicThread thread, bool isLastPage) { if (ThreadCatalogID == -1) { if (IsNormalThreads) { if (IsDefaultList) { if (isLastPage) { return(BbsUrlHelper.GetThreadUrl(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, PageNumber)); } else { return(BbsUrlHelper.GetThreadUrl(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, 1, PageNumber)); } } else { if (isLastPage) { return(BbsUrlHelper.GetThreadUrlForExtParms(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, "Action=" + Action + "&page=" + PageNumber)); } else { return(BbsUrlHelper.GetThreadUrlForExtParms(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, 1, "Action=" + Action + "&page=" + PageNumber)); } } } else { if (string.Compare(Action, "recycled", true) == 0) { return(BbsUrlHelper.GetThreadUrl(CodeName, thread.RedirectThreadID, thread.TotalPages, thread.ThreadTypeString, "recyclebin")); } else if (string.Compare(Action, "unapproved", true) == 0) { return(BbsUrlHelper.GetThreadUrl(CodeName, thread.RedirectThreadID, thread.TotalPages, thread.ThreadTypeString, "unapprovethreads")); } else { return(BbsUrlHelper.GetThreadUrl(CodeName, thread.RedirectThreadID, thread.TotalPages, thread.ThreadTypeString, "unapproveposts")); } } } else { if (isLastPage) { return(BbsUrlHelper.GetThreadUrlForExtParms(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, "ThreadCatalogID=" + ThreadCatalogID + "&page=" + PageNumber)); } else { return(BbsUrlHelper.GetThreadUrlForExtParms(CodeName, thread.RedirectThreadID, thread.ThreadTypeString, 1, "ThreadCatalogID=" + ThreadCatalogID + "&page=" + PageNumber)); } } }
protected string GetArchiverThreadLink(BasicThread thread, string linkStyle) { if (string.IsNullOrEmpty(linkStyle)) { linkStyle = "<a href=\"{0}\">{1}</a>"; } Forum forum = null; string subject = null; if (thread.ThreadType == ThreadType.Move || thread.ThreadType == ThreadType.Join) { int index = thread.SubjectText.IndexOf(','); if (index > 0) { string threadIDStr = thread.SubjectText.Substring(0, index); subject = thread.SubjectText.Substring(index + 1); } BasicThread redirectThread = PostBOV5.Instance.GetThread(thread.RedirectThreadID); if (redirectThread != null) { forum = ForumBO.Instance.GetForum(redirectThread.ForumID); } if (forum == null) { forum = ForumBO.Instance.GetForum(thread.ForumID); } } else { forum = ForumBO.Instance.GetForum(thread.ForumID); } string url = BbsUrlHelper.GetArchiverThreadUrl(forum.CodeName, thread.RedirectThreadID); if (subject == null) { subject = thread.SubjectText; } if (thread.ThreadType == ThreadType.Move) { return("已移动:" + string.Format(linkStyle, url, subject)); } else if (thread.ThreadType == ThreadType.Join) { return("已合并:" + string.Format(linkStyle, url, subject)); } else { return(string.Format(linkStyle, url, subject)); } }
public override PropResult Apply(HttpRequest request, int threadID, string param) { StringList paramList = StringList.Parse(param); int timeLimit = int.Parse(paramList[0]); ThreadStatus stickType = StringUtil.TryParse <ThreadStatus>(paramList[1]); List <int> forumIDs = StringUtil.Split2 <int>(paramList[2], ','); string unit = paramList[3]; BasicThread thread = PostBOV5.Instance.GetThread(threadID); if (thread == null) { return(Error("指定主题不存在")); } else if (thread.PostUserID != User.Current.UserID) { return(Error("本道具只能用于您本人发表的主题")); } else if (forumIDs.Contains(-1) == false && forumIDs.Contains(thread.ForumID) == false) { return(Error("目标主题所属版块不在本道具有效范围中")); } DateTime endDate = DateTimeUtil.Now; if (unit == "d") { endDate = endDate.AddDays(timeLimit); } else if (unit == "h") { endDate = endDate.AddHours(timeLimit); } else { endDate = endDate.AddMinutes(timeLimit); } PostBOV5.Instance.SetThreadsStickyStatus(User.Current, thread.ForumID, null, new int[] { threadID }, stickType, endDate, true, true, false, string.Empty); PropResult result = Succeed(); if (stickType == ThreadStatus.GlobalSticky) { result.LogForUser = string.Format("您用道具对主题《{0}》进行{1}小时的全局置顶", thread.Subject, timeLimit); } else { result.LogForUser = string.Format("您用道具对主题《{0}》进行{1}小时的版块置顶", thread.Subject, timeLimit); } return(result); }
protected bool IsNewThread(BasicThread thread) { if ((DateTimeUtil.Now - thread.CreateDate).TotalSeconds < AllSettings.Current.BbsSettings.NewThreadTime) { return(true); } else { return(false); } }
protected string GetThreadSubject(int threadID) { BasicThread thread = ThreadList.GetValue(threadID); if (thread == null) { return(string.Empty); } return(thread.SubjectText); }
protected new string GetThreadLink(BasicThread thread, int subjectLength, string linkStyle, bool addStyle) { if (myThreadType == MyThreadType.MyUnapprovedPostThread || myThreadType == MyThreadType.MyUnapprovedThread) { return(GetThreadLink(thread, subjectLength, 1, myThreadType.ToString(), linkStyle, addStyle)); } else { return(base.GetThreadLink(thread, subjectLength, linkStyle, addStyle)); } }
protected string GetThreadUrl(BasicThread thread, bool isLastPage) { if (isLastPage) { return(BbsUrlHelper.GetThreadUrl(thread.Forum.CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, PageNumber)); } else { return(BbsUrlHelper.GetThreadUrl(thread.Forum.CodeName, thread.RedirectThreadID, thread.ThreadTypeString, 1, PageNumber)); } }
protected bool AllowManageThread(BasicThread thread) { ManageForumPermissionSetNode managePermission = AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(thread.ForumID); if (managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads, thread.PostUserID) || managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsRecycled, thread.PostUserID)) { return(true); } return(false); }
public static void SetThreadCache(BasicThread thread) { /* * if (thread != null) * { * if (s_AllCachedThreads != null && s_AllCachedThreads.ContainsKey(thread.ThreadID)) * return; * string cacheKey = string.Format(CacheKey_Thread, thread.ThreadID); * CacheUtil.Set<BasicThread>(cacheKey, thread); * } */ }
protected string GetThreadUrl(int threadID) { BasicThread thread = ThreadList.GetValue(threadID); if (thread == null) { return(string.Empty); } Forum forum = thread.Forum; return(BbsUrlHelper.GetThreadUrl(forum.CodeName, thread.RedirectThreadID, 1, thread.ThreadTypeString, "unapproveposts")); }
public override void CopyFrom(BasicThread thread) { base.CopyFrom(thread); PolemizeThreadV5 polemize = (PolemizeThreadV5)thread; this.AgainstCount = polemize.AgainstCount; this.AgainstViewPoint = polemize.AgainstViewPoint; this.AgreeCount = polemize.AgreeCount; this.AgreeViewPoint = polemize.AgreeViewPoint; this.NeutralCount = polemize.NeutralCount; this.ExpiresDate = polemize.ExpiresDate; }
private void ProcessDownload3(HttpContext context, BasicThread thread, PostV5 post, int diskFileID) { Forum forum = ForumBO.Instance.GetForum(post.ForumID); ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID); if (false == permission.Can(userID, ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID) { ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif"); return; } if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子 { AuthUser user = User.Current; bool isBuy = false; if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取 { } if (!isBuy) { if (thread.Price > 0) { if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent) { if (false == post.IsFreeDiskFileID(diskFileID) && false == post.IsFreeAttachmentID(attachment.AttachmentID)) { if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user)) { Context.ThrowError <CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!")); return; //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0); } } } } } } if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID)) { if (false == OutputFileByID(context, attachment.FileID, attachment.FileName, attachment.FileType, outputMode)) { ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif"); } } else { ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif"); } }
protected void Page_Load(object sender, EventArgs e) { int threadID = _Request.Get <int>("ThreadID", Method.Get, 0); if (threadID <= 0) { ShowError(new InvalidParamError("ThreadID").Message); } BasicThread thread = PostBOV5.Instance.GetThread(threadID); if (thread is PollThreadV5) { } else { ShowError("该主题不是投票帖"); } poll = (PollThreadV5)thread; //SetPageTitle("投票详细情况"); if (!AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(poll.ForumID).Can(My, ForumPermissionSetNode.Action.ViewPollDetail)) { ShowError("您所在的用户组没有权限查看详细投票情况!"); } if (thread == null) { ShowError("主题不存在!"); } if (MyUserID == thread.PostUserID || AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(poll.ForumID).Can(My, ForumPermissionSetNode.Action.AlwaysViewContents) || poll.AlwaysEyeable || poll.IsVoted(MyUserID)) { } else { ShowError("需要投票后才能查看详细投票情况!"); } PollItemDetailList = PostBOV5.Instance.GetPollItemDetails(threadID); foreach (PollItem pi in poll.PollItems) { VoteTotalCount += pi.PollItemCount; } }
/// <summary> /// 将主题加入列表 如果不存在则加入列表最前面 如果存在则提到最前面 并更新 /// </summary> /// <param name="forumID"></param> /// <param name="orderType"></param> /// <param name="thread"></param> public static void AddForumThread(int forumID, ThreadOrderType orderType, BasicThread thread) { object obj; if (s_ForumLockers.TryGetValue(forumID, out obj) == false) { obj = new object(); s_ForumLockers.Add(forumID, obj); } lock (obj) { ThreadCollectionV5 cachedThreads = GetForumThreads(forumID, orderType); if (cachedThreads != null) { ThreadCollectionV5 threads = new ThreadCollectionV5(cachedThreads); int count = GetTotalCacheCount(orderType); ThreadCollectionV5 removedThreads = new ThreadCollectionV5(); BasicThread tempThread = threads.GetValue(thread.ThreadID); if (tempThread != null) { UpdateThreadCache(tempThread, thread); threads.RemoveByKey(thread.ThreadID); threads.Insert(0, tempThread); } else { UpdateAllCachedThreadsAddThreads(thread); threads.Insert(0, thread); } if (threads.Count > count) { removedThreads.Add(threads[threads.Count - 1]); threads.RemoveAt(threads.Count - 1); } if (removedThreads.Count > 0) { string cacheKey = string.Format(CacheKey_ForumThreadOrderType, orderType.ToString(), forumID, count); UpdateAllCachedThreadsRemoveThreads(removedThreads, forumID, null, cacheKey); } SetForumThreadsCache(forumID, orderType, threads, false); } } }
public string GetThreadUrl(int threadID) { BasicThread thread = Threads.GetValue(threadID); if (thread != null) { Forum forum = ForumBO.Instance.GetForum(thread.ForumID); if (forum == null) { return(string.Empty); } return(MaxLabs.bbsMax.Common.BbsUrlHelper.GetThreadUrl(forum.CodeName, threadID, thread.ThreadTypeString)); } return(string.Empty); }
/// <summary> /// Creates a new <see cref="IThread"/> instance of the specified thread type. /// </summary> /// <param name="threadType">The type of <see cref="IThread"/> to create.</param> public static IThread Create(ThreadType threadType) { IThread thread = new BasicThread(); switch (threadType) { case ThreadType.MockThread: thread = new MockThread(); break; default: // returns the default - BasicThread implementation break; } return(thread); }
public static bool Contains(int threadID, int postID) { bool isInListCache; BasicThread thread = GetThread(threadID, out isInListCache); if (thread != null) { if (isInListCache) { return(thread.ContainPostCache(postID)); } else { return(false); } } return(false); }
public static PostV5 GetPost(int threadID, int postID) { bool isInListCache; BasicThread thread = GetThread(threadID, out isInListCache); if (thread != null) { if (isInListCache) { return(thread.GetPostFromCache(postID)); } else { return(null); } } return(null); }
protected bool HasBuyed(PostV5 post) { if (post.PostType != PostType.ThreadContent) { return(true); } BasicThread thread = searchThreads.GetValue(post.ThreadID); if (thread == null) { return(true); } if (thread.Price == 0 || thread.PostUserID == MyUserID || thread.IsOverSellDays(thread.Forum.ForumSetting)) { return(true); } return(HasBuyThreadIDs.Contains(post.ThreadID)); }
protected void Page_Load(object sender, EventArgs e) { int threadid = _Request.Get <int>("threadid", Method.Get, 0); if (threadid < 0) { ShowError(new InvalidParamError("threadid")); } thread = PostBOV5.Instance.GetThread(threadid); if (thread == null) { ShowError(new ThreadNotExistsError()); } if (!AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID).Can(My, ForumPermissionSetNode.Action.ViewThread)) { ShowError("您没有权限查看主题操作记录!"); } threadlogList = PostBOV5.Instance.GetThreadManageLogs(threadid); }
protected void Page_Load(object sender, EventArgs e) { int threadid = _Request.Get<int>("threadid", Method.Get, 0); if (threadid < 0) { ShowError(new InvalidParamError("threadid")); } thread = PostBOV5.Instance.GetThread(threadid); if (thread == null) { ShowError(new ThreadNotExistsError()); } if (!AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(thread.ForumID).Can(My, ForumPermissionSetNode.Action.ViewThread)) { ShowError("您没有权限查看主题操作记录!"); } threadlogList = PostBOV5.Instance.GetThreadManageLogs(threadid); }
protected new string GetThreadPager(BasicThread thread, string style, string urlStyle) { if (ThreadCatalogID == -1) { if (IsNormalThreads) { if (IsDefaultList) { return(GetThreadPager(thread, style, urlStyle, null, false, null, PageNumber)); //return GetThreadLink(thread,subjectLength,1,false,(PageIndex+1)); } else { return(GetThreadPager(thread, style, urlStyle, string.Concat("Action=", Action, "&page=", PageNumber.ToString()), true, null, PageNumber)); } } else { if (StringUtil.EqualsIgnoreCase(Action, "recycled")) { return(GetThreadPager(thread, style, urlStyle, "recyclebin", false, null, PageNumber)); } else if (StringUtil.EqualsIgnoreCase(Action, "unapproved")) { return(GetThreadPager(thread, style, urlStyle, "unapprovethreads", false, null, PageNumber)); } else { return(GetThreadPager(thread, style, urlStyle, "unapproveposts", false, null, PageNumber)); } } } else { return(GetThreadPager(thread, style, urlStyle, string.Concat("ThreadCatalogID=", ThreadCatalogID.ToString(), "&page=", PageNumber.ToString()), true, null, PageNumber)); } }
protected bool CanDeleteTopic(BasicThread thread) { if (thread == null) return true; return AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(thread.ForumID).Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads, thread.PostUserID); }
protected new string GetThreadLink(BasicThread thread, int subjectLength, string linkStyle, bool addStyle) { if (myThreadType == MyThreadType.MyUnapprovedPostThread || myThreadType == MyThreadType.MyUnapprovedThread) { return GetThreadLink(thread, subjectLength, 1, myThreadType.ToString(), linkStyle, addStyle); } else return base.GetThreadLink(thread, subjectLength, linkStyle, addStyle); }
public static void SetThreadCache(BasicThread thread) { /* if (thread != null) { if (s_AllCachedThreads != null && s_AllCachedThreads.ContainsKey(thread.ThreadID)) return; string cacheKey = string.Format(CacheKey_Thread, thread.ThreadID); CacheUtil.Set<BasicThread>(cacheKey, thread); } */ }
public override void GetAttachment(int diskFileID, int postID, out Attachment attachment, out PostV5 post, out BasicThread thread) { attachment = null; post = null; thread = null; using (SqlQuery query = new SqlQuery()) { query.CommandText = "bx_GetAttachmentByDiskFileID"; query.CommandType = CommandType.StoredProcedure; query.CreateParameter("@DiskFileID", diskFileID, SqlDbType.Int); query.CreateParameter("@PostID", postID, SqlDbType.Int); using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { attachment = new Attachment(reader); } if (reader.NextResult()) { while (reader.Read()) { post = new PostV5(reader); } } if (reader.NextResult()) { while (reader.Read()) { thread = GetThread(reader, null); } } } } }
protected string GetThreadLastPageUrl(BasicThread thread) { return BbsUrlHelper.GetThreadUrl(thread.Forum.CodeName, thread.RedirectThreadID, thread.ThreadTypeString, thread.TotalPages, 1); }
private static string ProcessFreeTag(string content, BasicThread thread, Forum forum) { AuthUser user = User.Current; if (user.UserID == thread.PostUserID || thread.IsOverSellDays(forum.ForumSetting) || thread.IsBuyed(user) || (AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(forum.ForumID).Can(user, ForumPermissionSetNode.Action.AlwaysViewContents))) content = regex_free.Replace(content, string.Format(freeStyle, "$1")); else { content = ProcessFreeTag(content,thread.IsBuyed(user)); } return content; }
protected bool IsShowCheckBox(BasicThread thread) { return AllowManageThread(thread); }
protected bool GetPosts(ThreadType threadType, out int? totalCount, out BasicThread thread, out PostCollectionV5 posts) { totalCount = null; thread = null; posts = null; ThreadType realThreadType = threadType; if (string.Compare(Type, SystemForum.RecycleBin.ToString(), true) == 0) { PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType); if (realThreadType != threadType) { BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type); } if (thread == null) { ShowError("您要查看的主题不存在或者已被删除"); } //totalCount = base.TotalPosts; return true; } else if (string.Compare(Type, SystemForum.UnapproveThreads.ToString(), true) == 0) { PostBOV5.Instance.GetPosts(ThreadID, false, PageNumber, PageSize, null, true, true, true, true, ref thread, out posts, ref realThreadType); //m_Thread.ThreadContent = m_PostList[0]; totalCount = posts.TotalRecords; if (realThreadType != threadType) { BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(realThreadType)), "type=" + Type); } if (thread == null) { ShowError("您要查看的主题不存在或者已被删除"); } return true; } else if (string.Compare(Type, MyThreadType.MyUnapprovedThread.ToString(), true) == 0) //|| string.Compare(Type, MyThreadType.MyUnapprovedPostThread.ToString(), true) == 0) { int count; PostBOV5.Instance.GetUnapprovedPostThread(ThreadID, MyUserID, PageNumber, PageSize, out thread, out posts, out count); if (thread == null) { ShowError("您要查看的主题不存在或者已被删除"); } if (posts.Count > 0) thread.ThreadContent = posts[0]; else ShowError("您要查看的主题不存在或者已被删除"); totalCount = count; return true; } else if (IsGetPost) { if (threadType != ThreadType.Normal) { BbsRouter.JumpToUrl(BbsUrlHelper.GetThreadUrl(CodeName, ThreadID, PostBOV5.Instance.GetThreadTypeString(ThreadType.Normal)), "type=getpost&postid=" + PostID); } thread = PostBOV5.Instance.GetThread(ThreadID); PostV5 post = PostBOV5.Instance.GetPost(PostID, true); if (post == null) { ShowError("您要查看的帖子不存在或者已被删除"); } posts = new PostCollectionV5(); posts.Add(post); totalCount = 1; return true; } else return false; }
public static string FormatRequotePost(string content, PostV5 reply, BasicThread thread) { //引用的时候 用户自定义的表情 不再使用快捷方式显示 (会照成无法显示,因为发帖页 只列出了当前发帖者的表情) //TODO:管理员编辑别人的帖子时 也会出现同样的情况-- content = regex_faceShortcut.Replace(content, ""); //bool userEmotion = reply.EnableEmoticons; //if(userEmotion) //{ // ForumSettingItem setting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(reply.ForumID); // userEmotion = setting.CreatePostAllowEmoticon.GetValue(reply.UserID); //} //content = EmoticonParser.ParseToHtml(reply.UserID, content, userEmotion, userEmotion); if (thread.Price > 0) { PostV5 post = PostBOV5.Instance.GetThreadFirstPost(thread.ThreadID, false); if (post != null && post.PostID == reply.PostID) //需要购买的帖子 { content = ProcessFreeWhenRequoteTag(content); } } content = content.Replace("{$root}", Globals.AppRoot); content = regex_ubb.Replace(content, delegate(Match m) { string temp = regex_code.Replace(m.Groups[1].Value, delegate(Match m2) { return string.Concat("[code]", m2.Groups[1].Value, "[/code]"); }); return temp; }); ForumSettingItem setting = AllSettings.Current.ForumSettings.Items.GetForumSettingItem(thread.ForumID); if (setting.EnableHiddenTag) { content = regex_hide.Replace(content, "[******隐藏内容******]"); } return content;//System.Web.HttpUtility.HtmlEncode(content); }
/// <summary> /// 将主题加入列表 如果不存在则加入列表最前面 如果存在则提到最前面 并更新 /// </summary> /// <param name="orderType"></param> /// <param name="thread"></param> public static void AddAllForumThread(ThreadOrderType orderType, BasicThread thread) { if (IsInCache(orderType)) { AddAllForumThreadToCache(orderType, thread); return; } int count = GetTotalCacheCount(orderType); lock (s_AllForumTopThreadsLocker) { if (s_AllForumTopThreads == null) { return; //AllForumTopThreads = new Dictionary<ThreadOrderType, ThreadCollectionV5>(); } Dictionary<ThreadOrderType, ThreadCollectionV5> tempAllForumTopThreads = new Dictionary<ThreadOrderType, ThreadCollectionV5>(); foreach (KeyValuePair<ThreadOrderType, ThreadCollectionV5> pair in s_AllForumTopThreads) { tempAllForumTopThreads.Add(pair.Key, pair.Value); } lock (s_AllForumTopThreadsLockers[orderType]) { ThreadCollectionV5 temp; tempAllForumTopThreads.TryGetValue(orderType, out temp); if (temp == null) return; ThreadCollectionV5 threads = new ThreadCollectionV5(temp); if (threads.Count == 0) { threads.Add(thread); tempAllForumTopThreads[orderType] = threads; UpdateAllCachedThreadsAddThreads(thread); } else { BasicThread tempThread; threads.TryGetValue(thread.ThreadID, out tempThread); ThreadCollectionV5 removedThreads = new ThreadCollectionV5(); if (tempThread != null) { UpdateThreadCache(tempThread, thread);//此处是为了更新 AllCachedThreads 和其它缓存 里的这个主题 threads.RemoveByKey(thread.ThreadID); //removedThreads.Add(tempThread); } else { UpdateAllCachedThreadsAddThreads(thread); } threads.Insert(0, thread); if (threads.Count > count) { removedThreads.Add(threads[threads.Count - 1]); threads.RemoveAt(threads.Count - 1); } UpdateAllCachedThreadsRemoveThreads(removedThreads, null, orderType, null); } tempAllForumTopThreads[orderType] = threads; } s_AllForumTopThreads = tempAllForumTopThreads; } }
public static void CreateLog(string tag,BasicThread thread) { }
private void ProcessDownload3(HttpContext context, BasicThread thread, PostV5 post,int diskFileID) { Forum forum = ForumBO.Instance.GetForum(post.ForumID); ForumPermissionSetNode permission = AllSettings.Current.ForumPermissionSet.Nodes.GetPermission(post.ForumID); if (false == permission.Can(userID,ForumPermissionSetNode.Action.ViewAttachment) && attachment.UserID != userID) { ShowErrorMessage(context, "您没有权限下载附件!", "您没有权限下载附件.gif"); return; } if (!AlwaysViewContents(forum, post.UserID) && attachment.UserID != userID)//检查是否是出售的帖子 { AuthUser user = User.Current; bool isBuy = false; if (user.BuyedThreads.TryGetValue(post.ThreadID, out isBuy))//缓存中获取 { } if (!isBuy) { if (thread.Price > 0) { if (post.PostType == MaxLabs.bbsMax.Enums.PostType.ThreadContent) { if (false == post.IsFreeDiskFileID(diskFileID) && false == post.IsFreeAttachmentID(attachment.AttachmentID)) { if (!thread.IsOverSellDays(forum.ForumSetting) && !thread.IsBuyed(user)) { Context.ThrowError<CustomError>(new CustomError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!")); return; //Bbs3Globals.ShowError("error", "该附件所在的帖子需要购买,您还没有购买该帖子没有权限下载附件!", 0); } } } } } } if (CheckPermission(forum.ForumSetting) || AlwaysViewContents(forum, attachment.UserID)) { if (false == OutputFileByID(context, attachment.FileID, attachment.FileName, attachment.FileType, outputMode)) { ShowErrorMessage(context, "该附件不存在,可能被移动或被删除!", "文件不存在.gif"); } } else { ShowErrorMessage(context, "你还没有购买此附件,不能下载!", "needpay.gif"); } }
protected string GetArchiverThreadLink(BasicThread thread) { return GetArchiverThreadLink(thread, null); }
public override RevertableCollection<BasicThread> GetThreadWithReverters(IEnumerable<int> threadIDs) { if (ValidateUtil.HasItems(threadIDs) == false) return null; RevertableCollection<BasicThread> threads = new RevertableCollection<BasicThread>(); using (SqlQuery query = new SqlQuery()) { query.CommandText = @" SELECT A.*, SubjectReverter = ISNULL(R.SubjectReverter, '') FROM bx_Threads A WITH(NOLOCK) LEFT JOIN bx_ThreadReverters R WITH(NOLOCK) ON R.ThreadID = A.ThreadID WHERE A.ThreadID IN (@ThreadIDs)"; query.CreateInParameter<int>("@ThreadIDs", threadIDs); using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { string nameReverter = reader.Get<string>("SubjectReverter"); BasicThread thread = new BasicThread(reader); threads.Add(thread, nameReverter); } } } return threads; }
protected string GetArchiverThreadLink(BasicThread thread, string linkStyle) { if (string.IsNullOrEmpty(linkStyle)) linkStyle = "<a href=\"{0}\">{1}</a>"; Forum forum = null; string subject = null; if (thread.ThreadType == ThreadType.Move || thread.ThreadType == ThreadType.Join) { int index = thread.SubjectText.IndexOf(','); if (index > 0) { string threadIDStr = thread.SubjectText.Substring(0, index); subject = thread.SubjectText.Substring(index + 1); } BasicThread redirectThread = PostBOV5.Instance.GetThread(thread.RedirectThreadID); if(redirectThread!=null) { forum = ForumBO.Instance.GetForum(redirectThread.ForumID); } if (forum == null) forum = ForumBO.Instance.GetForum(thread.ForumID); } else forum = ForumBO.Instance.GetForum(thread.ForumID); string url = BbsUrlHelper.GetArchiverThreadUrl(forum.CodeName, thread.RedirectThreadID); if (subject == null) subject = thread.SubjectText; if (thread.ThreadType == ThreadType.Move) return "已移动:" + string.Format(linkStyle, url, subject); else if (thread.ThreadType == ThreadType.Join) return "已合并:" + string.Format(linkStyle, url, subject); else return string.Format(linkStyle, url, subject); }
/* private static BasicThread GetThreadFromCache(int threadID) { string cacheKey = string.Format(CacheKey_Thread, threadID); return CacheUtil.Get<BasicThread>(cacheKey); } private static void RemoveThreadCache(int threadID) { string cacheKey = string.Format(CacheKey_Thread, threadID); CacheUtil.Remove(cacheKey); } */ /// <summary> /// 更新缓存的主题olThread 为newThread ,只更新BasicThreadV5中的属性,没有更新子类的属性 不更新点击数 /// </summary> /// <param name="olThread"></param> /// <param name="newThread"></param> public static void UpdateThreadCache(BasicThread olThread, BasicThread newThread) { int totalView = olThread.TotalViews; olThread.CopyFrom(newThread); olThread.TotalViews = totalView; }
protected bool AllowManageThread(BasicThread thread) { ManageForumPermissionSetNode managePermission = AllSettings.Current.ManageForumPermissionSet.Nodes.GetPermission(thread.ForumID); if (managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.DeleteAnyThreads, thread.PostUserID) || managePermission.Can(My, ManageForumPermissionSetNode.ActionWithTarget.SetThreadsRecycled, thread.PostUserID)) return true; return false; }
private static void UpdateAllCachedThreadsRemoveThread(BasicThread thread, int? forumID, ThreadOrderType? excludeOrderType, string excludeCacheKey) { ThreadCollectionV5 threads = new ThreadCollectionV5(); threads.Add(thread); UpdateAllCachedThreadsRemoveThreads(threads, forumID, excludeOrderType, excludeCacheKey); }
public override bool CreatePost(int threadID, bool getPost, bool isApproved, PostType postType, int iconID, string subject, string content , bool enableHtml, bool enableMaxCode3, bool enableSignature, bool enableReplyNotice, int forumID, int postUserID, string userName , string ipAddress, int parentID, bool updateSortOrder, AttachmentCollection attachments, IEnumerable<int> historyAttachmentIDs , BasicThread thread , out PostV5 post, out int totalPosts, out List<int> AttachmentIDs, out Dictionary<string, int> fileIDs, out bool threadEnableReplyNotice) { AttachmentIDs = new List<int>(); fileIDs = new Dictionary<string, int>(); threadEnableReplyNotice = true; post = null; using (SqlQuery query = new SqlQuery()) { query.CommandType = CommandType.StoredProcedure; query.CommandText = "bx_v5_CreatePost"; SetCreatePostParams(query, forumID, iconID, subject, postUserID, userName, content, enableHtml, enableMaxCode3 , enableSignature, enableReplyNotice, ipAddress, attachments, historyAttachmentIDs); query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int); query.CreateParameter<int>("@PostType", (int)postType, SqlDbType.TinyInt); query.CreateParameter<bool>("@IsApproved", isApproved, SqlDbType.Bit); query.CreateParameter<int>("@PostRandNumber", GetSortNumber("post"), SqlDbType.TinyInt); query.CreateParameter<int>("@ParentID", parentID, SqlDbType.Int); query.CreateParameter<bool>("@UpdateSortOrder", updateSortOrder, SqlDbType.Bit); query.CreateParameter("@GetExtendedInfo", true, SqlDbType.Bit); query.CreateParameter("@GetThreadEnableReplyNotice", true, SqlDbType.Bit); query.CreateParameter<int>("@PostID", SqlDbType.Int, ParameterDirection.Output); query.CreateParameter<bool>("@GetPost", getPost, SqlDbType.Bit); query.CreateParameter<bool>("@GetThread", false, SqlDbType.Bit); string extendData = null; using (XSqlDataReader reader = query.ExecuteReader()) { while (reader.Read()) { threadEnableReplyNotice = reader.Get<bool>("EnableReplyNotice"); } if (attachments.Count > 0) { if (reader.NextResult()) { while (reader.Read()) { AttachmentIDs.Add(reader.Get<int>(0)); } if (reader.NextResult()) { while (reader.Read()) { string fileID = reader.Get<string>("fileID"); if (fileIDs.ContainsKey(fileID) == false) fileIDs.Add(fileID, reader.Get<int>("attachmentID")); } } } } if (getPost) { PostCollectionV5 posts = GetPosts(reader, false); if (posts.Count > 0) post = posts[0]; else post = null; } extendData = GetExtendData(thread, thread.ThreadType, reader, false); } if (getPost == false) { post = new PostV5(); post.PostID = (int)query.Parameters["@PostID"].Value; } int returnValue = (int)query.Parameters["@ErrorCode"].Value; if (returnValue != -1) { totalPosts = Convert.ToInt32(query.Parameters["@UserTotalPosts"].Value); if (extendData != null) { UpdateThreadExtendData(extendData, threadID, query); } } else { totalPosts = 0; return false; } return true; } }
public override void GetThreadWithReplies(int threadID, int totalCount, bool getThread, int pageNumber, int pageSize, out BasicThread thread, out PostCollectionV5 replies) { using (SqlQuery query = new SqlQuery()) { query.Pager.IsDesc = true; query.Pager.ResultFields = "*"; query.Pager.SortField = "[SortOrder]"; query.Pager.PrimaryKey = "[PostID]"; query.Pager.PageNumber = pageNumber; query.Pager.PageSize = pageSize; query.Pager.TotalRecords = totalCount; query.Pager.SelectCount = true; query.Pager.TableName = "[bx_Posts]"; query.Pager.Condition = " ThreadID=@ThreadID AND [ThreadStatus]<4 "; if (getThread) { query.Pager.AfterExecute = string.Concat(@" SELECT ", ThreadFields, @" FROM [bx_Threads] WITH (NOLOCK) WHERE [ThreadID] = @ThreadID AND [ThreadStatus]<4; "); } query.CreateParameter<int>("@ThreadID", threadID, SqlDbType.Int); thread = null; using (XSqlDataReader reader = query.ExecuteReader()) { replies = new PostCollectionV5(reader); if (reader.NextResult()) { while (reader.Read()) { totalCount = reader.Get<int>(0); } } if (reader.NextResult()) { while (reader.Read()) { thread = new BasicThread(reader); } } } } }
public override bool GetThread(int threadID, bool normalOnly, int totalCount, bool getThread, bool getReplies, int postUserID, int pageIndex, int pageSize, out BasicThread thread, out PostCollectionV5 replies, out int repliesCountForUser) { throw new NotImplementedException(); }
private static void AddAllForumThreadToCache(ThreadOrderType orderType, BasicThread thread) { AddForumThread(0, orderType, thread); }
protected bool IsOverSellThreadDays(BasicThread thread) { if(SellThreadDays == 0) return false; return thread.CreateDate.AddSeconds(SellThreadDays) <= DateTimeUtil.Now; }