Ejemplo n.º 1
0
    /// <summary>
    /// Custom layout checkbox checked changed.
    /// </summary>
    protected void chkCustomLayout_CheckedChanged(object sender, EventArgs e)
    {
        pnlCustomLayout.Visible = !pnlCustomLayout.Visible;

        // Add delete confirmation
        if (!chkCustomLayout.Checked && IsLayoutSet)
        {
            lnkSave.OnClientClick = "return ConfirmDelete();";
        }
        // Remove delete confirmation and reload HTML editor content
        else if (chkCustomLayout.Checked)
        {
            lnkSave.OnClientClick = "";

            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null && bfi.FormEmailTemplate != null)
            {
                htmlEditor.ResolvedValue = bfi.FormEmailTemplate;
            }
        }
    }
Ejemplo n.º 2
0
    public override bool LoadData(ActivityInfo ai)
    {
        if ((ai == null) || !ModuleEntry.IsModuleLoaded(ModuleEntry.BIZFORM) || (ai.ActivityType != PredefinedActivityType.BIZFORM_SUBMIT))
        {
            return(false);
        }

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(ai.ActivityItemID);

        if (bfi == null)
        {
            return(false);
        }

        string qs = String.Format("?bizid={0}&recid={1}", bfi.FormID, ai.ActivityItemDetailID);

        qs = URLHelper.AddUrlParameter(qs, "hash", QueryHelper.GetHash(qs));
        btnView.Visible       = true;
        btnView.OnClientClick = "DisplaySurveyDetails('" + qs + "'); return false;";
        return(true);
    }
        /// <summary>
        /// Loads model for the dashboard live tile.
        /// </summary>
        /// <param name="liveTileContext">Context of the live tile. Contains information about the user and the site the model is requested for</param>
        /// <exception cref="ArgumentNullException"><paramref name="liveTileContext"/> is null</exception>
        /// <returns>Live tile model</returns>
        public LiveTileModel GetModel(LiveTileContext liveTileContext)
        {
            if (liveTileContext == null)
            {
                throw new ArgumentNullException("liveTileContext");
            }

            return(CacheHelper.Cache(() =>
            {
                // If site has more than 1 form on lower license, BizFormItemProvider.GetItems method returns null which results in exception
                // Standard license check
                if (!BizFormItemProvider.LicenseVersionCheck(RequestContext.CurrentDomain, ObjectActionEnum.Edit))
                {
                    return null;
                }

                var formsClassNames = BizFormInfoProvider.GetBizForms()
                                      .OnSite(liveTileContext.SiteInfo.SiteID)
                                      .Source(s => s.Join <DataClassInfo>("FormClassID", "ClassID"))
                                      .Column("ClassName")
                                      .GetListResult <string>();

                // Leave tile empty if there are no forms on current site
                if (!formsClassNames.Any())
                {
                    return null;
                }

                int newSubmissionsCount = formsClassNames.Sum(className => BizFormItemProvider.GetItems(className)
                                                              .WhereGreaterThan("FormInserted", DateTime.Now.AddDays(-7).Date)
                                                              .Count);

                return new LiveTileModel
                {
                    Value = newSubmissionsCount,
                    Description = ResHelper.GetString("bizform.livetiledescription"),
                };
            }
                                     , new CacheSettings(5, "FormsLiveTileModelProvider", liveTileContext.SiteInfo.SiteID)));
        }
Ejemplo n.º 4
0
    private string GetUniGridWhereCondition()
    {
        // Global administrators can see all forms.
        if (currentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.Admin))
        {
            return("FormSiteID = " + SiteContext.CurrentSiteID);
        }

        var bizFormsAvailableForUser = BizFormInfoProvider.GetBizForms()
                                       .Column("CMS_Form.FormID")
                                       .OnSite(SiteContext.CurrentSiteID)
                                       .Distinct()
                                       .Source(s => s.LeftJoin <BizFormRoleInfo>("FormID", "FormID"))
                                       .Where(new WhereCondition()
                                              .WhereIn("RoleID", UserRoleInfoProvider.GetUserRoles().Column("RoleID").WhereEquals("UserID", currentUser.UserID))
                                              .Or()
                                              .WhereNull("FormAccess")
                                              .Or()
                                              .WhereEquals("FormAccess", (int)FormAccessEnum.AllBizFormUsers));

        return(new WhereCondition().WhereIn("CMS_Form.FormID", bizFormsAvailableForUser).ToString(true));
    }
Ejemplo n.º 5
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }
        FieldEditor.FormType = FormTypeEnum.BizForm;
        formId = QueryHelper.GetInteger("formid", 0);
        // Get bizform info
        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        FieldEditor.Visible = false;
        if (bfi != null)
        {
            // Get form class info
            DataClassInfo dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
            if (dci != null)
            {
                if (dci.ClassIsCoupledClass)
                {
                    // Setup the field editor
                    CurrentMaster.BodyClass         += " FieldEditorBody";
                    FieldEditor.Visible              = true;
                    FieldEditor.ClassName            = dci.ClassName;
                    FieldEditor.EnableSimplifiedMode = true;
                    FieldEditor.Mode = FieldEditorModeEnum.BizFormDefinition;
                    FieldEditor.OnAfterDefinitionUpdate += FieldEditor_OnAfterDefinitionUpdate;
                    FieldEditor.OnFieldNameChanged      += FieldEditor_OnFieldNameChanged;
                }
                else
                {
                    pnlError.Visible = true;
                }
            }
        }
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        // Get form id from url
        int formId = QueryHelper.GetInteger("formid", 0);

        // Get form object
        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        rfvDisplayName.Text = GetString("BizFormGeneral.rfvDisplayName");

        if ((!RequestHelper.IsPostBack()) && (bfi != null))
        {
            LoadData();
        }
    }
