public ActionResult DeleteCustomUrl(UrlIdDto dto)
        {
            ActionResult     actionResult       = new ActionResult();
            PageUrlsServices pageUrlsController = new PageUrlsServices();
            PageUrlResult    pageUrlResult;

            try
            {
                pageUrlResult = pageUrlsController.DeleteCustomUrl(dto);
                if (!pageUrlResult.Success)
                {
                    actionResult.AddError("DeleteCustomUrl.Error", pageUrlResult.ErrorMessage);
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            if (actionResult.IsSuccess)
            {
                actionResult.Data = GetCustomUrls(dto.TabId);
            }

            return(actionResult);
        }
Beispiel #2
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 static ActionResult DeletePackage(DeletePackageDto deletePackage)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                PackageInfo package = PackageController.Instance.GetExtensionPackage(Null.NullInteger, p => p.PackageID == deletePackage.Id);
                if (package == null)
                {
                    actionResult.AddError("NotFound", "NotFound");
                    return(actionResult);
                }

                Installer installer = new Installer(package, Globals.ApplicationMapPath);
                installer.UnInstall(deletePackage.DeleteFiles);

                actionResult.IsSuccess = true;
                return(actionResult);
            }
            catch (Exception ex)
            {
                actionResult.HasErrors = true;
                actionResult.AddError("", "", ex);
                return(actionResult);
            }
        }
