Beispiel #1
0
        /// <summary>
        /// Sends error email to moderator telling them verification email wasn't sent
        /// </summary>
        /// <param name="email"></param>
        /// <param name="verificationUid"></param>
        private void SendVerficationErrorEmailToModerator(string email, Guid verificationUid)
        {

            // Should use the email templaing system for this task.
            String from = email;
            if (from == String.Empty)
                from = "Anonymous";

            if (InputContext.ViewingUser != null)
            {
                from = InputContext.ViewingUser.UserName;
                if (InputContext.ViewingUser.IsEditor)
                    from += " (Editor)";
            }

            String emailSubject = "Error: Unable to send complaint verification email to user - missing template";
            String emailBody = "Verfication Code: " + verificationUid.ToString() + "\r\n";

            String moderatorEmail = InputContext.CurrentSite.ModeratorsEmail;
            int siteId = InputContext.CurrentSite.SiteID;

            int userId = 0;
            if (InputContext.ViewingUser != null)
                userId = InputContext.ViewingUser.UserID;

            try
            {
                //Actually send the email.
                DnaMessage sendMessage = new DnaMessage(InputContext);
                sendMessage.SendEmailOrSystemMessage(userId, email, email, null, siteId, emailSubject, emailBody);
            }
            catch (DnaEmailException e)
            {
                AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Sends an imformative email to the moderator with the complaint details
        /// </summary>
        /// <param name="modId"></param>
        /// <param name="email"></param>
        /// <param name="postId"></param>
        /// <param name="h2g2Id"></param>
        /// <param name="url"></param>
        /// <param name="complaintText"></param>
        private void SendErrorEmailToModerator(int modId, string email, int postId, int h2g2Id, string url, String complaintText)
        {

            // Should use the email templaing system for this task.
            String from = email;
            if (from == String.Empty)
                from = "Anonymous";

            if (InputContext.ViewingUser != null)
            {
                from = InputContext.ViewingUser.UserName;
                if (InputContext.ViewingUser.IsEditor)
                    from += " (Editor)";
            }

            String emailSubject = "Error: Unable to send complaint receipt to user - missing template";
            String emailBody = "Complaint from: " + from + "\r\n";
            emailBody += "ModerationReference: " + Convert.ToString(modId) + "\r\n";
            if (postId > 0)
            {
                emailBody += " about post " + Convert.ToString(postId) + "\r\n";
            }
            else if (h2g2Id > 0)
            {
                emailBody += " about article " + Convert.ToString(h2g2Id) + "\r\n";
            }
            else
            {
                emailBody += " about page " + Convert.ToString(url) + "\r\n";
            }
            //if (hidden)
                //emailBody += " (HIDDEN)";
            emailBody += "\r\n\r\n";
            emailBody += complaintText;

            String moderatorEmail = InputContext.CurrentSite.ModeratorsEmail;
            int siteId = InputContext.CurrentSite.SiteID;

            int userId = 0;
            if (InputContext.ViewingUser != null)
                userId = InputContext.ViewingUser.UserID;

            try
            {
                //Actually send the email.
                DnaMessage sendMessage = new DnaMessage(InputContext);
                sendMessage.SendEmailOrSystemMessage(userId, email, email, null, siteId, emailSubject, emailBody);
            }
            catch (DnaEmailException e)
            {
                AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Sends verification email for user to verify email
        /// </summary>
        /// <param name="email"></param>
        /// <param name="verificationUid"></param>
        private void SendVerificationEmail(string email, Guid verificationUid)
        {
            // do any necessary substitutions
            string emailSubject;
            string emailBody;
            int siteId = InputContext.CurrentSite.SiteID;
            int userId = InputContext.ViewingUser == null ? 0 : InputContext.ViewingUser.UserID;

            EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "UserComplaintEmailVerification", out emailSubject, out emailBody);

            if (string.IsNullOrEmpty(emailBody) || string.IsNullOrEmpty(emailSubject))
            {
                InputContext.Diagnostics.WriteWarningToLog("UserComplaintEmailVerification",
                    string.Format("Missing Verification template: site={0}, type=UserComplaintEmailVerification", siteId));
                SendVerficationErrorEmailToModerator(InputContext.CurrentSite.ModeratorsEmail, verificationUid);
                VerifySubmission(verificationUid);
                return;
            }

            String from = InputContext.CurrentSite.ModeratorsEmail;
            emailBody = emailBody.Replace("++**verificationcode**++", Convert.ToString(verificationUid.ToString()));
            emailBody = emailBody.Replace("++**urlname**++", InputContext.CurrentSite.SiteName);
            string moderatorEmail = InputContext.CurrentSite.ModeratorsEmail;

            try
            {

                //Actually send the email.
                DnaMessage sendMessage = new DnaMessage(InputContext);
                sendMessage.SendEmailOrSystemMessage(userId, email, moderatorEmail, moderatorEmail, siteId, emailSubject, emailBody);
            }
            catch (DnaEmailException e)
            {
                AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
            }

        }
Beispiel #4
0
        /// <summary>
        /// Send Email using Email template mechanism.
        /// </summary>
        /// <param name="complaintText"></param>
        /// <param name="email"></param>
        /// <param name="modId"></param>
        /// <param name="postId"></param>
        /// <param name="h2g2Id"></param>
        /// <param name="title"></param>
        private void SendEmail(string complaintText, string email, int modId, int postId, int h2g2Id, string title)
        {
            // do any necessary substitutions
            string emailSubject;
            string emailBody;
            int siteId = InputContext.CurrentSite.SiteID;
            int userId = InputContext.ViewingUser == null ? 0 : InputContext.ViewingUser.UserID;

            EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "UserComplaintEmail", out emailSubject, out emailBody);

            if (string.IsNullOrEmpty(emailBody) || string.IsNullOrEmpty(emailSubject))
            {
                InputContext.Diagnostics.WriteWarningToLog("ComplaintSendEmail", 
                    string.Format("Missing email template: site={0}, type=UserComplaintEmail", siteId));
                SendErrorEmailToModerator(modId, InputContext.CurrentSite.ModeratorsEmail, postId, h2g2Id, title, complaintText);
                return;
            }

            String from = email;
            if (from == String.Empty)
                from = "Anonymous";

            if (InputContext.ViewingUser.UserLoggedIn)
            {
                from = InputContext.ViewingUser.UserName;
                if (InputContext.ViewingUser.IsEditor)
                    from += " (Editor)";
            }
            emailSubject = emailSubject.Replace("++**nickname**++", from);

            emailBody = emailBody.Replace("++**nickname**++", Convert.ToString(from));
            emailBody = emailBody.Replace("++**reference_number**++", Convert.ToString(modId));

            if (postId > 0)
            {
                emailBody = emailBody.Replace("++**content_type**++", "Post");
            }
            else if (h2g2Id > 0)
            {
                emailBody = emailBody.Replace("++**content_type**++", "Article");
            }
            else
            {
                emailBody = emailBody.Replace("++**content_type**++", "Item");
            }

            emailBody = emailBody.Replace("++**content_subject**++", title);


            emailBody = emailBody.Replace("++**inserted_text**++", complaintText);

            string moderatorEmail = InputContext.TheSiteList.GetSite(siteId).GetEmail(BBC.Dna.Sites.Site.EmailType.Moderators);

            try
            {
                
                //Actually send the email.
                DnaMessage sendMessage = new DnaMessage(InputContext);
                sendMessage.SendEmailOrSystemMessage(userId, email, moderatorEmail, moderatorEmail, siteId, emailSubject, emailBody);
            }
            catch (DnaEmailException e)
            {
                AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
            }

        }
Beispiel #5
0
        private void SendComplainantEmail(ModerationItemStatus decision, int siteId, int modId, int complainantId, String complainantEmail, String customText)
        {
            String emailSubject = "";
            String emailBody = ""; ;
            if (decision == ModerationItemStatus.Passed)
            {
                EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "RejectComplaintEmail", out emailSubject, out emailBody);
            }
            else if (decision == ModerationItemStatus.PassedWithEdit)
            {
                EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "UpholdComplaintEditEntryEmail", out emailSubject, out emailBody);
            }
            else if (decision == ModerationItemStatus.Failed)
            {
                EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "UpholdComplaintEmail", out emailSubject, out emailBody);
            }

            String reference = "P" + Convert.ToString(modId);
            emailBody = emailBody.Replace("++**reference_number**++", reference);
            emailSubject = emailSubject.Replace("++**reference_number**++", reference);

            if (decision == ModerationItemStatus.Passed || decision == ModerationItemStatus.PassedWithEdit)
            {
                emailBody = emailBody.Replace("++**inserted_text**++", customText);
            }

            try
            {
                //Actually send the email.
                DnaMessage sendMessage = new DnaMessage(InputContext);
                String sender = InputContext.TheSiteList.GetSite(siteId).ModeratorsEmail;
                sendMessage.SendEmailOrSystemMessage(complainantId, complainantEmail, sender, siteId, emailSubject, emailBody);
            }
            catch (DnaEmailException e)
            {
                AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
            }
        }