Ejemplo n.º 7
0
    protected void gridData_OnAction(string actionName, object actionArgument)
    {
        switch (actionName.ToLower())
        {
        case "delete":
            CheckPermissions("DeleteData");

            // Get record ID
            int formRecordID = ValidationHelper.GetInteger(actionArgument, 0);

            // Get BizFormInfo object
            if (bfi != null)
            {
                // Get class object
                if (dci != null)
                {
                    // Get record object
                    IDataClass formRecord = DataClassFactory.NewDataClass(dci.ClassName, formRecordID);
                    if (!formRecord.IsEmpty())
                    {
                        // Delete all files of the record
                        BizFormInfoProvider.DeleteBizFormRecordFiles(dci.ClassFormDefinition, formRecord, CMSContext.CurrentSiteName);

                        // Delete the form record
                        formRecord.Delete();

                        // Update number of entries in BizFormInfo
                        if (bfi != null)
                        {
                            BizFormInfoProvider.RefreshDataCount(bfi.FormName, bfi.FormSiteID);
                        }
                    }
                }
            }

            break;
        }
    }
        private GeneralResultDTO SubmitNewKitRequestInternal(string name, string description, int[] productIDs, string[] productNames)
        {
            var newKitRequestForm = BizFormInfoProvider.GetBizFormInfo(_NewKitRequestFormCodeName, SiteContext.CurrentSiteID);

            if (newKitRequestForm != null)
            {
                var    newKitRequestFormClass     = DataClassInfoProvider.GetDataClassInfo(newKitRequestForm.FormClassID);
                string newKitRequestFormClassName = newKitRequestFormClass.ClassName;

                BizFormItem newFormItem = BizFormItem.New(newKitRequestFormClassName);

                newFormItem.SetValue("Name", name);
                newFormItem.SetValue("Description", description);
                newFormItem.SetValue("ProductNames", string.Join("|", productNames));
                newFormItem.SetValue("ProductNodeIDs", string.Join("|", productIDs));

                newFormItem.SetValue("Site", SiteContext.CurrentSite.DisplayName);
                newFormItem.SetValue("User", MembershipContext.AuthenticatedUser.UserName);

                newFormItem.SetValue("FormInserted", DateTime.Now);
                newFormItem.SetValue("FormUpdated", DateTime.Now);

                newFormItem.Insert();

                SendFormEmail(newFormItem);

                return(new GeneralResultDTO {
                    success = true
                });
            }
            else
            {
                return(new GeneralResultDTO {
                    success = false, errorMessage = ResHelper.GetString("Kadena.NewKitRequest.ContactFormRepositoryNotFound", LocalizationContext.CurrentCulture.CultureCode)
                });
            }
        }
Ejemplo n.º 9
0
    /// <summary>
    /// Button OK clicked.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        BizFormInfo bfi            = null;
        string      reportFields   = "";
        bool        noItemSelected = (chkListFields.SelectedIndex == -1) ? true : false;

        foreach (ListItem item in chkListFields.Items)
        {
            // Display all fields
            if (noItemSelected)
            {
                reportFields += item.Value + ";";
            }
            // Display only selected fields
            else if (item.Selected)
            {
                reportFields += item.Value + ";";
            }
        }

        if (reportFields != "")
        {
            // Remove ending ';'
            reportFields = reportFields.TrimEnd(';');
        }

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        if (bfi != null)
        {
            // Save report fields
            bfi.FormReportFields = reportFields;
            BizFormInfoProvider.SetBizFormInfo(bfi);

            // Close dialog window
            ltlScript.Text = ScriptHelper.GetScript("CloseAndRefresh();");
        }
    }
Ejemplo n.º 10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        formId       = QueryHelper.GetInteger("formid", 0);
        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi == null)
        {
            lblError.Visible = true;
            lblError.Text    = GetString("general.invalidid");
            return;
        }

        classId = bfi.FormClassID;

        // Init breadcrumbs
        string[,] breadcrumbs = new string[2, 3];

        // Return to list item in breadcrumbs
        breadcrumbs[0, 0] = GetString("altforms.listlink");
        breadcrumbs[0, 1] = "~/CMSModules/BizForms/Tools/AlternativeForms/AlternativeForms_List.aspx?formid=" + formId;
        breadcrumbs[0, 2] = "";
        breadcrumbs[1, 0] = GetString("altform.newbread");
        breadcrumbs[1, 1] = "";
        breadcrumbs[1, 2] = "";

        this.CurrentMaster.Title.Breadcrumbs = breadcrumbs;

        nameElem.ShowSubmitButton = true;
        nameElem.Click           += new EventHandler(nameElem_Click);
    }
Ejemplo n.º 11
0
    /// <summary>
    /// Button OK clicked.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        BizFormInfo bfi            = null;
        string      reportFields   = string.Empty;
        bool        noItemSelected = (chkListFields.SelectedIndex == -1) ? true : false;

        foreach (ListItem item in chkListFields.Items)
        {
            // Display all fields
            if (noItemSelected)
            {
                reportFields += item.Value + ";";
            }
            // Display only selected fields
            else if (item.Selected)
            {
                reportFields += item.Value + ";";
            }
        }

        if (!string.IsNullOrEmpty(reportFields))
        {
            // Remove ending ';'
            reportFields = reportFields.TrimEnd(';');
        }

        bfi = BizFormInfoProvider.GetBizFormInfo(formId);
        if (bfi != null)
        {
            // Save report fields
            bfi.FormReportFields = reportFields;
            BizFormInfoProvider.SetBizFormInfo(bfi);

            // Close dialog window
            ScriptHelper.RegisterStartupScript(this, typeof(string), "Forms_SelectFields", "CloseAndRefresh();", true);
        }
    }
        private void CreateFormSubmission(TreeNode document, string formName, ContactInfo contact)
        {
            var form      = BizFormInfoProvider.GetBizFormInfo(formName, currentSite.SiteID);
            var classInfo = DataClassInfoProvider.GetDataClassInfo(form.FormClassID);
            var formItem  = new BizFormItem(classInfo.ClassName);
            var url       = DocumentURLProvider.GetAbsoluteLiveSiteURL(document);

            CopyDataFromContactToForm(contact, classInfo, formItem);
            SetFormSpecificData(formName, contact, formItem);
            formItem.Insert();

            var activity = new ActivityInfo
            {
                ActivityContactID    = contact.ContactID,
                ActivityItemID       = form.FormID,
                ActivityItemDetailID = formItem.ItemID,
                ActivitySiteID       = currentSite.SiteID,
                ActivityTitle        = nameBuilder.CreateTitle(PredefinedActivityType.BIZFORM_SUBMIT, form.FormDisplayName),
                ActivityType         = PredefinedActivityType.BIZFORM_SUBMIT,
                ActivityURL          = url
            };

            ActivityInfoProvider.SetActivityInfo(activity);
        }
Ejemplo n.º 13
0
    /// <summary>
    /// Sets visibility of custom layout form.
    /// </summary>
    private void SetCustomLayoutVisibility(bool visible)
    {
        pnlCustomLayout.Visible = visible;
        AttachmentTitle.Visible = visible;
        AttachmentList.Visible  = visible;

        // Remove content checking and add delete confirmation
        if (!visible && IsLayoutSet)
        {
            lnkSave.OnClientClick = "return ConfirmDelete();";
        }
        // Remove delete confirmation and add content checking
        else if (visible)
        {
            lnkSave.OnClientClick = string.Empty;

            // Reload HTML editor content
            BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);
            if (bfi != null && bfi.FormConfirmationTemplate != null)
            {
                htmlEditor.ResolvedValue = bfi.FormConfirmationTemplate;
            }
        }
    }
