Example #1
0
        protected override void OnPreInit(EventArgs e)
        {
            base.OnPreInit(e);
            MasterPageFile = string.Format("~{0}", NewsLetterConfiguration.GetModuleBaseDir("Plugin/Newsletter.Master"));
            if (Page.User.IsInRole("CmsAdmins") == false &&
                Page.User.IsInRole("NewsletterEditors") == false &&
                Page.User.IsInRole("NewsletterAdmins"))
            {
                throw new AccessDeniedException();
            }

            //  MasterPageFile = EPiServer.UriSupport.ResolveUrlFromUIBySettings("MasterPages/EPiServerUI.Master");

            if (Page.ClientScript.IsClientScriptIncludeRegistered("bootstrap") == false)
            {
                Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "bootstrap", NewsLetterConfiguration.GetModuleBaseDir("/content/js/bootstrap.js"));
            }

            if (Page.ClientScript.IsClientScriptIncludeRegistered("jquery") == false)
            {
                Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "jquery", NewsLetterConfiguration.GetModuleBaseDir("/content/js/jquery-1.11.2.min.js"));
            }

            if (Page.ClientScript.IsClientScriptIncludeRegistered("jsRender") == false)
            {
                Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "jsRender", NewsLetterConfiguration.GetModuleBaseDir("/content/js/jsrender.min.js"));
            }
        }
Example #2
0
 protected SendGridSettings GetSettings()
 {
     return(new SendGridSettings
     {
         ApiKey = NewsLetterConfiguration.GetAppSettingsConfigValueEx <string>("Newsletter.SendGrid.ApiKey", "")
     });
 }
Example #3
0
        /// <summary>
        /// Returns a report in html format.
        /// </summary>
        /// <returns></returns>
        public MailInformation GetHtmlReport()
        {
            string subject = string.Format("Mail Sender Log, mail sent between {0} and {1}", this.SendStart, this.SendStop);
            string from    = NewsLetterConfiguration.GetAppSettingsConfigValueEx <string>("EPsSendMailSendReportMailTo", null);

            return(GetHtmlReport(subject, from));
        }
Example #4
0
        void SaveNewNewsletter_ClickHandler(object sender, EventArgs e)
        {
            string name = txtNewNewsletterName.Text;
            string desc = txtNewNewsletterDesc.Text;

            if (string.IsNullOrEmpty(name))
            {
                ShowError("Name cannot be empty");
            }

            // Create and Save
            Job newJob = new Job(0, name, desc);

            newJob.PageId = CurrentPage.ContentLink.ID;
            newJob.Save();

            //Redirect to the job page
            if (newJob.Id != 0)
            {
                /// TODO: This surely cannot work with EPiServer 7.x
                Response.Redirect(NewsLetterConfiguration.GetEditPanelLink(newJob));
            }
            else
            {
                ShowError("Something went wrong saving new job");
            }
        }
 public NewsLetterDetailsView()
 {
     Key            = "NewsletterDetailsView";
     LanguagePath   = "/bvnetwork/sendmail/view";
     ControllerType = "epi-cms/widget/IFrameController";
     ViewType       = VirtualPathUtility.ToAbsolute(NewsLetterConfiguration.GetModuleBaseDir("/Plugin/Jobs/JobEdit.aspx"));
     IconClass      = "newsletterView";
 }
Example #6
0
        protected override void InitializeWorkItemDescriptors()
        {
            LocalizationService localizationService = ServiceLocator.Current.GetInstance <LocalizationService>();

            List <RecipientListProviderDescriptor> recipientProviders = NewsLetterConfiguration.GetRecipientListProviderDescriptors();

            foreach (RecipientListProviderDescriptor descriptor in recipientProviders)
            {
                AddProviderWithChecks(WorkItemProviders, descriptor);
            }
        }
        public ActionResult Index()
        {
            return(new RedirectResult(NewsLetterConfiguration.GetModuleBaseDir("plugin/newsletters.aspx")));

            //NewsletterListModel model = new NewsletterListModel();
            //model.Title = "Newsletters";
            //return View(NewsLetterConfiguration.GetModuleBaseDir() + "/Views/Newsletter/Index.cshtml", model);

            //ContentResult result = new ContentResult();
            //result.Content = "Home";

            //return result;
        }
