/// <summary> /// Posts a message to the editor of an article that it has been submitted to a review forum /// </summary> /// <param name="submitterID"></param> /// <param name="editorID"></param> /// <param name="userName"></param> /// <param name="H2G2ID"></param> /// <param name="siteID"></param> /// <param name="reviewForumID"></param> /// <param name="forumID"></param> /// <param name="threadID"></param> /// <param name="postID"></param> /// <param name="subject"></param> /// <param name="comments"></param> public void NotifyAuthorOnPersonalSpace(int submitterID, int editorID, string userName, int H2G2ID, int siteID, int reviewForumID, int forumID, int threadID, int postID, string subject, string comments) { XmlElement submitReviewForum = AddElementTag(RootElement, "SUBMIT-REVIEW-FORUM"); int userForumID = 0; using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("fetchpersonalspaceforum")) { dataReader.AddParameter("userid", editorID); dataReader.AddParameter("siteid", siteID); dataReader.Execute(); // Check to see if we found anything if (dataReader.HasRows && dataReader.Read()) { userForumID = dataReader.GetInt32NullAsZero("ForumID"); } } if (userForumID == 0) { throw new DnaException("No Personal Space Forum - Failed to send message to Personal Space"); } if (submitterID == 0) { AddErrorXml("NO-USER","Failed to get User details", submitReviewForum); } User submitter = new User(InputContext); submitter.CreateUser(submitterID); string submitterName = submitter.UserName; ReviewForum reviewForum = new ReviewForum(InputContext); reviewForum.InitialiseViaReviewForumID(reviewForumID, false); string generatedSubject = "Your entry has been submitted to '" + reviewForum.ReviewForumName + "'"; string generatedBody = "Entry: " + subject + " - A" + H2G2ID + " \n"; generatedBody += "Author: " + userName + " - U" + editorID + " \n"; generatedBody += "Submitter: " + submitterName + " - U" + submitterID + "\n\n"; generatedBody += "This is an automated message.\n\n"; generatedBody += "Your entry above has been submitted to the Review Forum '" + reviewForum.ReviewForumName + "'" + " by the Researcher named above. For more information about what happens next check out <./>ReviewForums-Next</.>.\n\n"; generatedBody += "You can see the discussion about your entry at " + "F" + forumID + "?thread=" + threadID + "\n\n"; generatedBody += "If you'd rather your entry wasn't in this Review Forum then you can remove it by visiting " + "<./>" + reviewForum.UrlFriendlyName + "</.> and clicking on the relevant 'Remove' link." + " To prevent it being put into a Review Forum in the future, please click on the 'Edit Entry' button and tick the 'Not for Review' box.\n\n"; if (forumID > 0) { // Check the user input for profanities! //ProfanityFilter profanityFilter = new ProfanityFilter(InputContext); string matchingProfanity = String.Empty; List<Term> terms = null; ProfanityFilter.FilterState filterState = ProfanityFilter.CheckForProfanities(InputContext.CurrentSite.ModClassID, generatedSubject + " " + generatedBody, out matchingProfanity, out terms, forumID); bool forceModeration = false; if (filterState == ProfanityFilter.FilterState.FailBlock) { AddErrorXml("profanityblocked", matchingProfanity, submitReviewForum); return; } else if (filterState == ProfanityFilter.FilterState.FailRefer) { forceModeration = true; } if(InputContext.GetSiteOptionValueBool("General", "IsURLFiltered") && !(InputContext.ViewingUser.IsEditor || InputContext.ViewingUser.IsNotable)) { URLFilter URLFilter = new URLFilter(InputContext); List<string> nonAllowedURLs = new List<string>(); URLFilter.FilterState URLFilterState = URLFilter.CheckForURLs(generatedSubject + " " + generatedBody, nonAllowedURLs); if (URLFilterState == URLFilter.FilterState.Fail) { //return immediately - these don't get submitted AddErrorXml("nonAllowedURLsFound", "For example " + nonAllowedURLs[0], submitReviewForum); return; } } //Filter for email addresses. if (InputContext.GetSiteOptionValueBool("Forum", "EmailAddressFilter") && !(InputContext.ViewingUser.IsEditor || InputContext.ViewingUser.IsNotable)) { if (EmailAddressFilter.CheckForEmailAddresses(generatedSubject + " " + generatedBody)) { //return immediately - these don't get submitted AddErrorXml("EmailAddressFilter", "Email Address Found.", submitReviewForum); return; } } string hash = String.Empty; string hashString = generatedSubject + "<:>" + generatedBody + "<:>" + submitterID + "<:>" + userForumID + "<:>0"; // Setup the stored procedure object using (IDnaDataReader reader = InputContext.CreateDnaDataReader("posttoforum")) { reader.AddParameter("userID", submitterID); reader.AddParameter("forumid", userForumID); reader.AddParameter("inreplyto", DBNull.Value); reader.AddParameter("threadid", DBNull.Value); reader.AddParameter("subject", generatedSubject); reader.AddParameter("content", generatedBody); reader.AddParameter("poststyle", 2); reader.AddParameter("Hash", DnaHasher.GenerateHash(hashString)); reader.AddParameter("forcemoderation", forceModeration); // Now call the procedure reader.Execute(); } } }