/// <summary>
        /// Updates the review forum with the supplied data if it is valid, otherwise
		///		produces the form with valid error messages, false if it didn't handle the reques
        /// </summary>
        /// <param name="reviewForumID"></param>
        /// <param name="name"></param>
        /// <param name="url"></param>
        /// <param name="recommendable"></param>
        /// <param name="incubateTime"></param>
        /// <param name="currentSiteID"></param>
        /// <returns></returns>
        public bool RequestUpdate(int reviewForumID, string name, string url, bool recommendable, int incubateTime, int currentSiteID)
        {
            ReviewForum reviewForum = new ReviewForum(InputContext);

            reviewForum.InitialiseViaReviewForumID(reviewForumID, true);

            if (!reviewForum.IsInitialised)
            {
                AddErrorXml("BADID", "Invalid Review Forum ID", RootElement);
                return false;
            }

            //check that the site the request is from is the same as the site for the reviewforum
            if (reviewForum.SiteID != currentSiteID)
            {
                AddErrorXml("SITE", "This review forum does not belong to this site", RootElement);
                return false;
            }

            reviewForum.Update(name, url, recommendable, incubateTime);

            XmlElement success = AddElementTag(RootElement, "SUCCESS");
            AddAttribute(success, "TYPE", "UPDATE");

            AddInside(reviewForum);
            return true;
        }
Beispiel #2
0
        /// <summary>
        /// Functions generates the Try Create Review Forum Builder XML
        /// </summary>
        /// <param name="ID">ID of the review forum to get</param>
        /// <param name="skip">Number to skip</param>
        /// <param name="show">Number to show</param>
        /// <param name="orderBy">Ordering of the review forum</param>
        /// <param name="direction">Direction of ordering </param>
        /// <param name="entry">Whether we need to add a description at the top</param>
        public void TryCreateReviewForumBuilderXML(int ID, int skip, int show, ReviewForum.OrderBy orderBy, bool direction, bool entry)
        {
            ReviewForum reviewForum = new ReviewForum(InputContext);

            reviewForum.InitialiseViaReviewForumID(ID, false);

            if (SwitchSites(reviewForum.SiteID, ID, skip, show, orderBy, direction, entry))
            {
                return;
            }

            reviewForum.GetReviewForumThreadList(show, skip, orderBy, direction);
            //add the entry 
            if (entry)
            {
                GuideEntrySetup guideEntrySetup = new GuideEntrySetup(reviewForum.H2G2ID);
                //guideEntrySetup.ShowReferences = true;
                guideEntrySetup.SafeToCache = true;

                GuideEntry guideEntry = new GuideEntry(InputContext, guideEntrySetup);
                guideEntry.Initialise();

                _GuideEntryElement = CreateElement("ROOT");
                _GuideEntryElement.AppendChild(ImportNode(guideEntry.RootElement.FirstChild));
            }
            //add the fact that we don't want/have an entry
            else
            {
                _GuideEntryElement = CreateElement("ROOT");
                AddElementTag(_GuideEntryElement, "NOGUIDE");
            }

            AddInside(reviewForum);
        }
Beispiel #3
0
        public void Test01GetReviewForumTest()
        {
            Console.WriteLine("Before ReviewForumTests - GetReviewForumTest");

            ReviewForum reviewForum = new ReviewForum(_context);

            reviewForum.InitialiseViaReviewForumID(1, true);

            XmlElement xml = reviewForum.RootElement;

            Assert.IsTrue(xml.SelectSingleNode("REVIEWFORUM") != null, "The xml is not generated correctly!!!");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();

            Console.WriteLine("After ReviewForumTests - GetReviewForumTest");
        }
Beispiel #4
0
        bool SwitchSites(int siteID, int ID, int skip, int show, ReviewForum.OrderBy orderBy, bool direction, bool entry)
        {
	        if (siteID != InputContext.CurrentSite.SiteID)
	        {
		        string URL = "RF" + ID;
		        URL += "&Skip=" + skip;
		        URL += "&Show=" + show;

			    URL += "&Order=" + orderBy.ToString();
			    URL += "&Dir=" + direction;
                URL += "&Entry=" + entry;

                return true;
	        }

	        return false;
        }
