Ejemplo n.º 1
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"),
                                       ModuleMessage.ModuleMessageType.YellowWarning);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                //check portal expiry date
                if (!CheckExpired())
                {
                    if ((PortalSettings.ActiveTab.StartDate < DateAndTime.Now && PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                        {
                            success = ProcessModule(objModule);
                        }
                    }
                    else
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                else
                {
                    AddPageMessage(this,
                                   "",
                                   string.Format(Localization.GetString("ContractExpired.Error"), PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email),
                                   ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                Response.Redirect(Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error")), true);
            }
            return(success);
        }
Ejemplo n.º 2
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // We need to ensure that Content Item exists since in old versions Content Items are not needed for tabs
                this.EnsureContentItemForTab(this.PortalSettings.ActiveTab);

                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    this.HandleAccesDenied(true);
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        this.HandleAccesDenied(false);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        this.Response.Redirect(this.NavigationManager.NavigateURL(this.PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                // check portal expiry date
                if (!this.CheckExpired())
                {
                    if ((this.PortalSettings.ActiveTab.StartDate < DateAndTime.Now && this.PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        foreach (var objModule in PortalSettingsController.Instance().GetTabModules(this.PortalSettings))
                        {
                            success = this.ProcessModule(objModule);
                        }
                    }
                    else
                    {
                        this.HandleAccesDenied(false);
                    }
                }
                else
                {
                    AddPageMessage(
                        this,
                        string.Empty,
                        string.Format(Localization.GetString("ContractExpired.Error"), this.PortalSettings.PortalName, Globals.GetMediumDate(this.PortalSettings.ExpiryDate.ToString(CultureInfo.InvariantCulture)), this.PortalSettings.Email),
                        ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                // If request localized page which haven't complete translate yet, redirect to default language version.
                var redirectUrl = Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error"));

                // Current locale will use default if did'nt find any
                Locale currentLocale = LocaleController.Instance.GetCurrentLocale(this.PortalSettings.PortalId);
                if (this.PortalSettings.ContentLocalizationEnabled &&
                    TabController.CurrentPage.CultureCode != currentLocale.Code)
                {
                    redirectUrl = new LanguageTokenReplace {
                        Language = currentLocale.Code
                    }.ReplaceEnvironmentTokens("[URL]");
                }

                this.Response.Redirect(redirectUrl, true);
            }

            return(success);
        }
Ejemplo n.º 3
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// - Obtain PortalSettings from Current Context
        /// - redirect to a specific tab based on name
        /// - if first time loading this page then reload to avoid caching
        /// - set page title and stylesheet
        /// - check to see if we should show the Assembly Version in Page Title
        /// - set the background image if there is one selected
        /// - set META tags, copyright, keywords and description
        /// </remarks>
        /// -----------------------------------------------------------------------------
        private void InitializePage()
        {
            //There could be a pending installation/upgrade process
            if (InstallBlocker.Instance.IsInstallInProgress())
            {
                Exceptions.ProcessHttpException(new HttpException(503, Localization.GetString("SiteAccessedWhileInstallationWasInProgress.Error", Localization.GlobalResourceFile)));
            }

            //Configure the ActiveTab with Skin/Container information
            PortalSettingsController.Instance().ConfigureActiveTab(PortalSettings);

            //redirect to a specific tab based on name
            if (!String.IsNullOrEmpty(Request.QueryString["tabname"]))
            {
                TabInfo tab = TabController.Instance.GetTabByName(Request.QueryString["TabName"], PortalSettings.PortalId);
                if (tab != null)
                {
                    var parameters = new List <string>(); //maximum number of elements
                    for (int intParam = 0; intParam <= Request.QueryString.Count - 1; intParam++)
                    {
                        switch (Request.QueryString.Keys[intParam].ToLowerInvariant())
                        {
                        case "tabid":
                        case "tabname":
                            break;

                        default:
                            parameters.Add(
                                Request.QueryString.Keys[intParam] + "=" + Request.QueryString[intParam]);
                            break;
                        }
                    }
                    Response.Redirect(NavigationManager.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true);
                }
                else
                {
                    //404 Error - Redirect to ErrorPage
                    Exceptions.ProcessHttpException(Request);
                }
            }
            string cacheability = Request.IsAuthenticated ? Host.AuthenticatedCacheability : Host.UnauthenticatedCacheability;

            switch (cacheability)
            {
            case "0":
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                break;

            case "1":
                Response.Cache.SetCacheability(HttpCacheability.Private);
                break;

            case "2":
                Response.Cache.SetCacheability(HttpCacheability.Public);
                break;

            case "3":
                Response.Cache.SetCacheability(HttpCacheability.Server);
                break;

            case "4":
                Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
                break;

            case "5":
                Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
                break;
            }

            //Only insert the header control if a comment is needed
            if (!String.IsNullOrWhiteSpace(Comment))
            {
                Page.Header.Controls.AddAt(0, new LiteralControl(Comment));
            }

            if (PortalSettings.ActiveTab.PageHeadText != Null.NullString && !Globals.IsAdminControl())
            {
                Page.Header.Controls.Add(new LiteralControl(PortalSettings.ActiveTab.PageHeadText));
            }

            if (!string.IsNullOrEmpty(PortalSettings.PageHeadText))
            {
                metaPanel.Controls.Add(new LiteralControl(PortalSettings.PageHeadText));
            }

            //set page title
            if (UrlUtils.InPopUp())
            {
                var strTitle    = new StringBuilder(PortalSettings.PortalName);
                var slaveModule = UIUtilities.GetSlaveModule(PortalSettings.ActiveTab.TabID);

                //Skip is popup is just a tab (no slave module)
                if (slaveModule.DesktopModuleID != Null.NullInteger)
                {
                    var    control   = ModuleControlFactory.CreateModuleControl(slaveModule) as IModuleControl;
                    string extension = Path.GetExtension(slaveModule.ModuleControl.ControlSrc.ToLowerInvariant());
                    switch (extension)
                    {
                    case ".mvc":
                        var segments = slaveModule.ModuleControl.ControlSrc.Replace(".mvc", "").Split('/');

                        control.LocalResourceFile = String.Format("~/DesktopModules/MVC/{0}/{1}/{2}.resx",
                                                                  slaveModule.DesktopModule.FolderName,
                                                                  Localization.LocalResourceDirectory,
                                                                  segments[0]);
                        break;

                    default:
                        control.LocalResourceFile = string.Concat(
                            slaveModule.ModuleControl.ControlSrc.Replace(
                                Path.GetFileName(slaveModule.ModuleControl.ControlSrc), string.Empty),
                            Localization.LocalResourceDirectory, "/",
                            Path.GetFileName(slaveModule.ModuleControl.ControlSrc));
                        break;
                    }
                    var title = Localization.LocalizeControlTitle(control);

                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                    strTitle.Append(string.Concat(" > ", title));
                }
                else
                {
                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                }

                //Set to page
                Title = strTitle.ToString();
            }
            else
            {
                //If tab is named, use that title, otherwise build it out via breadcrumbs
                if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Title))
                {
                    Title = PortalSettings.ActiveTab.Title;
                }
                else
                {
                    //Elected for SB over true concatenation here due to potential for long nesting depth
                    var strTitle = new StringBuilder(PortalSettings.PortalName);
                    foreach (TabInfo tab in PortalSettings.ActiveTab.BreadCrumbs)
                    {
                        strTitle.Append(string.Concat(" > ", tab.TabName));
                    }
                    Title = strTitle.ToString();
                }
            }

            //set the background image if there is one selected
            if (!UrlUtils.InPopUp() && FindControl("Body") != null)
            {
                if (!string.IsNullOrEmpty(PortalSettings.BackgroundFile))
                {
                    var fileInfo = GetBackgroundFileInfo();
                    var url      = FileManager.Instance.GetUrl(fileInfo);

                    ((HtmlGenericControl)FindControl("Body")).Attributes["style"] = string.Concat("background-image: url('", url, "')");
                }
            }

            //META Refresh
            // Only autorefresh the page if we are in VIEW-mode and if we aren't displaying some module's subcontrol.
            if (PortalSettings.ActiveTab.RefreshInterval > 0 && this.PortalSettings.UserMode == PortalSettings.Mode.View && Request.QueryString["ctl"] == null)
            {
                MetaRefresh.Content = PortalSettings.ActiveTab.RefreshInterval.ToString();
                MetaRefresh.Visible = true;
            }
            else
            {
                MetaRefresh.Visible = false;
            }

            //META description
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Description))
            {
                Description = PortalSettings.ActiveTab.Description;
            }
            else
            {
                Description = PortalSettings.Description;
            }

            //META keywords
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.KeyWords))
            {
                KeyWords = PortalSettings.ActiveTab.KeyWords;
            }
            else
            {
                KeyWords = PortalSettings.KeyWords;
            }

            //META copyright
            if (!string.IsNullOrEmpty(PortalSettings.FooterText))
            {
                Copyright = PortalSettings.FooterText.Replace("[year]", DateTime.Now.Year.ToString());
            }
            else
            {
                Copyright = string.Concat("Copyright (c) ", DateTime.Now.Year, " by ", PortalSettings.PortalName);
            }

            //META generator

            Generator = "";


            //META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag
            if (!UrlUtils.InPopUp() &&
                !(HeaderTextRegex.IsMatch(PortalSettings.ActiveTab.PageHeadText) ||
                  HeaderTextRegex.IsMatch(PortalSettings.PageHeadText)))
            {
                MetaRobots.Visible = true;
                var allowIndex = true;
                if ((PortalSettings.ActiveTab.TabSettings.ContainsKey("AllowIndex") &&
                     bool.TryParse(PortalSettings.ActiveTab.TabSettings["AllowIndex"].ToString(), out allowIndex) &&
                     !allowIndex)
                    ||
                    (Request.QueryString["ctl"] != null &&
                     (Request.QueryString["ctl"] == "Login" || Request.QueryString["ctl"] == "Register")))
                {
                    MetaRobots.Content = "NOINDEX, NOFOLLOW";
                }
                else
                {
                    MetaRobots.Content = "INDEX, FOLLOW";
                }
            }

            //NonProduction Label Injection
            if (NonProductionVersion() && Host.DisplayBetaNotice && !UrlUtils.InPopUp())
            {
                string versionString = string.Format(" ({0} Version: {1})", DotNetNukeContext.Current.Application.Status,
                                                     DotNetNukeContext.Current.Application.Version);
                Title += versionString;
            }

            //register the custom stylesheet of current page
            if (PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()))
            {
                var customStylesheet = Path.Combine(PortalSettings.HomeDirectory, PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString());
                ClientResourceManager.RegisterStyleSheet(this, customStylesheet);
            }

            // Cookie Consent
            if (PortalSettings.ShowCookieConsent)
            {
                ClientAPI.RegisterClientVariable(this, "cc_morelink", PortalSettings.CookieMoreLink, true);
                ClientAPI.RegisterClientVariable(this, "cc_message", Localization.GetString("cc_message", Localization.GlobalResourceFile), true);
                ClientAPI.RegisterClientVariable(this, "cc_dismiss", Localization.GetString("cc_dismiss", Localization.GlobalResourceFile), true);
                ClientAPI.RegisterClientVariable(this, "cc_link", Localization.GetString("cc_link", Localization.GlobalResourceFile), true);
                ClientResourceManager.RegisterScript(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.js", FileOrder.Js.DnnControls);
                ClientResourceManager.RegisterStyleSheet(Page, "~/Resources/Shared/Components/CookieConsent/cookieconsent.min.css", FileOrder.Css.ResourceCss);
                ClientResourceManager.RegisterScript(Page, "~/js/dnn.cookieconsent.js", FileOrder.Js.DefaultPriority);
            }
        }
