Пример #1
0
 /// <summary>
 /// Returns true if user control is valid.
 /// </summary>
 public override bool IsValid()
 {
     string[] values = ValidationHelper.GetString(uniSelector.Value, string.Empty).Split(new char[] { ';' });
     foreach (string className in values)
     {
         if ((className != string.Empty) && !MacroResolver.ContainsMacro(className))
         {
             DataClassInfo di = DataClassInfoProvider.GetDataClass(className);
             if (di == null)
             {
                 ValidationError = GetString("formcontrols_selectcustomtable.notexist").Replace("%%code%%", className);
                 return(false);
             }
         }
     }
     return(true);
 }
Пример #2
0
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        string errorMessage = null;

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        if (bfi != null)
        {
            if (chkSendToEmail.Checked)
            {
                // Validate form
                errorMessage = new Validator().NotEmpty(txtFromEmail.Text, GetString("BizFormGeneral.EmptyFromEmail"))
                               .NotEmpty(txtToEmail.Text, GetString("BizFormGeneral.EmptyToEmail"))
                               .NotEmpty(txtSubject.Text, GetString("BizFormGeneral.EmptyEmailSubject")).Result;

                // Check if to e-mail contains macro expression or e-mails separated by semicolon
                if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtToEmail.Text.Trim()) && !ValidationHelper.AreEmails(txtToEmail.Text.Trim()))
                {
                    errorMessage = GetString("BizFormGeneral.EmptyToEmail");
                }

                // Check if from e-mail contains macro expression or e-mails separated by semicolon
                if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtFromEmail.Text.Trim()) && !ValidationHelper.IsEmail(txtFromEmail.Text.Trim()))
                {
                    errorMessage = GetString("BizFormGeneral.EmptyFromEmail");
                }

                if (string.IsNullOrEmpty(errorMessage))
                {
                    bfi.FormSendFromEmail           = txtFromEmail.Text.Trim();
                    bfi.FormSendToEmail             = txtToEmail.Text.Trim();
                    bfi.FormEmailSubject            = txtSubject.Text.Trim();
                    bfi.FormEmailAttachUploadedDocs = chkAttachDocs.Checked;
                    if (chkCustomLayout.Checked)
                    {
                        bfi.FormEmailTemplate = htmlEditor.ResolvedValue.Trim();
                    }
                    else
                    {
                        bfi.FormEmailTemplate = null;
                    }
                }
            }
            else
            {
                bfi.FormSendFromEmail    = null;
                bfi.FormSendToEmail      = null;
                bfi.FormEmailSubject     = null;
                bfi.FormEmailTemplate    = null;
                txtToEmail.Text          = string.Empty;
                txtFromEmail.Text        = string.Empty;
                txtSubject.Text          = string.Empty;
                chkAttachDocs.Checked    = true;
                htmlEditor.ResolvedValue = string.Empty;
            }

            if (string.IsNullOrEmpty(errorMessage))
            {
                try
                {
                    BizFormInfoProvider.SetBizFormInfo(bfi);
                    ShowChangesSaved();
                    EnableDisableForm(bfi.FormEmailTemplate);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
            }
        }
    }
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        string errorMessage = null;

        // Check 'EditForm' permission
        if (!currentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditForm");
        }

        // Validate form
        errorMessage = new Validator().NotEmpty(txtEmailFrom.Text.Trim(), GetString("bizform_edit_autoresponder.emptyemail")).NotEmpty(txtEmailSubject.Text.Trim(), GetString("bizform_edit_autoresponder.emptysubject")).Result;

        // Check if from e-mail contains macro expression or e-mails separated by semicolon
        if (string.IsNullOrEmpty(errorMessage) && !MacroResolver.ContainsMacro(txtEmailFrom.Text.Trim()) && !ValidationHelper.IsEmail(txtEmailFrom.Text.Trim()))
        {
            errorMessage = GetString("bizform_edit_autoresponder.emptyemail");
        }

        if ((string.IsNullOrEmpty(errorMessage)) || (!pnlCustomLayout.Visible))
        {
            errorMessage = String.Empty;
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null)
            {
                // Save custom layout
                if (!string.IsNullOrEmpty(drpEmailField.SelectedValue))
                {
                    bfi.FormConfirmationTemplate      = htmlEditor.ResolvedValue.Trim();
                    bfi.FormConfirmationEmailField    = drpEmailField.SelectedValue;
                    bfi.FormConfirmationEmailSubject  = txtEmailSubject.Text.Trim();
                    bfi.FormConfirmationSendFromEmail = txtEmailFrom.Text.Trim();

                    try
                    {
                        BizFormInfoProvider.SetBizFormInfo(bfi);
                        ShowChangesSaved();
                        EnableDisableForm(bfi.FormConfirmationTemplate);
                    }
                    catch (Exception ex)
                    {
                        errorMessage = ex.Message;
                    }
                }
                // Delete custom layout if exists
                else
                {
                    bfi.FormConfirmationTemplate      = null;
                    bfi.FormConfirmationEmailField    = drpEmailField.SelectedValue;
                    bfi.FormConfirmationEmailSubject  = string.Empty;
                    bfi.FormConfirmationSendFromEmail = string.Empty;

                    // Delete all attachments
                    MetaFileInfoProvider.DeleteFiles(bfi.FormID, FormObjectType.BIZFORM, MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT);

                    try
                    {
                        BizFormInfoProvider.SetBizFormInfo(bfi);
                        if (IsLayoutSet)
                        {
                            ShowConfirmation(GetString("Bizform_Edit_Autoresponder.LayoutDeleted"));
                        }
                        else
                        {
                            ShowChangesSaved();
                        }
                        EnableDisableForm(bfi.FormConfirmationTemplate);
                    }
                    catch (Exception ex)
                    {
                        errorMessage = ex.Message;
                    }
                }
            }
        }

        if (!string.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
        }
    }