/// <summary>
    /// Gets and bulk updates dynamic newsletters. Called when the "Get and bulk update newsletters" button is pressed.
    /// Expects the CreateDynamicNewsletter method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateDynamicNewsletters()
    {
        // Prepare the parameters
        string where = "NewsletterName LIKE N'MyNewDynamicNewsletter%'";

        // Get the data
        DataSet newsletters = NewsletterInfoProvider.GetNewsletters(where, null, 0, null);

        if (!DataHelper.DataSourceIsEmpty(newsletters))
        {
            // Loop through the individual items
            foreach (DataRow newsletterDr in newsletters.Tables[0].Rows)
            {
                // Create object from DataRow
                NewsletterInfo modifyNewsletter = new NewsletterInfo(newsletterDr);

                // Update the properties
                modifyNewsletter.NewsletterDisplayName = modifyNewsletter.NewsletterDisplayName.ToUpper();

                // Save the changes
                NewsletterInfoProvider.SetNewsletterInfo(modifyNewsletter);
            }

            return(true);
        }

        return(false);
    }
Exemple #2
0
        private static void SubscribeCoffeeGeekContactGroupToEmailCampaign(PersonaInfo persona)
        {
            var issueInfo = IssueInfoProvider.GetIssues().WhereIn("IssueNewsletterID",
                                                                  NewsletterInfoProvider.GetNewsletters().WhereEquals("NewsletterName", "CoffeeClubMembership")
                                                                  .Column("NewsletterID")).TopN(1).FirstOrDefault();

            if (issueInfo == null)
            {
                return;
            }

            var contactGroup = CreateContactGroup(persona);

            if (IssueContactGroupInfoProvider.GetIssueContactGroupInfo(issueInfo.IssueID,
                                                                       contactGroup.ContactGroupID) != null)
            {
                return;
            }

            IssueContactGroupInfoProvider.SetIssueContactGroupInfo(new IssueContactGroupInfo
            {
                IssueID        = issueInfo.IssueID,
                ContactGroupID = contactGroup.ContactGroupID
            });
        }
    private void AddErrorMessage(ICollection <int> irremovableNewsletterIds)
    {
        var newsletters = NewsletterInfoProvider.GetNewsletters()
                          .WhereIn("NewsletterID", irremovableNewsletterIds)
                          .Columns("NewsletterDisplayName")
                          .GetListResult <string>();

        lblErrorMessage.Text    = string.Format(GetString("newsletter.templatenewsletter.lastbindingerror"), string.Join(", ", newsletters));
        lblErrorMessage.Visible = true;
    }
Exemple #4
0
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        string templateId = actionArgument.ToString();

        switch (actionName.ToLowerCSafe())
        {
        // Edit the template
        case "edit":
            URLHelper.Redirect("NewsletterTemplate_Edit.aspx?templateid=" + templateId);
            break;

        // Delete the template
        case "delete":
            // Check 'Manage templates' permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.newsletter", "managetemplates"))
            {
                RedirectToCMSDeskAccessDenied("cms.newsletter", "managetemplates");
            }

            // Check if the template is used in a newsletter
            string where = string.Format("(NewsletterTemplateID={0}) OR (NewsletterSubscriptionTemplateID={0}) OR (NewsletterUnsubscriptionTemplateID={0}) OR (NewsletterOptInTemplateID={0})", templateId);

            DataSet newsByEmailtempl = NewsletterInfoProvider.GetNewsletters(where, null, 1, "NewsletterID");
            if (DataHelper.DataSourceIsEmpty(newsByEmailtempl))
            {
                // Check if the template is used in an issue
                DataSet newsletterIssues = IssueInfoProvider.GetIssues("IssueTemplateID = " + templateId, null, 1, "IssueID");
                if (DataHelper.DataSourceIsEmpty(newsletterIssues))
                {
                    // Delete EmailTemplate object from database
                    EmailTemplateInfoProvider.DeleteEmailTemplateInfo(ValidationHelper.GetInteger(templateId, 0));
                }
                else
                {
                    ShowError(GetString("NewsletterTemplate_List.TemplateInUseByNewsletterIssue"));
                }
            }
            else
            {
                ShowError(GetString("NewsletterTemplate_List.TemplateInUseByNewsletter"));
            }
            break;
        }
    }
    /// <summary>
    /// Gets and bulk updates dynamic newsletters. Called when the "Get and bulk update newsletters" button is pressed.
    /// Expects the CreateDynamicNewsletter method to be run first.
    /// </summary>
    private bool GetAndBulkUpdateDynamicNewsletters()
    {
        // Get the data
        var newsletters = NewsletterInfoProvider.GetNewsletters().Where("NewsletterName", QueryOperator.Like, "MyNewDynamicNewsletter%");

        if (newsletters.Any())
        {
            // Loop through the individual items
            foreach (var newsletter in newsletters)
            {
                // Update the properties
                newsletter.NewsletterDisplayName = newsletter.NewsletterDisplayName.ToUpper();

                // Save the changes
                NewsletterInfoProvider.SetNewsletterInfo(newsletter);
            }

            return(true);
        }

        return(false);
    }
