Exemplo n.º 1
0
    /// <summary>
    /// Removes the macro signatures from the input text
    /// </summary>
    /// <param name="input">Input text</param>
    private static string RemoveMacroSignatures(string input)
    {
        if (!string.IsNullOrEmpty(input) && QueryHelper.GetBoolean("processMacroSecurity", false))
        {
            bool containsMacro;

            var valueIsMacro = QueryHelper.GetBoolean("valueIsMacro", false);

            // If value is macro, convert to full macro expression
            if (valueIsMacro)
            {
                input         = "{%" + input + "%}";
                containsMacro = true;
            }
            else
            {
                containsMacro = input.Contains("{");
            }

            // Remove the signatures
            if (containsMacro)
            {
                input = MacroSecurityProcessor.RemoveSecurityParameters(input, true, null);
            }

            // If value is macro, trim back the full expression
            if (valueIsMacro)
            {
                input = input.Substring(2, input.Length - 4);
            }
        }

        return(input);
    }
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING_FROM_ALL))
        {
            return(false);
        }

        // Get issue subject
        int issueId   = ai.ActivityItemID;
        var issueInfo = IssueInfoProvider.GetIssueInfo(issueId);

        if (issueInfo != null)
        {
            // Get newsletter name
            var newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(issueInfo.IssueNewsletterID);
            if (newsletterInfo != null)
            {
                ucDetails.AddRow("om.activitydetails.newsletter", newsletterInfo.NewsletterDisplayName);
            }

            var issueSubject = MacroSecurityProcessor.RemoveSecurityParameters(issueInfo.IssueSubject, true, null);
            ucDetails.AddRow("om.activitydetails.newsletterissue", issueSubject);
        }

        return(ucDetails.IsDataLoaded);
    }
Exemplo n.º 3
0
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || (ai.ActivityType != PredefinedActivityType.NEWSLETTER_OPEN))
        {
            return(false);
        }

        // Get newsletter name
        int            newsletterId   = ai.ActivityItemID;
        NewsletterInfo newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(newsletterId);

        if (newsletterInfo != null)
        {
            string subject = ValidationHelper.GetString(newsletterInfo.NewsletterDisplayName, null);
            ucDetails.AddRow("om.activitydetails.newsletter", subject);
        }

        // Get issue subject
        int       issueId   = ai.ActivityItemDetailID;
        IssueInfo issueInfo = IssueInfoProvider.GetIssueInfo(issueId);

        if (issueInfo != null)
        {
            string subject = ValidationHelper.GetString(issueInfo.IssueSubject, null);
            ucDetails.AddRow("om.activitydetails.newsletterissue", MacroSecurityProcessor.RemoveSecurityParameters(subject, true, null));
        }

        return(ucDetails.IsDataLoaded);
    }
Exemplo n.º 4
0
    /// <summary>
    /// Handles the UniGrid's OnExternalDataBound event.
    /// </summary>
    /// <param name="sender">The sender</param>
    /// <param name="sourceName">Name of the source</param>
    /// <param name="parameter">The data row</param>
    /// <returns>Formatted value to be used in the UniGrid</returns>
    protected object UniGrid_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerCSafe())
        {
        case "issuesubject":
            return(HTMLHelper.HTMLEncode(MacroSecurityProcessor.RemoveSecurityParameters(parameter.ToString(), true, null)));

        case "issueopenedemails":
            return(GetOpenedEmails(parameter as DataRowView));

        case "issuestatus":
            IssueStatusEnum status = IssueStatusEnum.Idle;
            if ((parameter != DBNull.Value) && (parameter != null))
            {
                status = (IssueStatusEnum)parameter;
            }
            return(GetString(String.Format("newsletterissuestatus." + Convert.ToString(status))));

        case "viewclickedlinks":
            if (sender is CMSGridActionButton)
            {
                // Hide 'view clicked links' action if tracking is not available or if the issue has no tracked links
                CMSGridActionButton imageButton = sender as CMSGridActionButton;
                if (!mTrackingEnabled)
                {
                    imageButton.Visible = false;
                }
                else
                {
                    GridViewRow gvr = parameter as GridViewRow;
                    if (gvr != null)
                    {
                        DataRowView drv = gvr.DataItem as DataRowView;
                        if (drv != null)
                        {
                            int issueId = ValidationHelper.GetInteger(drv["IssueID"], 0);
                            // Try to get one tracked link (only ID) of the issue
                            var links = LinkInfoProvider.GetLinks().WhereEquals("LinkIssueID", issueId).TopN(1).Column("LinkID");
                            if (!links.Any())
                            {
                                imageButton.Visible = false;
                            }
                        }
                    }
                }
            }
            return(sender);

        default:
            return(parameter);
        }
    }
    /// <summary>
    /// Returns a subject of an issue. A/B test icon is added to the subject if the issue is an A/B test.
    /// </summary>
    /// <param name="rowView">A <see cref="DataRowView" /> that represents one row from UniGrid's source</param>
    private string GetIssueSubject(DataRowView rowView)
    {
        var isABTest = DataHelper.GetBoolValue(rowView.Row, "IssueIsABTest");
        var subject  = HTMLHelper.HTMLEncode(MacroSecurityProcessor.RemoveSecurityParameters(DataHelper.GetStringValue(rowView.Row, "IssueSubject"), true, null));

        // Add the icon for A/B tests
        if (isABTest)
        {
            subject += UIHelper.GetAccessibleIconTag("NodeLink icon-two-squares-line tn", GetString("unigrid.newsletter_issue.abtesticontooltip"));
        }

        return(subject);
    }
