Beispiel #1
0
 private void GetChildForums(int forumID, ref ForumCollection forums)
 {
     foreach (Forum forum in GetAllForums())
     {
         if (forum.ParentID == forumID)
         {
             forums.Add(forum);
             GetChildForums(forum.ForumID, ref forums);
         }
     }
 }
Beispiel #2
0
        public ForumCollection GetAll()
        {
            SharePointListDescriptor descriptor      = Provider.GetAllListItems(ForumConstants.Lists_Forums);
            ForumCollection          forumCollection = new ForumCollection();

            foreach (SharePointListItem listItem in descriptor.SharePointListItems)
            {
                forumCollection.Add(ForumMapper.CreateDomainObject(listItem));
            }

            return(forumCollection);
        }
Beispiel #3
0
        public ForumCollection FindByCategoryId(int id)
        {
            SharePointListDescriptor descriptor      = Provider.GetListItemsByField(ForumConstants.Lists_Forums, "CategoryID", id.ToString());
            ForumCollection          forumCollection = new ForumCollection();

            foreach (SharePointListItem listItem in descriptor.SharePointListItems)
            {
                forumCollection.Add(ForumMapper.CreateDomainObject(listItem));
            }

            return(forumCollection);
        }
Beispiel #4
0
        //=====================

        private void GetSubForums(string separator, Forum forum, GetForumFilter filter, ref ForumCollection forums, ref List <string> forumSeparators)
        {
            ForumCollection childForums = forum.AllSubForums;

            foreach (Forum tempForum in childForums)
            {
                if (filter == null || filter(tempForum))
                {
                    forums.Add(tempForum);
                    forumSeparators.Add(separator);
                    GetSubForums(separator + separator, tempForum, filter, ref forums, ref forumSeparators);
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// 筛选出所有符合条件的版块
        /// </summary>
        /// <param name="filter"></param>
        /// <returns></returns>
        internal ForumCollection GetForums(GetForumFilter filter)
        {
            ForumCollection result = new ForumCollection();

            foreach (Forum forum in GetAllForums())
            {
                if (filter(forum))
                {
                    result.Add(forum);
                }
            }

            return(result);
        }
        private static ForumCollection DBMapping(DBForumCollection dbCollection)
        {
            if (dbCollection == null)
                return null;

            ForumCollection collection = new ForumCollection();
            foreach (DBForum dbItem in dbCollection)
            {
                Forum item = DBMapping(dbItem);
                collection.Add(item);
            }

            return collection;
        }
Beispiel #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="separator"></param>
        /// <param name="filter">如果为null则返回所有版块</param>
        /// <param name="forums"></param>
        /// <param name="forumSeparators"></param>
        public void GetTreeForums(string separator, GetForumFilter filter, out ForumCollection forums, out List <string> forumSeparators)
        {
            ForumCollection rootForums = GetCategories();

            forums          = new ForumCollection();
            forumSeparators = new List <string>();
            foreach (Forum forum in rootForums)
            {
                if (filter == null || filter(forum))
                {
                    forums.Add(forum);
                    forumSeparators.Add(string.Empty);
                    GetSubForums(separator, forum, filter, ref forums, ref forumSeparators);
                }
            }
        }
Beispiel #8
0
        private void initForums()
        {
            lock (allForumsLocker)
            {
                if (s_AllForums == null ||
                    s_AllForumsIndexByCodename == null ||
                    s_AllForumsForGuestList == null ||
                    s_Categories == null ||
                    s_CategoriesForGuestList == null)
                {
                    s_AllForums = ForumDaoV5.Instance.GetAllForums();
                    s_AllForumsIndexByCodename = new Dictionary <string, Forum>();
                    s_AllForumsForGuestList    = new ForumCollection();
                    s_Categories             = new ForumCollection();
                    s_CategoriesForGuestList = new ForumCollection();
                    foreach (Forum forum in s_AllForums)
                    {
                        if (s_AllForumsIndexByCodename.ContainsKey(forum.CodeName) == false)
                        {
                            s_AllForumsIndexByCodename.Add(forum.CodeName, forum);
                        }

                        if (forum.CanDisplayInList(User.Guest))
                        {
                            s_AllForumsForGuestList.Add(forum);
                        }

                        if (forum.ForumID > 0 && forum.ParentID == 0)
                        {
                            s_Categories.Add(forum);
                        }

                        if (forum.ForumID > 0 && forum.ParentID == 0 && forum.CanVisit(User.Guest))
                        {
                            s_CategoriesForGuestList.Add(forum);
                        }
                    }
                }
            }
        }
        // *********************************************************************
        //  GetChildForums
        //
        /// <summary>
        /// Used to return a collection of forums for a parent forum
        /// </summary>
        /// <param name="forumGroupId">Forum Group ID to retrieve forums for</param>
        /// <param name="username">Username making the request</param>
        /// <param name="showAll">Show forums marked as inactive?</param>
        ///
        // ***********************************************************************/
        public ForumCollection GetChildForums(int forumId, string username, bool showAll)
        {
            ForumCollection allForums;
            ForumCollection subForums = new ForumCollection();

            // First get all the forums
            allForums = GetAllForums(showAll, username);

            // Sort the forums
            allForums.Sort();

            // Find all the forums that belong to the requested forumGroupId
            foreach (Forum f in allForums)
            {
                if (f.ParentId == forumId)
                {
                    subForums.Add(f);
                }
            }

            subForums.Sort();

            return(subForums);
        }
        // *********************************************************************
        //  GetForumsByForumGroupId
        //
        /// <summary>
        /// Used to return a narrow collection of forums that belong to a given forum id.
        /// The username is provied for personalization, e.g. if the user has new
        /// posts in the forum. Note, this only returns ParentID = 0 forums
        /// </summary>
        /// <param name="forumGroupId">Forum Group ID to retrieve forums for</param>
        /// <param name="username">Username making the request</param>
        /// <param name="showAll">Show forums marked as inactive?</param>
        ///
        // ***********************************************************************/
        public ForumCollection GetForumsByForumGroupId(int forumGroupId, string username, bool showAll)
        {
            ForumCollection allForums;
            ForumCollection forumsBelongingToGroup = new ForumCollection();

            // First get all the forums
            allForums = GetAllForums(showAll, username);

            // Sort the forums
            allForums.Sort();

            // Find all the forums that belong to the requested forumGroupId
            foreach (Forum f in allForums)
            {
                if ((f.ForumGroupId == forumGroupId) && (f.ParentId == 0))
                {
                    forumsBelongingToGroup.Add(f);
                }
            }

            forumsBelongingToGroup.Sort();

            return(forumsBelongingToGroup);
        }
Beispiel #11
0
        public ForumCollection Forums_List(int PortalId, int ModuleId)
        {
            ForumCollection f = new ForumCollection();
            object obj = DataCache.CacheRetrieve(string.Format(CacheKeys.ForumList, ModuleId));
            if (obj != null)
            {
                f = (ForumCollection)obj;
            }
            else
            {
                using (IDataReader dr = SqlHelper.ExecuteReader(_connectionString, dbPrefix + "ForumsList", PortalId, ModuleId))
                {

                    Forum fi = null;
                    ForumGroupInfo gi = null;
                    while (dr.Read())
                    {
                        fi = new Forum();
                        gi = new ForumGroupInfo();
                        fi.ModuleId = int.Parse(dr["ModuleId"].ToString());
                        fi.ForumID = Convert.ToInt32(dr["ForumId"].ToString());
                        fi.Active = bool.Parse(dr["Active"].ToString());
                        fi.ForumDesc = dr["ForumDesc"].ToString();
                        fi.ForumGroupId = int.Parse(dr["ForumGroupId"].ToString());
                        fi.ForumID = int.Parse(dr["ForumId"].ToString());
                        fi.ForumName = dr["ForumName"].ToString();
                        fi.GroupName = dr["GroupName"].ToString();
                        fi.Hidden = bool.Parse(dr["Hidden"].ToString());
                        fi.ParentForumId = Convert.ToInt32(dr["ParentForumId"].ToString());
                        DateTime postTime;
                        if (! (DateTime.TryParse(dr["LastPostDate"].ToString(), out postTime)))
                        {
                            fi.LastPostDateTime = new DateTime();
                        }
                        else
                        {
                            fi.LastPostDateTime = postTime;
                        }

                        fi.LastTopicId = int.Parse(dr["LastTopicId"].ToString());
                        fi.LastReplyId = int.Parse(dr["LastReplyId"].ToString());
                        fi.LastPostSubject = dr["LastPostSubject"].ToString();
                        fi.LastPostDisplayName = dr["LastPostAuthorName"].ToString();
                        fi.LastPostUserID = int.Parse(dr["LastPostAuthorId"].ToString());
                        fi.LastPostUserName = fi.LastPostDisplayName;
                        fi.LastRead = DateTime.Parse(dr["LastRead"].ToString());
                        gi.Active = bool.Parse(dr["GroupActive"].ToString());
                        gi.Hidden = bool.Parse(dr["GroupHidden"].ToString());
                        gi.GroupName = fi.GroupName;
                        gi.ForumGroupId = fi.ForumGroupId;
                        gi.PrefixURL = dr["GroupPrefixURL"].ToString();
                            //gi.SEO = dr("GroupSEO").ToString
                        fi.ForumGroup = gi;
                        fi.Security.Announce = dr["CanAnnounce"].ToString();
                        fi.Security.Attach = dr["CanAttach"].ToString();
                        fi.Security.Create = dr["CanCreate"].ToString();
                        fi.Security.Delete = dr["CanDelete"].ToString();
                        fi.Security.Edit = dr["CanEdit"].ToString();
                        fi.Security.Lock = dr["CanLock"].ToString();
                        fi.Security.ModApprove = dr["CanModApprove"].ToString();
                        fi.Security.ModDelete = dr["CanModDelete"].ToString();
                        fi.Security.ModEdit = dr["CanModEdit"].ToString();
                        fi.Security.ModLock = dr["CanModLock"].ToString();
                        fi.Security.ModMove = dr["CanModMove"].ToString();
                        fi.Security.ModPin = dr["CanModPin"].ToString();
                        fi.Security.ModSplit = dr["CanModSplit"].ToString();
                        fi.Security.ModUser = dr["CanModUser"].ToString();
                        fi.Security.Pin = dr["CanPin"].ToString();
                        fi.Security.Poll = dr["CanPoll"].ToString();
                        fi.Security.Block = dr["CanBlock"].ToString();
                        fi.Security.Read = dr["CanRead"].ToString();
                        fi.Security.Reply = dr["CanReply"].ToString();
                        fi.Security.Subscribe = dr["CanSubscribe"].ToString();
                        fi.Security.Trust = dr["CanTrust"].ToString();
                        fi.Security.View = dr["CanView"].ToString();
                        fi.ForumSettings = LoadSettings(dr);
                        fi.PrefixURL = dr["PrefixURL"].ToString();
                            //.SEO = dr("ForumSEO").ToString
                        fi.TotalTopics = int.Parse(dr["TotalTopics"].ToString());
                        fi.TotalReplies = int.Parse(dr["TotalReplies"].ToString());
                        f.Add(fi);
                    }
                    dr.Close();
                }

                DataCache.CacheStore(string.Format(CacheKeys.ForumList, ModuleId), f);
            }
            return f;
        }
        public ForumCollection Forums_List(int PortalId, int ModuleId)
        {
            ForumCollection f   = new ForumCollection();
            object          obj = DataCache.CacheRetrieve(string.Format(CacheKeys.ForumList, ModuleId));

            if (obj != null)
            {
                f = (ForumCollection)obj;
            }
            else
            {
                using (IDataReader dr = SqlHelper.ExecuteReader(_connectionString, dbPrefix + "ForumsList", PortalId, ModuleId))
                {
                    Forum          fi = null;
                    ForumGroupInfo gi = null;
                    while (dr.Read())
                    {
                        fi               = new Forum();
                        gi               = new ForumGroupInfo();
                        fi.ModuleId      = int.Parse(dr["ModuleId"].ToString());
                        fi.ForumID       = Convert.ToInt32(dr["ForumId"].ToString());
                        fi.Active        = bool.Parse(dr["Active"].ToString());
                        fi.ForumDesc     = dr["ForumDesc"].ToString();
                        fi.ForumGroupId  = int.Parse(dr["ForumGroupId"].ToString());
                        fi.ForumID       = int.Parse(dr["ForumId"].ToString());
                        fi.ForumName     = dr["ForumName"].ToString();
                        fi.GroupName     = dr["GroupName"].ToString();
                        fi.Hidden        = bool.Parse(dr["Hidden"].ToString());
                        fi.ParentForumId = Convert.ToInt32(dr["ParentForumId"].ToString());
                        DateTime postTime;
                        if (!(DateTime.TryParse(dr["LastPostDate"].ToString(), out postTime)))
                        {
                            fi.LastPostDateTime = new DateTime();
                        }
                        else
                        {
                            fi.LastPostDateTime = postTime;
                        }

                        fi.LastTopicId         = int.Parse(dr["LastTopicId"].ToString());
                        fi.LastReplyId         = int.Parse(dr["LastReplyId"].ToString());
                        fi.LastPostSubject     = dr["LastPostSubject"].ToString();
                        fi.LastPostDisplayName = dr["LastPostAuthorName"].ToString();
                        fi.LastPostUserID      = int.Parse(dr["LastPostAuthorId"].ToString());
                        fi.LastPostUserName    = fi.LastPostDisplayName;
                        fi.LastRead            = DateTime.Parse(dr["LastRead"].ToString());
                        gi.Active       = bool.Parse(dr["GroupActive"].ToString());
                        gi.Hidden       = bool.Parse(dr["GroupHidden"].ToString());
                        gi.GroupName    = fi.GroupName;
                        gi.ForumGroupId = fi.ForumGroupId;
                        gi.PrefixURL    = dr["GroupPrefixURL"].ToString();
                        //gi.SEO = dr("GroupSEO").ToString
                        fi.ForumGroup          = gi;
                        fi.Security.Announce   = dr["CanAnnounce"].ToString();
                        fi.Security.Attach     = dr["CanAttach"].ToString();
                        fi.Security.Create     = dr["CanCreate"].ToString();
                        fi.Security.Delete     = dr["CanDelete"].ToString();
                        fi.Security.Edit       = dr["CanEdit"].ToString();
                        fi.Security.Lock       = dr["CanLock"].ToString();
                        fi.Security.ModApprove = dr["CanModApprove"].ToString();
                        fi.Security.ModDelete  = dr["CanModDelete"].ToString();
                        fi.Security.ModEdit    = dr["CanModEdit"].ToString();
                        fi.Security.ModLock    = dr["CanModLock"].ToString();
                        fi.Security.ModMove    = dr["CanModMove"].ToString();
                        fi.Security.ModPin     = dr["CanModPin"].ToString();
                        fi.Security.ModSplit   = dr["CanModSplit"].ToString();
                        fi.Security.ModUser    = dr["CanModUser"].ToString();
                        fi.Security.Pin        = dr["CanPin"].ToString();
                        fi.Security.Poll       = dr["CanPoll"].ToString();
                        fi.Security.Block      = dr["CanBlock"].ToString();
                        fi.Security.Read       = dr["CanRead"].ToString();
                        fi.Security.Reply      = dr["CanReply"].ToString();
                        fi.Security.Subscribe  = dr["CanSubscribe"].ToString();
                        fi.Security.Trust      = dr["CanTrust"].ToString();
                        fi.Security.View       = dr["CanView"].ToString();
                        fi.ForumSettings       = LoadSettings(dr);
                        fi.PrefixURL           = dr["PrefixURL"].ToString();
                        //.SEO = dr("ForumSEO").ToString
                        fi.TotalTopics  = int.Parse(dr["TotalTopics"].ToString());
                        fi.TotalReplies = int.Parse(dr["TotalReplies"].ToString());
                        f.Add(fi);
                    }
                    dr.Close();
                }

                DataCache.CacheStore(string.Format(CacheKeys.ForumList, ModuleId), f);
            }
            return(f);
        }
Beispiel #13
0
        public string Render()
        {
            if (string.IsNullOrEmpty(Template))
            {
                return("Please specify a template");
            }
            StringBuilder sb = new StringBuilder();

            Data.ForumsDB   fdb            = new Data.ForumsDB();
            ForumCollection allForums      = fdb.Forums_List(PortalId, ModuleId);
            ForumCollection filteredForums = new ForumCollection();

            foreach (Forum f in allForums)
            {
                if (f.ForumGroup.Active && f.Active && f.ParentForumId == 0)
                {
                    if (Permissions.HasPerm(f.Security.View, ForumUser.UserRoles))
                    {
                        f.TabId     = TabId;
                        f.SubForums = GetSubForums(allForums, f.ForumID);
                        filteredForums.Add(f);
                    }
                }
            }
            string        groupTemplate    = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]");
            string        forumTemplate    = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]");
            string        subForumTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]");
            int           currGroup        = -1;
            string        gtmp             = string.Empty;
            string        ftmp             = string.Empty;
            string        subtmp           = string.Empty;
            StringBuilder list             = new StringBuilder();
            bool          inprogress       = false;

            foreach (Forum f in filteredForums)
            {
                if (currGroup != f.ForumGroupId)
                {
                    if (!(string.IsNullOrEmpty(gtmp)))
                    {
                        gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty);
                        list.Append(gtmp);
                    }
                    gtmp      = groupTemplate;
                    gtmp      = TemplateUtils.ReplaceSubSection(gtmp, "[FORUMHOLDER]", "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]");
                    gtmp      = ParseForumGroup(f.ForumGroup, gtmp);
                    ftmp      = forumTemplate;
                    ftmp      = TemplateUtils.ReplaceSubSection(ftmp, "[SUBFORUMHOLDER]", "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]");
                    subtmp    = subForumTemplate;
                    currGroup = f.ForumGroupId;
                }
                string forums = ParseForum(f, ftmp);
                if (f.SubForums != null)
                {
                    foreach (Forum s in f.SubForums)
                    {
                        forums = forums.Replace("[SUBFORUMHOLDER]", ParseForum(s, subtmp) + "[SUBFORUMHOLDER]");
                    }
                }
                forums = forums.Replace("[SUBFORUMHOLDER]", string.Empty);
                gtmp   = gtmp.Replace("[FORUMHOLDER]", forums + "[FORUMHOLDER]");
            }
            gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty);
            list.Append(gtmp);
            Template = TemplateUtils.ReplaceSubSection(Template, list.ToString(), "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]");
            return(Template);
        }