Ejemplo n.º 4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        ///
        /// </summary>
        /// <remarks>
        /// - Obtain PortalSettings from Current Context
        /// - redirect to a specific tab based on name
        /// - if first time loading this page then reload to avoid caching
        /// - set page title and stylesheet
        /// - check to see if we should show the Assembly Version in Page Title
        /// - set the background image if there is one selected
        /// - set META tags, copyright, keywords and description
        /// </remarks>
        /// <history>
        ///     [sun1]	1/19/2004	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        private void InitializePage()
        {
            //Configure the ActiveTab with Skin/Container information
            PortalSettingsController.Instance().ConfigureActiveTab(PortalSettings);

            //redirect to a specific tab based on name
            if (!String.IsNullOrEmpty(Request.QueryString["tabname"]))
            {
                TabInfo tab = TabController.Instance.GetTabByName(Request.QueryString["TabName"], PortalSettings.PortalId);
                if (tab != null)
                {
                    var parameters = new List <string>(); //maximum number of elements
                    for (int intParam = 0; intParam <= Request.QueryString.Count - 1; intParam++)
                    {
                        switch (Request.QueryString.Keys[intParam].ToLower())
                        {
                        case "tabid":
                        case "tabname":
                            break;

                        default:
                            parameters.Add(
                                Request.QueryString.Keys[intParam] + "=" + Request.QueryString[intParam]);
                            break;
                        }
                    }
                    Response.Redirect(Globals.NavigateURL(tab.TabID, Null.NullString, parameters.ToArray()), true);
                }
                else
                {
                    //404 Error - Redirect to ErrorPage
                    Exceptions.ProcessHttpException(Request);
                }
            }
            if (Request.IsAuthenticated)
            {
                switch (Host.AuthenticatedCacheability)
                {
                case "0":
                    Response.Cache.SetCacheability(HttpCacheability.NoCache);
                    break;

                case "1":
                    Response.Cache.SetCacheability(HttpCacheability.Private);
                    break;

                case "2":
                    Response.Cache.SetCacheability(HttpCacheability.Public);
                    break;

                case "3":
                    Response.Cache.SetCacheability(HttpCacheability.Server);
                    break;

                case "4":
                    Response.Cache.SetCacheability(HttpCacheability.ServerAndNoCache);
                    break;

                case "5":
                    Response.Cache.SetCacheability(HttpCacheability.ServerAndPrivate);
                    break;
                }
            }

            //page comment
            if (Host.DisplayCopyright)
            {
                Comment += string.Concat(Environment.NewLine,
                                         "<!--*********************************************-->",
                                         Environment.NewLine,
                                         "<!-- DNN Platform - http://www.dnnsoftware.com   -->",
                                         Environment.NewLine,
                                         "<!-- Copyright (c) 2002-2015, by DNN Corporation -->",
                                         Environment.NewLine,
                                         "<!--*********************************************-->",
                                         Environment.NewLine);
            }

            //Only insert the header control if a comment is needed
            if (!String.IsNullOrWhiteSpace(Comment))
            {
                Page.Header.Controls.AddAt(0, new LiteralControl(Comment));
            }

            if (PortalSettings.ActiveTab.PageHeadText != Null.NullString && !Globals.IsAdminControl())
            {
                Page.Header.Controls.Add(new LiteralControl(PortalSettings.ActiveTab.PageHeadText));
            }

            if (!string.IsNullOrEmpty(PortalSettings.PageHeadText))
            {
                metaPanel.Controls.Add(new LiteralControl(PortalSettings.PageHeadText));
            }

            //set page title
            if (UrlUtils.InPopUp())
            {
                var strTitle    = new StringBuilder(PortalSettings.PortalName);
                var slaveModule = UIUtilities.GetSlaveModule(PortalSettings.ActiveTab.TabID);

                //Skip is popup is just a tab (no slave module)
                if (slaveModule.DesktopModuleID != Null.NullInteger)
                {
                    var control = ModuleControlFactory.CreateModuleControl(slaveModule) as IModuleControl;
                    control.LocalResourceFile = string.Concat(
                        slaveModule.ModuleControl.ControlSrc.Replace(Path.GetFileName(slaveModule.ModuleControl.ControlSrc), string.Empty),
                        Localization.LocalResourceDirectory, "/", Path.GetFileName(slaveModule.ModuleControl.ControlSrc));
                    var title = Localization.LocalizeControlTitle(control);

                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                    strTitle.Append(string.Concat(" > ", title));
                }
                else
                {
                    strTitle.Append(string.Concat(" > ", PortalSettings.ActiveTab.LocalizedTabName));
                }

                //Set to page
                Title = strTitle.ToString();
            }
            else
            {
                //If tab is named, use that title, otherwise build it out via breadcrumbs
                if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Title))
                {
                    Title = PortalSettings.ActiveTab.Title;
                }
                else
                {
                    //Elected for SB over true concatenation here due to potential for long nesting depth
                    var strTitle = new StringBuilder(PortalSettings.PortalName);
                    foreach (TabInfo tab in PortalSettings.ActiveTab.BreadCrumbs)
                    {
                        strTitle.Append(string.Concat(" > ", tab.TabName));
                    }
                    Title = strTitle.ToString();
                }
            }

            //set the background image if there is one selected
            if (!UrlUtils.InPopUp() && FindControl("Body") != null)
            {
                if (!string.IsNullOrEmpty(PortalSettings.BackgroundFile))
                {
                    var fileInfo = GetBackgroundFileInfo();
                    var url      = FileManager.Instance.GetUrl(fileInfo);

                    ((HtmlGenericControl)FindControl("Body")).Attributes["style"] = string.Concat("background-image: url('", url, "')");
                }
            }

            //META Refresh
            // Only autorefresh the page if we are in VIEW-mode and if we aren't displaying some module's subcontrol.
            if (PortalSettings.ActiveTab.RefreshInterval > 0 && this.PortalSettings.UserMode == PortalSettings.Mode.View && Request.QueryString["ctl"] == null)
            {
                MetaRefresh.Content = PortalSettings.ActiveTab.RefreshInterval.ToString();
                MetaRefresh.Visible = true;
            }
            else
            {
                MetaRefresh.Visible = false;
            }

            //META description
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.Description))
            {
                Description = PortalSettings.ActiveTab.Description;
            }
            else
            {
                Description = PortalSettings.Description;
            }

            //META keywords
            if (!string.IsNullOrEmpty(PortalSettings.ActiveTab.KeyWords))
            {
                KeyWords = PortalSettings.ActiveTab.KeyWords;
            }
            else
            {
                KeyWords = PortalSettings.KeyWords;
            }
            if (Host.DisplayCopyright)
            {
                KeyWords += ",DotNetNuke,DNN";
            }

            //META copyright
            if (!string.IsNullOrEmpty(PortalSettings.FooterText))
            {
                Copyright = PortalSettings.FooterText.Replace("[year]", DateTime.Now.Year.ToString());
            }
            else
            {
                Copyright = string.Concat("Copyright (c) ", DateTime.Now.Year, " by ", PortalSettings.PortalName);
            }

            //META generator
            if (Host.DisplayCopyright)
            {
                Generator = "DotNetNuke ";
            }
            else
            {
                Generator = "";
            }

            //META Robots - hide it inside popups and if PageHeadText of current tab already contains a robots meta tag
            if (!UrlUtils.InPopUp() &&
                !Regex.IsMatch(PortalSettings.ActiveTab.PageHeadText, "<meta([^>])+name=('|\")robots('|\")", RegexOptions.IgnoreCase | RegexOptions.Multiline) &&
                !Regex.IsMatch(PortalSettings.PageHeadText, "<meta([^>])+name=('|\")robots('|\")", RegexOptions.IgnoreCase | RegexOptions.Multiline)
                )
            {
                MetaRobots.Visible = true;
                var allowIndex = true;
                if ((PortalSettings.ActiveTab.TabSettings.ContainsKey("AllowIndex") &&
                     bool.TryParse(PortalSettings.ActiveTab.TabSettings["AllowIndex"].ToString(), out allowIndex) &&
                     !allowIndex)
                    ||
                    (Request.QueryString["ctl"] != null &&
                     (Request.QueryString["ctl"] == "Login" || Request.QueryString["ctl"] == "Register")))
                {
                    MetaRobots.Content = "NOINDEX, NOFOLLOW";
                }
                else
                {
                    MetaRobots.Content = "INDEX, FOLLOW";
                }
            }

            //NonProduction Label Injection
            if (NonProductionVersion() && Host.DisplayBetaNotice && !UrlUtils.InPopUp())
            {
                string versionString = string.Format(" ({0} Version: {1})", DotNetNukeContext.Current.Application.Status,
                                                     DotNetNukeContext.Current.Application.Version);
                Title += versionString;
            }

            //register DNN SkinWidgets Inititialization scripts
            if (PortalSettings.EnableSkinWidgets & !UrlUtils.InPopUp())
            {
                jQuery.RequestRegistration();
                // don't use the new API to register widgets until we better understand their asynchronous script loading requirements.
                ClientAPI.RegisterStartUpScript(Page, "initWidgets", string.Format("<script type=\"text/javascript\" src=\"{0}\" ></script>", ResolveUrl("~/Resources/Shared/scripts/initWidgets.js")));
            }

            //register the custom stylesheet of current page
            if (PortalSettings.ActiveTab.TabSettings.ContainsKey("CustomStylesheet") && !string.IsNullOrEmpty(PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString()))
            {
                var customStylesheet = Path.Combine(PortalSettings.HomeDirectory, PortalSettings.ActiveTab.TabSettings["CustomStylesheet"].ToString());
                ClientResourceManager.RegisterStyleSheet(this, customStylesheet);
            }
        }
