protected void Page_Load(Object sender, EventArgs e)
        {
            try
            {
                UserInfo objUserInfo = null;
                int      intUserID   = -1;
                if (Request.IsAuthenticated)
                {
                    objUserInfo = UserController.GetCurrentUserInfo();
                    if (objUserInfo != null)
                    {
                        intUserID = objUserInfo.UserID;
                    }
                }

                int intRoleId = -1;
                if (Request.QueryString["roleid"] != null)
                {
                    intRoleId = int.Parse(Request.QueryString["roleid"]);
                }

                string           strProcessorUserId  = "";
                PortalController objPortalController = new PortalController();
                PortalInfo       objPortalInfo       = objPortalController.GetPortal(PortalSettings.PortalId);
                if (objPortalInfo != null)
                {
                    strProcessorUserId = objPortalInfo.ProcessorUserId;
                }

                Hashtable settings = PortalSettings.GetSiteSettings(PortalSettings.PortalId);
                string    strPayPalURL;

                if (intUserID != -1 && intRoleId != -1 && !String.IsNullOrEmpty(strProcessorUserId))
                {
                    strPayPalURL = "https://www.paypal.com/cgi-bin/webscr?";

                    if (Request.QueryString["cancel"] != null)
                    {
                        // build the cancellation PayPal URL
                        strPayPalURL += "cmd=_subscr-find&alias=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                    }
                    else
                    {
                        strPayPalURL += "cmd=_ext-enter";

                        RoleController objRoles = new RoleController();

                        RoleInfo objRole = objRoles.GetRole(intRoleId, PortalSettings.PortalId);
                        if (objRole.RoleID != -1)
                        {
                            int intTrialPeriod = 1;
                            if (objRole.TrialPeriod != 0)
                            {
                                intTrialPeriod = objRole.TrialPeriod;
                            }
                            int intBillingPeriod = 1;
                            if (objRole.BillingPeriod != 0)
                            {
                                intBillingPeriod = objRole.BillingPeriod;
                            }
                            // explicitely format numbers using en-US so numbers are correctly built
                            CultureInfo enFormat   = new CultureInfo("en-US");
                            string      strService = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.ServiceFee);
                            string      strTrial   = string.Format(enFormat.NumberFormat, "{0:#####0.00}", objRole.TrialFee);

                            if (objRole.BillingFrequency == "O" || objRole.TrialFrequency == "O")  //one-time payment
                            {
                                // build the payment PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + string.Format("{0:0.00}", objRole.ServiceFee) + " " + PortalSettings.Currency + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                strPayPalURL += "&quantity=1";
                                strPayPalURL += "&amount=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                            else //recurring payments
                            {
                                // build the subscription PayPal URL
                                strPayPalURL += "&redirect_cmd=_xclick-subscriptions&business=" + Globals.HTTPPOSTEncode(strProcessorUserId);
                                strPayPalURL += "&item_name=" + Globals.HTTPPOSTEncode(PortalSettings.PortalName + " - " + objRole.RoleName + " ( " + string.Format("{0:0.00}", objRole.ServiceFee) + " " + PortalSettings.Currency + " every " + intBillingPeriod.ToString() + " " + GetBillingFrequencyCode(objRole.BillingFrequency) + " )");
                                strPayPalURL += "&item_number=" + Globals.HTTPPOSTEncode(intRoleId.ToString());
                                strPayPalURL += "&no_shipping=1&no_note=1";
                                if (objRole.TrialFrequency != "N")
                                {
                                    strPayPalURL += "&a1=" + Globals.HTTPPOSTEncode(strTrial);
                                    strPayPalURL += "&p1=" + Globals.HTTPPOSTEncode(intTrialPeriod.ToString());
                                    strPayPalURL += "&t1=" + Globals.HTTPPOSTEncode(objRole.TrialFrequency);
                                }
                                strPayPalURL += "&a3=" + Globals.HTTPPOSTEncode(strService);
                                strPayPalURL += "&p3=" + Globals.HTTPPOSTEncode(intBillingPeriod.ToString());
                                strPayPalURL += "&t3=" + Globals.HTTPPOSTEncode(objRole.BillingFrequency);
                                strPayPalURL += "&src=1";
                                strPayPalURL += "&currency_code=" + Globals.HTTPPOSTEncode(PortalSettings.Currency);
                            }
                        }

                        ListController ctlList = new ListController();

                        strPayPalURL += "&custom=" + Globals.HTTPPOSTEncode(intUserID.ToString());
                        strPayPalURL += "&first_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.FirstName);
                        strPayPalURL += "&last_name=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.LastName);
                        try
                        {
                            if (objUserInfo.Profile.Country == "United States")
                            {
                                ListEntryInfo colList = ctlList.GetListEntryInfo("Region", objUserInfo.Profile.Region, "Country:US");
                                strPayPalURL += "&address1=" + Globals.HTTPPOSTEncode(Convert.ToString(!String.IsNullOrEmpty(objUserInfo.Profile.Unit) ? objUserInfo.Profile.Unit + " " : "") + objUserInfo.Profile.Street);
                                strPayPalURL += "&city=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.City);
                                strPayPalURL += "&state=" + Globals.HTTPPOSTEncode(colList.Value);
                                strPayPalURL += "&zip=" + Globals.HTTPPOSTEncode(objUserInfo.Profile.PostalCode);
                            }
                        }
                        catch
                        {
                            // issue getting user address
                        }

                        // Return URL
                        if (Convert.ToString(settings["paypalsubscriptionreturn"]) != "")
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptionreturn"]));
                        }
                        else
                        {
                            strPayPalURL += "&return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        // Cancellation URL
                        if (Convert.ToString(settings["paypalsubscriptioncancelreturn"]) != "")
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptioncancelreturn"]));
                        }
                        else
                        {
                            strPayPalURL += "&cancel_return=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)));
                        }

                        // Instant Payment Notification URL
                        if (Convert.ToString(settings["paypalsubscriptionnotifyurl"]) != "")
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Convert.ToString(settings["paypalsubscriptionnotifyurl"]));
                        }
                        else
                        {
                            strPayPalURL += "&notify_url=" + Globals.HTTPPOSTEncode(Globals.AddHTTP(Globals.GetDomainName(Request)) + "/admin/Sales/PayPalIPN.aspx");
                        }

                        strPayPalURL += "&sra=1"; // reattempt on failure
                    }

                    // redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
                else
                {
                    // Cancellation URL
                    if (Convert.ToString(settings["paypalsubscriptioncancelreturn"]) != "")
                    {
                        strPayPalURL = Convert.ToString(settings["paypalsubscriptioncancelreturn"]);
                    }
                    else
                    {
                        strPayPalURL = Globals.AddHTTP(Globals.GetDomainName(Request));
                    }

                    // redirect to PayPal
                    Response.Redirect(strPayPalURL, true);
                }
            }
            catch (Exception exc)  //Page failed to load
            {
                Exceptions.ProcessPageLoadException(exc);
            }
        }