Ejemplo n.º 14
0
        private IEnumerable <CampaignConversionData> PrepareCafeSamplePromotionConversions()
        {
            var document1 =
                CampaignDataGeneratorHelpers.GetDocument(PagePathAmericasCoffeePoster);
            var document2   = CampaignDataGeneratorHelpers.GetDocument(PagePathColombia);
            var bizFormInfo = BizFormInfoProvider.GetBizFormInfo(TryFreeSampleFormCodeName, _mSite.SiteID);

            return(new List <CampaignConversionData>
            {
                new CampaignConversionData
                {
                    ConversionName = "try_free_sample",
                    ConversionDisplayName = ConversionFormsubmissionTryFreeSample,
                    ConversionActivityType = "bizformsubmit",
                    ConversionItemId = bizFormInfo.FormID,
                    ConversionOrder = 1,
                    ConversionIsFunnelStep = false
                },
                new CampaignConversionData
                {
                    ConversionName = "america_coffee_poster",
                    ConversionDisplayName = document1.DocumentName,
                    ConversionActivityType = "pagevisit",
                    ConversionItemId = document1.NodeID,
                    ConversionOrder = 2,
                    ConversionIsFunnelStep = false
                },
                new CampaignConversionData
                {
                    ConversionName = "userregistration",
                    ConversionDisplayName = "",
                    ConversionActivityType = "userregistration",
                    ConversionItemId = new int?(),
                    ConversionOrder = 3,
                    ConversionIsFunnelStep = false
                },
                new CampaignConversionData
                {
                    ConversionName = "colombia",
                    ConversionDisplayName = document2.DocumentName,
                    ConversionActivityType = "pagevisit",
                    ConversionItemId = document2.NodeID,
                    ConversionOrder = 1,
                    ConversionIsFunnelStep = true
                },
                new CampaignConversionData
                {
                    ConversionName = "try_free_sample_1",
                    ConversionDisplayName = ConversionFormsubmissionTryFreeSample,
                    ConversionActivityType = "bizformsubmit",
                    ConversionItemId = bizFormInfo.FormID,
                    ConversionOrder = 2,
                    ConversionIsFunnelStep = true
                },
                new CampaignConversionData
                {
                    ConversionName = "america_coffee_poster_1",
                    ConversionDisplayName = document1.DocumentName,
                    ConversionActivityType = "pagevisit",
                    ConversionItemId = document1.NodeID,
                    ConversionOrder = 3,
                    ConversionIsFunnelStep = true
                }
            });
        }
Ejemplo n.º 15
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!BizFormInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.BizForms, ObjectActionEnum.Insert))
        {
            ShowError(GetString("LicenseVersion.BizForm"));
            return;
        }

        string formDisplayName = txtFormDisplayName.Text.Trim();
        string formName        = txtFormName.Text.Trim();
        string tableName       = txtTableName.Text.Trim();

        string errorMessage = new Validator().NotEmpty(formDisplayName, rfvFormDisplayName.ErrorMessage).
                              NotEmpty(formName, rfvFormName.ErrorMessage).
                              NotEmpty(tableName, rfvTableName.ErrorMessage).
                              IsIdentifier(formName, GetString("bizform_edit.errorformnameinidentifierformat")).
                              IsIdentifier(tableName, GetString("BizForm_Edit.ErrorFormTableNameInIdentifierFormat")).Result;

        if (!String.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
            return;
        }

        var bizFormObj = new BizFormInfo
        {
            FormDisplayName             = formDisplayName,
            FormName                    = formName,
            FormSiteID                  = SiteContext.CurrentSiteID,
            FormEmailAttachUploadedDocs = true,
            FormItems                   = 0,
            FormClearAfterSave          = false,
            FormLogActivity             = true
        };

        // Ensure the code name
        bizFormObj.Generalized.EnsureCodeName();

        // Table name is combined from prefix ('BizForm_<sitename>_') and custom table name
        string safeFormName = ValidationHelper.GetIdentifier(bizFormObj.FormName);

        bizFormObj.FormName = safeFormName;

        string className = bizFormNamespace + "." + safeFormName;

        // Generate the table name
        if (String.IsNullOrEmpty(tableName) || (tableName == InfoHelper.CODENAME_AUTOMATIC))
        {
            tableName = safeFormName;
        }
        tableName = FormTablePrefix + tableName;

        TableManager tm = new TableManager(null);

        // TableName wont be longer than 60 letters and will be unique
        if (tableName.Length > 60)
        {
            string tmpTableName = tableName.Substring(0, 59);
            int    x            = 1;
            do
            {
                tableName = tmpTableName + x;
                x++;
            } while (tm.TableExists(tableName));
        }

        // TableName should be unique
        if (tm.TableExists(tableName))
        {
            ShowError(string.Format(GetString("bizform_edit.errortableexists"), tableName));
            return;
        }

        // If first letter of safeFormName is digit, add "PK" to beginning
        string primaryKey = BizFormInfoProvider.GenerateFormPrimaryKeyName(bizFormObj.FormName);

        try
        {
            // Create new table in DB
            tm.CreateTable(tableName, primaryKey);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex);
            ShowError(string.Format(GetString("bizform_edit.createtableerror"), tableName));
            return;
        }

        // Change table owner
        try
        {
            string owner = SqlHelper.GetDBSchema(SiteContext.CurrentSiteName);
            if (!String.IsNullOrEmpty(owner) && (owner.ToLowerCSafe() != "dbo"))
            {
                tm.ChangeDBObjectOwner(tableName, owner);
                tableName = owner + "." + tableName;
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex);
        }

        // Create the BizForm class
        DataClassInfo dci = BizFormInfoProvider.CreateBizFormDataClass(className, formDisplayName, tableName, primaryKey);

        try
        {
            // Create new bizform dataclass
            using (CMSActionContext context = new CMSActionContext())
            {
                // Disable logging of tasks
                context.DisableLogging();

                DataClassInfoProvider.SetDataClassInfo(dci);
            }
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex);
            ShowError(ex.Message);

            CleanUpOnError(tableName, tm, dci);
            return;
        }

        // Create new bizform
        bizFormObj.FormClassID = dci.ClassID;
        try
        {
            BizFormInfoProvider.SetBizFormInfo(bizFormObj);
        }
        catch (Exception ex)
        {
            EventLogProvider.LogException("BIZFORM_NEW", EventType.ERROR, ex);
            ShowError(ex.Message);

            CleanUpOnError(tableName, tm, dci, bizFormObj);
            return;
        }

        // Redirect to Form builder tab
        string url = UIContextHelper.GetElementUrl("CMS.Form", "Forms.Properties", false, bizFormObj.FormID);

        url = URLHelper.AddParameterToUrl(url, "tabname", "Forms.FormBuldier");
        URLHelper.Redirect(url);
    }