Beispiel #4
0
        public ActionResult DeleteListEntry(int entryId, string propertyName)
        {
            ActionResult actionResult = new ActionResult();

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

                if (actionResult.IsSuccess)
                {
                    ListController listController = new ListController();
                    listController.DeleteListEntryByID(entryId, true);
                    actionResult.Data = new { Managers.MemberProfileManager.GetListInfo(propertyName, PortalSettings.PortalId).Data.Entries };
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
        public ActionResult UpdatePortalSettings(string FileId, string HomeIcon, UpdateSiteSettingsRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                int      pid      = request.PortalId ?? (PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId;
                UserInfo userInfo = UserController.Instance.GetCurrentUserInfo();
                if (!userInfo.IsSuperUser && pid != (PortalController.Instance.GetCurrentSettings() as PortalSettings).PortalId)
                {
                    actionResult.AddError("InvalidUser.Error", DotNetNuke.Services.Localization.Localization.GetString("InvalidUser.Error", Components.Constants.LocalResourcesFile));
                }

                string cultureCode = string.IsNullOrEmpty(request.CultureCode) ? LocaleController.Instance.GetCurrentLocale(pid).Code : request.CultureCode;

                Locale language = LocaleController.Instance.GetLocale(pid, cultureCode);
                if (language == null)
                {
                    actionResult.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, Localization.GetString("InvalidLocale.ErrorMessage", Components.Constants.LocalResourcesFile));
                }

                PortalInfo portalInfo = PortalController.Instance.GetPortal(pid, cultureCode);
                //portalInfo.PortalName = request.PortalName;

                if (request.LogoFile != null && request.LogoFile.fileId > 0)
                {
                    portalInfo.LogoFile = FileManager.Instance.GetFile(request.LogoFile.fileId).RelativePath;
                }

                //portalInfo.FooterText = request.FooterText;

                PortalController.Instance.UpdatePortalInfo(portalInfo);
                PortalController.UpdatePortalSetting(pid, "TimeZone", request.TimeZone, false);

                if (request.FavIcon != null && request.FavIcon.fileId > 0)
                {
                    new FavIcon(pid).Update(request.FavIcon.fileId);
                }

                PortalController.UpdatePortalSetting(pid, "DefaultIconLocation", "icons/" + request.IconSet, false, cultureCode);

                //update social sharing logo
                if (!string.IsNullOrEmpty(FileId) && Convert.ToInt32(FileId) > 0)
                {
                    PortalController.UpdatePortalSetting(pid, "SocialSharingLogo", "FileID=" + FileId, true, cultureCode);
                }

                if (!string.IsNullOrEmpty(HomeIcon) && Convert.ToInt32(HomeIcon) > 0)
                {
                    PortalController.UpdatePortalSetting(pid, "HomeScreenIcon", "Fileid=" + HomeIcon, true, cultureCode);
                }

                actionResult.Data = BrowseUploadFactory.GetFile(PortalSettings, request.LogoFile.fileId);
            }
            catch (Exception ex)
            {
                actionResult.AddError("HttpStatusCode.InternalServerError" + HttpStatusCode.InternalServerError, ex.Message);
            }
            return(actionResult);
        }
Beispiel #6
0
        public ActionResult DeleteProfileProperty(int propertyId)
        {
            ActionResult actionResult = new ActionResult();

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

                if (actionResult.IsSuccess)
                {
                    ProfilePropertyDefinition propertyDefinition = ProfileController.GetPropertyDefinition(propertyId, pid);

                    if (!CanDeleteProperty(propertyDefinition))
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), "ForbiddenDelete");
                    }
                    if (actionResult.IsSuccess)
                    {
                        ProfileController.DeletePropertyDefinition(propertyDefinition);
                        DataCache.ClearDefinitionsCache(pid);
                        actionResult.Data = new { MemberProfile = Managers.MemberProfileManager.GetProfileProperties(pid).Data.Properties };
                    }
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
Beispiel #7
0
            public static ActionResult UpdateProfilePropertyLocalization(UpdateProfilePropertyLocalizationRequest request)
            {
                ActionResult           actionResult = new ActionResult();
                SiteSettingsController _controller  = new SiteSettingsController();

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

                    if (actionResult.IsSuccess)
                    {
                        DNNLocalization.Locale language = DNNLocalization.LocaleController.Instance.GetLocale(pid, request.Language);
                        if (language == null)
                        {
                            actionResult.AddError(HttpStatusCode.BadRequest.ToString(), string.Format(DNNLocalization.Localization.GetString("InvalidLocale.ErrorMessage", PersonaBar.Constants.LocalResourcesFile), request.Language));
                        }

                        if (actionResult.IsSuccess)
                        {
                            _controller.SaveLocalizedKeys(pid, request.PropertyName, request.PropertyCategory, request.Language, request.PropertyNameString,
                                                          request.PropertyHelpString, request.PropertyRequiredString, request.PropertyValidationString, request.CategoryNameString);
                            DataCache.ClearCache();
                        }
                    }
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
Beispiel #8
0
            public static ActionResult GetProfileSettings(int?portalId)
            {
                ActionResult actionResult = new ActionResult();

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

                    FriendlyUrlSettings          urlSettings  = new FriendlyUrlSettings(pid);
                    System.Collections.Hashtable userSettings = UserController.GetUserSettings(pid);

                    actionResult.Data = new
                    {
                        Settings = new
                        {
                            PortalId = pid,
                            RedirectOldProfileUrl = Config.GetFriendlyUrlProvider() == "advanced" && urlSettings.RedirectOldProfileUrl,
                            urlSettings.VanityUrlPrefix,
                            ProfileDefaultVisibility = userSettings["Profile_DefaultVisibility"] == null ? (int)UserVisibilityMode.AdminOnly : Convert.ToInt32(userSettings["Profile_DefaultVisibility"]),
                            ProfileDisplayVisibility = PortalController.GetPortalSettingAsBoolean("Profile_DisplayVisibility", pid, true)
                        },
                        UserVisibilityOptions = GetVisibilityOptions()
                    };
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
Beispiel #9
0
        public ActionResult UpdatePrivacySettings(UpdatePrivacySettingsRequest request)
        {
            ActionResult actionResult = new ActionResult();

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

                PortalController.UpdatePortalSetting(pid, "ShowCookieConsent", "False", false);
                PortalController.UpdatePortalSetting(pid, "Vanjaro_CookieConsent", request.ShowCookieConsent.ToString(), false);
                //HostController.Instance.Update("Copyright", request.DisplayCopyright ? "Y" : "N", false);
                PortalController.UpdatePortalSetting(pid, "CookieMoreLink", request.CookieMoreLink, false, request.CultureCode);
                HostController.Instance.Update("CheckUpgrade", request.CheckUpgrade ? "Y" : "N", false);
                HostController.Instance.Update("DnnImprovementProgram", request.DnnImprovementProgram ? "Y" : "N", false);
                PortalController.UpdatePortalSetting(pid, "DataConsentActive", request.DataConsentActive.ToString(), false);
                PortalController.UpdatePortalSetting(pid, "DataConsentUserDeleteAction", request.DataConsentUserDeleteAction.ToString(), false);
                PortalController.UpdatePortalSetting(pid, "DataConsentConsentRedirect", ValidateTabId(request.DataConsentConsentRedirect, pid).ToString(), false);
                PortalController.UpdatePortalSetting(pid, "DataConsentDelay", request.DataConsentDelay.ToString(), false);
                PortalController.UpdatePortalSetting(pid, "DataConsentDelayMeasurement", request.DataConsentDelayMeasurement, false);
                DataCache.ClearCache();

                actionResult.Data = true;
            }
            catch (Exception exc)
            {
                actionResult.AddError("HttpStatusCode.InternalServerError", exc.Message);
            }
            return(actionResult);
        }
Beispiel #10
0
        public ActionResult DeleteConnection(string Id)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                AzureConnector           AzureConnector = new AzureConnector();
                IEnumerable <IConnector> connectors     = AzureConnector.GetConnectors(PortalSettings.PortalId);

                IConnector connector = connectors.FirstOrDefault(c => c.Id == Id);
                if (connector != null)
                {
                    connector.DeleteConnector(PortalSettings.PortalId);
                    actionResult.IsSuccess = true;
                    actionResult.Data      = Manager.ConnectorsManager.GetAll(PortalSettings.PortalId);
                    return(actionResult);
                }
                actionResult.AddError("ErrConnectorNotFound", Localization.GetString("ErrConnectorNotFound.Text", Constants.LocalResourceFile));
                return(actionResult);
            }
            catch (Exception ex)
            {
                actionResult.AddError("InternalServerError", "InternalServerError", ex);
                return(actionResult);
            }
        }