Beispiel #5
0
        /// <summary>
        /// Gets the params for the page
        /// </summary>
        /// <param name="ID">ID of the review forum to get</param>
        /// <param name="skip">Number to skip</param>
        /// <param name="show">Number to show</param>
        /// <param name="orderBy">Ordering of the review forum</param>
        /// <param name="direction">Direction of ordering </param>
        /// <param name="entry">Whether we need to add a description at the top</param>
        private void TryGetPageParams(ref int ID, ref int skip, ref int show, ref ReviewForum.OrderBy orderBy, ref bool direction, ref bool entry)
        {
            ID = InputContext.GetParamIntOrZero("ID", _docDnaID);
            if (ID <= 0)
            {
                throw new DnaException("Review Forum Builder - No Review Forum ID passed in.");
            }
	        skip = 0;
	        show = 20;       	
	        // get the skip and show parameters if any
            if (InputContext.DoesParamExist("Skip", _docDnaSkip))
	        {
                skip = InputContext.GetParamIntOrZero("Skip", _docDnaSkip);
                if (skip < 0)
		        {
                    skip = 0;
		        }
	        }
            if (InputContext.DoesParamExist("Show", _docDnaShow))
	        {
                show = InputContext.GetParamIntOrZero("Show", _docDnaShow);
                if (show <= 0)
		        {
                    show = 20;
		        }
	        }

            direction = false;
            if (InputContext.DoesParamExist("Dir", _docDnaDirection))
            {
                int dir = InputContext.GetParamIntOrZero("Dir", _docDnaDirection);
                if (dir == 1)
                {
                    direction = true;
                }
                else
                {
                    direction = false;
                }
            }

            entry = true;
            //check whether we need to add a guideentry description at the top
            if (InputContext.DoesParamExist("Entry", _docDnaEntry))
            {
                int showEntryBody = InputContext.GetParamIntOrZero("Entry", _docDnaEntry);
                if (showEntryBody == 1)
                {
                    entry = true;
                }
                else
                {
                    entry = false;
                }
            }

            orderBy = ReviewForum.OrderBy.LASTPOSTED;
            if (InputContext.DoesParamExist("Order", _docDnaOrder))
	        {
                string order = InputContext.GetParamStringOrEmpty("Order", _docDnaOrder);

                if (order == "dateentered")
		        {
                    orderBy = ReviewForum.OrderBy.DATEENTERED;
		        }
		        else if(order == "lastposted")
		        {
                    orderBy = ReviewForum.OrderBy.LASTPOSTED;
		        }
		        else if(order == "authorid")
		        {
                    orderBy = ReviewForum.OrderBy.AUTHORID;
		        }
		        else if(order == "authorname")
		        {
                    orderBy = ReviewForum.OrderBy.AUTHORNAME;
		        }
		        else if (order == "entry")
		        {
                    orderBy = ReviewForum.OrderBy.H2G2ID;
		        }
		        else if (order == "subject")
		        {
                    orderBy = ReviewForum.OrderBy.SUBJECT;
		        }
		        else
		        {
                    orderBy = ReviewForum.OrderBy.LASTPOSTED;
		        }
	        }

        }