Beispiel #14
0
		public string Render()
		{
			if (string.IsNullOrEmpty(Template))
			{
				return "Please specify a template";
			}
			StringBuilder sb = new StringBuilder();
			Data.ForumsDB fdb = new Data.ForumsDB();
			ForumCollection allForums = fdb.Forums_List(PortalId, ModuleId);
			ForumCollection filteredForums = new ForumCollection();
			foreach (Forum f in allForums)
			{
				if (f.ForumGroup.Active && f.Active && f.ParentForumId == 0)
				{
					if (Permissions.HasPerm(f.Security.View, ForumUser.UserRoles))
					{
						f.TabId = TabId;
						f.SubForums = GetSubForums(allForums, f.ForumID);
						filteredForums.Add(f);
					}
				}
			}
			string groupTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]");
			string forumTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]");
			string subForumTemplate = TemplateUtils.GetTemplateSection(Template, "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]");
			int currGroup = -1;
			string gtmp = string.Empty;
			string ftmp = string.Empty;
			string subtmp = string.Empty;
			StringBuilder list = new StringBuilder();
			bool inprogress = false;
			foreach (Forum f in filteredForums)
			{
				if (currGroup != f.ForumGroupId)
				{
					if (! (string.IsNullOrEmpty(gtmp)))
					{
						gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty);
						list.Append(gtmp);
					}
					gtmp = groupTemplate;
					gtmp = TemplateUtils.ReplaceSubSection(gtmp, "[FORUMHOLDER]", "[AF:DIR:FORUM]", "[/AF:DIR:FORUM]");
					gtmp = ParseForumGroup(f.ForumGroup, gtmp);
					ftmp = forumTemplate;
					ftmp = TemplateUtils.ReplaceSubSection(ftmp, "[SUBFORUMHOLDER]", "[AF:DIR:SUBFORUM]", "[/AF:DIR:SUBFORUM]");
					subtmp = subForumTemplate;
					currGroup = f.ForumGroupId;
				}
				string forums = ParseForum(f, ftmp);
				if (f.SubForums != null)
				{
					foreach (Forum s in f.SubForums)
					{
						forums = forums.Replace("[SUBFORUMHOLDER]", ParseForum(s, subtmp) + "[SUBFORUMHOLDER]");
					}
				}
				forums = forums.Replace("[SUBFORUMHOLDER]", string.Empty);
				gtmp = gtmp.Replace("[FORUMHOLDER]", forums + "[FORUMHOLDER]");

			}
			gtmp = gtmp.Replace("[FORUMHOLDER]", string.Empty);
			list.Append(gtmp);
			Template = TemplateUtils.ReplaceSubSection(Template, list.ToString(), "[AF:DIR:FORUMGROUP]", "[/AF:DIR:FORUMGROUP]");
			return Template;
		}