Пример #2
0
        public void Initialize(int PortalId)
        {
            _PortalID                = PortalId;
            _TabID                   = -1;
            _ModuleID                = -1;
            _ModuleDefID             = -1;
            _ModuleOrder             = -1;
            _PaneName                = "";
            _ModuleTitle             = "";
            _AuthorizedEditRoles     = "";
            _CacheTime               = -1;
            _AuthorizedViewRoles     = "";
            _Alignment               = "";
            _Color                   = "";
            _Border                  = "";
            _IconFile                = "";
            _AllTabs                 = false;
            _Visibility              = VisibilityState.Maximized;
            _IsDeleted               = false;
            _Header                  = "";
            _Footer                  = "";
            _StartDate               = Null.NullDate;
            _EndDate                 = Null.NullDate;
            _DisplayTitle            = true;
            _DisplayPrint            = true;
            _DisplaySyndicate        = false;
            _InheritViewPermissions  = false;
            _ContainerSrc            = "";
            _DesktopModuleID         = -1;
            _FriendlyName            = "";
            _Description             = "";
            _Version                 = "";
            _IsPremium               = false;
            _IsAdmin                 = false;
            _SupportedFeatures       = 0;
            _BusinessControllerClass = "";
            _ModuleControlId         = -1;
            _ControlSrc              = "";
            _ControlType             = SecurityAccessLevel.Anonymous;
            _ControlTitle            = "";
            _HelpUrl                 = "";
            _ContainerPath           = "";
            _PaneModuleIndex         = 0;
            _PaneModuleCount         = 0;
            _IsDefaultModule         = false;
            _AllModules              = false;

            // get default module settings
            Hashtable settings = PortalSettings.GetSiteSettings(PortalId);

            if (Convert.ToString(settings["defaultmoduleid"]) != "" && Convert.ToString(settings["defaulttabid"]) != "")
            {
                ModuleController objModules = new ModuleController();
                ModuleInfo       objModule  = objModules.GetModule(int.Parse(Convert.ToString(settings["defaultmoduleid"])), int.Parse(Convert.ToString(settings["defaulttabid"])), true);
                if (objModule != null)
                {
                    _CacheTime        = objModule.CacheTime;
                    _Alignment        = objModule.Alignment;
                    _Color            = objModule.Color;
                    _Border           = objModule.Border;
                    _IconFile         = objModule.IconFile;
                    _Visibility       = objModule.Visibility;
                    _ContainerSrc     = objModule.ContainerSrc;
                    _DisplayTitle     = objModule.DisplayTitle;
                    _DisplayPrint     = objModule.DisplayPrint;
                    _DisplaySyndicate = objModule.DisplaySyndicate;
                }
            }
        }
        /// <summary>
        /// Restores selected modules in the listbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// <remarks>
        /// Adds a log entry for each restored module to the EventLog
        /// </remarks>
        /// <history>
        ///     [VMasanas]	18/08/2004	Added support for multiselect listbox
        /// </history>
        protected void cmdRestoreModule_Click(Object sender, ImageClickEventArgs e)
        {
            EventLogController objEventLog = new EventLogController();
            ModuleController   objModules  = new ModuleController();
            ListItem           item;

            if (cboTab.SelectedItem != null)
            {
                foreach (ListItem tempLoopVar_item in lstModules.Items)
                {
                    item = tempLoopVar_item;
                    if (item.Selected)
                    {
                        ModuleInfo objModule = objModules.GetModule(int.Parse(item.Value), Null.NullInteger);
                        if (objModule != null)
                        {
                            objModule.IsDeleted = false;
                            objModule.TabID     = Null.NullInteger;
                            objModules.UpdateModule(objModule);

                            // set defaults
                            objModule.CacheTime        = 0;
                            objModule.Alignment        = "";
                            objModule.Color            = "";
                            objModule.Border           = "";
                            objModule.IconFile         = "";
                            objModule.Visibility       = VisibilityState.Maximized;
                            objModule.ContainerSrc     = "";
                            objModule.DisplayTitle     = true;
                            objModule.DisplayPrint     = true;
                            objModule.DisplaySyndicate = false;
                            objModule.AllTabs          = false;

                            // get default module settings
                            Hashtable settings = PortalSettings.GetSiteSettings(PortalId);
                            if (Convert.ToString(settings["defaultmoduleid"]) != "" && Convert.ToString(settings["defaulttabid"]) != "")
                            {
                                ModuleInfo objDefaultModule = objModules.GetModule(int.Parse(Convert.ToString(settings["defaultmoduleid"])), int.Parse(Convert.ToString(settings["defaulttabid"])));
                                if (objDefaultModule != null)
                                {
                                    objModule.CacheTime        = objDefaultModule.CacheTime;
                                    objModule.Alignment        = objDefaultModule.Alignment;
                                    objModule.Color            = objDefaultModule.Color;
                                    objModule.Border           = objDefaultModule.Border;
                                    objModule.IconFile         = objDefaultModule.IconFile;
                                    objModule.Visibility       = objDefaultModule.Visibility;
                                    objModule.ContainerSrc     = objDefaultModule.ContainerSrc;
                                    objModule.DisplayTitle     = objDefaultModule.DisplayTitle;
                                    objModule.DisplayPrint     = objDefaultModule.DisplayPrint;
                                    objModule.DisplaySyndicate = objDefaultModule.DisplaySyndicate;
                                }
                            }

                            // add tab module
                            objModule.TabID       = int.Parse(cboTab.SelectedItem.Value);
                            objModule.PaneName    = Globals.glbDefaultPane;
                            objModule.ModuleOrder = -1;
                            objModules.AddModule(objModule);

                            objEventLog.AddLog(objModule, PortalSettings, UserId, "", EventLogController.EventLogType.MODULE_RESTORED);
                        }
                    }
                }
                BindData();
            }
        }
