Exemplo n.º 1
0
        /// <summary>
        /// Functions generates the TryCreateSubmitReviewForumXML XML
        /// </summary>
        /// <param name="H2G2ID">H2G2 ID of the article to submit</param>
        /// <param name="action">Action to take</param>
        /// <param name="response">Response Comments</param>
        /// <param name="reviewForumID">Review Forum ID to submit an article </param>
        /// <param name="rFID">rfID ID of the thread to Delete</param>
        public void TryCreateSubmitReviewForumXML(int H2G2ID, string action, string response, int reviewForumID, int rFID)
        {
            ReviewSubmissionForum submitReview = new ReviewSubmissionForum(InputContext);

            if (action == "submitrequest")
            {
                submitReview.RequestSubmitArticle(H2G2ID, InputContext.CurrentSite.SiteID, String.Empty, -1);
            }
	        else if(action == "submitarticle")
            {
                if (response != String.Empty)
                {
                    submitReview.SubmitArticle(InputContext.ViewingUser, H2G2ID, InputContext.CurrentSite.SiteID, response, reviewForumID);
                }
                else
                {
                    submitReview.SubmittedWithEmptyComments(H2G2ID, InputContext.CurrentSite.SiteID, reviewForumID);
                }
            }
	        else if(action == "removethread")
            {
                int threadID = 0;
                int forumID = 0;
                submitReview.RemoveThreadFromForum(InputContext.ViewingUser.UserID, rFID, H2G2ID, ref threadID, ref forumID, false);
            }
            else
            {
                throw new DnaException("Invalid action parameters");
            }
            AddInside(submitReview);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the recommendations status in the DB to show that it has
		///		been accepted by a member of staff. Also returns the details to
		///		allow an acceptance email to be sent to the scout.
        /// </summary>
        /// <param name="user">user doing the acceptance</param>
        /// <param name="h2g2ID_Old"></param>
        /// <param name="recommendationID">ID of the scout recommendation to accept</param>
        /// <param name="comments">any comments to attached to the recommendation</param>
        /// <param name="scoutEmail">email address to send the scouts acceptance email to</param>
        /// <param name="scoutEmailSubject">subject line for the email to scout</param>
        /// <param name="scoutEmailText">text of the acceptance email to scout</param>
        /// <param name="authorEmail">email address to send the authors acceptance email to</param>
        /// <param name="authorEmailSubject">subject line for the email to author</param>
        /// <param name="authorEmailText">text of the acceptance email to author</param>
        public void SubmitAccept(IUser user, int h2g2ID_Old, int recommendationID, string comments, ref string scoutEmail, ref string scoutEmailSubject, ref string scoutEmailText, ref string authorEmail, ref string authorEmailSubject, ref string authorEmailText)
        {
            // if daft h2g2ID_Old value given or user not editorthen fail
            if (h2g2ID_Old <= 0 || user.UserID == 0 || !user.IsEditor)
            {
                return;
            }
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("AcceptScoutRecommendation"))
            {
                dataReader.AddParameter("RecommendationID", recommendationID);
                dataReader.AddParameter("AcceptorID", user.UserID);
                dataReader.AddParameter("Comments", comments);
                dataReader.Execute();

                // Check to see if we found anything
                if (dataReader.HasRows && dataReader.Read())
                {
                    CreateBlankForm();
                    XmlElement submission = AddElementTag(_processRecommendationForm, "SUBMISSION");
                    AddAttribute(submission, "SUCCESS", 1);

                    // get the email address of the scout that recommended this entry
                    scoutEmail = dataReader.GetStringNullAsEmpty("ScoutEmail");
                    // get the authors email address
                    authorEmail = dataReader.GetStringNullAsEmpty("AuthorEmail");

                    string scoutName = dataReader.GetStringNullAsEmpty("ScoutName");
                    string authorName = dataReader.GetStringNullAsEmpty("AuthorName");

                    int h2g2ID_New = dataReader.GetInt32NullAsZero("h2g2ID");
                    string entrySubject = dataReader.GetStringNullAsEmpty("Subject");
                    DateTime dateRecommended = dataReader.GetDateTime("DateRecommended");

                    CreateScoutAcceptanceEmail(scoutName, entrySubject, h2g2ID_New, dateRecommended, ref scoutEmailSubject, ref scoutEmailText);
                    CreateAuthorAcceptanceEmail(authorEmail, entrySubject, h2g2ID_New, dateRecommended, ref authorEmailSubject, ref authorEmailText);

                    //remove the article from the review forum, this also updates the article
                    int reviewForumID = FetchReviewForumMemberDetails(h2g2ID_Old);

                    ReviewSubmissionForum reviewSubmissionForum = new ReviewSubmissionForum(InputContext);

                    int threadID = 0;
                    int forumID = 0;

                    reviewSubmissionForum.RemoveThreadFromForum(user.UserID, reviewForumID, h2g2ID_Old, ref threadID, ref forumID, true);
                    PostThreadRemovedMessage(threadID);
                }
                else
                {
                    // add some XML to show failed submission
                    XmlElement submission = AddElementTag(_processRecommendationForm, "SUBMISSION");
                    AddAttribute(submission, "SUCCESS", 0);
                }
            }
        }