Пример #1
0
            public static ActionResult GetSiteAlias(UserInfo userInfo, int portalAliasId)
            {
                ActionResult actionResult = new ActionResult();

                try
                {
                    PortalAliasInfo alias = PortalAliasController.Instance.GetPortalAliasByPortalAliasID(portalAliasId);
                    if (!userInfo.IsSuperUser && alias.PortalID != PortalSettings.Current.PortalId)
                    {
                        actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                    }

                    if (actionResult.IsSuccess)
                    {
                        UpdateSiteAliasRequest PortalAlias = new UpdateSiteAliasRequest()
                        {
                            PortalId      = alias.PortalID,
                            PortalAliasID = alias.PortalAliasID,
                            HTTPAlias     = alias.HTTPAlias,
                            BrowserType   = alias.BrowserType.ToString(),
                            Skin          = alias.Skin,
                            CultureCode   = alias.CultureCode,
                            IsPrimary     = alias.IsPrimary
                        };
                        actionResult.Data = PortalAlias;
                    }
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
        public ActionResult AddSiteAlias(UpdateSiteAliasRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int pid = request.PortalId ?? PortalSettings.Current.PortalId;
                if (!UserInfo.IsSuperUser && pid != PortalSettings.Current.PortalId)
                {
                    actionResult.AddError(HttpStatusCode.Unauthorized.ToString(), Components.Constants.AuthFailureMessage);
                }

                string strAlias = request.HTTPAlias;
                if (!string.IsNullOrEmpty(strAlias))
                {
                    strAlias = strAlias.Trim();
                }

                if (IsHttpAliasValid(strAlias))
                {
                    PortalAliasCollection aliases = PortalAliasController.Instance.GetPortalAliases();
                    if (aliases.Contains(strAlias))
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), string.Format(Localization.GetString("DuplicateAlias", Dnn.PersonaBar.SiteSettings.Components.Constants.Constants.LocalResourcesFile)));
                    }

                    if (actionResult.IsSuccess)
                    {
                        Enum.TryParse(request.BrowserType, out BrowserTypes browser);
                        PortalAliasInfo portalAlias = new PortalAliasInfo()
                        {
                            PortalID    = pid,
                            HTTPAlias   = strAlias,
                            Skin        = request.Skin,
                            CultureCode = request.CultureCode,
                            BrowserType = browser,
                            IsPrimary   = request.IsPrimary
                        };
                        PortalAliasController.Instance.AddPortalAlias(portalAlias);
                        actionResult.Data = new { SiteAliases = Managers.DomainManager.GetSiteAliases(PortalSettings.Current.PortalId, UserInfo).Data };
                    }
                }
                else
                {
                    actionResult.AddError(HttpStatusCode.BadRequest.ToString(), string.Format(Localization.GetString("InvalidAlias", Dnn.PersonaBar.SiteSettings.Components.Constants.Constants.LocalResourcesFile)));
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
        public ActionResult AddUpdateSiteAlias(UpdateSiteAliasRequest request)
        {
            ActionResult actionResult = new ActionResult();

            if (request.PortalAliasID > 0)
            {
                actionResult = UpdateSiteAlias(request);
            }
            else
            {
                actionResult = AddSiteAlias(request);
            }

            return(actionResult);
        }
        public static List <IUIData> GetData(string Identifier, Dictionary <string, string> parameters, Dictionary <string, string> UIEngineInfo, UserInfo userInfo, PortalSettings portalSettings)
        {
            Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>();

            switch (Identifier.ToLower())
            {
            case "domain_domains":
            {
                string ActiveSiteAlias = portalSettings.PortalAlias != null && !string.IsNullOrEmpty(portalSettings.PortalAlias.HTTPAlias) ? portalSettings.PortalAlias.HTTPAlias : string.Empty;
                Settings.Add("PortalAliases", new UIData {
                        Name = "PortalAliases", Options = Managers.DomainManager.GetSiteAliases(portalSettings.PortalId, userInfo).Data, Value = ActiveSiteAlias
                    });
                return(Settings.Values.ToList());
            }

            case "domain_settings":
            {
                int sid = 0;
                UpdateSiteAliasRequest updateSiteAliasRequest = new UpdateSiteAliasRequest()
                {
                    PortalId = portalSettings.PortalId, CultureCode = portalSettings.CultureCode
                };
                if (parameters.Count > 0)
                {
                    sid = int.Parse(parameters["sid"]);
                }

                if (sid > 0)
                {
                    updateSiteAliasRequest = Managers.DomainManager.GetSiteAlias(userInfo, sid).Data;
                }

                Settings.Add("UpdateSiteAliasRequest", new UIData {
                        Name = "UpdateSiteAliasRequest", Options = updateSiteAliasRequest
                    });
                Settings.Add("Languages", new UIData {
                        Name = "Languages", Options = Managers.DomainManager.GetSiteAliases(portalSettings.PortalId, userInfo).Data.Languages, Value = !string.IsNullOrEmpty(updateSiteAliasRequest.CultureCode) ? updateSiteAliasRequest.CultureCode : "Default"
                    });
                return(Settings.Values.ToList());
            }

            default:
                return(null);
            }
        }