public static void AddShout(User fromUser, int hostID, string message, string toUsername, int? chatID) { if (!String.IsNullOrEmpty(message) && (!fromUser.IsBanned)) { Shout shout = new Shout(); shout.HostID = hostID; shout.Message = TextHelper.EncodeAndReplaceComment(message); shout.FromUserID = fromUser.UserID; User toUser = null; if (!string.IsNullOrEmpty(toUsername)) { toUser = UserCache.GetUserByUsername(toUsername); shout.ToUserID = toUser.UserID; //record the event as an alert UserBR.AddUserAlertMessage(toUser.UserID, Incremental.Kick.Common.Enums.AlertMessageEnum.ProfileShoutComment); } if (chatID.HasValue) shout.ChatID = chatID; shout.Save(); if (!chatID.HasValue) { if (toUser == null) UserAction.RecordShout(hostID, fromUser); else UserAction.RecordShout(hostID, fromUser, toUser); } ShoutCache.Remove(hostID, shout.ToUserID, chatID); } }
public static WeightedTagList AddUserStoryTags(string tagString, User user, int storyID, int hostID) { WeightedTagList tags = GetOrInsertTags(tagString, user.IsAdministrator); StoryUserHostTagCollection storyUserHostTags = new StoryUserHostTagCollection(); foreach (WeightedTag tag in tags) { StoryUserHostTag storyUserHostTag = new StoryUserHostTag(); //TODO: GJ: move to WeightedTag.ToStoryUserHostTag() storyUserHostTag.StoryID = storyID; storyUserHostTag.HostID = hostID; storyUserHostTag.UserID = user.UserID; storyUserHostTag.TagID = tag.TagID; storyUserHostTags.Add(storyUserHostTag); StoryCache.ClearUserTaggedStories(tag.TagName, user.UserID, storyID); } storyUserHostTags.BatchSave(); UserAction.RecordTag(hostID, user, Story.FetchByID(storyID), tags); //when a user adds a tag, we need to mark the story as updated //so update the index during the incremental crawl Story story = Story.FetchByID(storyID); story.UpdatedOn = DateTime.Now; story.Save(); return tags; }
public static string AddStory(int hostID, string title, string description, string url, short categoryID, User user, string ipAddress) { if (user.IsBanned) return GetStoryIdentifier(title); //to stop the spammers //TODO: improve the validation string storyIdentifier = GetStoryIdentifier(title); if (description.Length > 2500) description = description.Substring(0, 2500); url = url.Trim(); if (url.Length > 980) throw new Exception("The url is too long"); title = HttpUtility.HtmlEncode(title); description = HttpUtility.HtmlEncode(description); Story story = new Story(); story.HostID = hostID; story.StoryIdentifier = storyIdentifier; story.Title = title; story.Description = description; story.Url = url; story.CategoryID = categoryID; story.UserID = user.UserID; story.KickCount = 0; story.SpamCount = 0; story.ViewCount = 0; story.CommentCount = 0; story.IsPublishedToHomepage = false; story.IsSpam = false; story.AdsenseID = user.AdsenseID; story.IPAddress = ipAddress; story.PublishedOn = DateTime.Now; story.UpdatedOn = DateTime.Now; story.Save(); UserAction.RecordStorySubmission(hostID, user, story); UserCache.KickStory(story.StoryID, user.UserID, hostID, ipAddress); TagBR.AddUserStoryTags(CategoryCache.GetCategory(categoryID, hostID).TagIdentifier, user, story.StoryID, hostID); System.Diagnostics.Trace.WriteLine("AddStory: " + title); //now send a trackback ping Host host = HostCache.GetHost(hostID); string storyUrl = host.RootUrl + "/" + CategoryCache.GetCategory(categoryID, hostID).CategoryIdentifier + "/" + story.StoryIdentifier; TrackbackHelper.SendTrackbackPing_Begin(url, title, storyUrl, "You've been kicked (a good thing) - Trackback from " + host.SiteTitle, host.SiteTitle); return story.StoryIdentifier; }
public static User GetUser(int userID) { CacheManager<string, User> userCache = GetUserCache(); string cacheKey = GetUserProfileCacheKey(userID); User user = userCache[cacheKey]; lock (_getUserLock) { if (user == null) { if (userID == 0) { user = new User(0); user.Username = "******"; } else { user = User.FetchByID(userID); } userCache.Insert(cacheKey, user, CacheHelper.CACHE_DURATION_IN_SECONDS, System.Web.Caching.CacheItemPriority.NotRemovable); } } return user; }
public static UserCollection GetOnlineUsers(int minutesSinceLastActive, int hostID, User userProfile) { string cacheKey = String.Format("OnlineUsers_{0}_{1}", minutesSinceLastActive, hostID); CacheManager<string, UserCollection> userCollectionCache = GetUserCollectionCache(); UserCollection users = userCollectionCache[cacheKey]; if (users == null) { users = User.FetchOnlineUsers(minutesSinceLastActive, hostID); userCollectionCache.Insert(cacheKey, users, 60, System.Web.Caching.CacheItemPriority.NotRemovable); } // If current user has permissions show all online users if (userProfile.IsModerator || userProfile.IsAdministrator) return users; // Otherwise show only users who choose to appear online users.RemoveAll(delegate(User user) { return !user.AppearOnline; }); return users; }
protected void btnChangeEmail_Click(object sender, EventArgs e) { if (Page.IsValid) { ChangeEmailPanel.Visible = false; if (!String.IsNullOrEmpty(Email.Text)) { Incremental.Kick.Dal.User userTable = UserBR.GetUserByEmail(Email.Text.Trim()); if (userTable == null) { Kick.Helpers.EmailHelper.SendChangedEmailEmail(Email.Text, this.KickPage.KickUserProfile.Username, this.KickPage.KickUserProfile.Email, this.KickPage.HostProfile); SuccessPanel.Visible = true; } else { FailedPanel.Visible = true; } } } }
public static void AddShout(User fromUser, int hostID, string message) { AddShout(fromUser, hostID, message, null, null); }
public void DataBind(User user) { this._user = user; }
public static void MarkAsSpam(int storyID, int hostID, User moderator) { Story story = Story.FetchByID(storyID); if (story.HostID != hostID) throw new ArgumentException("The story does not belong to the host"); else { story.IsSpam = true; story.UpdatedOn = DateTime.Now; story.Save(); UserAction.RecordStoryDeletion(hostID, story, moderator); EmailHelper.SendStoryDeletedEmail(Story.FetchByID(storyID), HostCache.GetHost(hostID)); } }
public static UserAction RecordStoryDeletion(int hostID, Story story, User moderator) { UserAction userAction = Create(hostID, moderator.UserID, ActionType.StoryDeletion); userAction.Message = String.Format(" deleted {0}", GetStoryLink(story)); userAction.Save(); return userAction; }
public Gravatar(User user, int size) { this._user = user; this._size = size; }
public UserProfileHeader(User user) { this.User = user; }
public static UserAction RecordUserUnBan(int hostID, User user, User moderator) { UserAction userAction = Create(hostID, moderator.UserID, ActionType.UserUnBan); userAction.ToUserID = user.UserID; UserLink userLink = new UserLink(user); userAction.Message = String.Format(" un-banned {0}", ControlHelper.RenderControl(userLink)); userAction.Save(); return userAction; }
public AnonymousKickPrincipal(IIdentity identity, User userProfile) : base(identity, userProfile) { }
public static UserAction RecordUserPassedTest(int hostID, User user) { UserAction userAction = Create(hostID, user.UserID, ActionType.UserPassedTest); UserLink userLink = new UserLink(user); userAction.Message = String.Format("passed the knowledge test, congratulations!", ControlHelper.RenderControl(userLink)); userAction.Save(); return userAction; }
public static UserAction RecordUserRegistration(int hostID, User user) { UserAction userAction = Create(hostID, user.UserID, ActionType.UserRegistration); userAction.Message = "has joined the site. Welcome!!"; userAction.Save(); return userAction; }
public static UserAction RecordUnKick(int hostID, User user, Story story) { UserAction userAction = Create(hostID, user.UserID, story.StoryID, ActionType.Kick); userAction.Message = String.Format("un-kicked {0}", GetStoryLink(story)); userAction.Save(); return userAction; }
public static UserAction RecordTag(int hostID, User user, Story story, WeightedTagList tags) { UserAction userAction = Create(hostID, user.UserID, story.StoryID, ActionType.Tag); if (tags.Count > 0) { TagCommaList tagList = new TagCommaList(); tagList.DataBind(tags, story.StoryID, false); userAction.Message = String.Format("tagged {0} with {1}", GetStoryLink(story), ControlHelper.RenderControl(tagList)); userAction.Save(); } return userAction; }
public static UserAction RecordStorySubmission(int hostID, User user, Story story) { UserAction userAction = Create(hostID, user.UserID, story.StoryID, ActionType.StorySubmission); userAction.Message = String.Format("submitted {0}", GetStoryLink(story)); userAction.Save(); return userAction; }
public static void SendUserUnBanEmail(User user, Host host) { Send_Begin(host.Email, user.Email, "[" + host.SiteTitle + "]", String.Format(@" A moderator has un-banned you from {0}. Welcome back!!", host.SiteTitle), host); }
public static void UnMarkAsSpam(int storyID, int hostID, User moderator) { Story story = Story.FetchByID(storyID); if (story.HostID != hostID) throw new ArgumentException("The media does not belong to the host"); else { story.IsSpam = false; story.UpdatedOn = DateTime.Now; story.Save(); } }
public void DataBind(User userProfile) { this._userProfile = userProfile; }
public static void SendUserBanEmail(User user, Host host) { Send_Begin(host.Email, user.Email, "[" + host.SiteTitle + "]", String.Format(@" A moderator has banned you from {0}. Please let us know if you think this was in error.", host.SiteTitle), host); }
public Gravatar(int userID, int size) { this._user = UserCache.GetUser(userID); this._size = size; }
public static UserAction RecordShout(int hostID, User user) { UserAction userAction = Create(hostID, user.UserID, ActionType.Shout); userAction.Message = "shouted something"; userAction.Save(); return userAction; }
public void UnBan(User moderator, Host host) { this.IsBanned = false; this.Save(); this.UpdateStoryCommentShoutSpamStatus(false); EmailHelper.SendUserUnBanEmail(this, host); UserAction.RecordUserUnBan(this.HostID, this, moderator); UserCache.RemoveUser(this.UserID); }
public UserLink(User user) { this.DataBind(user); }
public static UserAction RecordComment(int hostID, User user, Story story, int commentID) { UserAction userAction = Create(hostID, user.UserID, story.StoryID, ActionType.Comment); userAction.Message = String.Format("commented on {0}", GetStoryLink(story, commentID)); userAction.Save(); return userAction; }
public static UserAction RecordShout(int hostID, User user, User toUser) { UserAction userAction = Create(hostID, user.UserID, ActionType.Shout); UserLink userLink = new UserLink(toUser); userAction.Message = String.Format("shouted something on {0}'s profile", ControlHelper.RenderControl(userLink)); userAction.Save(); return userAction; }
public KickPrincipal(IIdentity identity, User userProfile) : base(identity, userProfile.Roles.Split('|')) { this._userProfile = userProfile; }
public static int GetOnlineUsersCount(int minutesSinceLastActive, int hostID, User userProfile) { return GetOnlineUsers(minutesSinceLastActive, hostID, userProfile).Count; }