示例#1
0
        private void SetupPage(FQDNN_Form oForm, FQDNN_FormPage oCurrentPage)
        {
            this.FindControl(oCurrentPage.GetControlID()).Visible = true;

            foreach (FQDNN_FormControl oPageControl in oCurrentPage.FQDNN_FormControl)
            {
                SetupPageControl(oPageControl);
            }

            //set previous and next page button's visibility
            FormSettings oFormSettings = new FormSettings();
            bool bUserCanNavigateBackInTheForm = oFormSettings.UserCanNavigateBack(oForm.FQDNN_FormSetting.ToList());

            if (bUserCanNavigateBackInTheForm)
            {
                ((Button)this.FindControl(oCurrentPage.GetPreviousPageControlID())).Click += PreviousPage;
            }
            ((Button)this.FindControl(oCurrentPage.GetNextPageControlID())).Click += NextPage;

            if (PageNumber == 1 || !bUserCanNavigateBackInTheForm)
            {
                this.FindControl(oCurrentPage.GetPreviousPageControlID()).Visible = false;
            }
            if (PageNumber == TotalPages)
            {
                this.FindControl(oCurrentPage.GetNextPageControlID()).Visible = false;
            }
        }
示例#2
0
        private void SetupForm()
        {
            DataAccess oDataAccess = new DataAccess();
            FQDNN_Form oForm = oDataAccess.GetFullForm(FormID);

            FQDNN_FormPage oCurrentPage = null;

            TotalPages = oForm.FQDNN_FormPage.Count;

            //find current page
            foreach (FQDNN_FormPage oFormPage in oForm.FQDNN_FormPage)
            {
                this.FindControl(oFormPage.GetControlID()).Visible = false;

                if (oFormPage.PageNumber == PageNumber)
                {
                    oCurrentPage = oFormPage;
                }
            }

            if (oCurrentPage != null)
            {
                SetupPage(oForm, oCurrentPage);
            }

            //display or hide the submit button
            this.FindControl(oForm.GetSubmitButtonControlID()).Visible = false;
            if (PageNumber == TotalPages)
            {
                FormSettings oFormSettings = new FormSettings();
                if (oFormSettings.GetRedirectAction(oForm.FQDNN_FormSetting.ToList()) != FormSettings.FormRedirectActions.LastPageIsFinal)
                {
                    this.FindControl(oForm.GetSubmitButtonControlID()).Visible = true;
                    ((Button)this.FindControl(oForm.GetSubmitButtonControlID())).Click += SubmitForm;
                }
            }

            //display final generic message if there is not redirect or last page
            System.Web.UI.Control GenericMessageControl = this.FindControl(oForm.GetGenericMessageControlID());
            if (GenericMessageControl != null)
            {
                GenericMessageControl.Visible = false;
                if (PageNumber == GenericMessagePageNumber)
                {
                    GenericMessageControl.Visible = true;
                }
            }
        }