Ejemplo n.º 5
0
        private bool ProcessMasterModules()
        {
            bool success = true;

            if (TabPermissionController.CanViewPage())
            {
                // Versioning checks.
                if (!TabController.CurrentPage.HasAVisibleVersion)
                {
                    Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                }

                int urlVersion;
                if (TabVersionUtils.TryGetUrlVersion(out urlVersion))
                {
                    if (!TabVersionUtils.CanSeeVersionedPages())
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"),
                                       ModuleMessage.ModuleMessageType.YellowWarning);
                        return(true);
                    }

                    if (TabVersionController.Instance.GetTabVersions(TabController.CurrentPage.TabID).All(tabVersion => tabVersion.Version != urlVersion))
                    {
                        Response.Redirect(Globals.NavigateURL(PortalSettings.ErrorPage404, string.Empty, "status=404"));
                    }
                }

                //check portal expiry date
                if (!CheckExpired())
                {
                    if ((PortalSettings.ActiveTab.StartDate < DateAndTime.Now && PortalSettings.ActiveTab.EndDate > DateAndTime.Now) || TabPermissionController.CanAdminPage() || Globals.IsLayoutMode())
                    {
                        // Check for MVC async call
                        if (Request.QueryString.AllKeys.Contains("moduleId") &&
                            Request.QueryString.AllKeys.Contains("controller") &
                            Request.QueryString.AllKeys.Contains("action") &&
                            Request.QueryString.AllKeys.Contains("async") &&
                            Request.QueryString["async"].ToLower() == "true")
                        {
                            // Get module ID
                            var moduleId = 0;
                            success = int.TryParse(Request.QueryString["moduleId"], out moduleId);

                            if (success)
                            {
                                // Get module info
                                foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                                {
                                    if (objModule.ModuleID == moduleId)
                                    {
                                        // process only this module
                                        success = ProcessModule(objModule);
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (var objModule in PortalSettingsController.Instance().GetTabModules(PortalSettings))
                            {
                                success = ProcessModule(objModule);
                            }
                        }
                    }
                    else
                    {
                        AddPageMessage(this, "", Localization.GetString("TabAccess.Error"), ModuleMessage.ModuleMessageType.YellowWarning);
                    }
                }
                else
                {
                    AddPageMessage(this,
                                   "",
                                   string.Format(Localization.GetString("ContractExpired.Error"), PortalSettings.PortalName, Globals.GetMediumDate(PortalSettings.ExpiryDate.ToString()), PortalSettings.Email),
                                   ModuleMessage.ModuleMessageType.RedError);
                }
            }
            else
            {
                //If request localized page which haven't complete translate yet, redirect to default language version.
                var    redirectUrl   = Globals.AccessDeniedURL(Localization.GetString("TabAccess.Error"));
                Locale defaultLocale = LocaleController.Instance.GetDefaultLocale(PortalSettings.PortalId);
                if (PortalSettings.ContentLocalizationEnabled &&
                    TabController.CurrentPage.CultureCode != defaultLocale.Code)
                {
                    redirectUrl = new LanguageTokenReplace {
                        Language = defaultLocale.Code
                    }.ReplaceEnvironmentTokens("[URL]");
                }

                Response.Redirect(redirectUrl, true);
            }
            return(success);
        }