Ejemplo n.º 16
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 = "";

        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          = "";
                txtFromEmail.Text        = "";
                txtSubject.Text          = "";
                chkAttachDocs.Checked    = true;
                htmlEditor.ResolvedValue = "";
            }

            if (errorMessage == "")
            {
                try
                {
                    BizFormInfoProvider.SetBizFormInfo(bfi);
                    DisplayInfoMessage(GetString("General.ChangesSaved"));
                    EnableDisableForm(bfi.FormEmailTemplate);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
            }

            if (errorMessage != "")
            {
                DisplayErrorMessage(errorMessage);
            }
        }
    }
Ejemplo n.º 17
0
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!currentUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToAccessDenied("cms.form", "EditForm");
        }

        // Validate form
        string 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) && !MacroProcessor.ContainsMacro(txtEmailFrom.Text.Trim()) && !ValidationHelper.IsEmail(txtEmailFrom.Text.Trim()))
        {
            errorMessage = GetString("bizform_edit_autoresponder.emptyemail");
        }

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

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

                    // Delete all attachments
                    MetaFileInfoProvider.DeleteFiles(formInfo.FormID, BizFormInfo.OBJECT_TYPE, ObjectAttachmentsCategories.FORMLAYOUT);

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

        if (!string.IsNullOrEmpty(errorMessage))
        {
            ShowError(errorMessage);
        }
    }
    /// <summary>
    /// On items selected event handling.
    /// </summary>
    private void usRoles_OnItemsSelected(object sender, EventArgs e)
    {
        AclProvider aclProv = null;

        // Create Acl provider to current treenode
        if (Node != null)
        {
            aclProv = new AclProvider(Tree);
        }

        // Remove old items
        string newValues = ValidationHelper.GetString(usRoles.Value, null);
        string items     = DataHelper.GetNewItemsInList(newValues, CurrentValues);

        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int roleID = ValidationHelper.GetInteger(item, 0);

                    if (PollID > 0)
                    {
                        // Remove role from poll
                        ModuleCommands.PollsRemoveRoleFromPoll(roleID, PollID);
                    }
                    else if (FormID > 0)
                    {
                        // Remove role from form
                        BizFormInfoProvider.RemoveRoleFromForm(roleID, FormID);
                    }
                    else if (BoardID > 0)
                    {
                        // Check permissions
                        if (CMSContext.CurrentUser.IsAuthorizedPerResource("cms.messageboards", CMSAdminControl.PERMISSION_MODIFY))
                        {
                            // Remove message board from board
                            ModuleCommands.MessageBoardRemoveRoleFromBoard(roleID, BoardID);
                        }
                    }
                    else if (Node != null)
                    {
                        if (aclProv != null)
                        {
                            // Remove role from treenode
                            aclProv.RemoveRole(NodeID, roleID);
                        }
                    }
                }
            }
        }

        // Add new items
        items = DataHelper.GetNewItemsInList(CurrentValues, newValues);
        if (!String.IsNullOrEmpty(items))
        {
            string[] newItems = items.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            if (newItems != null)
            {
                // Add all new items to site
                foreach (string item in newItems)
                {
                    int roleID = ValidationHelper.GetInteger(item, 0);

                    if (PollID > 0)
                    {
                        // Add poll role
                        ModuleCommands.PollsAddRoleToPoll(roleID, PollID);
                    }
                    else if (FormID > 0)
                    {
                        // Add BizForm role
                        BizFormInfoProvider.AddRoleToForm(roleID, FormID);
                    }
                    else if (BoardID > 0)
                    {
                        // Add role to the message board
                        ModuleCommands.MessageBoardAddRoleToBoard(roleID, BoardID);
                    }
                    else if (Node != null)
                    {
                        // Add role to treenode
                        if (aclProv != null)
                        {
                            aclProv.SetRolePermissions(Node, 0, 0, roleID);
                        }
                    }
                }
            }
        }

        // Log synchronization task
        if (Node != null)
        {
            DocumentSynchronizationHelper.LogDocumentChange(Node, TaskTypeEnum.UpdateDocument, Node.TreeProvider);
        }

        RaiseOnChanged();
    }
    /// <summary>
    /// Save button is clicked.
    /// </summary>
    protected void lnkSave_Click(object sender, EventArgs e)
    {
        // Check 'EditForm' permission
        if (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource("cms.form", "EditForm"))
        {
            RedirectToAccessDenied("cms.form", "EditForm");
        }

        string errorMessage = null;

        if (formInfo != 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) && !MacroProcessor.ContainsMacro(txtToEmail.Text.Trim()) && !txtToEmail.IsValid())
                {
                    errorMessage = GetString("BizFormGeneral.EmptyToEmail");
                }

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

                if (string.IsNullOrEmpty(errorMessage))
                {
                    formInfo.FormSendFromEmail = txtFromEmail.Text.Trim();
                    formInfo.FormSendToEmail = txtToEmail.Text.Trim();
                    formInfo.FormEmailSubject = txtSubject.Text.Trim();
                    formInfo.FormEmailAttachUploadedDocs = chkAttachDocs.Checked;
                    if (chkCustomLayout.Checked)
                    {
                        formInfo.FormEmailTemplate = htmlEditor.ResolvedValue.Trim();
                    }
                    else
                    {
                        formInfo.FormEmailTemplate = null;
                    }
                }
            }
            else
            {
                formInfo.FormSendFromEmail = null;
                formInfo.FormSendToEmail = null;
                formInfo.FormEmailSubject = null;
                formInfo.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(formInfo);
                    ShowChangesSaved();
                    EnableDisableForm(formInfo.FormEmailTemplate);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;
                }
            }

            if (!string.IsNullOrEmpty(errorMessage))
            {
                ShowError(errorMessage);
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.DisplayControlsPanel = true;

        int formId       = 0;
        int formRecordId = 0;

        // Check 'ReadData' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadData");
        }
        // Check 'EditData' permission
        else if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "EditData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "EditData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);

        if (formId > 0)
        {
            // Get form record id
            formRecordId = QueryHelper.GetInteger("formrecordid", 0);

            string currentRecord = "";

            // Edit record
            if (formRecordId > 0)
            {
                currentRecord = GetString("BizForm_Edit_EditRecord.EditRecord");
                if (!RequestHelper.IsPostBack())
                {
                    chkSendNotification.Checked  = false;
                    chkSendAutoresponder.Checked = false;
                }
            }
            // New record
            else
            {
                currentRecord = GetString("BizForm_Edit_EditRecord.NewRecord");
                if (!RequestHelper.IsPostBack())
                {
                    chkSendNotification.Checked  = true;
                    chkSendAutoresponder.Checked = true;
                }
            }

            // Initializes page title
            string[,] breadcrumbs = new string[2, 3];
            breadcrumbs[0, 0]     = GetString("BizForm_Edit_EditRecord.Data");
            breadcrumbs[0, 1]     = "~/CMSModules/BizForms/Tools/BizForm_Edit_Data.aspx?formid=" + formId;
            breadcrumbs[0, 2]     = "";
            breadcrumbs[1, 0]     = currentRecord;
            breadcrumbs[1, 1]     = "";
            breadcrumbs[1, 2]     = "";

            CurrentMaster.Title.Breadcrumbs = breadcrumbs;

            bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
            EditedObject = bfi;

            if (!RequestHelper.IsPostBack())
            {
                // Get form info
                if (bfi != null)
                {
                    // Set form
                    formElem.FormName          = bfi.FormName;
                    formElem.ItemID            = formRecordId;
                    formElem.ShowPrivateFields = true;
                }
            }

            formElem.FormRedirectToUrl  = String.Empty;
            formElem.FormDisplayText    = String.Empty;
            formElem.FormClearAfterSave = false;
            formElem.OnBeforeSave      += formElem_OnBeforeSave;
        }
    }
