public static TopicInfo GetTopic(int topicid) { ITopic dal = Factory <ITopic> .Create("Topic"); TopicInfo topic = dal.GetById(topicid); if (topic != null) { topic.Forum = Forums.GetForum(topic.ForumId); topic.PollId = GetTopicPollId(topicid); topic.IsArchived = false; } else { //let's check archives IArchiveForum archDal = Factory <IArchiveForum> .Create("ArchiveForums"); topic = archDal.GetTopic(topicid); if (topic != null) { topic.Forum = Forums.GetForum(topic.ForumId); topic.IsArchived = true; } } return(topic); }
public static MemberInfo GetMember(string username) { if (String.IsNullOrEmpty(username)) { return(null); } List <int> roleList = new List <int> { 0 }; roleList.AddRange(SnitzCachedLists.UserRoles().Select(role => role.Key)); IMember dal = Factory <IMember> .Create("Member"); var member = dal.GetByName(username).FirstOrDefault(); if (!string.IsNullOrEmpty(member.Signature)) { member.ParsedSignature = member.Signature.ParseTags(); } member.AllowedForums = Forums.AllowedForums(member).ToArray(); // Run a search against the data store return(member); }
public static List <ForumJumpto> GetCachedForumList(bool search) { List <ForumJumpto> fullforumlist; if (HttpContext.Current.Cache["forumjumplist"] != null) { fullforumlist = (List <ForumJumpto>)HttpContext.Current.Cache["forumjumplist"]; } else { fullforumlist = Forums.ListForumJumpTo(); if (search && Config.AllowSearchAllForums) { fullforumlist.Insert(0, new ForumJumpto { Name = "[All Forums]", Id = -1, Category = "" }); } else if (fullforumlist[0].Id != -1) { fullforumlist.Insert(0, new ForumJumpto { Name = "[Select Forum]", Id = -99, Category = "" }); } HttpContext.Current.Cache["forumjumplist"] = fullforumlist; } return(fullforumlist); }
public static int AddForumSubscription(int memberid, int forumid) { ForumInfo forum = Forums.GetForum(forumid); ISubscription dal = Factory <ISubscription> .Create("Subscription"); return(dal.Add(new SubscriptionInfo { MemberId = memberid, ForumId = forumid, CategoryId = forum.CatId, TopicId = 0 })); }
public static List <MemberInfo> GetAvailableModerators(int forumId) { List <MemberInfo> moderators = new List <MemberInfo>(); foreach (ForumModeratorInfo moderator in Forums.GetAvailableModerators(forumId)) { moderators.Add(Members.GetMember(moderator.MemberId)); } return(moderators); }
public static IEnumerable <ForumInfo> GetCategoryForums(int categoryid, MemberInfo member) { IForum dal = Factory <IForum> .Create("Forum"); var allowedforums = Forums.AllowedForums(member); if (member == null) { allowedforums = Forums.ViewableForums(); } return(dal.GetByParent(categoryid).Where(catforum => allowedforums.Contains(catforum.Id))); }
public static Dictionary <int, string> GetCurrentModeratorsIdName(int forumId) { var moderators = Forums.GetForumModerators(forumId); Dictionary <int, string> myDictionary = new Dictionary <int, string>(); foreach (var moderator in moderators) { if (!myDictionary.Keys.Contains(moderator.Id)) { myDictionary.Add(moderator.MemberId, Members.GetMember(moderator.MemberId).Username); } } return(myDictionary); }
public static List <TopicInfo> GetLatestTopics(int topicCount) { string user = HttpContext.Current.User.Identity.Name; bool isadmin = Roles.IsUserInRole(user, "Administrator"); bool ismoderator = Roles.IsUserInRole(user, "Moderator"); ITopic dal = Factory <ITopic> .Create("Topic"); var topics = dal.GetLatestTopics(topicCount, ""); List <int> roleList = new List <int> { 0 }; roleList.AddRange(SnitzCachedLists.UserRoles().Select(role => role.Key)); List <TopicInfo> allowedTopics = new List <TopicInfo>(); foreach (var activeTopic in topics) { activeTopic.Forum = Forums.GetForum(activeTopic.ForumId); if (activeTopic.Status == 2 || activeTopic.Status == 3) { if (!(isadmin || ismoderator || user == activeTopic.AuthorName)) { continue; } } if (activeTopic.Forum.AllowedRoles.Count == 0) { allowedTopics.Add(activeTopic); } else { if (activeTopic.Forum.AllowedRoles.Any(role => roleList.Contains(role) || isadmin)) { allowedTopics.Add(activeTopic); } } } return(allowedTopics); }