Beispiel #6
0
        private void SendAuthorEmail(ModerationItemStatus decision, int siteId, int forumId, int threadId, int postId, int authorId, String authorEmail, String emailType, String customText)
        {

            String contentURL = @"http://www.bbc.co.uk/dna/" + InputContext.TheSiteList.GetSite(siteId).SiteName + @"/F" + Convert.ToString(forumId) + @"?thread=" + Convert.ToString(threadId) + "&post=" + Convert.ToString(postId) + @"#p" + Convert.ToString(postId);
            String subject = "";
            String body = "";
            using (IDnaDataReader dataReader = InputContext.CreateDnaDataReader("fetchpostdetails"))
            {
                dataReader.AddParameter("postid", postId);
                dataReader.Execute();
                if (dataReader.Read())
                {
                    subject = dataReader.GetStringNullAsEmpty("subject");
                    body = dataReader.GetStringNullAsEmpty("text");
                }
            }

            String emailSubject = "";
            String emailBody = ""; ;
            if (decision == ModerationItemStatus.Failed)
            {
                EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "ContentRemovedEmail", out emailSubject, out emailBody);
            }
            else if (decision == ModerationItemStatus.PassedWithEdit)
            {
                EmailTemplates.FetchEmailText(AppContext.ReaderCreator, siteId, "ContentFailedAndEditedEmail", out emailSubject, out emailBody);
            }
            else
            {
                AddErrorXml("EMAIL", "Unable to send email: No email template.", RootElement);
                return;
            }


            String insertText;
            if (EmailTemplates.FetchInsertText(AppContext.ReaderCreator, siteId, emailType, out insertText))
            {
                emailBody = emailBody.Replace("++**inserted_text**++", insertText);
                emailBody = emailBody.Replace("++**inserted_text**++", customText);
                emailBody = emailBody.Replace("++**content_type**++", "Posting");
                emailBody = emailBody.Replace("++**add_content_method**++", "post it");
                emailBody = emailBody.Replace("++**content_url**++", contentURL);
                emailBody = emailBody.Replace("++**content_subject**++", subject);
                emailBody = emailBody.Replace("++**content_text**++", body);
                emailSubject = emailSubject.Replace("++**content_type**++", "Posting");


                try
                {
                    //Actually send the email.
                    DnaMessage sendMessage = new DnaMessage(InputContext);
                    String sender = InputContext.TheSiteList.GetSite(siteId).ModeratorsEmail;
                    sendMessage.SendEmailOrSystemMessage(authorId, authorEmail, sender, siteId, emailSubject, emailBody);
                }
                catch (DnaEmailException e)
                {
                    AddErrorXml("EMAIL", "Unable to send email." + e.Message, RootElement);
                }
            }
            else
            {
                AddErrorXml("EMAIL", "Unable to send email: No email template reason.", RootElement);
            }
        }