Exemple #6
0
    private bool UnsubscribeFromNewsletter()
    {
        string SubscriberMail = txtmail.Text;
        string newlettername  = string.Empty;
        bool   result         = false;
        // Gets the subscriber and newsletter
        SubscriberInfo subscriber = SubscriberInfoProvider.GetSubscriberInfo(SubscriberMail, CMSContext.CurrentSiteID);

        if (subscriber != null)
        {
            DataSet newsletters = NewsletterInfoProvider.GetNewsletters(null, null, 0, null);
            if (!DataHelper.DataSourceIsEmpty(newsletters))
            {
                // Loops through the items
                foreach (DataRow newsletterDr in newsletters.Tables[0].Rows)
                {
                    newlettername = newsletterDr["NewsletterName"].ToString();
                    NewsletterInfo newsletter = NewsletterInfoProvider.GetNewsletterInfo(newlettername, CMSContext.CurrentSiteID);

                    if (newsletter != null)
                    {
                        // Unubscribes from 'My new static newsletter'
                        SubscriberInfoProvider.Unsubscribe(subscriber.SubscriberID, newsletter.NewsletterID);
                        result = true;
                        break;
                    }
                }
            }
            lblerror.Text = "La désinscription a été effectuée avec succès.";
            temp          = "found";
        }
        else
        {
            lblerror.Text = "L'email n'a pas été trouvé dans la base de données. Veuillez réessayer. ";
            txtmail.Text  = "";
            temp          = "not found";
        }
        return(result);
    }
    /// <summary>
    /// Handles the UniGrid's OnAction event.
    /// </summary>
    /// <param name="actionName">Name of item (button) that throws event</param>
    /// <param name="actionArgument">ID (value of Primary key) of corresponding data row</param>
    protected void uniGrid_OnAction(string actionName, object actionArgument)
    {
        string templateId = actionArgument.ToString();

        switch (actionName.ToLowerCSafe())
        {
        // Edit the template
        case "edit":

            string url = UIContextHelper.GetElementUrl("cms.newsletter", "TemplateProperties", false, templateId.ToInteger(0));
            URLHelper.Redirect(url);

            break;

        // Delete the template
        case "delete":
            // Check 'Manage templates' permission
            var template = EmailTemplateInfoProvider.GetEmailTemplateInfo(ValidationHelper.GetInteger(actionArgument, 0));
            if (template == null)
            {
                RedirectToAccessDenied(GetString("general.invalidparameters"));
            }

            if (!template.CheckPermissions(PermissionsEnum.Delete, CurrentSiteName, CurrentUser))
            {
                RedirectToAccessDenied("cms.newsletter", "managetemplates");
            }

            // Check if the template is used in a newsletter
            var newsByEmailtempl = NewsletterInfoProvider
                                   .GetNewsletters()
                                   .WhereEquals("NewsletterTemplateID", templateId)
                                   .Or()
                                   .WhereEquals("NewsletterSubscriptionTemplateID", templateId)
                                   .Or()
                                   .WhereEquals("NewsletterUnsubscriptionTemplateID", templateId)
                                   .Or()
                                   .WhereEquals("NewsletterOptInTemplateID", templateId)
                                   .Column("NewsletterID")
                                   .TopN(1);

            if (!newsByEmailtempl.Any())
            {
                // Check if the template is used in an issue
                var newsletterIssuesIDs = IssueInfoProvider.GetIssues().WhereEquals("IssueTemplateID", templateId).TopN(1).Column("IssueID");
                if (!newsletterIssuesIDs.Any())
                {
                    // Delete EmailTemplate object from database
                    EmailTemplateInfoProvider.DeleteEmailTemplateInfo(ValidationHelper.GetInteger(templateId, 0));
                }
                else
                {
                    ShowError(GetString("NewsletterTemplate_List.TemplateInUseByNewsletterIssue"));
                }
            }
            else
            {
                ShowError(GetString("NewsletterTemplate_List.TemplateInUseByNewsletter"));
            }
            break;
        }
    }