Beispiel #11
0
            private static ActionResult ValidateProperty(ProfilePropertyDefinition definition)
            {
                bool           isValid = true;
                ActionResult   httpPropertyValidationError = new ActionResult();
                ListController objListController           = new ListController();
                string         strDataType       = objListController.GetListEntryInfo("DataType", definition.DataType).Value;
                Regex          propertyNameRegex = new Regex("^[a-zA-Z0-9]+$");

                if (!propertyNameRegex.Match(definition.PropertyName).Success)
                {
                    isValid = false;
                    httpPropertyValidationError.AddError("NoSpecialCharacterName", string.Format(DNNLocalization.Localization.GetString("NoSpecialCharacterName.Text", PersonaBar.Constants.LocalResourcesFile)));
                }

                switch (strDataType)
                {
                case "Text":
                    if (definition.Required && definition.Length == 0)
                    {
                        isValid = Null.NullBoolean;
                        httpPropertyValidationError.AddError("RequiredTextBox", string.Format(DNNLocalization.Localization.GetString("RequiredTextBox", PersonaBar.Constants.LocalResourcesFile)));
                    }
                    break;
                }

                //if (isValid == false)
                //{
                //    httpPropertyValidationError.AddError("RequiredTextBox", string.Format(Localization.GetString("RequiredTextBox", PersonaBar.Constants.LocalResourcesFile)));
                //}
                return(httpPropertyValidationError);
            }
        public ActionResult InstallAvailablePackage(string FileName, string Type)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                string installFolder = Managers.ExtensionsManager.GetPackageInstallFolder(Type);
                if (string.IsNullOrEmpty(installFolder) || string.IsNullOrEmpty(FileName))
                {
                    actionResult.AddError("InvalidPackage", "InvalidPackage");
                    return(actionResult);
                }

                string packagePath = Path.Combine(Globals.ApplicationMapPath, "Install", installFolder, FileName);
                if (!File.Exists(packagePath))
                {
                    actionResult.AddError("NotFound", "NotFound");
                    return(actionResult);
                }

                using (FileStream stream = new FileStream(packagePath, FileMode.Open))
                {
                    InstallResultDto InstallResultDto = InstallController.Instance.InstallPackage(PortalSettings, UserInfo, null, packagePath, stream);
                    actionResult.Data      = InstallResultDto;
                    actionResult.IsSuccess = true;
                    return(actionResult);
                }
            }
            catch (Exception ex)
            {
                actionResult.AddError("", "", ex);
                return(actionResult);
            }
        }