Beispiel #6
0
        /// <summary>
        /// Creates the entry's data
        /// </summary>
        /// <param name="parentNode">The node that you want to add the xml to</param>
        private void AddEntryData(XmlNode parentNode)
        {
            // Add the various peices of data to the tree
            AddStatusTag(parentNode, _status);
            AddIntElement(parentNode, "H2G2ID", _h2g2ID);

            // Now the create the Submittable XML
            XmlNode submittableNode = AddElementTag(parentNode, "SUBMITTABLE");

            // See if we're user generated
            if (_status == 3)
            {
                int forumID = 0;
                int threadID = 0;
                int postID = 0;
                int reviewForumID = 0;

                // Fetch the entries review forum details
                using (IDnaDataReader reader = InputContext.CreateDnaDataReader("fetchreviewforummemberdetails"))
                {
                    reader.AddParameter("h2g2id", _h2g2ID);
                    reader.Execute();

                    // Make sure we got something back
                    if (reader.HasRows && reader.Read())
                    {
                        forumID = reader.GetInt32("ForumID");
                        threadID = reader.GetInt32("ThreadID");
                        postID = reader.GetInt32("PostID");
                        reviewForumID = reader.GetInt32("ReviewForumID");

                        // Set the type attribute
                        AddAttribute(submittableNode, "TYPE", "IN");

                        // Create the ReviewForum object and insert it into the entry
                        ReviewForum reviewForum = new ReviewForum(InputContext);
                        reviewForum.InitialiseViaReviewForumID(reviewForumID, true);
                        submittableNode.AppendChild(ImportNode(reviewForum.RootElement));

                        // Now insert the rest
                        XmlNode forumNode = AddElementTag(submittableNode, "FORUM");
                        AddAttribute(forumNode, "ID", forumID);
                        XmlNode threadNode = AddElementTag(submittableNode, "THREAD");
                        AddAttribute(threadNode, "ID", threadID);
                        XmlNode postNode = AddElementTag(submittableNode, "POST");
                        AddAttribute(postNode, "ID", postID);
                    }
                    else if (IsSubmittable)
                    {
                        // Set the type attribute
                        AddAttribute(submittableNode, "TYPE", "YES");
                    }
                    else
                    {
                        // Set the type attribute
                        AddAttribute(submittableNode, "TYPE", "NO");
                    }
                }
            }
        }
        /// <summary>
        /// Adds in a new edit review forum
        /// </summary>
        /// <param name="name"></param>
        /// <param name="url"></param>
        /// <param name="recommendable"></param>
        /// <param name="incubateTime"></param>
        /// <param name="currentSiteID"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public bool DoAddNew(string name, string url, bool recommendable, int incubateTime, int currentSiteID, int userID)
        {
            if (name == String.Empty)
            {
                AddErrorXml("BADNAME", "The review forum name is invalid", RootElement);
                return false;
            }

            if (url == String.Empty || url.IndexOf(" ") >= 0)
            {
                AddErrorXml("BADURL", "The url name is invalid", RootElement);
                return false;
            }

            if (incubateTime < 0)
            {
                AddErrorXml("BADINCUBATE", "The incubate time is invalid", RootElement);
                return false;
            }

            ReviewForum reviewForum = new ReviewForum(InputContext);

            if (!reviewForum.AreNamesUniqueWithinSite(name, url, currentSiteID))
            {
                AddErrorXml("BADNAMES", "The names supplied already exist for this site", RootElement);
                return false;
            }

            try
            {
                reviewForum.CreateAndInitialiseNewReviewForum(name, url, incubateTime, recommendable, currentSiteID, userID);

                XmlElement success = AddElementTag(RootElement, "SUCCESS");
                AddAttribute(success, "TYPE", "ADDNEW");
            }
            catch (DnaException ex)
            {
                AddElementTag(RootElement, "BLANKFORM");
                AddErrorXml("ADDNEW", "There was an error while adding the review forum." + ex.Message, RootElement);

                reviewForum.InitialiseFromData(0, name, url, incubateTime, recommendable, 0, userID);
            }

            AddInside(reviewForum);

            return true;
        }
        /// <summary>
        /// Creates the EditReviewForumForm with data from the reviewforum
        /// </summary>
        /// <param name="reviewForumID"></param>
        /// <param name="currentSiteID"></param>
        /// <returns>true if created from database or if it generated a proper error</returns>
        public bool CreateFromDB(int reviewForumID, int currentSiteID)
        {
	        ReviewForum reviewForum = new ReviewForum(InputContext);
        	
            reviewForum.InitialiseViaReviewForumID(reviewForumID, true);

            if (!reviewForum.IsInitialised)
	        {
		        AddErrorXml("BADID", "Invalid Review Forum ID", RootElement);
		        return false;
	        }

	        if (reviewForum.SiteID != currentSiteID)
	        {
                AddErrorXml("SITE", "This review forum does not belong to this site", RootElement);
		        return false;
	        }

            AddInside(reviewForum);
            return true;
        }
