Closed GoogleCodeExporter closed 9 years ago
Not that hard to do. Deleting the story is the same as marking it as spam.
In StoryBR.cs Add:
public static void UnMarkAsSpam(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 = false;
story.UpdatedOn = DateTime.Now;
story.Save();
// Might want to delete the RecordStoryDeletion action // TODO
// UserAction.RecordStoryDeletion(hostID, story, moderator);
// EmailHelper.SendStoryDeletedEmail(Story.FetchByID(storyID),
HostCache.GetHost(hostID));
}
}
In ajaxServices.ashx add:
[JsonRpcMethod("moderatorUnMarkAsSpam")]
public void ModeratorUnMarkAsSpam(int storyID)
{
DemandModeratorRole();
StoryBR.UnMarkAsSpam(storyID, HostProfile.HostID, KickUserProfile);
}
In hostmoderator.js add:
function UnDelete(storyID) {
if(confirm("Are you sure you want to undelete this story?")) {
StartLoading();
ajaxServices.moderatorUnMarkAsSpam(storyID, function(response) {
FinishLoading(); });
}
}
Now comes the harder part, if story==null or story.IsSpam the view page
redirects
you, so it now needs some rewiring:
Change View.aspx.cs _load
if (story == null || story.IsSpam && !this.KickUserProfile.IsModerator)
Response.Redirect("/missingstory");
This will allow the story to always load if you are a moderator.
In StorySummary.cs - Change Render delete link to:
// Render delete story link
if(KickPage.IsHostModerator)
{
string deleteText = "delete";
if(_story.SpamCount > 0)
deleteText += " (spam count is " + _story.SpamCount + ")";
if (_story.IsSpam)
{
writer.WriteLine(
@" |
<span class=""ModeratorLink""><a
href=""javascript:UnDelete({0});"">{1}</a></span>
",
_story.StoryID, "un" + deleteText);
}
else
{
writer.WriteLine(
@" |
<span class=""ModeratorLink""><a
href=""javascript:Delete({0});"">{1}</a></span>
",
_story.StoryID, deleteText);
}
}
Works for me. :)
Since the stories are cached it takes a few minutes to reflect the change.
Original comment by DustinBr...@gmail.com
on 8 Jan 2008 at 9:23
Original comment by DustinBr...@gmail.com
on 17 Jan 2008 at 8:15
Checked in after downloading latest revision - also added plusviewcount on image
clicks (icon aarow out and preview img) and read more clicks. Also in this
revision
is the fade out div/delete after using delete or report as spam.
Original comment by DustinBr...@gmail.com
on 17 Jan 2008 at 9:59
Original issue reported on code.google.com by
yesthatm...@gmail.com
on 2 Jan 2008 at 6:26