Example #1
0
	protected void LoadData(BXMailerTemplate t)
    {
        if (t == null)
            return;
                
        ActiveCheckBox.Checked = t.Active;

		FromTextBox.Text = t.EmailFrom;
        ToTextBox.Text = t.EmailTo;
        SubjectTextBox.Text = t.Subject;

        RadioText.Checked = RadioHtml.Checked = false;
        if (t.BodyType == BXMailerTemplateBodyType.Html)
            RadioHtml.Checked = true;
        else
            RadioText.Checked = true;

        BccTextBox.Text = t.Bcc;
        MessageTextBox.Text = t.Message;

		foreach (ListItem sel in mailEventTypes.Items)
			if (sel.Value.Equals(t.Name, StringComparison.InvariantCultureIgnoreCase))
			{
				mailEventTypes.SelectedValue = sel.Value;
				break;
			}

		foreach (ListItem item in siteList.Items)
			item.Selected = t.Sites.Contains(item.Value);
    }
Example #2
0
	private void Save()
	{
		int id;
		bool newTemplate;

		newTemplate = !int.TryParse(IdHiddenField.Value, out id);

		currentTemplate = newTemplate ? new BXMailerTemplate(mailEventTypes.SelectedValue) : BXMailerTemplate.GetById(id);
		if (currentTemplate == null)
			return;

		currentTemplate.Active = ActiveCheckBox.Checked;
		if (!editTemplate)
			currentTemplate.Name = mailEventTypes.SelectedValue;
		currentTemplate.EmailFrom = FromTextBox.Text;
		currentTemplate.EmailTo = ToTextBox.Text;
		currentTemplate.Subject = SubjectTextBox.Text;
		currentTemplate.BodyType = RadioHtml.Checked ? BXMailerTemplateBodyType.Html : BXMailerTemplateBodyType.Text;
		currentTemplate.Bcc = BccTextBox.Text;
		currentTemplate.Message = MessageTextBox.Text;
		currentTemplate.Sites.Clear();
		foreach (ListItem item in siteList.Items)
			if (item.Selected)
				currentTemplate.Sites.Add(item.Value);
		currentTemplate.Save();
		IdHiddenField.Value = currentTemplate.Id.ToString();
	}
Example #3
0
	protected void Page_LoadComplete(object sender, EventArgs e)
    {
        MasterTitle = GetMessage("MasterTitle");

		SetTabTitle();

		int parsedId = 0;
		editTemplate = Int32.TryParse(IdHiddenField.Value, out parsedId);
		if (editTemplate)
		{
			templateId = parsedId;
			editTemplate = parsedId >= 0;
		}

		mailEventTypes.Visible = !editTemplate;
		typeIdLabel.Visible = editTemplate;
		
		string description = "";
		if (!editTemplate)
		{
			if (mailEventTypes.SelectedValue != null)
			{
				BXMailEventType et = BXMailEventTypeManager.FindEventTypeById(mailEventTypes.SelectedValue);
				if (et != null)
					description = et.DisplayDescription;
			}
		}
		else
		{
			if (currentTemplate == null)
				currentTemplate = BXMailerTemplate.GetById(templateId);
			if (currentTemplate == null)
				Response.Redirect("Mailer.aspx");
			lastUpdated.Text = HttpUtility.HtmlEncode(currentTemplate.LastUpdated.ToString());
			BXMailEventType et = BXMailEventTypeManager.FindEventTypeById(currentTemplate.Name);
			typeIdLabel.Text = "[" + currentTemplate.Name + "]";
			if (et != null)
			{
				typeIdLabel.Text += " == " + et.DisplayName;
				description = et.DisplayDescription;
			}
		}

		description = PredefinedFields + Environment.NewLine + description;
		availableFields.Text = (Regex.Replace(Encode(description), "(#(.*?)#)", "<a title=\"" + GetMessage("Kernel.Insert") + "\" href=\"javascript:PutString('$1')\">$1</a>")).Replace(Environment.NewLine, "<br/>");

		AddSeparator.Visible = editTemplate && currentUserCanModify;
		AddButton.Visible = editTemplate && currentUserCanModify;
		CopySeparator.Visible = editTemplate && currentUserCanModify;
		CopyButton.Visible = editTemplate && currentUserCanModify;
		DeleteSeparator.Visible = editTemplate && currentUserCanModify;
		DeleteButton.Visible = editTemplate && currentUserCanModify;

		BXTabControl1.ShowSaveButton = currentUserCanModify;
		BXTabControl1.ShowApplyButton = currentUserCanModify;
		PrepareResultMessage();
    }