示例#3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Page_Load runs when the control is loaded
        /// </summary>
        /// -----------------------------------------------------------------------------
        private void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                //check settings to decide which form to load
                if(Settings["FormGUID"] != null)
                {
                    DataAccess oDataAccess = new DataAccess();
                    FQDNN_Form Form = oDataAccess.GetActiveForm(Settings["FormGUID"].ToString(), new CommonLogic().GetCurrentLocale(), PortalId, PortalSettings.DefaultLanguage);
                    if (Form != null)
                    {
                        Form = oDataAccess.GetFullForm(Form.FormID);
                        FormSettings oFormSettings = new FormSettings();
                        //load the form and place it on this page if the user is allowed to file.
                        if (UserCanFileForm(UserInfo, Form))
                        {
                            string FormTemplateName = Form.FormID.ToString();
                            if (!String.IsNullOrEmpty(Form.FormTemplate))
                            {
                                FormTemplateName = Form.FormTemplate;
                            }

                            string FormTemplatePath = CommonLogic.PathToTemplates + FormTemplateName + ".ascx";
                            FormBase Template = (FormBase)LoadControl(FormTemplatePath);
                            Template.ModuleConfiguration = this.ModuleConfiguration;
                            Template.LocalResourceFile = this.LocalResourceFile;
                            Template.FormID = Form.FormID;
                            this.Controls.Add(Template);
                        }
                    }
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
示例#4
0
        protected void SubmitForm(object sender, EventArgs e)
        {
            SavePage();

            DataAccess oDataAccess = new DataAccess();
            FQDNN_Form oForm = oDataAccess.GetFullForm(FormID);

            FormSettings oFormSettings = new FormSettings();
            FormSettings.FormRedirectActions redirection = oFormSettings.GetRedirectAction(oForm.FQDNN_FormSetting.ToList());

            //perform different redirects after submitting form
            if (redirection == FormSettings.FormRedirectActions.RedirectToUrl)
            {
                string redirectUrl = oFormSettings.GetRedirectUrlAfterFiling(oForm.FQDNN_FormSetting.ToList());
                if(!String.IsNullOrEmpty(redirectUrl))
                {
                    Response.Redirect(redirectUrl);
                }
                else
                {
                    redirection = FormSettings.FormRedirectActions.GenericFinishedMessage;
                }
            }
            if (redirection == FormSettings.FormRedirectActions.RedirectToTab)
            {
                int redirectTabID = oFormSettings.GetRedirectTabAfterFiling(oForm.FQDNN_FormSetting.ToList());
                if (redirectTabID > 0)
                {
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(redirectTabID));
                }
                else
                {
                    redirection = FormSettings.FormRedirectActions.GenericFinishedMessage;
                }
            }
            if (redirection == FormSettings.FormRedirectActions.GenericFinishedMessage)
            {
                PageNumber = GenericMessagePageNumber;
                SetupForm();
            }
        }
        //check settings and return whether the current user is allowed to file the form
        public bool UserCanFileForm(UserInfo User, FQDNN_Form Form)
        {
            CommonLogic oCommonLogic = new CommonLogic();
            List<FQDNN_FormSetting> Settings = Form.FQDNN_FormSetting.ToList();
            FormSettings oFormSettings = new FormSettings();
            bool bFormAccessIsFiltered = oFormSettings.GetAccessIsFiltered(Settings);
            bool result = !bFormAccessIsFiltered;

            string listOfUsersAbleToFileForm = oFormSettings.GetListOfUsersAbleToFileForm(Settings);
            string listOfUserRolesAbleToFileForm = oFormSettings.GetListOfUserRolesAbleToFileForm(Settings);
            string listOfUsersNotAbleToFileForm = oFormSettings.GetListOfUsersNotAbleToFileForm(Settings);
            string listOfUserRolesNotAbleToFileForm = oFormSettings.GetListOfUserRolesNotAbleToFileForm(Settings);

            if (bFormAccessIsFiltered)
            {
                //if there are any allow rules then user is not allowed by default and then check if the user matches the rules.
                if (!String.IsNullOrEmpty(listOfUsersAbleToFileForm) || !String.IsNullOrEmpty(listOfUserRolesAbleToFileForm))
                {
                    result = false;
                    if (User != null)
                    {
                        if (!String.IsNullOrEmpty(listOfUsersAbleToFileForm))
                        {
                            if (oCommonLogic.IntIsInList(User.UserID, listOfUsersAbleToFileForm))
                            {
                                result = true;
                            }
                        }
                        if (!String.IsNullOrEmpty(listOfUserRolesAbleToFileForm))
                        {
                            if (oCommonLogic.UserIsInListOfRoles(User, listOfUserRolesAbleToFileForm))
                            {
                                result = true;
                            }
                        }
                    }
                }

                if (result == false)
                {
                    return false;
                }

                if (!String.IsNullOrEmpty(listOfUsersNotAbleToFileForm) || !String.IsNullOrEmpty(listOfUserRolesNotAbleToFileForm))
                {
                    if (User != null)
                    {
                        if (!String.IsNullOrEmpty(listOfUsersNotAbleToFileForm))
                        {
                            if (oCommonLogic.IntIsInList(User.UserID, listOfUsersNotAbleToFileForm))
                            {
                                result = false;
                            }
                        }
                        if (!String.IsNullOrEmpty(listOfUserRolesNotAbleToFileForm))
                        {
                            if (oCommonLogic.UserIsInListOfRoles(User, listOfUserRolesNotAbleToFileForm))
                            {
                                result = false;
                            }
                        }
                    }
                }
            }

            bool bUserCanFileMultipleTimes = oFormSettings.GetUserCanFileMultipleTimes(Settings);
            if (!bUserCanFileMultipleTimes)
            {
                DataAccess oDataAccess = new DataAccess();

                FQDNN_FormFiling oPreviousFormFiling = oDataAccess.GetLastFiling(User.UserID, oCommonLogic.GetUserIPAddress(), Form.FormID);

                if (oPreviousFormFiling != null)
                {
                    result = false;

                    bool bUserCanResumeFiling = oFormSettings.GetUserCanResumeFiling(Settings);
                    int iUserCanResumeInHours = oFormSettings.GetUserCanResumeInHours(Settings);

                    if (bUserCanResumeFiling)
                    {
                        DateTime Now = DateTime.Now;

                        if (Now > oPreviousFormFiling.DateCreated)
                        {
                            int hoursSincePreviousFiling = (Now - oPreviousFormFiling.DateCreated).Hours;
                            if (iUserCanResumeInHours > hoursSincePreviousFiling)
                            {
                                result = true;
                            }
                        }
                    }
                }
            }

            return result;
        }