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 string ReplaceBadWords(this string text) { const RegexOptions matchOptions = RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Singleline; if (!Config.FilterBadWords || String.IsNullOrEmpty(text)) { return(text); } List <BadwordInfo> bWords = SnitzCachedLists.GetCachedBadWordList(); string[] ReplaceText = new string[bWords.Count]; string[] BadWords = new string[bWords.Count]; int ii = 0; foreach (BadwordInfo dr in bWords) { string bw = dr.Badword; BadWords[ii] = Regex.Escape(bw); ReplaceText[ii] = dr.Replace; ++ii; } string strBadWords = String.Join("|", BadWords); try { Regex regexObj = new Regex(@"\b" + strBadWords, matchOptions); Match matchObj = regexObj.Match(text); while (matchObj.Success) { int pos = Array.IndexOf(BadWords, Regex.Escape(matchObj.Value)); string rText = ReplaceText[pos]; text = Regex.Replace(text, matchObj.Value, rText, matchOptions); matchObj = matchObj.NextMatch(); } } catch { // Most likely cause is a syntax error in the regular expression // throw (ex); return(text); } return(text); }
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); }