Ejemplo n.º 21
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Tools
        CurrentUserInfo user = CMSContext.CurrentUser;

        if (!user.IsAuthorizedPerUIElement("CMS.Desk", "Tools"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Desk", "Tools");
        }

        // Check permissions for CMS Desk -> Tools -> BizForms
        if (!user.IsAuthorizedPerUIElement("CMS.Tools", "Form"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "Form");
        }

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

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (bfi != null)
        {
            // Check authorized roles for this form
            if (!bfi.IsFormAllowedForUser(CMSContext.CurrentUser.UserName, CMSContext.CurrentSiteName))
            {
                RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
            }
        }

        string[]      columnNames  = null;
        DataClassInfo dci          = null;
        Hashtable     reportFields = new Hashtable();
        FormInfo      fi           = null;

        // Initialize controls
        this.CurrentMaster.Title.TitleText     = GetString("BizForm_Edit_Data_SelectFields.Title");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_Form/selectfields.png");
        this.CurrentMaster.DisplayActionsPanel = true;

        btnSelectAll.Text = GetString("BizForm_Edit_Data_SelectFields.SelectAll");

        if (!RequestHelper.IsPostBack())
        {
            btnOk.Text     = GetString("General.OK");
            btnCancel.Text = GetString("General.Cancel");

            if (bfi != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames();
                }

                // Get report fields
                if (String.IsNullOrEmpty(bfi.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in bfi.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    foreach (string name in columnNames)
                    {
                        FormFieldInfo ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        ListItem item = new ListItem(ResHelper.LocalizeString(GetFieldCaption(ffi, name)), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Stores data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!selSite.UniSelector.HasData || !selectForm.HasData)
        {
            ShowError(GetString("srch.err.selectform"));
            return;
        }

        SearchIndexInfo sii = SearchIndexInfoProvider.GetSearchIndexInfo(ItemID);

        if (sii != null)
        {
            SearchIndexSettings     sis = sii.IndexSettings;
            SearchIndexSettingsInfo sisi;

            var isInsert = false;

            if (ItemGUID != Guid.Empty)
            {
                // If we are updating existing Search Index Settings Info
                sisi = sis.GetSearchIndexSettingsInfo(ItemGUID);
            }
            else
            {
                // If we are creating new Search Index Settings Info
                isInsert = true;

                sisi    = new SearchIndexSettingsInfo();
                sisi.ID = Guid.NewGuid();
            }

            // Save values
            if (sisi != null)
            {
                string formName = ValidationHelper.GetString(selectForm.Value, "");

                sisi.SetValue("FormName", formName);
                sisi.WhereCondition = txtWhere.TextArea.Text.Trim();
                sisi.SiteName       = selSite.Value.ToString();

                BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formName, sisi.SiteName);
                if (bfi != null)
                {
                    sisi.SetValue("DisplayName", bfi.FormDisplayName);
                    sisi.ClassNames = BizFormItemProvider.BIZFORM_ITEM_PREFIX + DataClassInfoProvider.GetClassName(bfi.FormClassID);
                }

                // Update settings item
                sis.SetSearchIndexSettingsInfo(sisi);

                // Update xml value
                sii.IndexSettings = sis;
                SearchIndexInfoProvider.SetSearchIndexInfo(sii);
                ItemGUID = sisi.ID;

                if (isInsert)
                {
                    // Redirect to edit mode
                    var editUrl = "SearchIndex_Content_Edit.aspx";
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "indexId", sii.IndexID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "guid", sisi.ID.ToString());
                    editUrl = URLHelper.AddParameterToUrl(editUrl, "saved", "1");
                    if (smartSearchEnabled)
                    {
                        editUrl = URLHelper.AddParameterToUrl(editUrl, "rebuild", "1");
                    }
                    URLHelper.Redirect(editUrl);
                }

                ShowChangesSaved();

                if (smartSearchEnabled)
                {
                    // Show rebuild message
                    ShowInformation(String.Format(GetString("srch.indexrequiresrebuild"), "<a href=\"javascript:" + Page.ClientScript.GetPostBackEventReference(this, "saved") + "\">" + GetString("General.clickhere") + "</a>"));
                }
            }
            // Error loading SearchIndexSettingsInfo
            else
            {
                ShowError(GetString("srch.err.loadingsisi"));
            }
        }
        // Error loading SearchIndexInfo
        else
        {
            ShowError(GetString("srch.err.loadingsii"));
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' and 'EditData' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        currentUser = CMSContext.CurrentUser;

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        // Get form id from URL
        formId = QueryHelper.GetInteger("formid", 0);
        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (bfi != null)
        {
            // Control initialization
            ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Autoresponder.ConfirmDelete") + "\">";

            drpEmailField.SelectedIndexChanged += new EventHandler(drpEmailField_SelectedIndexChanged);

            // Init header actions
            InitHeaderActions();

            // Initialize HTML editor
            InitHTMLEditor();

            if (!RequestHelper.IsPostBack())
            {
                // Get bizform class object
                formClassObj = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
                if (formClassObj != null)
                {
                    // Enable or disable form
                    EnableDisableForm(bfi.FormConfirmationTemplate);

                    // Fill list of available fields
                    FillFieldsList();

                    // Load dropdown list with form text fields
                    FormInfo fi = FormHelper.GetFormInfo(formClassObj.ClassName, false);
                    drpEmailField.DataSource = fi.GetFields(FormFieldDataTypeEnum.Text);
                    drpEmailField.DataBind();
                    drpEmailField.Items.Insert(0, new ListItem(GetString("bizform_edit_autoresponder.emptyemailfield"), string.Empty));

                    // Try to select specified field
                    ListItem li = drpEmailField.Items.FindByValue(bfi.FormConfirmationEmailField);
                    if (li != null)
                    {
                        li.Selected = true;
                    }

                    // Load email subject and email from address
                    txtEmailFrom.Text    = bfi.FormConfirmationSendFromEmail;
                    txtEmailSubject.Text = bfi.FormConfirmationEmailSubject;
                }
                else
                {
                    // Disable form by default
                    EnableDisableForm(null);
                }
            }
        }
    }
Ejemplo n.º 24
0
    /// <summary>
    /// Sets data to database.
    /// </summary>
    protected void btnOK_Click(object sender, EventArgs e)
    {
        if (!BizFormInfoProvider.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.BizForms, ObjectActionEnum.Insert))
        {
            ShowError(GetString("LicenseVersion.BizForm"));
            return;
        }

        DataClassInfo dci        = null;
        BizFormInfo   bizFormObj = null;

        string errorMessage = new Validator().NotEmpty(txtFormDisplayName.Text, rfvFormDisplayName.ErrorMessage).
                              NotEmpty(txtFormName.Text, rfvFormName.ErrorMessage).
                              NotEmpty(txtTableName.Text, rfvTableName.ErrorMessage).
                              IsIdentifier(txtFormName.Text, GetString("bizform_edit.errorformnameinidentifierformat")).
                              IsIdentifier(txtTableName.Text, GetString("BizForm_Edit.ErrorFormTableNameInIdentifierFormat")).Result;

        if (String.IsNullOrEmpty(errorMessage))
        {
            using (var tr = new CMSTransactionScope())
            {
                // Prepare the values
                string formDisplayName = txtFormDisplayName.Text.Trim();

                bizFormObj = new BizFormInfo();
                bizFormObj.FormDisplayName             = formDisplayName;
                bizFormObj.FormName                    = txtFormName.Text.Trim();
                bizFormObj.FormSiteID                  = SiteContext.CurrentSiteID;
                bizFormObj.FormEmailAttachUploadedDocs = true;
                bizFormObj.FormItems                   = 0;
                bizFormObj.FormClearAfterSave          = false;
                bizFormObj.FormLogActivity             = true;

                // Ensure the code name
                bizFormObj.Generalized.EnsureCodeName();

                // Table name is combined from prefix ('BizForm_<sitename>_') and custom table name
                string safeFormName = ValidationHelper.GetIdentifier(bizFormObj.FormName);
                bizFormObj.FormName = safeFormName;

                string className = bizFormNamespace + "." + safeFormName;

                // Generate the table name
                string tableName = txtTableName.Text.Trim();
                if (String.IsNullOrEmpty(tableName) || (tableName == InfoHelper.CODENAME_AUTOMATIC))
                {
                    tableName = safeFormName;
                }
                tableName = FormTablePrefix + tableName;

                TableManager tm = new TableManager(null);

                // TableName wont be longer than 60 letters and will be unique
                if (tableName.Length > 60)
                {
                    int x = 1;

                    while (tm.TableExists(tableName.Substring(0, 59) + x.ToString()))
                    {
                        x++;
                    }

                    tableName = tableName.Substring(0, 59) + x.ToString();
                }

                // If first letter of safeFormName is digit, add "PK" to beginning
                string primaryKey = BizFormInfoProvider.GenerateFormPrimaryKeyName(bizFormObj.FormName);

                try
                {
                    // Create new table in DB
                    tm.CreateTable(tableName, primaryKey);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Table with the same name already exists
                    ShowError(string.Format(GetString("bizform_edit.errortableexists"), tableName));
                    return;
                }

                // Change table owner
                try
                {
                    string owner = SqlHelper.GetDBSchema(SiteContext.CurrentSiteName);
                    if ((!String.IsNullOrEmpty(owner)) && (owner.ToLowerCSafe() != "dbo"))
                    {
                        tm.ChangeDBObjectOwner(tableName, owner);
                        tableName = owner + "." + tableName;
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("BIZFORM_NEW", "E", ex);
                }

                // Convert default datetime to string in english format
                string defaultDateTime = DateTime.Now.ToString(CultureHelper.EnglishCulture.DateTimeFormat);

                try
                {
                    // Add FormInserted and FormUpdated columns to the table
                    tm.AddTableColumn(tableName, "FormInserted", "datetime", false, defaultDateTime);
                    tm.AddTableColumn(tableName, "FormUpdated", "datetime", false, defaultDateTime);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Column wasn't added successfully
                    ShowError(errorMessage);

                    return;
                }

                // Create the BizForm class
                dci = BizFormInfoProvider.CreateBizFormDataClass(className, formDisplayName, tableName, primaryKey);

                try
                {
                    // Create new bizform dataclass
                    using (CMSActionContext context = new CMSActionContext())
                    {
                        // Disable logging of tasks
                        context.DisableLogging();

                        // Set default search settings
                        dci.ClassSearchEnabled = true;

                        DataClassInfoProvider.SetDataClassInfo(dci);

                        // Create default search settings
                        dci.ClassSearchSettings           = SearchHelper.GetDefaultSearchSettings(dci);
                        dci.ClassSearchCreationDateColumn = "FormInserted";
                        DataClassInfoProvider.SetDataClassInfo(dci);
                    }
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    // Class with the same name already exists
                    ShowError(errorMessage);

                    return;
                }

                // Create new bizform
                bizFormObj.FormClassID = dci.ClassID;

                try
                {
                    // Create new bizform
                    BizFormInfoProvider.SetBizFormInfo(bizFormObj);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message;

                    ShowError(errorMessage);

                    return;
                }

                tr.Commit();

                if (String.IsNullOrEmpty(errorMessage))
                {
                    // Redirect to Form builder tab
                    string url = UIContextHelper.GetElementUrl("CMS.Form", "Forms.Properties", false, bizFormObj.FormID);
                    url = URLHelper.AddParameterToUrl(url, "tabname", "Forms.FormBuldier");
                    URLHelper.Redirect(url);
                }
            }
        }
        else
        {
            ShowError(errorMessage);
        }
    }
Ejemplo n.º 25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' and 'EditData' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        currentUser = CMSContext.CurrentUser;

        // get form id from url
        formId = QueryHelper.GetInteger("formid", 0);
        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (bfi != null)
        {
            imgSave.ImageUrl = GetImageUrl("CMSModules/CMS_Content/EditMenu/save.png");
            mSave            = GetString("general.save");

            AttachmentTitle.TitleText = GetString("general.attachments");

            // Control initialization
            ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Autoresponder.ConfirmDelete") + "\">";

            drpEmailField.SelectedIndexChanged += new EventHandler(drpEmailField_SelectedIndexChanged);

            // Init attachment storage
            AttachmentList.SiteID = CMSContext.CurrentSiteID;
            AttachmentList.AllowPasteAttachments = true;
            AttachmentList.ObjectID   = bfi.FormID;
            AttachmentList.ObjectType = FormObjectType.BIZFORM;
            AttachmentList.Category   = MetaFileInfoProvider.OBJECT_CATEGORY_FORM_LAYOUT;

            // Initialize HTML editor
            InitHTMLEditor();

            if (!RequestHelper.IsPostBack())
            {
                // Get bizform class object
                formClassObj = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
                if (formClassObj != null)
                {
                    // Enable or disable form
                    EnableDisableForm(bfi.FormConfirmationTemplate);

                    // Fill list of available fields
                    FillFieldsList();

                    // Load dropdownlist with form text fields
                    FormInfo fi = FormHelper.GetFormInfo(formClassObj.ClassName, false);
                    drpEmailField.DataSource = fi.GetFields(FormFieldDataTypeEnum.Text);
                    drpEmailField.DataBind();
                    drpEmailField.Items.Insert(0, new ListItem(GetString("bizform_edit_autoresponder.emptyemailfield"), ""));

                    // Try to select specified field
                    ListItem li = drpEmailField.Items.FindByValue(bfi.FormConfirmationEmailField);
                    if (li != null)
                    {
                        li.Selected = true;
                    }

                    // Load email subject and emailfrom address
                    txtEmailFrom.Text    = bfi.FormConfirmationSendFromEmail;
                    txtEmailSubject.Text = bfi.FormConfirmationEmailSubject;
                }
                else
                {
                    // Disable form by default
                    EnableDisableForm(null);
                }
            }
        }
    }
Ejemplo n.º 26
0
    /// <summary>
    /// Builds and returns the list of object types that can contain macros.
    /// </summary>
    /// <param name="include">Object types to include in the list</param>
    /// <param name="exclude">Object types to exclude from the list</param>
    /// <remarks>
    /// Excludes the object types that cannot contain macros.
    /// </remarks>
    private IEnumerable <string> GetObjectTypesWithMacros(IEnumerable <string> include, IEnumerable <string> exclude)
    {
        // Get the system object types
        var objectTypes = ObjectTypeLists.AllObjectTypes.AsEnumerable();

        // Include custom table object types
        objectTypes = objectTypes.Union(DataClassInfoProvider.GetCustomTableClasses(null, null, 0, "ClassName").Tables[0].Select().Select(r => r["ClassName"].ToString()));

        // Include biz form object types
        objectTypes = objectTypes.Union(BizFormInfoProvider.GetAllBizForms().Tables[0].Select().Select(r => "bizformitem.bizform." + r["FormName"].ToString()));

        // Include object types
        if (include != null)
        {
            objectTypes = objectTypes.Union(include);
        }

        // Exclude object types
        if (exclude != null)
        {
            objectTypes = objectTypes.Except(exclude);
        }

        // Exclude object types that do not contain macros
        objectTypes = objectTypes.Except(new[] {
            PredefinedObjectType.STATISTICS,

            EmailObjectType.EMAIL,

            LicenseObjectType.LICENSEKEY,

            PredefinedObjectType.ACTIVITY,
            "om.pagevisit",
            "om.search",

            PredefinedObjectType.CHATONLINEUSER,
            PredefinedObjectType.EVENT,

            ResourceObjectType.RESOURCESTRING,
            ResourceObjectType.RESOURCETRANSLATION,
            ResourceObjectType.RESOURCETRANSLATED,

            "cms.objectsettings",

            SiteObjectType.USERROLELIST,
            SiteObjectType.MEMBERSHIPLIST,

            DocumentObjectType.USERDOCUMENTSLIST,

            "temp.file"
        });

        objectTypes = objectTypes.Where(t =>
        {
            try
            {
                var typeInfo = TranslationHelper.GetReadOnlyObject(t).TypeInfo;
                return(!typeInfo.Inherited && !typeInfo.IsBinding);
            }
            catch (Exception)
            {
                return(false);
            }
        });

        return(objectTypes);
    }
    /// <summary>
    /// Save data to Database.
    /// </summary>
    protected void SaveData()
    {
        // Check display name emptiness
        if (string.IsNullOrEmpty(txtDisplayName.Text))
        {
            ShowError(GetString("BizFormGeneral.rfvDisplayName"));
            return;
        }

        bfi.FormDisplayName      = txtDisplayName.Text;
        bfi.FormName             = txtCodeName.Text;
        bfi.FormSubmitButtonText = txtButtonText.Text;

        bfi.FormSubmitButtonImage = null;
        if (!string.IsNullOrEmpty(txtSubmitButtonImage.Text.Trim()))
        {
            bfi.FormSubmitButtonImage = txtSubmitButtonImage.Text.Trim();
        }

        // Set 'after submitting' behavior...
        bfi.FormRedirectToUrl = null;
        bfi.FormDisplayText   = null;

        // ... clear form
        bfi.FormClearAfterSave = radClear.Checked;

        // ... display text
        if (radDisplay.Checked)
        {
            if (!string.IsNullOrEmpty(txtDisplay.Text.Trim()))
            {
                bfi.FormDisplayText = txtDisplay.Text.Trim();
            }
            else
            {
                ShowError(GetString("BizFormGeneral.DisplayText"));
                return;
            }
        }
        else
        {
            txtDisplay.Text = string.Empty;
        }

        // ... redirect
        if (radRedirect.Checked)
        {
            bfi.FormRedirectToUrl = txtRedirect.Text.Trim();
        }
        else
        {
            txtRedirect.Text = string.Empty;
        }

        BizFormInfoProvider.SetBizFormInfo(bfi);

        ShowChangesSaved();

        // Reload header if changes were saved
        ScriptHelper.RefreshTabHeader(Page, bfi.FormDisplayName);
    }
Ejemplo n.º 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadData' permission
        CheckPermissions("ReadData");

        // Get form ID from url
        formId = QueryHelper.GetInteger("formid", 0);

        // Register scripts
        ScriptHelper.RegisterDialogScript(this);
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "SelectFields", ScriptHelper.GetScript("function SelectFields() { modalDialog('" +
                                                                                                            ResolveUrl("~/CMSModules/BizForms/Tools/BizForm_Edit_Data_SelectFields.aspx") + "?formid=" + formId + "'  ,'BizFormFields', 500, 500); }"));
        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "Edit", ScriptHelper.GetScript(
                                                   "function EditRecord(formId, recordId) { " +
                                                   "  document.location.replace('BizForm_Edit_EditRecord.aspx?formID=' + formId + '&formRecordID=' + recordId); } "
                                                   ));

        // Prepare header actions
        string[,] actions = new string[2, 6];
        // New record link
        actions[0, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[0, 1] = GetString("bizform_edit_data.newrecord");
        actions[0, 2] = null;
        actions[0, 3] = ResolveUrl("BizForm_Edit_EditRecord.aspx?formid=" + formId.ToString());
        actions[0, 4] = null;
        actions[0, 5] = GetImageUrl("CMSModules/CMS_Form/newrecord.png");
        // Select fields link
        actions[1, 0] = HeaderActions.TYPE_HYPERLINK;
        actions[1, 1] = GetString("bizform_edit_data.selectdisplayedfields");
        actions[1, 2] = null;
        actions[1, 3] = "javascript:SelectFields();";
        actions[1, 4] = null;
        actions[1, 5] = GetImageUrl("CMSModules/CMS_Form/selectfields16.png");

        CurrentMaster.HeaderActions.Actions = actions;

        // Initialize unigrid
        gridData.OnExternalDataBound += gridData_OnExternalDataBound;
        gridData.OnLoadColumns       += gridData_OnLoadColumns;
        gridData.OnAction            += gridData_OnAction;

        // Get BizFormInfo object
        bfi          = BizFormInfoProvider.GetBizFormInfo(formId);
        EditedObject = bfi;

        if (bfi != null)
        {
            dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);
            if (dci != null)
            {
                className = dci.ClassName;

                // Set alternative form and data container
                gridData.ObjectType     = BizFormItemProvider.GetObjectType(className);
                gridData.FilterFormName = className + "." + "filter";
                gridData.FilterFormData = bfi;

                // Get primary column name
                gridData.OrderBy = primaryColumn = GetPrimaryColumn(FormInfo, bfi.FormName);
            }
        }
    }
        private IEnumerable <CampaignConversionData> PrepareCafeSamplePromotionConversions()
        {
            var pageCoffeeSamples    = CampaignDataGeneratorHelpers.GetDocument(PAGE_PATH_COFFEE_SAMPLES);
            var formCoffeeSampleList = BizFormInfoProvider.GetBizFormInfo(COFFEE_SAMPLE_LIST_FORM_CODE_NAME, mSite.SiteID);

            var liveUrl = DocumentURLProvider.GetAbsoluteLiveSiteURL(pageCoffeeSamples);

            return(new List <CampaignConversionData>
            {
                /*  Campaign conversions. */
                new CampaignConversionData
                {
                    ConversionName = "coffee_samples",
                    ConversionDisplayName = pageCoffeeSamples.DocumentName,
                    ConversionActivityType = PredefinedActivityType.PAGE_VISIT,
                    ConversionItemID = null,
                    ConversionOrder = 1,
                    ConversionIsFunnelStep = false,
                    ConversionUrl = liveUrl
                },
                new CampaignConversionData
                {
                    ConversionName = "coffee_sample_list",
                    ConversionDisplayName = CONVERSION_FORMSUBMISSION_COFFEE_SAMPLE_LIST,
                    ConversionActivityType = PredefinedActivityType.BIZFORM_SUBMIT,
                    ConversionItemID = formCoffeeSampleList.FormID,
                    ConversionOrder = 2,
                    ConversionIsFunnelStep = false
                },

                /* Campaign journey steps. */
                new CampaignConversionData
                {
                    ConversionName = "coffee_samples_1",
                    ConversionDisplayName = pageCoffeeSamples.DocumentName,
                    ConversionActivityType = PredefinedActivityType.PAGE_VISIT,
                    ConversionItemID = null,
                    ConversionOrder = 1,
                    ConversionIsFunnelStep = true,
                    ConversionUrl = liveUrl
                },
                new CampaignConversionData
                {
                    ConversionName = "coffee_sample_list_1",
                    ConversionDisplayName = CONVERSION_FORMSUBMISSION_COFFEE_SAMPLE_LIST,
                    ConversionActivityType = PredefinedActivityType.BIZFORM_SUBMIT,
                    ConversionItemID = formCoffeeSampleList.FormID,
                    ConversionOrder = 2,
                    ConversionIsFunnelStep = true
                },
                new CampaignConversionData
                {
                    ConversionName = "purchase",
                    ConversionDisplayName = CONVERSION_PURCHASE,
                    ConversionActivityType = PredefinedActivityType.PURCHASE,
                    ConversionItemID = 0,
                    ConversionOrder = 3,
                    ConversionIsFunnelStep = true
                }
            });
        }
