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 <KeyValuePair <int, string> > AllowedForumsList(MemberInfo member) { List <int> roleList = new List <int> { 0 }; bool isadmin = Roles.IsUserInRole("Administrator"); roleList.AddRange(SnitzCachedLists.UserRoles().Select(role => role.Key)); IMember dal = Factory <IMember> .Create("Member"); return(new List <KeyValuePair <int, string> >(dal.GetAllowedForumList(member, roleList, isadmin))); }
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); }