Beispiel #9
0
        private void PerformTest(ReviewForum.OrderBy orderBy)
        {
            int forumID = SubmitArticleForReview();
            ReviewForum reviewForum = new ReviewForum(_context);

            reviewForum.InitialiseViaReviewForumID(1, true);

            reviewForum.GetReviewForumThreadList(20, 0, orderBy, false);

            XmlElement xml = reviewForum.RootElement;

            Assert.IsTrue(xml.SelectSingleNode("REVIEWFORUM/REVIEWFORUMTHREADS") != null, "The xml is not generated correctly!!!");
            
            Assert.IsTrue(xml.SelectSingleNode("REVIEWFORUM/REVIEWFORUMTHREADS[@ORDERBY='" + ((int) orderBy).ToString() +"']") != null, "The xml is not generated correctly - ORDER BY!!!");

            DnaXmlValidator validator = new DnaXmlValidator(xml.InnerXml, _schemaUri);
            validator.Validate();
        }
Beispiel #10
0
        private bool RecommendEntry(int H2G2ID)
        {
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("fetchreviewforummemberdetails"))
            {
                dataReader.AddParameter("h2g2id", H2G2ID);
                dataReader.Execute();

                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    int reviewForumID = dataReader.GetInt32NullAsZero("ReviewForumID");
                    DateTime dateEntered = dataReader.GetDateTime("DateEntered");
                    DateTime dateNow = DateTime.Now;
                    TimeSpan dateDiff = dateNow - dateEntered;

		            ReviewForum reviewForum = new ReviewForum(InputContext);
                    reviewForum.InitialiseViaReviewForumID(reviewForumID, false);

                    if (reviewForum.IsInitialised)
		            {
			            if (reviewForum.IsRecommendable)
			            {
				            int incubateTime = reviewForum.IncubateTime;

                            if (dateDiff.Days >= incubateTime)
				            {
					            return true;
				            }
			            }
            			
		            }
                }
	        }

	        return false;

        }
        /// <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();
                }
	        }
        }
        /// <summary>
        /// Remove the thread from the Forum
        /// </summary>
        /// <param name="userID"></param>
        /// <param name="rFID"></param>
        /// <param name="H2G2ID"></param>
        /// <param name="threadID"></param>
        /// <param name="forumID"></param>
        /// <param name="hasPermission"></param>
        public void RemoveThreadFromForum(int userID, int rFID, int H2G2ID, ref int threadID, ref int forumID, bool hasPermission)
        {
            XmlElement submitReviewForum = AddElementTag(RootElement, "SUBMIT-REVIEW-FORUM");
            if (rFID <= 0 || H2G2ID <= 0)
            {
                AddErrorXml("RMBADID", "Bad arguments for this action", submitReviewForum);
                return;
            }

            //Initialise the article
            GuideEntrySetup guideSetup = new GuideEntrySetup(H2G2ID);
            guideSetup.ShowEntryData = true;
            guideSetup.ShowPageAuthors = false;
            guideSetup.ShowReferences = false;

            GuideEntry guideEntry = new GuideEntry(InputContext, guideSetup);
            guideEntry.Initialise();

            int postID = 0;

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("fetchreviewforummemberdetails"))
            {
                dataReader.AddParameter("h2g2id", H2G2ID);
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    int submitterID = dataReader.GetInt32NullAsZero("SubmitterID");
                    postID = dataReader.GetInt32NullAsZero("PostID");
                    threadID = dataReader.GetInt32NullAsZero("ThreadID");
                    forumID = dataReader.GetInt32NullAsZero("ForumID");
                    int actualReviewForumID = dataReader.GetInt32NullAsZero("ReviewForumID");

	                //make sure that we are in the right review forum for the article
                    if (rFID != actualReviewForumID)
                    {
                        AddErrorXml("BADRFID", "The article is in a different review forum.", submitReviewForum);
                        return;
                    }

                	//Permission has been verified by the caller so don't check
                    if (!hasPermission)
                    {
 		                //ok if you're an editor
                        if (!InputContext.ViewingUser.IsEditor)
                        {
                            //ok if you are the author
                            if (!(guideEntry.AuthorsUserID == InputContext.ViewingUser.UserID))
                            {
                                //ok if you are the submitter
                                if (!(InputContext.ViewingUser.UserID == submitterID))
                                {
                                    AddErrorXml("BADUSER", "You do not have permission to move the thread", submitReviewForum);
                                }
                            }
                        }
                   }
                }
                else
                {
                    AddErrorXml("BADH2G2ID", "The article is not in a review forum.", submitReviewForum);
                    return;
                }
            }

            ReviewForum reviewForum = new ReviewForum(InputContext);
            reviewForum.InitialiseViaReviewForumID(rFID, false);
            if (!reviewForum.IsInitialised)
            {
                AddErrorXml("NOREVIEW", "Invalid Review Forum ID", submitReviewForum);
                return;
            }

            bool movedThread = false;

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("MoveThread2"))
            {
                dataReader.AddParameter("ThreadID", threadID);
                dataReader.AddParameter("ForumID", guideEntry.ForumID);
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    movedThread = dataReader.GetBoolean("Success");
                }
            }
            if(!movedThread)
            {
                AddErrorXml("NOMOVE", "Failed to move thread to article", submitReviewForum);
                return;
            }

            int removedFromPeerReview = 0;
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("removearticlefrompeerreview"))
            {
                dataReader.AddParameter("H2G2ID", H2G2ID);
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    removedFromPeerReview = dataReader.GetInt32NullAsZero("Success");
                }
            }

            bool undoneThread = false;
            if (removedFromPeerReview == 0)
            {
                using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("UndoThreadMove"))
                {
                    dataReader.AddParameter("ThreadID", threadID);
                    dataReader.AddParameter("PostID", 0);
                    dataReader.Execute();
                    // Check to see if we found anything
                    if (dataReader.HasRows && dataReader.Read())
                    {
                        undoneThread = dataReader.GetBoolean("Success");
                    }
                }
                if (!undoneThread)
                {
                    AddErrorXml("HALFMOVE", "The thread has been moved, but not from review", submitReviewForum);
                    return;
                }
                else
                {
                    AddErrorXml("NOMOVE", "Failed to move thread to article", submitReviewForum);
                    return;
                }
            }

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("ForceUpdateEntry"))
            {
                dataReader.AddParameter("H2G2ID", H2G2ID);
                dataReader.Execute();
            }

            string postSubject = String.Empty;
            string postText = String.Empty;
            string newSubject = String.Empty;

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("FetchPostDetails"))
            {
                dataReader.AddParameter("PostID", postID);
                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    postSubject = dataReader.GetStringNullAsEmpty("Subject");
                    postText = dataReader.GetStringNullAsEmpty("Text");

                    newSubject = reviewForum.ReviewForumName + ": " + postSubject;
                }
            }
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("UpdatePostDetails"))
            {
                dataReader.AddParameter("UserID", 0);
                dataReader.AddParameter("PostID", postID);
                dataReader.AddParameter("Subject", newSubject);
                dataReader.AddParameter("Text", postText);
                dataReader.AddParameter("SetLastUpdated", false);
                dataReader.AddParameter("ForceModerateAndHide", false);
                dataReader.AddParameter("IgnoreModeration", true);
                dataReader.Execute();
            }
            //update the thread first subject details
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("updatethreadfirstsubject"))
            {
                dataReader.AddParameter("ThreadID", threadID);
                dataReader.AddParameter("firstsubject", newSubject);
                dataReader.Execute();
            }
            //post the success story
            XmlElement movedThreadXml = AddElementTag(submitReviewForum, "MOVEDTHREAD");
            AddIntElement(movedThreadXml, "H2G2ID", H2G2ID);
            AddTextTag(movedThreadXml, "SUBJECT", guideEntry.Subject);
            XmlElement reviewForumXml = AddElementTag(movedThreadXml, "REVIEWFORUM");
            AddAttribute(reviewForumXml, "ID", rFID);
            AddTextTag(reviewForumXml, "REVIEWFORUMNAME", reviewForum.ReviewForumName);
            AddTextTag(reviewForumXml, "URLFRIENDLYNAME", reviewForum.UrlFriendlyName);

        }
        /// <summary>
        /// Submits an article to a review forum
        /// </summary>
        /// <param name="user"></param>
        /// <param name="H2G2ID"></param>
        /// <param name="siteID"></param>
        /// <param name="response"></param>
        /// <param name="reviewForumID"></param>
        public void SubmitArticle(IUser user, int H2G2ID, int siteID, string response, int reviewForumID)
        {
            XmlElement submitReviewForum = AddElementTag(RootElement, "SUBMIT-REVIEW-FORUM");
            if (user.UserID == 0)
            {
                AddGracefulErrorXml("NO_USERID", "You have not logged in!", "Login", "Login", submitReviewForum);
            }

            if (response == String.Empty)
            {
                AddErrorXml("NO_COMMENT", "There should be comments with this click back to back", submitReviewForum);
            }

            GuideEntrySetup guideSetup = new GuideEntrySetup(H2G2ID);
            guideSetup.ShowEntryData = true;
            guideSetup.ShowPageAuthors = true;
            guideSetup.ShowReferences = false;

            GuideEntry guideEntry = new GuideEntry(InputContext, guideSetup);
            guideEntry.Initialise();

            if (guideEntry.IsSubmittable && !user.IsEditor)
            {
                AddGracefulErrorXml("NO_SUBMIT", "This article is not for review", "FRONTPAGE", "Back to frontpage", submitReviewForum);
            }

            string subjectName = String.Empty;
            XmlElement subjectNameElement = (XmlElement) guideEntry.RootElement.SelectSingleNode("ARTICLE/SUBJECT");
            if (subjectNameElement != null)
            {
                subjectName = subjectNameElement.InnerText;
            }
            int editorID = 0;
            XmlElement editorIDElement = (XmlElement)guideEntry.RootElement.SelectSingleNode("PAGEAUTHOR/EDITOR/USERID");
            if (editorIDElement != null)
            {
                Int32.TryParse(editorIDElement.InnerText, out editorID);
            }

            string subject = "A" + H2G2ID.ToString() + " - " + subjectName;
            string aNumber = "A" + H2G2ID.ToString();

            User editor = new User(InputContext);
            editor.CreateUser(editorID);

            string editedComments = "Entry: " + subjectName + " - A" + H2G2ID + "\n";
            editedComments += "Author: " + editor.UserName + " - U" + editorID + "\n\n";
            editedComments += response;

            string hash = String.Empty;
            string hashString = subject + "<:>" + editedComments + "<:>" + user.UserID + "<:>0<:>0<:>0<:>ToReviewForum";

            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("addarticletoreviewforummembers"))
            {
                dataReader.AddParameter("h2g2id", H2G2ID);
                dataReader.AddParameter("reviewforumid", reviewForumID);
                dataReader.AddParameter("submitterid", user.UserID);
                dataReader.AddParameter("subject", subject);
                dataReader.AddParameter("content", editedComments);
                dataReader.AddParameter("Hash", DnaHasher.GenerateHash(hashString));

                dataReader.Execute();
                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    XmlElement article = AddTextTag(submitReviewForum, "ARTICLE", subjectName);
                    AddAttribute(article, "H2G2ID", H2G2ID);
                    XmlElement newThread = AddElementTag(submitReviewForum, "NEW-THREAD");
                    AddAttribute(newThread, "postid", dataReader.GetInt32NullAsZero("PostID"));
                    AddAttribute(newThread, "threadid", dataReader.GetInt32NullAsZero("ThreadID"));
                    AddAttribute(newThread, "forumid", dataReader.GetInt32NullAsZero("ForumID"));

                    ReviewForum reviewForum = new ReviewForum(InputContext);
                    reviewForum.InitialiseViaReviewForumID(reviewForumID, false);
                    AddInside(newThread, reviewForum);
                }
            }
        }