Example #8
0
        /// <summary>
        /// Gets the sender email address.
        /// </summary>
        /// <remarks>
        /// 1. Use MailSender property
        /// 2. Use Newsletter.DefaultFromAddress from appSettings
        /// 3. Construct noreply@SiteUrl
        /// </remarks>
        /// <param name="page">The page to extract information from.</param>
        /// <returns></returns>
        public virtual string GetMailSender(PageData page)
        {
            string fromAddress = null;

            if (page["MailSender"] != null)
            {
                fromAddress = page["MailSender"].ToString();
            }
            else
            {
                fromAddress = NewsLetterConfiguration.GetAppSettingsConfigValueEx <string>("Newsletter.DefaultFromAddress", "noreply@" + SiteDefinition.Current.SiteUrl.Host);
            }
            return(fromAddress);
        }
Example #9
0
        public IEnumerable <MenuItem> GetMenuItems()
        {
            List <MenuItem> menuItems       = new List <MenuItem>();
            var             newsletterRoles = new List <string>()
            {
                "NewsletterAdmins", "NewsletterEditors", "CmsAdmins"
            };
            SectionMenuItem sectionMenuItem = new SectionMenuItem("Newsletter", "/global/newsletter");

            sectionMenuItem.IsAvailable = x => newsletterRoles.Any(y => x.HttpContext.User.IsInRole(y));
            menuItems.Add(sectionMenuItem);


            // During installation, we'll show another menu
            int version = DatabaseVersion.GetInstalledDatabaseVersion();

            if (version == DatabaseVersion.NotInstalled)
            {
                // Link to database installer page
                UrlMenuItem urlMenuItem = new UrlMenuItem("Newsletter Installation", "/global/newsletter/install",
                                                          NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/admin/newsletterinstall.aspx");
                urlMenuItem.IsAvailable = ((RequestContext request) => true);
                urlMenuItem.SortIndex   = 100;
                menuItems.Add(urlMenuItem);
            }
            else
            {
                UrlMenuItem urlMenuItem = new UrlMenuItem("Newsletters", "/global/newsletter/newsletters", NewsLetterConfiguration.GetModuleBaseDir("/plugin/newsletters.aspx"));
                urlMenuItem.IsAvailable = ((RequestContext request) => true);
                urlMenuItem.SortIndex   = 100;
                menuItems.Add(urlMenuItem);

                urlMenuItem             = new UrlMenuItem("Lists", "/global/newsletter/lists", NewsLetterConfiguration.GetModuleBaseDir("/plugin/lists.aspx"));
                urlMenuItem.IsAvailable = ((RequestContext request) => true);
                urlMenuItem.SortIndex   = 200;
                menuItems.Add(urlMenuItem);

                //TODO: Add this menu item, when admin settings are ready to be moved from appsettings to dds
                //UrlMenuItem urlAdminMenuItem = new UrlMenuItem("Admin", "/global/newsletter/admin",
                //    NewsLetterConfiguration.GetModuleBaseDir() + "/plugin/Admin/NewsLetterAdmin.aspx");
                //urlAdminMenuItem.IsAvailable = ((RequestContext request) => true);
                //urlAdminMenuItem.SortIndex = 200;
            }

            return(menuItems.ToArray());
        }
        /// <summary>
        /// Gets the local license file path. Should not start with
        /// a back slash as it will be prepended along with the rest
        /// of the local path.
        /// </summary>
        /// <remarks>
        /// Default value is:
        /// "bvn\sendmail\license\aspNetEmail.xml.lic"
        /// </remarks>
        /// <returns>The root relative path (not URL) to the license xml file.</returns>
        private string GetLocalLicenseFilePath()
        {
            string localFile = null;
            // Should be of type:
            // bvn\sendmail\license\aspNetEmail.xml.lic (default)
            string nonStandardLicensePath = NewsLetterConfiguration.GetAppSettingsConfigValueEx <string>("EPsAspNetEmailRelativeLicensePath", null);

            if (string.IsNullOrEmpty(nonStandardLicensePath) == false)
            {
                localFile = EPiServer.Global.BaseDirectory + nonStandardLicensePath;
            }
            else
            {
                localFile = EPiServer.Global.BaseDirectory + REL_LICENSE_PATH;
            }

            return(localFile);
        }
        public void Initialize(IEmailImporter importer, IShowFeedback feedbackUi)
        {
            // Depending on what we're adding addresses to, we need to call different controllers
            string apiUrl = NewsLetterConfiguration.GetModuleBaseDir() + "/api/recipients/";
            int    id     = 0;

            if (importer is Job)
            {
                apiUrl = apiUrl + "AddRecipientsToJobFromEPiServerGroupname";
                id     = ((Job)importer).Id;
            }
            else
            {
                apiUrl = apiUrl + "AddRecipientsToListFromEPiServerGroupname";
                id     = ((RecipientList)importer).Id;
            }
            apiUrl = apiUrl + "?id=" + id.ToString();

            ApiUrl = apiUrl;
        }
Example #12
0
        public void Initialize(IEmailImporter importer, IShowFeedback feedbackUi)
        {
            // Depending on what we're adding addresses to, we need to call different controllers
            string apiUrl = NewsLetterConfiguration.GetModuleBaseDir() + "/api/recipients/";
            int    id     = 0;

            if (importer is Job)
            {
                apiUrl = apiUrl + "AddRecipientsToJobFromList";
                id     = ((Job)importer).Id;
                apiUrl = apiUrl + "?jobId=" + id.ToString();
            }
            else
            {
                // We're adding from a list to another listg
                apiUrl = apiUrl + "AddRecipientsToListFromList";
                id     = ((RecipientList)importer).Id;
                apiUrl = apiUrl + "?destinationListId=" + id.ToString();
            }

            ApiUrl = apiUrl;
        }
Example #13
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            _recipientProviders = NewsLetterConfiguration.GetRecipientListProviderDescriptors();

            foreach (RecipientListProviderDescriptor descriptor in _recipientProviders)
            {
                if (descriptor.ProviderControlExists)
                {
                    Control ctrl = Page.LoadControl(descriptor.UserControlUrl);
                    ctrl.Visible = false;
                    ctrl.ID      = descriptor.ProviderName + PROVIDER_SUFFIX;
                    _providerCtrls.Add(descriptor.ProviderName, ctrl);
                    pnlProviderContainer.Controls.Add(ctrl);

                    // Initialize the provider, needs to be done this
                    // early, or post backs won't work
                    ((IEmailImporterProvider)ctrl).Initialize(RecipientList, RecipientListBase);
                }
            }
        }
