Пример #1
0
        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);
            }
        }
Пример #2
0
        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;
        }
Пример #3
0
        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;
        }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #6
0
        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;
                    }
                }
            }
        }
Пример #7
0
 public static void AddShout(User fromUser, int hostID, string message)
 {
     AddShout(fromUser, hostID, message, null, null);
 }
Пример #8
0
 public void DataBind(User user)
 {
     this._user = user;
 }
Пример #9
0
        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));
            }
        }
Пример #10
0
 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;
 }
Пример #11
0
 public Gravatar(User user, int size)
 {
     this._user = user;
     this._size = size;
 }
Пример #12
0
 public UserProfileHeader(User user)
 {
     this.User = user;
 }
Пример #13
0
 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)
 {
 }
Пример #15
0
 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;
 }
Пример #16
0
 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;
 }
Пример #17
0
 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;
 }
Пример #18
0
        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;
        }
Пример #19
0
 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;
 }
Пример #20
0
 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);
 }
Пример #21
0
 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();
     }
 }
Пример #22
0
 public void DataBind(User userProfile)
 {
     this._userProfile = userProfile;
 }
Пример #23
0
        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);
        }
Пример #24
0
 public Gravatar(int userID, int size)
 {
     this._user = UserCache.GetUser(userID);
     this._size = size;
 }
Пример #25
0
 public static UserAction RecordShout(int hostID, User user)
 {
     UserAction userAction = Create(hostID, user.UserID, ActionType.Shout);
     userAction.Message = "shouted something";
     userAction.Save();
     return userAction;
 }
Пример #26
0
        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);
        }
Пример #27
0
 public UserLink(User user)
 {
     this.DataBind(user);
 }
Пример #28
0
 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;
 }
Пример #29
0
 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;
 }
Пример #30
0
 public KickPrincipal(IIdentity identity, User userProfile)
     : base(identity, userProfile.Roles.Split('|'))
 {
     this._userProfile = userProfile;
 }
Пример #31
0
 public static int GetOnlineUsersCount(int minutesSinceLastActive, int hostID, User userProfile)
 {
     return GetOnlineUsers(minutesSinceLastActive, hostID, userProfile).Count;
 }