Пример #1
0
    private void ShowTemplate(MailTemplate currentTemplate)
    {
        this.LabelCountryName.Text = Country.FromCode(currentTemplate.CountryCode).Name;
        this.LabelOrgName.Text     = "";
        if (currentTemplate.OrganizationId != 0)
        {
            this.LabelOrgName.Text = Organization.FromIdentity(currentTemplate.OrganizationId).Name;
            ButtonSave.Visible     = _authority.HasPermission(Permission.CanEditMailTemplates, currentTemplate.OrganizationId, -1, Authorization.Flag.Default);
        }
        else
        {
            ButtonSave.Visible = _authority.HasPermission(Permission.CanEditMailTemplates, Organization.RootIdentity, -1, Authorization.Flag.Default);
        }

        this.LabelTemplateName.Text  = currentTemplate.TemplateName;
        CurrentTemplateNameViewState = currentTemplate.TemplateName;
        CurrentTemplateIdViewState   = currentTemplate.TemplateId;
        currentTemplate.NormalizeHtml();

        TypedMailTemplate           typedTemplate = TypedMailTemplate.FromName(currentTemplate.TemplateName);
        Dictionary <string, string> placeholders  = new Dictionary <string, string>();

        foreach (string ph in typedTemplate.Placeholders.Keys)
        {
            placeholders.Add(ph.ToLower(), ph);
        }

        currentTemplate.MarkPlaceholderSpans(placeholders);

        RadEditor1.Content  = currentTemplate.TemplateBody;
        TextBoxSubject.Text = currentTemplate.TemplateTitle;
        SetEditorToolbar();
    }
Пример #2
0
    protected void ButtonSave_Click(object sender, EventArgs e)
    {
        if (this.CurrentTemplateIdViewState != 0 && ButtonCancelSaveAs.Visible == false)
        {
            MailTemplate currentTemplate = MailTemplate.FromIdentity(this.CurrentTemplateIdViewState);
            currentTemplate.TemplateBody = RadEditor1.Content;
            currentTemplate.NormalizeHtml();
            currentTemplate.TemplateTitle = TextBoxSubject.Text;
            currentTemplate.NormalizeHtml();
            currentTemplate.RemovePlaceholderSpans();
            currentTemplate.Update();
            ShowTemplate(currentTemplate);
            BuildTemplateDropdowns();
        }
        else
        {
            string cntryCode = "";
            string cntryLang = "";
            if (DropDownCountry.SelectedValue != "")
            {
                Country cntry = Country.FromCode(DropDownCountry.SelectedValue);
                cntryCode = cntry.Code;
                cntryLang = cntry.Culture.Substring(0, 2);
            }

            int          orgId = WSOrgTreeDropDown1.SelectedOrganizationId;
            Organization org   = Organization.FromIdentity(orgId);

            if (_authority.HasPermission(Permission.CanSetUpAutomail, orgId, org.DefaultCountry.GeographyId, Authorization.Flag.Default))
            {
                if (orgId == Organization.RootIdentity)
                {
                    orgId = 0;
                }

                MailTemplate currentTemplate = MailTemplate.Create(DropDownName.SelectedValue, cntryLang,
                                                                   cntryCode, orgId, RadEditor1.Content);
                this.CurrentTemplateIdViewState   = currentTemplate.TemplateId;
                this.CurrentTemplateNameViewState = currentTemplate.TemplateName;
                currentTemplate.TemplateBody      = RadEditor1.Content;
                currentTemplate.NormalizeHtml();
                currentTemplate.TemplateTitle = TextBoxSubject.Text;
                currentTemplate.NormalizeHtml();
                currentTemplate.MarkPlaceholderSpans();
                currentTemplate.Update();
                ShowTemplate(currentTemplate);
                BuildTemplateDropdowns();
                SetUIState(pageUIState.edit);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "StartupMessage", "alert('You have to select an organization for wich you have permissions to edit templates for.');", true);
            }
        }
    }
Пример #3
0
    private void ShowTemplate (MailTemplate currentTemplate)
    {
        this.LabelCountryName.Text = Country.FromCode(currentTemplate.CountryCode).Name;
        this.LabelOrgName.Text = "";
        if (currentTemplate.OrganizationId != 0)
        {
            this.LabelOrgName.Text = Organization.FromIdentity(currentTemplate.OrganizationId).Name;
            ButtonSave.Visible = _authority.HasPermission(Permission.CanEditMailTemplates, currentTemplate.OrganizationId, -1, Authorization.Flag.Default);
        }
        else
        {
            ButtonSave.Visible = _authority.HasPermission(Permission.CanEditMailTemplates, Organization.RootIdentity, -1, Authorization.Flag.Default);
        }

        this.LabelTemplateName.Text = currentTemplate.TemplateName;
        CurrentTemplateNameViewState = currentTemplate.TemplateName;
        CurrentTemplateIdViewState = currentTemplate.TemplateId;
        currentTemplate.NormalizeHtml();

        TypedMailTemplate typedTemplate = TypedMailTemplate.FromName(currentTemplate.TemplateName);
        Dictionary<string, string> placeholders = new Dictionary<string, string>();
        foreach (string ph in typedTemplate.Placeholders.Keys)
        {
            placeholders.Add(ph.ToLower(), ph);
        }

        currentTemplate.MarkPlaceholderSpans(placeholders);

        RadEditor1.Content = currentTemplate.TemplateBody;
        TextBoxSubject.Text = currentTemplate.TemplateTitle;
        SetEditorToolbar();
    }