Example #14
0
        /// <summary>
        /// Gets the mail subject.
        /// </summary>
        /// <remarks>
        /// 1. Use MailSubject property
        /// 2. Use PageName
        /// 2. Use Newsletter.DefaultMailSubject from appSetting
        /// 3. Use "Newsletter" as default
        /// </remarks>
        public virtual string GetMailSubject(PageData page)
        {
            string subject = null;

            if (page != null)
            {
                if (page["MailSubject"] != null)
                {
                    subject = page["MailSubject"].ToString();
                }

                if (subject == null)
                {
                    subject = page.PageName;
                }
            }

            if (subject == null)
            {
                subject = NewsLetterConfiguration.GetAppSettingsConfigValueEx <string>("Newsletter.DefaultMailSubject", "Newsletter");
            }

            return(subject);
        }
Example #15
0
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     MasterPageFile = string.Format("~{0}", NewsLetterConfiguration.GetModuleBaseDir("Plugin/Newsletter.Master"));
 }
Example #16
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Page.ClientScript.RegisterClientScriptInclude(Page.GetType(),
                                                   "jsRender",
                                                   NewsLetterConfiguration.GetModuleBaseDir() + "/content/js/jsrender.min.js");
 }
Example #17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.ClientScript.IsClientScriptIncludeRegistered("jquery") == false)
            {
                Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "jquery", NewsLetterConfiguration.GetModuleBaseDir() + "/content/js/jquery-1.11.2.min.js");
            }
            if (Page.ClientScript.IsClientScriptIncludeRegistered("bootstrap") == false)
            {
                Page.ClientScript.RegisterClientScriptInclude(Page.GetType(), "bootstrap", NewsLetterConfiguration.GetModuleBaseDir() + "/content/js/bootstrap.js");
            }

            if (NewsletterJob != null)
            {
                BindJobData(NewsletterJob);
            }

            if (!IsPostBack)
            {
                if (NewsletterJob == null)
                {
                    tblEditJob.Visible       = false;
                    pnlAddWorkItems.Visible  = false;
                    pnlJobStatus.Visible     = false;
                    pnlMiscActions.Visible   = false;
                    pnlNewNewsLetter.Visible = true;
                }
                CacheManager.Remove("CurrentSelection" + HttpContext.Current.User.Identity.Name);
            }

            cmdSendTest.DataBind();
        }