/// <summary> /// Creates new or updates existing newsletter issue. /// </summary> public bool Save() { if (validated || IsValid()) { IssueInfo issue = null; if (IssueID == 0) { // Initialize new issue issue = new IssueInfo(); issue.IssueUnsubscribed = 0; issue.IssueSentEmails = 0; issue.IssueNewsletterID = NewsletterID; issue.IssueSiteID = CMSContext.CurrentSiteID; } else { issue = IssueInfoProvider.GetIssueInfo(IssueID); } if (issue != null) { issue.IssueTemplateID = TemplateID; issue.IssueShowInNewsletterArchive = chkShowInArchive.Checked; issue.IssueSenderName = txtSenderName.Text.Trim(); issue.IssueSenderEmail = txtSenderEmail.Text.Trim(); // Saves content of editable region(s) // Get content from hidden field string content = hdnIssueContent.Value; string[] regions = null; if (!string.IsNullOrEmpty(content)) { // Split content for each region, separator is '#|#' regions = content.Split(new string[] { "#|#" }, StringSplitOptions.RemoveEmptyEntries); } issue.IssueText = IssueHelper.GetContentXML(regions); // Remove '#' from macros if included txtSubject.Text = txtSubject.Text.Trim().Replace("#%}", "%}"); // Sign macros if included in the subject issue.IssueSubject = MacroResolver.AddSecurityParameters(txtSubject.Text, CMSContext.CurrentUser.UserName, null); // Save issue IssueInfoProvider.SetIssueInfo(issue); // Update IssueID IssueID = issue.IssueID; return(true); } } return(false); }
/// <summary> /// Save click handler. /// </summary> protected void btnHidden_Click(object sender, EventArgs e) { string result = new Validator().NotEmpty(hdnNewsletterSubject.Value.Trim(), GetString("NewsletterContentEditor.SubjectRequired")).Result; if (result != String.Empty) { ltlScript2.Text = ScriptHelper.GetScript("if (parent.MsgInfo) { parent.MsgInfo(1); }"); return; } if (issue == null) { // Initialize new issue issue = new Issue(); issue.IssueUnsubscribed = 0; issue.IssueSentEmails = 0; issue.IssueTemplateID = templateId; issue.IssueNewsletterID = mNewsletterID; issue.IssueSiteID = CMSContext.CurrentSiteID; } // Saves content of editable region(s) issue.IssueText = SaveContent(); // Remove '#' from macros if included hdnNewsletterSubject.Value = hdnNewsletterSubject.Value.Trim().Replace("#%}", "%}"); // Sign macros if included in the subject issue.IssueSubject = MacroResolver.AddSecurityParameters(hdnNewsletterSubject.Value, CMSContext.CurrentUser.UserName, null); issue.IssueShowInNewsletterArchive = ValidationHelper.GetBoolean(hdnNewsletterShowInArchive.Value, false); // Save issue IssueProvider.SetIssue(issue); hdnIssueId.Value = issue.IssueID.ToString(); if (mIsNewIssue) { // Hide content if redirecting plcContent.Visible = false; } if (hdnNext.Value == "1") { ltlScript2.Text = ScriptHelper.GetScript("parent.NextClick('" + issue.IssueID.ToString() + "');"); } else { ltlScript2.Text = ScriptHelper.GetScript("if (parent.SaveClick) {parent.SaveClick('" + issue.IssueID.ToString() + "');} "); } }