Exemplo n.º 6
0
    protected object gridStrings_OnExternalDataBound(object sender, string sourceName, object parameter)
    {
        switch (sourceName.ToLowerInvariant())
        {
        case "culturetext":
        case "defaulttext":
        {
            var text = ValidationHelper.GetString(parameter, String.Empty);

            if (text.IndexOf('{') >= 0)
            {
                text = MacroSecurityProcessor.RemoveSecurityParameters(text, true, null);
            }

            return(text);
        }
        }

        return(parameter);
    }
Exemplo n.º 7
0
    public override bool LoadData(ActivityInfo ai)
    {
        if (ai == null)
        {
            return(false);
        }

        switch (ai.ActivityType)
        {
        case PredefinedActivityType.NEWSLETTER_SUBSCRIBING:
        case PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING:
            break;

        default:
            return(false);
        }

        // Get newsletter name
        NewsletterInfo newsletterInfo = NewsletterInfoProvider.GetNewsletterInfo(ai.ActivityItemID);

        if (newsletterInfo != null)
        {
            string subject = ValidationHelper.GetString(newsletterInfo.NewsletterDisplayName, null);
            ucDetails.AddRow("om.activitydetails.newsletter", subject);
        }

        // Get issue subject only for unsubscribing activity. Subscribing activity has reference to the subscriber in ItemDetailID.
        if (ai.ActivityType == PredefinedActivityType.NEWSLETTER_UNSUBSCRIBING)
        {
            IssueInfo issueInfo = IssueInfoProvider.GetIssueInfo(ai.ActivityItemDetailID);
            if (issueInfo != null)
            {
                string subject = ValidationHelper.GetString(issueInfo.IssueSubject, null);
                ucDetails.AddRow("om.activitydetails.newsletterissue", MacroSecurityProcessor.RemoveSecurityParameters(subject, true, null));
            }
        }

        return(ucDetails.IsDataLoaded);
    }
    protected void drpTransformationType_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Get the current code
        string code = TransformationCode;

        switch (TransformationType)
        {
        case TransformationTypeEnum.Ascx:

            if (!AscxEditAllowed)
            {
                // Ignore type change and reset transformation type selector
                drpType.SelectedValue = transformationInfo.TransformationType.ToStringRepresentation();
                ShowWarning(GetString("EditCode.NotAllowed"));
                break;
            }

            // Convert to ASCX syntax
            code = MacroSecurityProcessor.RemoveSecurityParameters(code, false, null);
            code = code.Replace("{% Register", "<%@ Register").Replace("{%", "<%#").Replace("%}", "%>");
            ShowMessage();
            break;

        case TransformationTypeEnum.Xslt:
            // No transformation
            break;

        default:
            // Convert to macro syntax
            code = code.Replace("<%@", "{%").Replace("<%#", "{%").Replace("<%=", "{%").Replace("<%", "{%").Replace("%>", "%}");
            break;
        }

        // Move the content if necessary
        if (TransformationType == TransformationTypeEnum.Html)
        {
            // Move from text to WYSIWYG
            if (txtCode.Visible)
            {
                tbWysiwyg.ResolvedValue = code;
                tbWysiwyg.Visible       = true;

                txtCode.Text    = string.Empty;
                txtCode.Visible = false;
            }
        }
        else
        {
            // Move from WYSIWYG to text
            if (tbWysiwyg.Visible)
            {
                code = HttpUtility.HtmlDecode(code);

                txtCode.Text    = code;
                txtCode.Visible = true;

                tbWysiwyg.ResolvedValue = string.Empty;
                tbWysiwyg.Visible       = false;
            }
            else
            {
                txtCode.Text = code;
            }
        }

        SetEditor();
    }
    protected void drpTransformationType_SelectedIndexChanged(object sender, EventArgs e)
    {
        // Get the current code
        string code = TransformationCode;

        switch (drpType.SelectedValue.ToLowerCSafe())
        {
        case "ascx":
            // Convert to ASCX syntax
            if (CMSString.Equals(drpType.SelectedValue, "ascx", true))
            {
                code = MacroSecurityProcessor.RemoveSecurityParameters(code, false, null);

                code = code.Replace("{% Register", "<%@ Register").Replace("{%", "<%#").Replace("%}", "%>");
            }

            ShowMessage();
            break;

        case "xslt":
            // No transformation
            break;

        default:
            // Convert to macro syntax
            code = code.Replace("<%@", "{%").Replace("<%#", "{%").Replace("<%=", "{%").Replace("<%", "{%").Replace("%>", "%}");
            break;
        }

        // Move the content if necessary
        if (CMSString.Equals(drpType.SelectedValue, "html", true))
        {
            // Move from text to WYSIWYG
            if (txtCode.Visible)
            {
                tbWysiwyg.ResolvedValue = code;
                tbWysiwyg.Visible       = true;

                txtCode.Text    = string.Empty;
                txtCode.Visible = false;
            }
        }
        else
        {
            // Move from WYSIWYG to text
            if (tbWysiwyg.Visible)
            {
                code = HttpUtility.HtmlDecode(code);

                txtCode.Text    = code;
                txtCode.Visible = true;

                tbWysiwyg.ResolvedValue = string.Empty;
                tbWysiwyg.Visible       = false;
            }
            else
            {
                txtCode.Text = code;
            }
        }

        SetEditor();
    }
