Beispiel #1
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;
        }
        /// <summary>
        /// Returns a string containing the tags for a given story, seperated
        /// by a space
        /// </summary>
        /// <param name="story"></param>
        /// <returns></returns>
        private string GetStoryTags(Story story)
        {
            TagCollection tags = Tag.FetchStoryTags(story.StoryID);
            StringBuilder sb = new StringBuilder();

            foreach (Tag tag in tags)
            {
                sb.Append(tag.TagIdentifier);
                sb.Append(' ');
            }

            return sb.ToString();
        }
Beispiel #3
0
 private static string GetStoryLink(Story story, int commentID)
 {
     return(string.Format(@"<a href=""/{0}/{1}#Comment_{3}"">{2}</a>", story.Category.CategoryIdentifier, story.StoryIdentifier, story.Title, commentID));
 }
Beispiel #4
0
 private static string GetStoryLink(Story story)
 {
     return(string.Format(@"<a href=""/{0}/{1}"">{2}</a>", story.Category.CategoryIdentifier, story.StoryIdentifier, story.Title));
 }
Beispiel #5
0
 public static Story FetchStoryByUrl(string url)
 {
     return(Story.FetchStoryByParameter(Story.Columns.Url, url));
 }
 // [rgn] Public Methods (2)
 /// <summary>
 /// binds the datas
 /// </summary>
 /// <param name="story">The story.</param>
 public void DataBind(Story story)
 {
     DataBind(story, true);
 }
Beispiel #7
0
 private static int GetStoryScore(Story story, Host host)
 {
     int score = 0;
     score += story.KickCount * host.Publish_KickScore;
     score += story.CommentCount * host.Publish_CommentScore;
     System.Diagnostics.Trace.WriteLine("Pub: Score of [" + score + "] for storyID " + story.StoryID);
     return score;
 }
Beispiel #8
0
 public bool Destroy(object StoryID)
 {
     return(Story.Destroy(StoryID) == 1);
 }
Beispiel #9
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;
 }
Beispiel #10
0
 public static UserAction RecordStoryPromotion(int hostID, Story story)
 {
     UserAction userAction = new UserAction();
     userAction.HostID = hostID;
     userAction.StoryID = story.StoryID;
     userAction.UserActionTypeID = (int)ActionType.StoryPromotion;
     userAction.Message = String.Format("{0} was published to homepage", GetStoryLink(story));
     userAction.Save();
     return userAction;
 }
Beispiel #11
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;
 }
Beispiel #12
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;
 }
Beispiel #13
0
        public static void SendStoryDeletedEmail(Story story, Host host)
        {
            Send_Begin(host.Email, story.User.Email, "[" + host.SiteTitle + "]",
                String.Format(@"
                Your post

                '{0}'
                '{1}'

                was deleted by a moderator.

                Please let us know if you think this was in error.", story.Title, story.Description), host);
        }
Beispiel #14
0
 public static CommentCollection FetchCommentsByStoryID(int storyID)
 {
     return(Story.FetchByID(storyID).CommentRecords());
 }
        public void Insert(int HostID,string StoryIdentifier,string Title,string Description,string Url,short CategoryID,int UserID,int KickCount,int SpamCount,int ViewCount,int CommentCount,bool IsPublishedToHomepage,bool IsSpam,string AdsenseID,DateTime CreatedOn,DateTime PublishedOn,DateTime UpdatedOn,string IPAddress)
        {
            Story item = new Story();

            item.HostID = HostID;

            item.StoryIdentifier = StoryIdentifier;

            item.Title = Title;

            item.Description = Description;

            item.Url = Url;

            item.CategoryID = CategoryID;

            item.UserID = UserID;

            item.KickCount = KickCount;

            item.SpamCount = SpamCount;

            item.ViewCount = ViewCount;

            item.CommentCount = CommentCount;

            item.IsPublishedToHomepage = IsPublishedToHomepage;

            item.IsSpam = IsSpam;

            item.AdsenseID = AdsenseID;

            item.CreatedOn = CreatedOn;

            item.PublishedOn = PublishedOn;

            item.UpdatedOn = UpdatedOn;

            item.IPAddress = IPAddress;

            item.Save(UserName);
        }
        /// <summary>
        /// Returns a string containing the usernames of users
        /// that kicked the story. The usernames are seperated
        /// by a space
        /// </summary>
        /// <param name="story">story to return the usernames for</param>
        /// <returns>string containing the usernames of users that kicked
        /// the story</returns>
        private string GetUserWhoKickedSearchString(Story story)
        {
            //dont use the cache since this maybe stale, we need
            //to get the data directly from the database otherwise
            //index wont be as fresh as could be, plus we could just
            //bloat the cache with the crawl
            UserCollection users = story.UsersWhoKicked;
            StringBuilder sb = new StringBuilder();

            foreach (User u in users)
            {
                sb.Append(u.Username);
                sb.Append(' ');
            }

            return sb.ToString();
        }
Beispiel #17
0
 public bool Delete(object StoryID)
 {
     return(Story.Delete(StoryID) == 1);
 }
Beispiel #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;
        }
Beispiel #19
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;
 }
Beispiel #20
0
 private static string GetStoryLink(Story story)
 {
     return string.Format(@"<a href=""/{0}/{1}"">{2}</a>", story.Category.CategoryIdentifier, story.StoryIdentifier, story.Title);
 }
Beispiel #21
0
        private static bool IsWeakStory(Story story, Host host)
        {
            if ((story.KickCount < host.Publish_MinimumStoryKickCount) || (story.CommentCount < host.Publish_MinimumStoryCommentCount))
                return true;

            //TODO: check the average kicks and comments per hour
            //TODO: check the view count

            return false;
        }
Beispiel #22
0
 private static string GetStoryLink(Story story, int commentID)
 {
     return string.Format(@"<a href=""/{0}/{1}#Comment_{3}"">{2}</a>", story.Category.CategoryIdentifier, story.StoryIdentifier, story.Title, commentID);
 }
 /// <summary>
 /// binds the datas
 /// </summary>
 /// <param name="story">The story.</param>
 /// <param name="isOddRow">if set to <c>true</c> [is odd row].</param>
 public void DataBind(Story story, bool isOddRow)
 {
     _story = story;
     _isOddRow = isOddRow;
 }
Beispiel #24
0
 public static Story FetchStoryByIdentifier(string storyIdentifier)
 {
     return(Story.FetchStoryByParameter(Story.Columns.StoryIdentifier, storyIdentifier));
 }