Beispiel #13
0
        public ActionResult UpdateProfileSettings(UpdateProfileSettingsRequest request)
        {
            ActionResult actionResult = new ActionResult();

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

                if (actionResult.IsSuccess)
                {
                    if (Config.GetFriendlyUrlProvider() == "advanced")
                    {
                        PortalController.UpdatePortalSetting(pid, FriendlyUrlSettings.RedirectOldProfileUrlSetting, request.RedirectOldProfileUrl ? "Y" : "N", true);
                    }
                    PortalController.UpdatePortalSetting(pid, FriendlyUrlSettings.VanityUrlPrefixSetting, request.VanityUrlPrefix, false);
                    PortalController.UpdatePortalSetting(pid, "Profile_DefaultVisibility", request.ProfileDefaultVisibility.ToString(), false);
                    PortalController.UpdatePortalSetting(pid, "Profile_DisplayVisibility", request.ProfileDisplayVisibility.ToString(), false);

                    DataCache.ClearPortalCache(pid, false);
                }
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
        private IActionResult ValidateDatabase()
        {
            var actionResult = new ActionResult();

            try
            {
                if (Database.CreateIfNotExists())
                {
                    actionResult.AddInfo("Database created.");
                }
                else if (Database.CompatibleWithModel(true))
                {
                    actionResult.AddInfo("Database is valid.");
                }
                else
                {
                    actionResult.AddError("Database is not valid.");
                }
            }
            catch (Exception e)
            {
                actionResult.AddError("Database is not available.\r\n{0}", Helper.ExpandMessages(e));
            }
            return(actionResult);
        }
Beispiel #15
0
        public ActionResult RemoveUserFromRole(UserRoleDto userRoleDto)
        {
            ActionResult response = new ActionResult();

            try
            {
                Validate(userRoleDto);
                UserInfo user = UserManager.GetUser(userRoleDto.UserId, PortalSettings, UserInfo, out response);
                if (user == null)
                {
                    return(response);
                }

                DotNetNuke.Security.Roles.RoleController.Instance.UpdateUserRole(PortalSettings.PortalId, userRoleDto.UserId, userRoleDto.RoleId,
                                                                                 RoleStatus.Approved, false, true);

                response.Data = new { userRoleDto.UserId, userRoleDto.RoleId };
            }
            catch (ArgumentException ex)
            {
                response.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, ex.Message);
            }
            catch (SecurityException ex)
            {
                response.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, ex.Message);
            }
            catch (Exception ex)
            {
                response.AddError("HttpStatusCode.BadRequest" + HttpStatusCode.BadRequest, ex.Message);
            }
            return(response);
        }
        public ActionResult UpdateRoles(int lid, ArrayList Roles)
        {
            string       ResourcesFile = "~/DesktopModules/Vanjaro/UXManager/Extensions/Menu/" + ExtensionInfo.Name + "/Views/Setting/App_LocalResources/Translator.resx";
            ActionResult actionResult  = new ActionResult();

            try
            {
                if (!UserInfo.IsInRole("Administrators"))
                {
                    actionResult.AddError("AuthFailureMessage", Constants.AuthFailureMessage);
                    return(actionResult);
                }
                Locale language = LocaleController.Instance.GetLocale(lid);
                if (language == null)
                {
                    actionResult.AddError("InvalidLocale.ErrorMessage", string.Format(Localization.GetString("InvalidLocale.ErrorMessage", ResourcesFile), language.Code));
                    return(actionResult);
                }
                PortalController.UpdatePortalSetting(PortalSettings.PortalId, $"DefaultTranslatorRoles-{language.Code}", string.Join(";", Roles.Cast <string>().ToArray()));

                actionResult.IsSuccess = true;
            }
            catch (Exception exc)
            {
                actionResult.AddError("", "", exc);
            }
            return(actionResult);
        }
        public ActionResult Index(RegisterDetails RegisterDetails)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                RegisterManager.MapRegisterDetail(RegisterDetails);
                if (RegisterManager.Validate())
                {
                    if (PortalSettings.UserRegistration != (int)Globals.PortalRegistrationType.NoRegistration)
                    {
                        actionResult = RegisterManager.CreateUser(RegisterDetails);
                    }
                    else
                    {
                        actionResult.AddError("Registration_NotAllowed", "User registration is not allowed.");
                    }
                }
                else
                {
                    if (RegisterManager.CreateStatus != UserCreateStatus.AddUser)
                    {
                        actionResult.AddError("Registration_Failed", UserController.GetUserCreateStatus(RegisterManager.CreateStatus));
                    }
                }
            }
            catch (Exception ex)
            {
                actionResult.AddError("Register_Error", ex.Message);
            }
            return(actionResult);
        }
            public static ActionResult CreateCustomUrl(SeoUrl dto)
            {
                ActionResult actionResult = new ActionResult();

                if (!SecurityService.Instance.CanManagePage(dto.TabId))
                {
                    //HttpStatusCode.Forbidden  message is hardcoded in DotNetnuke so we localized our side.
                    actionResult.AddError("HttpStatusCode.Forbidden", DotNetNuke.Services.Localization.Localization.GetString("UserAuthorizationForbidden", Components.Constants.LocalResourcesFile));
                }

                if (actionResult.IsSuccess)
                {
                    PageUrlResult result = PagesController.Instance.CreateCustomUrl(dto);
                    if (result.Success)
                    {
                        actionResult.Data = GetCustomUrls(dto.TabId);
                    }
                    else
                    {
                        actionResult.AddError("UrlPathNotUnique.Error", result.ErrorMessage);
                        actionResult.Data = actionResult.Data = new { result.SuggestedUrlPath };
                    }
                }
                return(actionResult);
            }
            public static UserInfo GetUser(int userId, PortalSettings portalSettings, UserInfo userInfo, out ActionResult actionResult)
            {
                actionResult = new ActionResult();
                UserInfo user = UserController.Instance.GetUserById(portalSettings.PortalId, userId);

                if (user == null)
                {
                    actionResult.AddError("HttpStatusCode.NotFound_" + HttpStatusCode.NotFound, Localization.GetString("UserNotFound", Constants.LocalResourcesFile));
                    return(null);
                }
                if (!IsAdmin(user, portalSettings))
                {
                    return(user);
                }

                if ((user.IsSuperUser && !userInfo.IsSuperUser) || !IsAdmin(portalSettings))
                {
                    actionResult.AddError("HttpStatusCode.NotFound_" + HttpStatusCode.Unauthorized, Localization.GetString("InSufficientPermissions", Constants.LocalResourcesFile));
                    return(null);
                }
                if (user.IsSuperUser)
                {
                    user = UserController.Instance.GetUserById(Null.NullInteger, userId);
                }

                return(user);
            }
