Esempio n. 1
0
        /// <summary>
        /// Binds the control and all its child controls to the specified data source.
        /// </summary>
        public override void DataBind()
        {
            if (HttpContext.Current != null)
            {
                //Init data
                ArrayList list = new ArrayList();

                // Obtain PortalSettings from Current Context
                PortalSettings PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"];

                string homeLink = "<a";
                string menuLink;

                // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                if (CssClass.Length != 0)
                {
                    homeLink = homeLink + " class=\"" + CssClass + "\"";
                }

                homeLink = homeLink + " href='" + HttpUrlBuilder.BuildUrl() + "'>" +
                           General.GetString("Appleseed", "HOME") + "</a>";

                // If user logged in, customize welcome message
                if (HttpContext.Current.Request.IsAuthenticated == true)
                {
                    if (ShowWelcome)
                    {
                        list.Add(PortalSettings.CurrentUser.Identity.Name + " (" + PortalSettings.CurrentUser.Identity.Email + ")");
                    }

                    var dashboardPage = PortalSettings.DesktopPages.FirstOrDefault(p => p.PageName == "Dashabord");
                    if (dashboardPage != null)
                    {
                        list.Add(string.Format("<a href='{0}'>{1}</a>", Appleseed.Framework.HttpUrlBuilder.BuildUrl(dashboardPage.PageID), General.GetString("Dashabord", "Dashabord")));
                    }

                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // Added by Mario Endara <*****@*****.**> (2004/11/06)
                    // Find Tab module to see if the user has add/edit rights
                    ModulesDB modules = new ModulesDB();
                    Guid      TabGuid = new Guid("{1C575D94-70FC-4A83-80C3-2087F726CBB3}");
                    // Added by Xu Yiming <*****@*****.**> (2004/12/6)
                    // Modify for support Multi or zero Pages Modules in a single portal.
                    bool HasEditPermissionsOnTabs = false;
                    int  TabModuleID = 0;

                    //					SqlDataReader result = modules.FindModulesByGuid(PortalSettings.PortalID, TabGuid);
                    //					while(result.Read())
                    //					{
                    //						TabModuleID=(int)result["ModuleId"];

                    foreach (ModuleItem m in modules.FindModuleItemsByGuid(PortalSettings.PortalID, TabGuid))
                    {
                        HasEditPermissionsOnTabs = PortalSecurity.HasEditPermissions(m.ID);
                        if (HasEditPermissionsOnTabs)
                        {
                            TabModuleID = m.ID;
                            break;
                        }
                    }

                    if (!HasEditPermissionsOnTabs || !ShowTabMan)
                    {
                        if (UserProfile.HasEditThisPageAccess())
                        {
                            HasEditPermissionsOnTabs = true;
                            this.ShowTabMan          = true;
                        }
                    }

                    // If user logged in and has Edit permission in the Tab module, reach tab management just one click
                    if (
                        ((ShowTabMan) && (HasEditPermissionsOnTabs) && UserPagePermissionDB.HasCurrentPageEditPermission() &&
                         PortalSettings.ActivePage.ParentPageID != 100 && PortalSettings.ActivePage.PageID != 100) ||
                        ((PortalSettings.ActivePage.ParentPageID == 100 || PortalSettings.ActivePage.PageID == 100) && PortalSecurity.IsInRole("Admins"))
                        )
                    {
                        // added by Mario Endara 2004/08/06 so PageLayout can return to this page
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                        var url = HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Pages/PageLayout.aspx?PageID=") +
                                  PortalSettings.ActivePage.PageID + "&amp;mID=" + TabModuleID.ToString() +
                                  "&amp;Alias=" + PortalSettings.PortalAlias + "&amp;lang=" + PortalSettings.PortalUILanguage +
                                  "&amp;returntabid=" + PortalSettings.ActivePage.PageID;
                        menuLink = menuLink + " href='" + url + "' onclick=\"openInModal('" + url + "','" + General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "');return false;\");>" +
                                   General.GetString("HEADER_MANAGE_TAB", "Edit This Page", null) + "</a>";
                        list.Add(menuLink);
                    }


                    if (
                        ((ShowTabMan) && (HasEditPermissionsOnTabs) && UserPagePermissionDB.HasCurrentPageEditPermission() &&
                         PortalSettings.ActivePage.ParentPageID != 100 && PortalSettings.ActivePage.PageID != 100) ||
                        ((PortalSettings.ActivePage.ParentPageID == 100 || PortalSettings.ActivePage.PageID == 100) && PortalSecurity.IsInRole("Admins"))
                        )
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='javascript:DnD();' id='hypDND'>" + General.GetString("DRAGNDROP", "DragNDrop", null) + "</a>";
                        list.Add(menuLink);
                    }

                    if (ShowEditProfile)
                    {
                        // 19/08/2004 Jonathan Fong
                        // www.gt.com.au
                        if (Context.User.Identity.AuthenticationType == "LDAP")
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" + "Profile" + "</a>";
                            list.Add(menuLink);
                        }
                        // If user is form add edit user link
                        else if (!(HttpContext.Current.User is WindowsPrincipal))
                        {
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            menuLink = menuLink + " href='" +
                                       HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                       "'>" +
                                       General.GetString("HEADER_EDIT_PROFILE", "Edit Profile", this) + "</a>";
                            list.Add(menuLink);
                        }
                    }

                    // if authentication mode is Cookie, provide a logoff link
                    if (Context.User.Identity.AuthenticationType == "Forms" ||
                        Context.User.Identity.AuthenticationType == "LDAP")
                    {
                        if (ShowLogOff)
                        {
                            // Corrections when ShowSecureLogon is true. [email protected] (05/07/2004)
                            string href = Context.Request.Url.AbsolutePath;
                            if (ShowSecureLogon && Context.Request.IsSecureConnection)
                            {
                                string auxref = Context.Request.Url.AbsoluteUri;
                                auxref = auxref.Substring(0, auxref.IndexOf(Context.Request.Url.PathAndQuery));
                                href   = auxref + href;
                                href   = href.Replace("https", "http");
                            }
                            // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                            menuLink = "<a";
                            if (CssClass.Length != 0)
                            {
                                menuLink = menuLink + " class=\"" + CssClass + "\"";
                            }

                            // added code for redirection on same page after logged out
                            menuLink = menuLink + " href='javascript:void();' onclick=\"if(confirm('" + General.GetString("LOGOFF_CNF_MSG", "Log Off Confirmation: \\nAre you sure you want to log off?", null) + "')){window.location = '/DesktopModules/CoreModules/Admin/Logoff.aspx?redirecturl=" + href + "';  }else{return false;} \">" + General.GetString("HEADER_LOGOFF", "Logoff", null) + "</a>";



                            list.Add(menuLink);
                        }
                    }
                }
                else
                {
                    if (ShowHome)
                    {
                        list.Add(homeLink);
                    }

                    if (ShowHelp)
                    {
                        list.Add(GetHelpLink());
                    }

                    // if not authenticated and ShowLogon is true, provide a logon link

                    if (ShowLogon)
                    {
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink += string.Concat(" id=\"", this.ClientID, "_logon_link", "\"");
                        menuLink  = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Admin/Logon.aspx") +
                                    "'>" + General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }

                    var allowNewRegistration = false;
                    if (PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"] != null)
                    {
                        if (bool.Parse(PortalSettings.CustomSettings["SITESETTINGS_ALLOW_NEW_REGISTRATION"].ToString()))
                        {
                            allowNewRegistration = true;
                        }
                    }

                    if (ShowRegister && allowNewRegistration)
                    {
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + HttpUrlBuilder.BuildUrl("~/DesktopModules/CoreModules/Register/Register.aspx") +
                                   "'>" + General.GetString("REGISTER", "Register", null) + "</a>";
                        list.Add(menuLink);
                    }



                    // Thierry (Tiptopweb) 5 May 2003 : Secure Logon to Secure Directory
                    if (ShowSecureLogon)
                    {
                        // Added localized support. [email protected] (05/07/2004)
                        // added Class support by Mario Endara <*****@*****.**> 2004/10/04
                        menuLink = "<a";
                        if (CssClass.Length != 0)
                        {
                            menuLink = menuLink + " class=\"" + CssClass + "\"";
                        }

                        menuLink = menuLink + " href='" + PortalSettings.PortalSecurePath + "/Logon.aspx'>" +
                                   General.GetString("LOGON", "Logon", null) + "</a>";
                        list.Add(menuLink);
                    }
                }

                LanguageSwitcher ls = new LanguageSwitcher();
                Appleseed.Framework.Web.UI.WebControls.LanguageCultureCollection lcc = Appleseed.Framework.Localization.LanguageSwitcher.GetLanguageCultureList();
                if ((ShowLanguages) && (lcc.Count > 1))
                {
                    var mb = new StringBuilder();

                    mb.Append("<a");
                    if (CssClass.Length != 0)
                    {
                        mb.AppendFormat(" class=\"{0}\"", CssClass);
                    }

                    mb.AppendFormat("id = \"popUpLang\" >");

                    if ((ShowLangString) || (ShowLanguages))
                    {
                        string aux = General.GetString("LANGUAGE", "Language", null);
                        mb.AppendFormat("{0}", aux);
                    }
                    if (ShowFlags)
                    {
                        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                        string      dir         = HttpUrlBuilder.BuildUrl("~/aspnet_client/flags/flags_" + cultureInfo.ToString() + ".gif");
                        mb.AppendFormat("<img src=\"{0}\" alt=\"\" style=\"left:13px;position:relative\"/>", dir);
                    }
                    mb.Append("</a>");
                    list.Add(mb);
                }

                if (ShowTabMan && PortalSettings.IsAllowInviteMembers())
                {
                    menuLink = "<a";
                    if (CssClass.Length != 0)
                    {
                        menuLink = menuLink + " class=\"" + CssClass + "\"";
                    }

                    // added mID by Mario Endara <*****@*****.**> to support security check (2004/11/09)
                    var url = "/ASMemberInvite/MemberInvite/RenderView?pid=" +
                              PortalSettings.ActivePage.PageID;
                    menuLink = menuLink + " href='" + url + "' onclick=\"openInModal('" + url + "','" + General.GetString("HEADER_INVITE_MEMBERS", "Invite Members", null) + "');return false;\");>" +
                               General.GetString("HEADER_INVITE_MEMBERS", "Invite Members", null) + "</a>";
                    list.Add(menuLink);
                }
                innerDataSource = list;
            }
            base.DataBind();
            if (ShowLogon && DialogLogon)
            {
                //this new list control won't appear in the list, since it has no DataItem. However we need it for "holding" the Signin Control.
                var newItem = new DataListItem(this.Controls.Count, ListItemType.Item);
                this.Controls.Add(newItem);

                var logonDialogPlaceHolder = new PlaceHolder();
                newItem.Controls.Add(logonDialogPlaceHolder);

                if (_logonControl == null) //we ask this in case someone call the Databind more than once.
                {
                    _logonControl = Page.LoadControl(DialogLogonControlPath);
                    _logonControl.ViewStateMode = System.Web.UI.ViewStateMode.Enabled;
                }
                logonDialogPlaceHolder.Controls.Add(_logonControl);
            }
        }