Exemple #1
0
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            plcOther.Controls.Clear();

            if (AuthenticationHelper.IsAuthenticated())
            {
                // Set the layout of tab menu
                tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout);

                // Remove 'saved' parameter from query string
                string absoluteUri = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "saved");

                var currentUser = MembershipContext.AuthenticatedUser;

                // Get customer info
                GeneralizedInfo customer   = null;
                int             customerId = 0;

                var emptyCustomer = ModuleManager.GetReadOnlyObject(PredefinedObjectType.CUSTOMER);
                if (emptyCustomer != null)
                {
                    var q = emptyCustomer.Generalized.GetDataQuery(
                        true,
                        s => s
                        .WhereEquals("CustomerUserID", currentUser.UserID)
                        .OrderBy("CustomerCreated")
                        .TopN(1),
                        false
                        );

                    var result = q.Result;

                    if (!DataHelper.DataSourceIsEmpty(result))
                    {
                        customer   = ModuleManager.GetObject(result.Tables[0].Rows[0], PredefinedObjectType.CUSTOMER);
                        customerId = customer.ObjectID;
                    }
                }

                // Get friends enabled setting
                bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName);

                // Selected page URL
                string selectedPage = string.Empty;

                // Menu initialization
                tabMenu.UrlTarget = "_self";
                ArrayList activeTabs = new ArrayList();

                // Handle 'Notifications' tab displaying
                bool showNotificationsTab    = (DisplayMyNotifications && LicenseHelper.IsFeatureAvailableInUI(FeatureEnum.Notifications, ModuleName.NOTIFICATIONS));
                bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication();

                string tabName;

                // Personal tab
                if (DisplayMyPersonalSettings)
                {
                    tabName = personalTab;
                    activeTabs.Add(tabName);
                    tabMenu.TabItems.Add(new TabItem()
                    {
                        Text        = GetString("MyAccount.MyPersonalSettings"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab)
                    });

                    if (currentUser != null)
                    {
                        selectedPage = tabName;
                    }
                }

                // These items can be displayed only for customer
                if ((customer != null) && ModuleEntryManager.IsModuleLoaded(ModuleName.ECOMMERCE))
                {
                    if (DisplayMyDetails)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyDetails = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl;
                        if (ucMyDetails != null)
                        {
                            ucMyDetails.ID = "ucMyDetails";
                            plcOther.Controls.Add(ucMyDetails);

                            // Set new tab
                            tabName = detailsTab;
                            activeTabs.Add(tabName);
                            tabMenu.TabItems.Add(new TabItem()
                            {
                                Text        = GetString("MyAccount.MyDetails"),
                                RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab)
                            });

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyAddresses)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyAddresses = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl;
                        if (ucMyAddresses != null)
                        {
                            ucMyAddresses.ID = "ucMyAddresses";
                            plcOther.Controls.Add(ucMyAddresses);

                            // Set new tab
                            tabName = addressesTab;
                            activeTabs.Add(tabName);
                            tabMenu.TabItems.Add(new TabItem()
                            {
                                Text        = GetString("MyAccount.MyAddresses"),
                                RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab)
                            });

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyOrders)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyOrders = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl;
                        if (ucMyOrders != null)
                        {
                            ucMyOrders.ID = "ucMyOrders";
                            plcOther.Controls.Add(ucMyOrders);

                            // Set new tab
                            tabName = ordersTab;
                            activeTabs.Add(tabName);
                            tabMenu.TabItems.Add(new TabItem()
                            {
                                Text        = GetString("MyAccount.MyOrders"),
                                RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab)
                            });

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyCredits)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyCredit = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl;
                        if (ucMyCredit != null)
                        {
                            ucMyCredit.ID = "ucMyCredit";
                            plcOther.Controls.Add(ucMyCredit);

                            // Set new tab
                            tabName = creditTab;
                            activeTabs.Add(tabName);
                            tabMenu.TabItems.Add(new TabItem()
                            {
                                Text        = GetString("MyAccount.MyCredit"),
                                RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab)
                            });

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }
                }

                if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication)
                {
                    // Set new tab
                    tabName = passwordTab;
                    activeTabs.Add(tabName);
                    tabMenu.TabItems.Add(new TabItem()
                    {
                        Text        = GetString("MyAccount.ChangePassword"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab)
                    });

                    if (selectedPage == string.Empty)
                    {
                        selectedPage = tabName;
                    }
                }

                if ((ucMyNotifications == null) && showNotificationsTab)
                {
                    // Try to load the control dynamically (if available)
                    ucMyNotifications = Page.LoadUserControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl;
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.ID = "ucMyNotifications";
                        plcOther.Controls.Add(ucMyNotifications);

                        // Set new tab
                        tabName = notificationsTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("MyAccount.MyNotifications"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab)
                        });

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyMessages == null) && DisplayMyMessages && ModuleManager.IsModuleLoaded(ModuleName.MESSAGING))
                {
                    // Try to load the control dynamically (if available)
                    ucMyMessages = Page.LoadUserControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl;
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.ID = "ucMyMessages";
                        plcOther.Controls.Add(ucMyMessages);

                        // Set new tab
                        tabName = messagesTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("MyAccount.MyMessages"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab)
                        });

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyFriends == null) && DisplayMyFriends && ModuleManager.IsModuleLoaded(ModuleName.COMMUNITY) && friendsEnabled)
                {
                    // Try to load the control dynamically (if available)
                    ucMyFriends = Page.LoadUserControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl;
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.ID = "ucMyFriends";
                        plcOther.Controls.Add(ucMyFriends);

                        // Set new tab
                        tabName = friendsTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("MyAccount.MyFriends"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab)
                        });

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions)
                {
                    // Try to load the control dynamically (if available)
                    ucMyAllSubscriptions = Page.LoadUserControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl;
                    if (ucMyAllSubscriptions != null)
                    {
                        // Set control
                        ucMyAllSubscriptions.Visible = false;

                        ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs);
                        ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards);
                        ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters);
                        ucMyAllSubscriptions.SetValue("ShowForums", DisplayForums);
                        ucMyAllSubscriptions.SetValue("ShowReports", DisplayReports);
                        ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails);

                        ucMyAllSubscriptions.ID = "ucMyAllSubscriptions";
                        plcOther.Controls.Add(ucMyAllSubscriptions);

                        // Set new tab
                        tabName = subscriptionsTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("MyAccount.MyAllSubscriptions"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab)
                        });

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // My memberships
                if ((ucMyMemberships == null) && DisplayMyMemberships)
                {
                    // Try to load the control dynamically
                    ucMyMemberships = Page.LoadUserControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl;

                    if (ucMyMemberships != null)
                    {
                        ucMyMemberships.SetValue("UserID", currentUser.UserID);

                        if (!String.IsNullOrEmpty(MembershipsPagePath))
                        {
                            ucMyMemberships.SetValue("BuyMembershipURL", DocumentURLProvider.GetUrl(MembershipsPagePath));
                        }

                        plcOther.Controls.Add(ucMyMemberships);

                        // Set new tab
                        tabName = membershipsTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("myaccount.mymemberships"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, membershipsTab)
                        });

                        if (selectedPage == String.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyCategories == null) && DisplayMyCategories)
                {
                    // Try to load the control dynamically (if available)
                    ucMyCategories = Page.LoadUserControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl;
                    if (ucMyCategories != null)
                    {
                        ucMyCategories.Visible = false;

                        ucMyCategories.SetValue("DisplaySiteCategories", false);
                        ucMyCategories.SetValue("DisplaySiteSelector", false);

                        ucMyCategories.ID = "ucMyCategories";
                        plcOther.Controls.Add(ucMyCategories);

                        // Set new tab
                        tabName = categoriesTab;
                        activeTabs.Add(tabName);
                        tabMenu.TabItems.Add(new TabItem()
                        {
                            Text        = GetString("MyAccount.MyCategories"),
                            RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab)
                        });

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // Set CSS class
                pnlBody.CssClass = CssClass;

                // Get page URL
                page = QueryHelper.GetString(ParameterName, selectedPage);

                // Set controls visibility
                ucChangePassword.Visible        = false;
                ucChangePassword.StopProcessing = true;

                if (ucMyAddresses != null)
                {
                    ucMyAddresses.Visible        = false;
                    ucMyAddresses.StopProcessing = true;
                }

                if (ucMyOrders != null)
                {
                    ucMyOrders.Visible        = false;
                    ucMyOrders.StopProcessing = true;
                }

                if (ucMyDetails != null)
                {
                    ucMyDetails.Visible        = false;
                    ucMyDetails.StopProcessing = true;
                }

                if (ucMyCredit != null)
                {
                    ucMyCredit.Visible        = false;
                    ucMyCredit.StopProcessing = true;
                }

                if (ucMyAllSubscriptions != null)
                {
                    ucMyAllSubscriptions.Visible        = false;
                    ucMyAllSubscriptions.StopProcessing = true;
                    ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes);
                }

                if (ucMyNotifications != null)
                {
                    ucMyNotifications.Visible        = false;
                    ucMyNotifications.StopProcessing = true;
                }

                if (ucMyMessages != null)
                {
                    ucMyMessages.Visible        = false;
                    ucMyMessages.StopProcessing = true;
                }

                if (ucMyFriends != null)
                {
                    ucMyFriends.Visible        = false;
                    ucMyFriends.StopProcessing = true;
                }

                if (ucMyMemberships != null)
                {
                    ucMyMemberships.Visible        = false;
                    ucMyMemberships.StopProcessing = true;
                }

                if (ucMyCategories != null)
                {
                    ucMyCategories.Visible        = false;
                    ucMyCategories.StopProcessing = true;
                }

                tabMenu.SelectedTab = activeTabs.IndexOf(page);

                // Select current page
                switch (page)
                {
                case personalTab:
                    if (myProfile != null)
                    {
                        // Get alternative form info
                        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName);
                        if (afi != null)
                        {
                            myProfile.StopProcessing      = false;
                            myProfile.Visible             = true;
                            myProfile.AllowEditVisibility = AllowEditVisibility;
                            myProfile.AlternativeFormName = AlternativeFormName;
                        }
                        else
                        {
                            lblError.Text     = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName);
                            lblError.Visible  = true;
                            myProfile.Visible = false;
                        }
                    }
                    break;

                // My details tab
                case detailsTab:
                    if (ucMyDetails != null)
                    {
                        ucMyDetails.Visible        = true;
                        ucMyDetails.StopProcessing = false;
                        ucMyDetails.SetValue("Customer", customer);
                    }
                    break;

                // My addresses tab
                case addressesTab:
                    if (ucMyAddresses != null)
                    {
                        ucMyAddresses.Visible        = true;
                        ucMyAddresses.StopProcessing = false;
                        ucMyAddresses.SetValue("CustomerId", customerId);
                    }
                    break;

                // My orders tab
                case ordersTab:
                    if (ucMyOrders != null)
                    {
                        ucMyOrders.Visible        = true;
                        ucMyOrders.StopProcessing = false;
                        ucMyOrders.SetValue("CustomerId", customerId);
                        ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber);
                        ucMyOrders.SetValue("ShowOrderToShoppingCart", ShowOrderToShoppingCart);
                    }
                    break;

                // My credit tab
                case creditTab:
                    if (ucMyCredit != null)
                    {
                        ucMyCredit.Visible        = true;
                        ucMyCredit.StopProcessing = false;
                        ucMyCredit.SetValue("CustomerId", customerId);
                    }
                    break;

                // Password tab
                case passwordTab:
                    ucChangePassword.Visible            = true;
                    ucChangePassword.StopProcessing     = false;
                    ucChangePassword.AllowEmptyPassword = AllowEmptyPassword;
                    break;

                // Notification tab
                case notificationsTab:
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.Visible        = true;
                        ucMyNotifications.StopProcessing = false;
                        ucMyNotifications.SetValue("UserId", currentUser.UserID);
                        ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory);
                    }
                    break;

                // My messages tab
                case messagesTab:
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.Visible        = true;
                        ucMyMessages.StopProcessing = false;
                    }
                    break;

                // My friends tab
                case friendsTab:
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.Visible        = true;
                        ucMyFriends.StopProcessing = false;
                        ucMyFriends.SetValue("UserID", currentUser.UserID);
                    }
                    break;

                // My subscriptions tab
                case subscriptionsTab:
                    if (ucMyAllSubscriptions != null)
                    {
                        ucMyAllSubscriptions.Visible        = true;
                        ucMyAllSubscriptions.StopProcessing = false;

                        ucMyAllSubscriptions.SetValue("userid", currentUser.UserID);
                        ucMyAllSubscriptions.SetValue("siteid", SiteContext.CurrentSiteID);
                    }
                    break;

                // My memberships tab
                case membershipsTab:
                    if (ucMyMemberships != null)
                    {
                        ucMyMemberships.Visible        = true;
                        ucMyMemberships.StopProcessing = false;
                    }
                    break;

                // My categories tab
                case categoriesTab:
                    if (ucMyCategories != null)
                    {
                        ucMyCategories.Visible        = true;
                        ucMyCategories.StopProcessing = false;
                    }
                    break;
                }
            }
            else
            {
                // Hide control if current user is not authenticated
                Visible = false;
            }
        }
    }
    /// <summary>
    /// Initializes the control properties.
    /// </summary>
    protected void SetupControl()
    {
        if (StopProcessing)
        {
            // Do nothing
        }
        else
        {
            plcOther.Controls.Clear();

            if (MembershipContext.AuthenticatedUser.IsAuthenticated())
            {
                // Set the layout of tab menu
                tabMenu.TabControlLayout = BasicTabControl.GetTabMenuLayout(TabControlLayout);

                // Remove 'saved' parameter from query string
                string absoluteUri = URLHelper.RemoveParameterFromUrl(URLRewriter.CurrentURL, "saved");

                CurrentUserInfo currentUser = MembershipContext.AuthenticatedUser;

                // Get customer info
                GeneralizedInfo customer       = ModuleCommands.ECommerceGetCustomerInfoByUserId(currentUser.UserID);
                bool            userIsCustomer = (customer != null);

                // Get friends enabled setting
                bool friendsEnabled = UIHelper.IsFriendsModuleEnabled(SiteContext.CurrentSiteName);

                // Get customer ID
                int customerId = 0;
                if (userIsCustomer)
                {
                    customerId = ValidationHelper.GetInteger(customer.ObjectID, 0);
                }

                // Selected page URL
                string selectedPage = string.Empty;

                // Menu initialization
                tabMenu.UrlTarget = "_self";
                ArrayList activeTabs = new ArrayList();
                string    tabName    = string.Empty;

                // Set array size of tab control
                int arraySize = 0;
                if (DisplayMyPersonalSettings)
                {
                    arraySize++;
                }
                if (DisplayMyMessages)
                {
                    arraySize++;
                }

                // Handle 'Notifications' tab displaying
                bool hideUnavailableUI       = SettingsKeyInfoProvider.GetBoolValue("CMSHideUnavailableUserInterface");
                bool showNotificationsTab    = (DisplayMyNotifications && ModuleEntryManager.IsModuleLoaded(ModuleEntry.NOTIFICATIONS) && (!hideUnavailableUI || LicenseHelper.CheckFeature(URLHelper.GetCurrentDomain(), FeatureEnum.Notifications)));
                bool isWindowsAuthentication = RequestHelper.IsWindowsAuthentication();

                // Notification tab
                if (showNotificationsTab)
                {
                    arraySize++;
                }

                // Friends tab
                if (DisplayMyFriends && friendsEnabled)
                {
                    arraySize++;
                }

                // User password tab
                if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication)
                {
                    arraySize++;
                }

                // Subscriptions tab
                if (DisplayMySubscriptions)
                {
                    arraySize++;
                }

                // Memberships tab
                if (DisplayMyMemberships)
                {
                    arraySize++;
                }

                // Categories tab
                if (DisplayMyCategories)
                {
                    arraySize++;
                }

                // Ecommerce tabs
                if (DisplayMyCredits && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyDetails && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyAddresses && userIsCustomer)
                {
                    arraySize++;
                }
                if (DisplayMyOrders && userIsCustomer)
                {
                    arraySize++;
                }
                tabMenu.Tabs = new string[arraySize, 5];

                // Personal tab
                if (DisplayMyPersonalSettings)
                {
                    // Set new tab
                    tabName = personalTab;
                    activeTabs.Add(tabName);
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyPersonalSettings");
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, personalTab));

                    if (currentUser != null)
                    {
                        selectedPage = tabName;
                    }
                }

                // These items can be displayed only for customer
                if (userIsCustomer && ModuleEntryManager.IsModuleLoaded(ModuleEntry.ECOMMERCE))
                {
                    if (DisplayMyDetails)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyDetails = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyDetails.ascx") as CMSAdminControl;
                        if (ucMyDetails != null)
                        {
                            ucMyDetails.ID = "ucMyDetails";
                            plcOther.Controls.Add(ucMyDetails);

                            // Set new tab
                            tabName = detailsTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyDetails");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, detailsTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyAddresses)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyAddresses = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyAddresses.ascx") as CMSAdminControl;
                        if (ucMyAddresses != null)
                        {
                            ucMyAddresses.ID = "ucMyAddresses";
                            plcOther.Controls.Add(ucMyAddresses);

                            // Set new tab
                            tabName = addressesTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAddresses");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, addressesTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyOrders)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyOrders = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyOrders.ascx") as CMSAdminControl;
                        if (ucMyOrders != null)
                        {
                            ucMyOrders.ID = "ucMyOrders";
                            plcOther.Controls.Add(ucMyOrders);

                            // Set new tab
                            tabName = ordersTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyOrders");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, ordersTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }

                    if (DisplayMyCredits)
                    {
                        // Try to load the control dynamically (if available)
                        ucMyCredit = Page.LoadUserControl("~/CMSModules/Ecommerce/Controls/MyDetails/MyCredit.ascx") as CMSAdminControl;
                        if (ucMyCredit != null)
                        {
                            ucMyCredit.ID = "ucMyCredit";
                            plcOther.Controls.Add(ucMyCredit);

                            // Set new tab
                            tabName = creditTab;
                            activeTabs.Add(tabName);
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCredit");
                            tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, creditTab));

                            if (selectedPage == string.Empty)
                            {
                                selectedPage = tabName;
                            }
                        }
                    }
                }

                if (DisplayChangePassword && !currentUser.IsExternal && !isWindowsAuthentication)
                {
                    // Set new tab
                    tabName = passwordTab;
                    activeTabs.Add(tabName);
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.ChangePassword");
                    tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, passwordTab));

                    if (selectedPage == string.Empty)
                    {
                        selectedPage = tabName;
                    }
                }

                if ((ucMyNotifications == null) && showNotificationsTab)
                {
                    // Try to load the control dynamically (if available)
                    ucMyNotifications = Page.LoadUserControl("~/CMSModules/Notifications/Controls/UserNotifications.ascx") as CMSAdminControl;
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.ID = "ucMyNotifications";
                        plcOther.Controls.Add(ucMyNotifications);

                        // Set new tab
                        tabName = notificationsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyNotifications");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, notificationsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyMessages == null) && DisplayMyMessages && ModuleEntryManager.IsModuleLoaded(ModuleEntry.MESSAGING))
                {
                    // Try to load the control dynamically (if available)
                    ucMyMessages = Page.LoadUserControl("~/CMSModules/Messaging/Controls/MyMessages.ascx") as CMSAdminControl;
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.ID = "ucMyMessages";
                        plcOther.Controls.Add(ucMyMessages);

                        // Set new tab
                        tabName = messagesTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyMessages");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, messagesTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyFriends == null) && DisplayMyFriends && ModuleEntryManager.IsModuleLoaded(ModuleEntry.COMMUNITY) && friendsEnabled)
                {
                    // Try to load the control dynamically (if available)
                    ucMyFriends = Page.LoadUserControl("~/CMSModules/Friends/Controls/MyFriends.ascx") as CMSAdminControl;
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.ID = "ucMyFriends";
                        plcOther.Controls.Add(ucMyFriends);

                        // Set new tab
                        tabName = friendsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyFriends");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, friendsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyAllSubscriptions == null) && DisplayMySubscriptions)
                {
                    // Try to load the control dynamically (if available)
                    ucMyAllSubscriptions = Page.LoadUserControl("~/CMSModules/Membership/Controls/Subscriptions.ascx") as CMSAdminControl;
                    if (ucMyAllSubscriptions != null)
                    {
                        // Set control
                        ucMyAllSubscriptions.Visible = false;

                        ucMyAllSubscriptions.SetValue("ShowBlogs", DisplayBlogs);
                        ucMyAllSubscriptions.SetValue("ShowMessageBoards", DisplayMessageBoards);
                        ucMyAllSubscriptions.SetValue("ShowNewsletters", DisplayNewsletters);
                        ucMyAllSubscriptions.SetValue("ShowForums", DisplayForums);
                        ucMyAllSubscriptions.SetValue("ShowReports", DisplayReports);
                        ucMyAllSubscriptions.SetValue("sendconfirmationemail", SendConfirmationEmails);

                        ucMyAllSubscriptions.ID = "ucMyAllSubscriptions";
                        plcOther.Controls.Add(ucMyAllSubscriptions);

                        // Set new tab
                        tabName = subscriptionsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyAllSubscriptions");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, subscriptionsTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // My memberships
                if ((ucMyMemberships == null) && DisplayMyMemberships)
                {
                    // Try to load the control dynamically
                    ucMyMemberships = Page.LoadUserControl("~/CMSModules/Membership/Controls/MyMemberships.ascx") as CMSAdminControl;

                    if (ucMyMemberships != null)
                    {
                        ucMyMemberships.SetValue("UserID", currentUser.UserID);

                        if (!String.IsNullOrEmpty(MembershipsPagePath))
                        {
                            ucMyMemberships.SetValue("BuyMembershipURL", DocumentURLProvider.GetUrl(MembershipsPagePath));
                        }

                        plcOther.Controls.Add(ucMyMemberships);

                        // Set new tab
                        tabName = membershipsTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("myaccount.mymemberships");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, membershipsTab));

                        if (selectedPage == String.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                if ((ucMyCategories == null) && DisplayMyCategories)
                {
                    // Try to load the control dynamically (if available)
                    ucMyCategories = Page.LoadUserControl("~/CMSModules/Categories/Controls/Categories.ascx") as CMSAdminControl;
                    if (ucMyCategories != null)
                    {
                        ucMyCategories.Visible = false;

                        ucMyCategories.SetValue("DisplaySiteCategories", false);
                        ucMyCategories.SetValue("DisplaySiteSelector", false);

                        ucMyCategories.ID = "ucMyCategories";
                        plcOther.Controls.Add(ucMyCategories);

                        // Set new tab
                        tabName = categoriesTab;
                        activeTabs.Add(tabName);
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 0] = GetString("MyAccount.MyCategories");
                        tabMenu.Tabs[activeTabs.IndexOf(tabName), 2] = HTMLHelper.HTMLEncode(URLHelper.AddParameterToUrl(absoluteUri, ParameterName, categoriesTab));

                        if (selectedPage == string.Empty)
                        {
                            selectedPage = tabName;
                        }
                    }
                }

                // Set CSS class
                pnlBody.CssClass = CssClass;

                // Get page URL
                page = QueryHelper.GetString(ParameterName, selectedPage);

                // Set controls visibility
                ucChangePassword.Visible        = false;
                ucChangePassword.StopProcessing = true;

                if (ucMyAddresses != null)
                {
                    ucMyAddresses.Visible        = false;
                    ucMyAddresses.StopProcessing = true;
                }

                if (ucMyOrders != null)
                {
                    ucMyOrders.Visible        = false;
                    ucMyOrders.StopProcessing = true;
                }

                if (ucMyDetails != null)
                {
                    ucMyDetails.Visible        = false;
                    ucMyDetails.StopProcessing = true;
                }

                if (ucMyCredit != null)
                {
                    ucMyCredit.Visible        = false;
                    ucMyCredit.StopProcessing = true;
                }

                if (ucMyAllSubscriptions != null)
                {
                    ucMyAllSubscriptions.Visible        = false;
                    ucMyAllSubscriptions.StopProcessing = true;
                    ucMyAllSubscriptions.SetValue("CacheMinutes", CacheMinutes);
                }

                if (ucMyNotifications != null)
                {
                    ucMyNotifications.Visible        = false;
                    ucMyNotifications.StopProcessing = true;
                }

                if (ucMyMessages != null)
                {
                    ucMyMessages.Visible        = false;
                    ucMyMessages.StopProcessing = true;
                }

                if (ucMyFriends != null)
                {
                    ucMyFriends.Visible        = false;
                    ucMyFriends.StopProcessing = true;
                }

                if (ucMyMemberships != null)
                {
                    ucMyMemberships.Visible        = false;
                    ucMyMemberships.StopProcessing = true;
                }

                if (ucMyCategories != null)
                {
                    ucMyCategories.Visible        = false;
                    ucMyCategories.StopProcessing = true;
                }

                tabMenu.SelectedTab = activeTabs.IndexOf(page);

                // Select current page
                switch (page)
                {
                case personalTab:
                    if (myProfile != null)
                    {
                        // Get alternative form info
                        AlternativeFormInfo afi = AlternativeFormInfoProvider.GetAlternativeFormInfo(AlternativeFormName);
                        if (afi != null)
                        {
                            myProfile.StopProcessing      = false;
                            myProfile.Visible             = true;
                            myProfile.AllowEditVisibility = AllowEditVisibility;
                            myProfile.AlternativeFormName = AlternativeFormName;
                        }
                        else
                        {
                            lblError.Text     = String.Format(GetString("altform.formdoesntexists"), AlternativeFormName);
                            lblError.Visible  = true;
                            myProfile.Visible = false;
                        }
                    }
                    break;

                // My details tab
                case detailsTab:
                    if (ucMyDetails != null)
                    {
                        ucMyDetails.Visible        = true;
                        ucMyDetails.StopProcessing = false;
                        ucMyDetails.SetValue("Customer", customer);
                    }
                    break;

                // My addresses tab
                case addressesTab:
                    if (ucMyAddresses != null)
                    {
                        ucMyAddresses.Visible        = true;
                        ucMyAddresses.StopProcessing = false;
                        ucMyAddresses.SetValue("CustomerId", customerId);
                    }
                    break;

                // My orders tab
                case ordersTab:
                    if (ucMyOrders != null)
                    {
                        ucMyOrders.Visible        = true;
                        ucMyOrders.StopProcessing = false;
                        ucMyOrders.SetValue("CustomerId", customerId);
                        ucMyOrders.SetValue("ShowOrderTrackingNumber", ShowOrderTrackingNumber);
                    }
                    break;

                // My credit tab
                case creditTab:
                    if (ucMyCredit != null)
                    {
                        ucMyCredit.Visible        = true;
                        ucMyCredit.StopProcessing = false;
                        ucMyCredit.SetValue("CustomerId", customerId);
                    }
                    break;

                // Password tab
                case passwordTab:
                    ucChangePassword.Visible            = true;
                    ucChangePassword.StopProcessing     = false;
                    ucChangePassword.AllowEmptyPassword = AllowEmptyPassword;
                    break;

                // Notification tab
                case notificationsTab:
                    if (ucMyNotifications != null)
                    {
                        ucMyNotifications.Visible        = true;
                        ucMyNotifications.StopProcessing = false;
                        ucMyNotifications.SetValue("UserId", currentUser.UserID);
                        ucMyNotifications.SetValue("UnigridImageDirectory", UnigridImageDirectory);
                    }
                    break;

                // My messages tab
                case messagesTab:
                    if (ucMyMessages != null)
                    {
                        ucMyMessages.Visible        = true;
                        ucMyMessages.StopProcessing = false;
                    }
                    break;

                // My friends tab
                case friendsTab:
                    if (ucMyFriends != null)
                    {
                        ucMyFriends.Visible        = true;
                        ucMyFriends.StopProcessing = false;
                        ucMyFriends.SetValue("UserID", currentUser.UserID);
                    }
                    break;

                // My subscriptions tab
                case subscriptionsTab:
                    if (ucMyAllSubscriptions != null)
                    {
                        ucMyAllSubscriptions.Visible        = true;
                        ucMyAllSubscriptions.StopProcessing = false;

                        ucMyAllSubscriptions.SetValue("userid", currentUser.UserID);
                        ucMyAllSubscriptions.SetValue("siteid", CMSContext.CurrentSiteID);
                    }
                    break;

                // My memberships tab
                case membershipsTab:
                    if (ucMyMemberships != null)
                    {
                        ucMyMemberships.Visible        = true;
                        ucMyMemberships.StopProcessing = false;
                    }
                    break;

                // My categories tab
                case categoriesTab:
                    if (ucMyCategories != null)
                    {
                        ucMyCategories.Visible        = true;
                        ucMyCategories.StopProcessing = false;
                    }
                    break;
                }
            }
            else
            {
                // Hide control if current user is not authenticated
                Visible = false;
            }
        }
    }