Beispiel #20
0
            public static ActionResult UpdateProfileProperty(UpdateProfilePropertyRequest request)
            {
                ActionResult actionResult = new ActionResult();

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

                    if (actionResult.IsSuccess)
                    {
                        int definitionId = request.PropertyDefinitionId ?? Null.NullInteger;

                        if (definitionId != Null.NullInteger)
                        {
                            dynamic profileProperty = GetProfileProperty(request.PropertyDefinitionId, pid).Data.ProfileProperty;
                            request.PropertyName = profileProperty.PropertyName;
                            ProfilePropertyDefinition property = new ProfilePropertyDefinition(pid)
                            {
                                PropertyDefinitionId = definitionId,
                                DataType             = request.DataType,
                                DefaultValue         = request.DefaultValue,
                                PropertyCategory     = request.PropertyCategory,
                                PropertyName         = request.PropertyName,
                                ReadOnly             = request.ReadOnly,
                                Required             = request.Required,
                                ValidationExpression = request.ValidationExpression,
                                ViewOrder            = request.ViewOrder,
                                Visible           = request.Visible,
                                Length            = request.Length,
                                DefaultVisibility = (UserVisibilityMode)request.DefaultVisibility
                            };

                            actionResult = ValidateProperty(property);
                            if (actionResult.IsSuccess)
                            {
                                ProfileController.UpdatePropertyDefinition(property);
                                DataCache.ClearDefinitionsCache(pid);
                                actionResult.Data    = new { MemberProfile = GetProfileProperties(pid).Data.Properties, PropertyLocalization = GetProfilePropertyLocalization(PortalSettings.Current.CultureCode, property.PropertyName, property.PropertyCategory).Data, GetListInfo(property.PropertyName, PortalSettings.Current.PortalId).Data.Entries };
                                actionResult.Message = DNNLocalization.Localization.GetString("MemberProfileUpdated", Components.Constants.LocalResourcesFile);
                            }
                        }
                    }
                    else
                    {
                        actionResult.AddError(HttpStatusCode.BadRequest.ToString(), "");
                    }
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
Beispiel #21
0
        public static ActionResult SaveResxEntries(int PortalId, UserInfo UserInfo, int lid, UpdateTransaltionsRequest request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                Enum.TryParse(request.Mode, false, out LanguageResourceMode resourceMode);

                if (!UserInfo.IsSuperUser && resourceMode == LanguageResourceMode.Host)
                {
                    actionResult.AddError("AuthFailureMessage", Components.Constants.AuthFailureMessage);
                    return(actionResult);
                }

                Locale language = LocaleController.Instance.GetLocale(lid);

                switch (resourceMode)
                {
                case LanguageResourceMode.System:
                case LanguageResourceMode.Host:
                case LanguageResourceMode.Portal:
                    break;

                default:
                    actionResult.AddError("BadRequest", "UnsupportedMode");
                    return(actionResult);
                }

                if (language == null)
                {
                    actionResult.AddError("BadRequest", Localization.GetString("InvalidLocale.ErrorMessage", Locale_ResourceFile));
                    return(actionResult);
                }
                string resourceFile = request.ResourceFile.ToString();
                if (request.ResourceFile.ToString().IndexOf("_/", StringComparison.Ordinal) == 0)
                {
                    resourceFile = resourceFile.Substring(2);
                }
                if (string.IsNullOrEmpty(resourceFile))
                {
                    actionResult.AddError("BadRequest", string.Format(Localization.GetString("MissingResourceFileName", Locale_ResourceFile), language.Code));
                    return(actionResult);
                }

                selectedResourceFile = HttpContext.Current.Server.MapPath("~/" + resourceFile);
                string message = SaveResourceFileFile(PortalId, resourceMode, language.Code, request.Entries);
                actionResult.IsSuccess = true;
                actionResult.Message   = message;
                return(actionResult);
            }
            catch (Exception ex)
            {
                actionResult.AddError("", "", ex);
                return(actionResult);
            }
        }