Пример #4
0
        /// <Summary>
        /// ShowRequiredFields sets up displaying which fields are required
        /// </Summary>
        private void ShowRequiredFields()
        {
            Hashtable settings = PortalSettings.GetSiteSettings(PortalSettings.PortalId);

            lblStreetRequired.Text    = ((Convert.ToString(settings["addressstreet"]) == "N") ? "" : "*").ToString();
            lblCityRequired.Text      = ((Convert.ToString(settings["addresscity"]) == "N") ? "" : "*").ToString();
            lblCountryRequired.Text   = ((Convert.ToString(settings["addresscountry"]) == "N") ? "" : "*").ToString();
            lblRegionRequired.Text    = ((Convert.ToString(settings["addressregion"]) == "N") ? "" : "*").ToString();
            lblPostalRequired.Text    = ((Convert.ToString(settings["addresspostal"]) == "N") ? "" : "*").ToString();
            lblTelephoneRequired.Text = ((Convert.ToString(settings["addresstelephone"]) == "N") ? "" : "*").ToString();
            lblCellRequired.Text      = ((Convert.ToString(settings["addresscell"]) == "N") ? "" : "*").ToString();
            lblFaxRequired.Text       = ((Convert.ToString(settings["addressfax"]) == "N") ? "" : "*").ToString();

            if (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName))
            {
                if (lblCountryRequired.Text == "*")
                {
                    chkCountry.Checked = true;
                    valCountry.Enabled = true;
                }
                if (lblRegionRequired.Text == "*")
                {
                    chkRegion.Checked = true;
                    if (cboRegion.Visible == true)
                    {
                        valRegion1.Enabled = true;
                        valRegion2.Enabled = false;
                    }
                    else
                    {
                        valRegion1.Enabled = false;
                        valRegion2.Enabled = true;
                    }
                }
                if (lblCityRequired.Text == "*")
                {
                    chkCity.Checked = true;
                    valCity.Enabled = true;
                }
                if (lblStreetRequired.Text == "*")
                {
                    chkStreet.Checked = true;
                    valStreet.Enabled = true;
                }
                if (lblPostalRequired.Text == "*")
                {
                    chkPostal.Checked = true;
                    valPostal.Enabled = true;
                }
                if (lblTelephoneRequired.Text == "*")
                {
                    chkTelephone.Checked = true;
                    valTelephone.Enabled = true;
                }
                if (lblCellRequired.Text == "*")
                {
                    chkCell.Checked = true;
                    valCell.Enabled = true;
                }
                if (lblFaxRequired.Text == "*")
                {
                    chkFax.Checked = true;
                    valFax.Enabled = true;
                }
            }

            if (lblCountryRequired.Text == "")
            {
                valCountry.Enabled = false;
            }
            if (lblRegionRequired.Text == "")
            {
                valRegion1.Enabled = false;
                valRegion2.Enabled = false;
            }
            if (lblCityRequired.Text == "")
            {
                valCity.Enabled = false;
            }
            if (lblStreetRequired.Text == "")
            {
                valStreet.Enabled = false;
            }
            if (lblPostalRequired.Text == "")
            {
                valPostal.Enabled = false;
            }
            if (lblTelephoneRequired.Text == "")
            {
                valTelephone.Enabled = false;
            }
            if (lblCellRequired.Text == "")
            {
                valCell.Enabled = false;
            }
            if (lblFaxRequired.Text == "")
            {
                valFax.Enabled = false;
            }
        }