Пример #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);
        }
Пример #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);
        }
Пример #3
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);
        }