Beispiel #22
0
            internal static ActionResult UpdateBasicSearchSettings(UpdateBasicSearchSettingsRequest request)
            {
                ActionResult actionResult = new ActionResult();

                try
                {
                    if (request.MinWordLength == Null.NullInteger || request.MinWordLength == 0)
                    {
                        actionResult.AddError("valIndexWordMinLengthRequired.Error", Localization.GetString("valIndexWordMinLengthRequired.Error", Constants.LocalResourcesFile));
                    }
                    else if (request.MaxWordLength == Null.NullInteger || request.MaxWordLength == 0)
                    {
                        actionResult.AddError("valIndexWordMaxLengthRequired.Error", Localization.GetString("valIndexWordMaxLengthRequired.Error", Constants.LocalResourcesFile));
                    }
                    else if (request.MinWordLength >= request.MaxWordLength)
                    {
                        actionResult.AddError("valIndexWordMaxLengthRequired.Error", Localization.GetString("valIndexWordMaxLengthRequired.Error", Constants.LocalResourcesFile));
                    }

                    if (actionResult.IsSuccess)
                    {
                        int oldMinLength = HostController.Instance.GetInteger("Search_MinKeyWordLength", 3);
                        if (request.MinWordLength != oldMinLength)
                        {
                            HostController.Instance.Update("Search_MinKeyWordLength", request.MinWordLength.ToString());
                        }

                        int oldMaxLength = HostController.Instance.GetInteger("Search_MaxKeyWordLength", 255);
                        if (request.MaxWordLength != oldMaxLength)
                        {
                            HostController.Instance.Update("Search_MaxKeyWordLength", request.MaxWordLength.ToString());
                        }

                        HostController.Instance.Update("Search_AllowLeadingWildcard", request.AllowLeadingWildcard ? "Y" : "N");
                        HostController.Instance.Update(SearchTitleBoostSetting, (request.TitleBoost == Null.NullInteger) ? DefaultSearchTitleBoost.ToString() : request.TitleBoost.ToString());
                        HostController.Instance.Update(SearchTagBoostSetting, (request.TagBoost == Null.NullInteger) ? DefaultSearchTagBoost.ToString() : request.TagBoost.ToString());
                        HostController.Instance.Update(SearchContentBoostSetting, (request.ContentBoost == Null.NullInteger) ? DefaultSearchContentBoost.ToString() : request.ContentBoost.ToString());
                        HostController.Instance.Update(SearchDescriptionBoostSetting, (request.DescriptionBoost == Null.NullInteger) ? DefaultSearchDescriptionBoost.ToString() : request.DescriptionBoost.ToString());
                        HostController.Instance.Update(SearchAuthorBoostSetting, (request.AuthorBoost == Null.NullInteger) ? DefaultSearchAuthorBoost.ToString() : request.AuthorBoost.ToString());

                        string oldAnalyzer = HostController.Instance.GetString("Search_CustomAnalyzer", string.Empty);
                        string newAnalyzer = request.SearchCustomAnalyzer.Trim();
                        if (!oldAnalyzer.Equals(newAnalyzer))
                        {
                            HostController.Instance.Update("Search_CustomAnalyzer", newAnalyzer);
                            //force the app restart to use new analyzer.
                            Config.Touch();
                        }
                    }
                }
                catch (Exception ex)
                {
                    actionResult.AddError("HttpStatusCode.InternalServerError", ex.Message);
                }
                return(actionResult);
            }
        public ActionResult UpdateScheduleItem(ScheduleDto scheduleDto)
        {
            ActionResult ActionResult = new ActionResult();
            dynamic      Result       = new ExpandoObject();

            try
            {
                if (scheduleDto.RetryTimeLapse == 0)
                {
                    scheduleDto.RetryTimeLapse = Null.NullInteger;
                }

                if (!SchedulerManager.VerifyValidTimeLapseRetry(scheduleDto.TimeLapse, scheduleDto.TimeLapseMeasurement, scheduleDto.RetryTimeLapse, scheduleDto.RetryTimeLapseMeasurement))
                {
                    ActionResult.AddError("InvalidFrequencyAndRetry", Localization.GetString("InvalidFrequencyAndRetry", Components.Constants.TaskSchedulerResourcesFile));
                }
                else
                {
                    ScheduleItem existingItem = SchedulingProvider.Instance().GetSchedule(scheduleDto.ScheduleID);

                    ScheduleItem updatedItem = _controller.CreateScheduleItem(scheduleDto.TypeFullName, scheduleDto.FriendlyName, scheduleDto.TimeLapse, scheduleDto.TimeLapseMeasurement,
                                                                              scheduleDto.RetryTimeLapse, scheduleDto.RetryTimeLapseMeasurement, scheduleDto.RetainHistoryNum, scheduleDto.AttachToEvent, scheduleDto.CatchUpEnabled,
                                                                              scheduleDto.Enabled, scheduleDto.ObjectDependencies, scheduleDto.ScheduleStartDate, scheduleDto.Servers);
                    updatedItem.ScheduleID = scheduleDto.ScheduleID;


                    if (updatedItem.ScheduleStartDate != existingItem.ScheduleStartDate ||
                        updatedItem.Enabled ||
                        updatedItem.Enabled != existingItem.Enabled ||
                        updatedItem.TimeLapse != existingItem.TimeLapse ||
                        updatedItem.RetryTimeLapse != existingItem.RetryTimeLapse ||
                        updatedItem.RetryTimeLapseMeasurement != existingItem.RetryTimeLapseMeasurement ||
                        updatedItem.TimeLapseMeasurement != existingItem.TimeLapseMeasurement)
                    {
                        SchedulingProvider.Instance().UpdateSchedule(updatedItem);
                        ActionResult.Message = Localization.GetString("ScheduleItemUpdateSuccess", Components.Constants.TaskSchedulerResourcesFile);
                    }
                    else
                    {
                        ActionResult.Message = Localization.GetString("ScheduleItemUpdateSuccess", Components.Constants.TaskSchedulerResourcesFile);
                        SchedulingProvider.Instance().UpdateScheduleWithoutExecution(updatedItem);
                    }
                    Result.Status        = "Success";
                    Result.ScheduleItems = SchedulerManager.GetScheduleItems(0, 14);
                    ActionResult.Data    = Result;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
                Result.Status = exc.Message.ToString();
                ActionResult.AddError("ScheduleItemUpdateError", Localization.GetString("ScheduleItemUpdateError", Components.Constants.TaskSchedulerResourcesFile));
            }
            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);
        }