Exemplo n.º 10
0
    /// <summary>
    /// Loads content from specific newsletter template.
    /// </summary>
    private void LoadContent()
    {
        EmailTemplateInfo emailTemplate = EmailTemplateInfoProvider.GetEmailTemplateInfo(mTemplateID);

        if ((emailTemplate == null) || string.IsNullOrEmpty(emailTemplate.TemplateBody))
        {
            return;
        }

        // Remove security parameters from macros
        string templateText = MacroSecurityProcessor.RemoveSecurityParameters(emailTemplate.TemplateBody, true, null);

        if (!RequestHelper.IsPostBack() && (issue != null))
        {
            // Load content of editable regions
            IssueHelper.LoadRegionsContents(ref regionsContents, issue.IssueText);
        }

        CMSEditableRegion editableRegion = null;
        LiteralControl    before         = null;
        int    count     = 0;
        int    textStart = 0;
        string region    = null;

        string[] parts           = null;
        string   name            = null;
        string   toolbarLocation = "Out:CKEditorToolbar";
        string   toolbarSetName  = "Newsletter";

        int editRegStart = templateText.IndexOfCSafe("$$", textStart);
        int editRegEnd   = 0;

        // Apply CSS e-mail template style
        HTMLHelper.AddToHeader(Page, CSSHelper.GetCSSFileLink(EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName)));

        while (editRegStart >= 0)
        {
            count++;

            before = new LiteralControl();
            // Get template text surrounding editable regions - make links absolute
            before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart, (editRegStart - textStart)));
            plcContent.Controls.Add(before);

            // End of region
            editRegStart += 2;
            textStart     = editRegStart;
            if (editRegStart < templateText.Length - 1)
            {
                editRegEnd = templateText.IndexOfCSafe("$$", editRegStart);
                if (editRegEnd >= 0)
                {
                    region = templateText.Substring(editRegStart, editRegEnd - editRegStart);
                    parts  = (region + ":" + ":").Split(':');

                    try
                    {
                        name = parts[0];
                        if (!string.IsNullOrEmpty(name.Trim()))
                        {
                            Regex intNumber = RegexHelper.GetRegex("^[0-9]+");
                            int   width     = ValidationHelper.GetInteger(intNumber.Match(parts[1]).Value, 0);
                            int   height    = ValidationHelper.GetInteger(intNumber.Match(parts[2]).Value, 0);

                            editableRegion            = new CMSEditableRegion();
                            editableRegion.ID         = name;
                            editableRegion.RegionType = CMSEditableRegionTypeEnum.HtmlEditor;
                            editableRegion.ViewMode   = ViewModeEnum.Edit;

                            editableRegion.DialogHeight = height;
                            editableRegion.DialogWidth  = width;

                            editableRegion.WordWrap = false;
                            editableRegion.HtmlAreaToolbarLocation = toolbarLocation;
                            editableRegion.RegionTitle             = name;
                            editableRegion.UseStylesheet           = false;
                            editableRegion.HTMLEditorCssStylesheet = EmailTemplateInfoProvider.GetStylesheetUrl(emailTemplate.TemplateName);

                            if (!mReadOnly)
                            {
                                editableRegion.HtmlAreaToolbar = toolbarSetName;
                            }
                            else
                            {
                                editableRegion.HtmlAreaToolbar = "Disabled";
                            }

                            CMSHtmlEditor editor = editableRegion.HtmlEditor;
                            editor.AddExtraPlugin("CMSPlugins");
                            editor.AddExtraPlugin("autogrow");
                            editor.AutoGrowMinHeight            = height;
                            editor.LinkDialogConfig.UseFullURL  = true;
                            editor.QuickInsertConfig.UseFullURL = true;
                            editor.ResolverName = "NewsletterResolver";

                            DialogConfiguration dialogConfig = editor.MediaDialogConfig;
                            dialogConfig.UseFullURL         = true;
                            dialogConfig.MetaFileObjectID   = (issue != null) ? issue.IssueID : 0;
                            dialogConfig.MetaFileObjectType = (issue != null) && issue.IssueIsVariant ? NewsletterObjectType.NEWSLETTERISSUEVARIANT : NewsletterObjectType.NEWSLETTERISSUE;
                            dialogConfig.MetaFileCategory   = MetaFileInfoProvider.OBJECT_CATEGORY_ISSUE;
                            dialogConfig.HideAttachments    = false;

                            editableRegion.LoadContent(ValidationHelper.GetString(regionsContents[name.ToLowerCSafe()], string.Empty));

                            plcContent.Controls.Add(editableRegion);

                            textStart = editRegEnd + 2;
                        }
                    }
                    catch
                    {
                    }
                }
            }
            editRegStart = templateText.IndexOfCSafe("$$", textStart);
        }

        before      = new LiteralControl();
        before.Text = URLHelper.MakeLinksAbsolute(templateText.Substring(textStart));

        plcContent.Controls.Add(before);
    }
    /// <summary>
    /// Generates tables
    /// </summary>
    private void GenerateTable()
    {
        tblData.Controls.Clear();

        Hashtable ht = data.ConvertToHashtable();

        TableHeaderRow th = new TableHeaderRow()
        {
            TableSection = TableRowSection.TableHeader
        };
        TableHeaderCell ha = new TableHeaderCell();
        TableHeaderCell hn = new TableHeaderCell();
        TableHeaderCell hv = new TableHeaderCell();

        th.CssClass = "unigrid-head";

        ha.Text     = GetString("unigrid.actions");
        ha.CssClass = "unigrid-actions-header";

        hn.Text  = GetString("xmleditor.propertyname");
        hn.Width = Unit.Pixel(180);
        hv.Text  = GetString("xmleditor.propertyvalue");
        hv.Width = Unit.Pixel(500);

        th.Cells.Add(ha);
        th.Cells.Add(hn);
        th.Cells.Add(hv);

        tblData.Rows.Add(th);

        ArrayList keys = new ArrayList(ht);

        keys.Sort(new CustomStringComparer());

        foreach (DictionaryEntry okey in keys)
        {
            String key   = ValidationHelper.GetString(okey.Key, String.Empty);
            String value = ValidationHelper.GetString(okey.Value, String.Empty);

            bool isInvalid = (key == INVALIDTOKEN);
            key = isInvalid ? invalidKey : key;

            if (value == String.Empty)
            {
                continue;
            }

            TableRow tr = new TableRow();

            // Actions
            TableCell tna = new TableCell();
            tna.CssClass = "unigrid-actions";

            var imgEdit = new CMSGridActionButton();
            imgEdit.OnClientClick = String.Format("displayEdit('{1}','{0}'); return false; ", key, ClientID);
            imgEdit.IconCssClass  = "icon-edit";
            imgEdit.IconStyle     = GridIconStyle.Allow;
            imgEdit.ID            = key + "_edit";
            imgEdit.ToolTip       = GetString("xmleditor.edititem");

            var imgOK = new CMSGridActionButton();
            imgOK.IconCssClass  = "icon-check";
            imgOK.IconStyle     = GridIconStyle.Allow;
            imgOK.OnClientClick = String.Format("approveCustomChanges('{0}','{1}');return false;", ClientID, key);
            imgOK.ID            = key + "_ok";
            imgOK.ToolTip       = GetString("xmleditor.approvechanges");

            var imgDelete = new CMSGridActionButton();
            imgDelete.OnClientClick = " if (confirm('" + GetString("xmleditor.deleteconfirm") + "')) {" + ControlsHelper.GetPostBackEventReference(tblData, "delete_" + key) + "} ;return false;";
            imgDelete.IconCssClass  = "icon-bin";
            imgDelete.IconStyle     = GridIconStyle.Critical;
            imgDelete.ID            = key + "_del";
            imgDelete.ToolTip       = GetString("xmleditor.deleteitem");

            var imgUndo = new CMSGridActionButton();
            imgUndo.OnClientClick = String.Format("if (confirm('" + GetString("xmleditor.confirmcancel") + "')) undoCustomChanges('{0}','{1}'); return false;", ClientID, key);
            imgUndo.IconCssClass  = "icon-arrow-crooked-left";
            imgUndo.ID            = key + "_undo";
            imgUndo.ToolTip       = GetString("xmleditor.undochanges");

            tna.Controls.Add(imgEdit);
            tna.Controls.Add(imgOK);
            tna.Controls.Add(imgDelete);
            tna.Controls.Add(imgUndo);

            value = MacroSecurityProcessor.RemoveSecurityParameters(value, false, null);

            // Labels
            Label lblName = new Label();
            lblName.ID   = "sk" + key;
            lblName.Text = key;

            Label lblValue = new Label();
            lblValue.ID   = "sv" + key;
            lblValue.Text = value;

            // Textboxes
            CMSTextBox txtName = new CMSTextBox();
            txtName.Text     = key;
            txtName.ID       = "tk" + key;
            txtName.CssClass = "XmlEditorTextbox";

            CMSTextBox txtValue = new CMSTextBox();
            txtValue.Text     = value;
            txtValue.ID       = "tv" + key;
            txtValue.CssClass = "XmlEditorTextbox";
            txtValue.Width    = Unit.Pixel(490);

            labels.Add(lblName);
            labels.Add(lblValue);

            textboxes.Add(txtName);
            textboxes.Add(txtValue);

            TableCell tcn = new TableCell();
            tcn.Controls.Add(lblName);
            tcn.Controls.Add(txtName);

            TableCell tcv = new TableCell();
            tcv.Controls.Add(lblValue);
            tcv.Controls.Add(txtValue);

            tr.Cells.Add(tna);
            tr.Cells.Add(tcn);
            tr.Cells.Add(tcv);

            tblData.Rows.Add(tr);

            lblValue.CssClass = String.Empty;
            lblName.CssClass  = "CustomEditorKeyClass";

            if (isInvalid)
            {
                imgDelete.AddCssClass("hidden");
                imgEdit.AddCssClass("hidden");

                lblName.AddCssClass("hidden");
                lblValue.AddCssClass("hidden");

                RegisterEnableScript(false);
            }
            else
            {
                imgOK.AddCssClass("hidden");
                imgUndo.AddCssClass("hidden");

                txtName.CssClass  += " hidden";
                txtValue.CssClass += " hidden";
            }
        }
    }