Ejemplo n.º 30
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check 'ReadForm' and 'EditData' permission
        if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.form", "ReadForm"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadForm");
        }

        // Get form id from URL
        formId = QueryHelper.GetInteger("formid", 0);

        // Add save action
        save = new SaveAction(Page);
        menu.AddAction(save);

        // Register for action
        ComponentEvents.RequestEvents.RegisterForEvent(ComponentEvents.SAVE, lnkSave_Click);

        // Control initialization
        ltlConfirmDelete.Text = "<input type=\"hidden\" id=\"confirmdelete\" value=\"" + GetString("Bizform_Edit_Notificationemail.ConfirmDelete") + "\">";

        chkSendToEmail.Text = GetString("BizFormGeneral.chkSendToEmail");
        chkAttachDocs.Text  = GetString("BizForm_Edit_NotificationEmail.AttachUploadedDocs");

        chkCustomLayout.Text = GetString("BizForm_Edit_NotificationEmail.CustomLayout");

        // Initialize HTML editor
        InitHTMLEditor();

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (!RequestHelper.IsPostBack())
        {
            if (bfi != null)
            {
                // Get form class object
                formClassObj = DataClassInfoProvider.GetDataClass(bfi.FormClassID);

                // Fill list of available fields
                FillFieldsList();

                // Load email from/to address and email subject
                txtFromEmail.Text      = ValidationHelper.GetString(bfi.FormSendFromEmail, "");
                txtToEmail.Text        = ValidationHelper.GetString(bfi.FormSendToEmail, "");
                txtSubject.Text        = ValidationHelper.GetString(bfi.FormEmailSubject, "");
                chkAttachDocs.Checked  = bfi.FormEmailAttachUploadedDocs;
                chkSendToEmail.Checked = ((txtFromEmail.Text + txtToEmail.Text) != "");
                if (!chkSendToEmail.Checked)
                {
                    txtFromEmail.Enabled    = false;
                    txtToEmail.Enabled      = false;
                    txtSubject.Enabled      = false;
                    chkAttachDocs.Enabled   = false;
                    chkCustomLayout.Visible = false;
                    pnlCustomLayout.Visible = false;
                }
                else
                {
                    // Enable or disable form
                    EnableDisableForm(bfi.FormEmailTemplate);
                }
            }
            else
            {
                // Disable form by default
                EnableDisableForm(null);
            }
        }
    }