Beispiel #25
0
            public static ActionResult AddProfileProperty(UpdateProfilePropertyRequest request)
            {
                ActionResult actionResult = new ActionResult();

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

                    if (actionResult.IsSuccess)
                    {
                        ProfilePropertyDefinition property = new ProfilePropertyDefinition(pid)
                        {
                            DataType             = request.DataType,
                            DefaultValue         = request.DefaultValue,
                            PropertyCategory     = request.PropertyCategory,
                            PropertyName         = request.PropertyName,
                            ReadOnly             = request.ReadOnly,
                            Required             = !Globals.IsHostTab(PortalSettings.Current.ActiveTab.TabID) && request.Required,
                            ValidationExpression = request.ValidationExpression,
                            ViewOrder            = request.ViewOrder,
                            Visible           = request.Visible,
                            Length            = request.Length,
                            DefaultVisibility = (UserVisibilityMode)request.DefaultVisibility
                        };

                        actionResult = ValidateProperty(property);

                        if (actionResult.IsSuccess)
                        {
                            int propertyId = ProfileController.AddPropertyDefinition(property);
                            if (propertyId < Null.NullInteger)
                            {
                                actionResult.AddError(HttpStatusCode.BadRequest.ToString(), string.Format(DNNLocalization.Localization.GetString("DuplicateName", PersonaBar.Constants.LocalResourcesFile)));
                            }
                            else
                            {
                                DataCache.ClearDefinitionsCache(pid);
                                actionResult.Data    = new { MemberProfile = GetProfileProperties(pid).Data.Properties, PropertyLocalization = GetProfilePropertyLocalization(PortalSettings.Current.CultureCode, property.PropertyName, property.PropertyCategory).Data };
                                actionResult.Message = DNNLocalization.Localization.GetString("MemberProfileAdded", Components.Constants.LocalResourcesFile);
                            }
                        }
                    }
                }
                catch (Exception exc)
                {
                    actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
                }
                return(actionResult);
            }
Beispiel #26
0
        public static ActionResult Save(Connector postData, int PortalId)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                string            name           = postData.Name;
                string            displayName    = postData.DisplayName;
                string            id             = postData.Id;
                AzureConnector    AzureConnector = new AzureConnector();
                List <IConnector> connectors     = AzureConnector.GetConnectors(PortalId).ToList();

                IConnector connector = connectors.FirstOrDefault(c => c.Id == id);

                if (connector == null && string.IsNullOrEmpty(id))
                {
                    connector = new AzureConnector
                    {
                        Id          = null,
                        DisplayName = null
                    };
                }
                if (connector != null && !string.IsNullOrEmpty(displayName) && connector.DisplayName != displayName)
                {
                    connector.DisplayName = string.IsNullOrEmpty(displayName) ? "" : displayName;
                }

                bool validated = false;
                if (connector != null)
                {
                    bool saved = connector.SaveConfig(PortalId, postData.Configurations, ref validated,
                                                      out string customErrorMessage);
                    if (!saved)
                    {
                        string Message = string.IsNullOrEmpty(customErrorMessage)
                                    ? Localization.GetString("ErrSavingConnectorSettings.Text", Components.Constants.LocalResourceFile)
                                    : customErrorMessage;
                        actionResult.AddError("ErrSavingConnectorSettings", Message);
                        return(actionResult);
                    }
                }
                actionResult.IsSuccess = true;
                actionResult.Data      = connector?.Id;
                return(actionResult);
            }
            catch (Exception ex)
            {
                Exceptions.LogException(ex);
                actionResult.AddError("InternalServerError", "InternalServerError", ex);
                return(actionResult);
            }
        }
Beispiel #27
0
            public static ActionResult CreateUser(RegisterDetails RegisterDetails)
            {
                ActionResult actionResult = new ActionResult();

                User.Membership.Approved = PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;
                CreateStatus             = UserController.CreateUser(ref User);
                DataCache.ClearPortalUserCountCache(PortalSettings.Current.PortalId);

                try
                {
                    if (CreateStatus == UserCreateStatus.Success)
                    {
                        ////Assocate alternate Login with User and proceed with Login
                        //if (!String.IsNullOrEmpty(AuthenticationType))
                        //{
                        //    AuthenticationController.AddUserAuthentication(User.UserID, AuthenticationType, UserToken);
                        //}

                        ActionResult result = CompleteUserCreation(CreateStatus, User, true, !(HttpContext.Current.Request.IsAuthenticated && PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName)) && !(HttpContext.Current.Request.IsAuthenticated && (User.UserID == (PortalController.Instance.GetCurrentSettings() as PortalSettings).UserInfo.UserID)));
                        if (result.IsSuccess)
                        {
                            if (string.IsNullOrEmpty(result.Message))
                            {
                                IDictionary <string, object> dynObjects = new ExpandoObject() as IDictionary <string, object>;
                                dynObjects.Add("RedirectURL", GetRedirectUrl());
                                actionResult.Data = dynObjects;
                            }
                            actionResult.Message = result.Message;
                        }
                        else
                        {
                            string errorMessage = string.Empty;
                            foreach (KeyValuePair <string, Exception> error in result.Errors)
                            {
                                errorMessage = error.Value.ToString();
                            }
                            actionResult.AddError("RegisterManager.CompleteUserCreation", errorMessage);
                        }
                    }
                    else
                    {
                        actionResult.AddError("RegisterManager.CreateUser", UserController.GetUserCreateStatus(CreateStatus));
                    }
                }
                catch (Exception exc) //Module failed to load
                {
                    Exceptions.ProcessModuleLoadException(null, exc);
                }
                return(actionResult);
            }
        public ActionResult Search(string Keyword, int index, int size, string IconFolder)
        {
            ActionResult   actionResult = new ActionResult();
            string         path         = !string.IsNullOrEmpty(IconFolder) ? Path.Combine(Globals.ApplicationMapPath, "Icons\\" + IconFolder) : Path.Combine(Globals.ApplicationMapPath, PortalSettings.Current.DefaultIconLocation.Replace('/', '\\'));
            DirectoryInfo  di           = new DirectoryInfo(path);
            List <dynamic> data         = new List <dynamic>();

            if (di.Exists)
            {
                try
                {
                    string SearchPattern = !string.IsNullOrEmpty(Keyword) ? "*" + Keyword.ToLower() + "*.svg" : "*.svg";
                    IOrderedEnumerable <FileInfo> icons = di.GetFiles(SearchPattern, SearchOption.AllDirectories).OrderBy(i => i.Name);

                    foreach (FileInfo file in icons.Skip(index).Take(size))
                    {
                        if (file.Exists)
                        {
                            data.Add(new { Name = file.Name.Replace(file.Extension.ToString(), ""), SVG = XDocument.Load(file.FullName.ToString()).ToString() });
                        }
                    }

                    if (actionResult.IsSuccess)
                    {
                        actionResult.Data = new { All_Icons = data, Total_Icon = data.Count > 0 ? icons.Count() : 0 };
                    }
                }
                catch (Exception ex)
                {
                    actionResult.AddError("Icon_Search", ex.Message);
                }
            }
            return(actionResult);
        }
Beispiel #29
0
        public ActionResult Enabled(int lid)
        {
            string       ResourcesFile = "~/DesktopModules/Vanjaro/UXManager/Extensions/Menu/" + ExtensionInfo.Name + "/Views/Setting/App_LocalResources/Languages.resx";
            ActionResult actionResult  = new ActionResult();
            Locale       language      = LocaleController.Instance.GetLocale(lid);

            if (language == null)
            {
                actionResult.AddError("InvalidLocale.ErrorMessage", string.Format(Localization.GetString("InvalidLocale.ErrorMessage", ResourcesFile), language.Code));
                return(actionResult);
            }
            if (PortalSettings.DefaultLanguage != language.Code)
            {
                if (LanguagesManager.IsLanguageEnabled(PortalSettings.PortalId, language.Code))
                {
                    //remove language from portal
                    Localization.RemoveLanguageFromPortal(PortalSettings.PortalId, language.LanguageId);
                    LanguagesManager.SetTabUrlsActiveToRedirect(language.LanguageId);
                }
                else
                {
                    //Add language to portal
                    Localization.AddLanguageToPortal(PortalSettings.PortalId, language.LanguageId, true);
                    LanguagesManager.UpdateTabUrlsDefaultLocale();
                }
            }
            actionResult.Data      = LanguagesManager.GetLanguages(PortalSettings, UserInfo);
            actionResult.IsSuccess = true;
            return(actionResult);
        }
        private ActionResult UpdateGeneralSettings(dynamic request)
        {
            ActionResult actionResult = new ActionResult();

            try
            {
                HostController.Instance.Update("AutoAccountUnlockDuration", request.AutoAccountUnlockDuration.Value.ToString(), false);
                HostController.Instance.Update("AsyncTimeout", request.AsyncTimeout.Value.ToString(), false);
                HostController.Instance.Update("FileExtensions", SecurityManager.ValidateFileExtension(request.FileExtensions.Value.ToString()), false);

                long    maxCurrentRequest = Config.GetMaxUploadSize();
                dynamic maxUploadByMb     = request.MaxUploadSize.Value * 1024 * 1024;
                if (maxCurrentRequest != maxUploadByMb)
                {
                    Config.SetMaxUploadSize(maxUploadByMb);
                }

                DataCache.ClearCache();
            }
            catch (Exception exc)
            {
                actionResult.AddError(HttpStatusCode.InternalServerError.ToString(), exc.Message);
            }
            return(actionResult);
        }
        /// <summary>
        /// Load of 3D geometry from the file
        /// </summary>
        /// <param name="fullFileName">The path to the file with 3D geometry</param>
        /// <param name="sceneEngine">The engine of the scene</param>
        /// <returns></returns>
        public ActionResult<SceneElement> LoadGeometry(string fullFileName, ISceneEngine sceneEngine)
        {
            var polygon = new Polygon();
            
            var actionResult = new ActionResult<SceneElement>("Import Wavefront format geometry") {Value = polygon};

            if (!File.Exists(fullFileName))
            {
                actionResult.AddError(Resources.Message_LoadGeometry_File_N_not_found, fullFileName);
                return actionResult;
            }
            try
            {
                LoadGeometryFromFile(fullFileName, sceneEngine, polygon, actionResult);
            }
            catch (Exception e)
            {
                actionResult.AddError(e);
            }
            return actionResult;
        }