private string GetNodeIcon(TabInfo tab, out string toolTip) { if (PortalSettings.HomeTabId == tab.TabID) { toolTip = Localization.GetString("lblHome", LocalResourcesFile); return(IconHome); } if (IsSecuredTab(tab)) { if (IsAdminTab(tab)) { toolTip = Localization.GetString("lblAdminOnly", LocalResourcesFile); return(AdminOnlyIcon); } if (IsRegisteredUserTab(tab)) { toolTip = Localization.GetString("lblRegistered", LocalResourcesFile); return(RegisteredUsersIcon); } toolTip = Localization.GetString("lblSecure", LocalResourcesFile); return(SecuredIcon); } toolTip = Localization.GetString("lblEveryone", LocalResourcesFile); return(AllUsersIcon); }
public static string LoginURL(string returnUrl, bool overrideSetting) { PortalSettings portalSettings = PortalController.Instance.GetCurrentSettings() as PortalSettings; string loginUrl; if (!string.IsNullOrEmpty(returnUrl)) { returnUrl = string.Format("returnurl={0}", returnUrl); } string popUpParameter = ""; if (HttpUtility.UrlDecode(returnUrl).IndexOf("popUp=true", StringComparison.OrdinalIgnoreCase) >= 0) { popUpParameter = "popUp=true"; } if (portalSettings.LoginTabId != -1 && !overrideSetting) { //if (ValidateLoginTabID(portalSettings.LoginTabId)) if (portalSettings.LoginTabId != -1) { loginUrl = string.IsNullOrEmpty(returnUrl) ? ServiceProvider.NavigationManager.NavigateURL(portalSettings.LoginTabId, "", popUpParameter) : ServiceProvider.NavigationManager.NavigateURL(portalSettings.LoginTabId, "", returnUrl, popUpParameter); } else { string strMessage = string.Format("error={0}", Localization.GetString("NoLoginControl", Localization.GlobalResourceFile)); //No account module so use portal tab loginUrl = string.IsNullOrEmpty(returnUrl) ? ServiceProvider.NavigationManager.NavigateURL(portalSettings.ActiveTab.TabID, "Login", strMessage, popUpParameter) : ServiceProvider.NavigationManager.NavigateURL(portalSettings.ActiveTab.TabID, "Login", returnUrl, strMessage, popUpParameter); } } else { //portal tab loginUrl = string.IsNullOrEmpty(returnUrl) ? ServiceProvider.NavigationManager.NavigateURL(portalSettings.ActiveTab.TabID, "Login", popUpParameter) : ServiceProvider.NavigationManager.NavigateURL(portalSettings.ActiveTab.TabID, "Login", returnUrl, popUpParameter); } return(loginUrl); }
public static List <IUIData> GetData(string Identifier, Dictionary <string, string> UIEngineInfo, UserInfo userInfo, Dictionary <string, string> parameters) { int uid = 0; if (parameters.Count > 0) { int.TryParse(parameters["uid"], out uid); } PortalSettings ps = PortalController.Instance.GetCurrentSettings() as PortalSettings; Dictionary <string, IUIData> Settings = new Dictionary <string, IUIData>(); switch (Identifier) { case "setting_updateprofile": { if (uid > 0) { Settings.Add("BrowseUrl", new UIData { Name = "BrowseUrl", Value = Common.Utilities.Utils.BrowseUrl(-1, "Manage") }); Settings.Add("AllowedAttachmentFileExtensions", new UIData { Name = "AllowedAttachmentFileExtensions", Value = FileSetting.FileType }); Settings.Add("MaxFileSize", new UIData { Name = "MaxFileSize", Value = FileSetting.FileSize.ToString() }); if (!(parameters.ContainsKey("username") && parameters.ContainsKey("password"))) { return(Settings.Values.ToList()); } int UserID = uid; string keyword = string.Empty; UserInfo user = DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, UserID); UserBasicDto userDetails = UsersController.Instance.GetUserDetail(ps.PortalId, UserID); ProfileController.GetUserProfile(ref user); Settings.Add("UserDetails", new UIData { Name = "UserDetails", Options = UserManager.MapUserBasicDto(user, userDetails) }); Settings.Add("UserRoles", new UIData { Name = "UserRoles", Options = UsersController.Instance.GetUserRoles(user, keyword, out int totalRoles).Select(r => UserRoleDto.FromRoleInfo(ps, r)) }); Settings.Add("IsAdmin", new UIData { Name = "IsAdmin", Value = userInfo.IsInRole("Administrators").ToString() }); Settings.Add("ProfilePropertiesByCategories", new UIData { Name = "ProfilePropertiesByCategories", Options = Managers.UserManager.GetLocalizedCategories(user.Profile.ProfileProperties, user, true).Select(x => new { x.Key, x.Value }) }); if (string.IsNullOrEmpty(user.Profile.PreferredLocale)) { if (string.IsNullOrEmpty(DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, ps.AdministratorId).Profile.PreferredLocale)) { user.Profile.SetProfileProperty("PreferredLocale", !string.IsNullOrEmpty(ps.DefaultLanguage) ? ps.DefaultLanguage : Thread.CurrentThread.CurrentCulture.Name); } else { user.Profile.SetProfileProperty("PreferredLocale", DotNetNuke.Entities.Users.UserController.GetUserById(ps.PortalId, ps.AdministratorId).Profile.PreferredLocale); } } List <Entities.ProfileProperties> profileProperties = new List <Entities.ProfileProperties>(); ListController listController = new ListController(); foreach (ProfilePropertyDefinition d in user.Profile.ProfileProperties) { string ControlType = UserManager.GetControlType(d.DataType); if (ControlType == "Country" || ControlType == "Region" || ControlType == "List") { d.PropertyValue = string.IsNullOrEmpty(d.PropertyValue) ? "-1" : d.PropertyValue; } List <ListEntryInfo> data = listController.GetListEntryInfoItems(d.PropertyName, "", PortalSettings.Current.PortalId).ToList(); data.Insert(0, new ListEntryInfo { Text = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile), Value = d.PropertyValue }); profileProperties.Add(new Entities.ProfileProperties { ProfilePropertyDefinition = d, ListEntries = data }); } Settings.Add("ProfileProperties", new UIData { Name = "ProfileProperties", Options = profileProperties }); //Profile URL dynamic Profile = null; if (!string.IsNullOrEmpty(user.Profile.Photo)) { Profile = BrowseUploadFactory.GetFile(ps, Convert.ToInt32(user.Profile.Photo)); } Settings.Add("PhotoURL", new UIData { Name = "PhotoURL", Options = Profile ?? user.Profile, Value = Vanjaro.Common.Utilities.UserUtils.GetProfileImage(PortalSettings.Current.PortalId, user.UserID, user.Email) }); var countries = GetCountryList(Thread.CurrentThread.CurrentCulture.Name).Values.OrderBy(x => x.NormalizedFullName).Select(x => new { Id = x.Id.ToString(), x.FullName, x.Name }).ToList(); countries.Insert(0, new { Id = "-1", FullName = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile), Name = Localization.GetString("NotSpecified", Components.Constants.LocalResourcesFile) }); Settings.Add("Countries", new UIData { Name = "Countries", OptionsText = "Key", OptionsValue = "Value", Options = countries }); ReadOnlyCollection <TimeZoneInfo> timeZones = TimeZoneInfo.GetSystemTimeZones(); var Timezones = timeZones.Cast <TimeZoneInfo>().Select(x => new { Id = x.Id.ToString(), x.DisplayName }); Settings.Add("Time_Zones", new UIData { Name = "Time_Zones", OptionsText = "Key", OptionsValue = "Value", Options = Timezones }); Dictionary <string, Locale> ActiveLocales = new LocaleController().GetLocales(ps.PortalId); var activeLocales = ActiveLocales.Values.Cast <Locale>().Select(x => new { x.Code, x.Culture, x.EnglishName, x.NativeName, KeyID = x.KeyID.ToString(), x.Text }).ToList(); Settings.Add("Active_Locales", new UIData { Name = "Active_Locales", OptionsText = "Key", OptionsValue = "Value", Options = activeLocales }); }
protected bool ShowSwitchLanguagesPanel() { if (PortalSettings.AllowUserUICulture && PortalSettings.ContentLocalizationEnabled) { if (CurrentUICulture == null) { object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture"); if (oCulture != null) { CurrentUICulture = oCulture.ToString(); } else { var l = new Localization(); CurrentUICulture = l.CurrentUICulture; } } IEnumerable<ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CurrentUICulture, "", false); return cultureListItems.Count() > 1; } return false; }
protected IEnumerable<string[]> LoadLanguagesList() { var result = new List<string[]>(); if (PortalSettings.AllowUserUICulture) { if(CurrentUICulture == null) { object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture"); if (oCulture != null) { CurrentUICulture = oCulture.ToString(); } else { var l = new Localization(); CurrentUICulture = l.CurrentUICulture; SetLanguage(true, CurrentUICulture); } } IEnumerable<ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, CurrentUICulture, "", false); foreach (var cultureItem in cultureListItems) { var selected = cultureItem.Value == CurrentUICulture ? "true" : "false"; string[] p = new string[] { cultureItem.Text, cultureItem.Value, selected }; result.Add(p); } } return result; }
//private static void UpdateProfile(UserInfo objUser, bool update) //{ // bool bUpdateUser = false; // if (ProfileProperties.Count > 0) // { // foreach (string key in ProfileProperties) // { // switch (key) // { // case "FirstName": // if (objUser.FirstName != ProfileProperties[key]) // { // objUser.FirstName = ProfileProperties[key]; // bUpdateUser = true; // } // break; // case "LastName": // if (objUser.LastName != ProfileProperties[key]) // { // objUser.LastName = ProfileProperties[key]; // bUpdateUser = true; // } // break; // case "Email": // if (objUser.Email != ProfileProperties[key]) // { // objUser.Email = ProfileProperties[key]; // bUpdateUser = true; // } // break; // case "DisplayName": // if (objUser.DisplayName != ProfileProperties[key]) // { // objUser.DisplayName = ProfileProperties[key]; // bUpdateUser = true; // } // break; // default: // objUser.Profile.SetProfileProperty(key, ProfileProperties[key]); // break; // } // } // if (update) // { // if (bUpdateUser) // { // UserController.UpdateUser(PortalSettings.Current.PortalId, objUser); // } // ProfileController.UpdateUserProfile(objUser); // } // } //} /// ----------------------------------------------------------------------------- /// <summary> /// ValidateUser runs when the user has been authorized by the data store. It validates for /// things such as an expiring password, valid profile, or missing DNN User Association /// </summary> /// <param name="objUser">The logged in User</param> /// <param name="ignoreExpiring">Ignore the situation where the password is expiring (but not yet expired)</param> /// ----------------------------------------------------------------------------- private static ActionResult ValidateUser(UserInfo objUser, bool ignoreExpiring) { ActionResult actionResult = new ActionResult(); UserValidStatus validStatus = UserValidStatus.VALID; string strMessage = Null.NullString; DateTime expiryDate = Null.NullDate; validStatus = UserController.ValidateUser(objUser, PortalSettings.Current.PortalId, ignoreExpiring); if (PasswordConfig.PasswordExpiry > 0) { expiryDate = objUser.Membership.LastPasswordChangeDate.AddDays(PasswordConfig.PasswordExpiry); } //Check if the User has valid Password/Profile switch (validStatus) { case UserValidStatus.VALID: //check if the user is an admin/host and validate their IP if (Host.EnableIPChecking) { bool isAdminUser = objUser.IsSuperUser || objUser.IsInRole(PortalSettings.Current.AdministratorRoleName); if (isAdminUser) { if (IPFilterController.Instance.IsIPBanned(HttpContext.Current.Request.UserHostAddress)) { PortalSecurity.Instance.SignOut(); actionResult.AddError("IPAddressBanned", Localization.GetString("IPAddressBanned", LocalResourceFile)); break; } } } //Set the Page Culture(Language) based on the Users Preferred Locale if ((objUser.Profile != null) && (objUser.Profile.PreferredLocale != null) && LocaleEnabled(objUser.Profile.PreferredLocale)) { Localization.SetLanguage(objUser.Profile.PreferredLocale); } else { Localization.SetLanguage(PortalSettings.Current.DefaultLanguage); } //Set the Authentication Type used AuthenticationController.SetAuthenticationType(AuthenticationType); //Complete Login IUserRequestIPAddressController userRequestIpAddressController = UserRequestIPAddressController.Instance; string ipAddress = userRequestIpAddressController.GetUserRequestIPAddress(new HttpRequestWrapper(HttpContext.Current.Request)); UserController.UserLogin(PortalSettings.Current.PortalId, objUser, PortalSettings.Current.PortalName, ipAddress, RememberMe); //check whether user request comes with IPv6 and log it to make sure admin is aware of that if (string.IsNullOrWhiteSpace(ipAddress)) { string ipAddressV6 = userRequestIpAddressController.GetUserRequestIPAddress(new HttpRequestWrapper(HttpContext.Current.Request), IPAddressFamily.IPv6); if (!string.IsNullOrWhiteSpace(ipAddressV6)) { AddEventLog(objUser.UserID, objUser.Username, PortalSettings.Current.PortalId, "IPv6", ipAddressV6); } } //redirect browser //var redirectUrl = RedirectURL; //Clear the cookie HttpContext.Current.Response.Cookies.Set(new HttpCookie("returnurl", "") { Expires = DateTime.Now.AddDays(-1), Path = (!string.IsNullOrEmpty(Globals.ApplicationPath) ? Globals.ApplicationPath : "/") }); actionResult.RedirectURL = GetRedirectUrl(); break; case UserValidStatus.PASSWORDEXPIRED: //strMessage = string.Format(Localization.GetString("PasswordExpired", LocalResourceFile), expiryDate.ToLongDateString()); //AddLocalizedModuleMessage(strMessage, ModuleMessage.ModuleMessageType.YellowWarning, true); actionResult.AddError("PASSWORDEXPIRED", string.Format(Localization.GetString("PasswordExpired", LocalResourceFile), expiryDate.ToLongDateString())); break; case UserValidStatus.PASSWORDEXPIRING: //strMessage = string.Format(Localization.GetString("PasswordExpiring", LocalResourceFile), expiryDate.ToLongDateString()); //AddLocalizedModuleMessage(strMessage, ModuleMessage.ModuleMessageType.YellowWarning, true); actionResult.AddError("PASSWORDEXPIRING", string.Format(Localization.GetString("PasswordExpiring", LocalResourceFile), expiryDate.ToLongDateString())); break; case UserValidStatus.UPDATEPASSWORD: string portalAlias = Globals.AddHTTP(PortalSettings.Current.PortalAlias.HTTPAlias); if (MembershipProviderConfig.PasswordRetrievalEnabled || MembershipProviderConfig.PasswordResetEnabled) { UserController.ResetPasswordToken(objUser); objUser = UserController.GetUserById(objUser.PortalID, objUser.UserID); } string redirTo = string.Format("{0}/default.aspx?ctl=PasswordReset&resetToken={1}&forced=true", portalAlias, objUser.PasswordResetToken); //Response.Redirect(redirTo); break; case UserValidStatus.UPDATEPROFILE: //Save UserID in ViewState so that can update profile later //When the user need update its profile to complete login, we need clear the login status because if the logrin is from //3rd party login provider, it may call UserController.UserLogin because they doesn't check this situation. actionResult.Data = new { UserExtensionURL = ServiceProvider.NavigationManager.NavigateURL("", "mid=0", "icp=true", "guid=fa7ca744-1677-40ef-86b2-ca409c5c6ed3#/updateprofile?uid=" + objUser.UserID) }; PortalSecurity.Instance.SignOut(); //Admin has forced profile update actionResult.AddError("ProfileUpdate", Localization.GetString("ProfileUpdate", LocalResourceFile)); break; case UserValidStatus.MUSTAGREETOTERMS: if (PortalSettings.Current.DataConsentConsentRedirect == -1) { //AddModuleMessage("MustConsent", ModuleMessage.ModuleMessageType.YellowWarning, true); actionResult.AddError("MUSTAGREETOTERMS", string.Format(Localization.GetString("MustConsent", LocalResourceFile), expiryDate.ToLongDateString())); } else { // Use the reset password token to identify the user during the redirect UserController.ResetPasswordToken(objUser); objUser = UserController.GetUserById(objUser.PortalID, objUser.UserID); actionResult.RedirectURL = ServiceProvider.NavigationManager.NavigateURL(PortalSettings.Current.DataConsentConsentRedirect, "", string.Format("token={0}", objUser.PasswordResetToken)); } break; } return(actionResult); }
public static ActionResult UserAuthenticated(UserAuthenticatedEventArgs e) { ActionResult actionResult = new ActionResult(); LoginStatus = e.LoginStatus; //Check the Login Status switch (LoginStatus) { case UserLoginStatus.LOGIN_USERNOTAPPROVED: switch (e.Message) { case "UnverifiedUser": if (e.User != null) { //First update the profile (if any properties have been passed) AuthenticationType = e.AuthenticationType; //ProfileProperties = e.Profile; RememberMe = e.RememberMe; //UpdateProfile(e.User, true); actionResult = ValidateUser(e.User, false); } break; case "EnterCode": actionResult.AddError(e.Message.ToString(), Localization.GetString(e.Message, LocalResourceFile)); break; case "InvalidCode": case "UserNotAuthorized": actionResult.AddError(e.Message.ToString(), Localization.GetString(e.Message, LocalResourceFile)); break; default: actionResult.AddError(e.Message.ToString(), Localization.GetString(e.Message, LocalResourceFile)); break; } break; case UserLoginStatus.LOGIN_USERLOCKEDOUT: if (Host.AutoAccountUnlockDuration > 0) { actionResult.AddError("UserLockedOut", string.Format(Localization.GetString("UserLockedOut", LocalResourceFile), Host.AutoAccountUnlockDuration)); } else { actionResult.AddError("UserLockedOut_ContactAdmin", Localization.GetString("UserLockedOut_ContactAdmin", LocalResourceFile)); } //notify administrator about account lockout ( possible hack attempt ) ArrayList Custom = new ArrayList { e.UserToken }; Message message = new Message { FromUserID = PortalSettings.Current.AdministratorId, ToUserID = PortalSettings.Current.AdministratorId, Subject = Localization.GetSystemMessage(PortalSettings.Current, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom), Body = Localization.GetSystemMessage(PortalSettings.Current, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom), Status = MessageStatusType.Unread }; //_messagingController.SaveMessage(_message); Mail.SendEmail(PortalSettings.Current.Email, PortalSettings.Current.Email, message.Subject, message.Body); break; case UserLoginStatus.LOGIN_FAILURE: //A Login Failure can mean one of two things: // 1 - User was authenticated by the Authentication System but is not "affiliated" with a DNN Account // 2 - User was not authenticated if (string.IsNullOrEmpty(e.Message)) { actionResult.AddError("LoginFailed", Localization.GetString("LoginFailed", LocalResourceFile)); } else { actionResult.AddError(e.Message.ToString(), Localization.GetString(e.Message, LocalResourceFile)); } break; default: if (e.User != null) { //First update the profile (if any properties have been passed) AuthenticationType = e.AuthenticationType; //ProfileProperties = e.Profile; RememberMe = e.RememberMe; //UpdateProfile(e.User, true); actionResult = ValidateUser(e.User, (e.AuthenticationType != "DNN")); } break; } return(actionResult); }
public static ActionResult OnSendPasswordClick(string Email) { UserInfo _user = null; int _userCount = Null.NullInteger; //pretty much alwasy display the same message to avoid hinting on the existance of a user name ActionResult actionResult = new ActionResult { Message = Localization.GetString("PasswordSent", Components.Constants.LocalResourcesFile) }; bool canSend = true; if (string.IsNullOrEmpty(Email)) { //No email address either (cannot retrieve password) canSend = false; actionResult.AddError("EnterUsernameEmail", Localization.GetString("EnterUsernameEmail", Components.Constants.LocalResourcesFile)); } if (actionResult.IsSuccess) { if (string.IsNullOrEmpty(Host.SMTPServer)) { //SMTP Server is not configured canSend = false; actionResult.AddError("OptionUnavailable", Localization.GetString("OptionUnavailable", Components.Constants.LocalResourcesFile)); string logMessage = Localization.GetString("SMTPNotConfigured", Components.Constants.LocalResourcesFile); actionResult.AddError("SMTPNotConfigured", logMessage); LogResult(logMessage, Email); } if (actionResult.IsSuccess && canSend) { _user = GetUser(Email); if (_user != null) { if (_user.IsDeleted) { canSend = false; } else { if (_user.Membership.Approved == false) { Mail.SendMail(_user, MessageType.PasswordReminderUserIsNotApproved, PortalSettings.Current); canSend = false; } if (MembershipProviderConfig.PasswordRetrievalEnabled || MembershipProviderConfig.PasswordResetEnabled) { UserController.ResetPasswordToken(_user); } if (canSend) { if (Mail.SendMail(_user, MessageType.PasswordReminder, PortalSettings.Current) != string.Empty) { canSend = false; } } } } else { if (_userCount > 1) { actionResult.AddError("MultipleUsers", Localization.GetString("MultipleUsers", Components.Constants.LocalResourcesFile)); } canSend = false; } if (actionResult.IsSuccess && canSend) { if (canSend) { LogResult(string.Empty, Email); } else { LogFailure(Localization.GetString("MultipleUsers", Components.Constants.LocalResourcesFile), Email); } // don't hide panel when e-mail only in use and error occured. We must provide negative feedback to the user, in case he doesn't rember what e-mail address he has used if (!canSend && _user == null && MembershipProviderConfig.RequiresUniqueEmail && PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", PortalSettings.Current.PortalId, false)) { actionResult.AddError("EmailNotFound", Localization.GetString("EmailNotFound", Components.Constants.LocalResourcesFile)); } } } } return(actionResult); }
public TabDto GetPortalTabs(UserInfo userInfo, int portalId, string cultureCode, bool isMultiLanguage, bool excludeAdminTabs = true, string roles = "", bool disabledNotSelectable = false, int sortOrder = 0, int selectedTabId = -1, string validateTab = "", bool includeHostPages = false, bool includeDisabled = false, bool includeDeleted = false, bool includeDeletedChildren = true) { var portalInfo = PortalController.Instance.GetPortal(portalId); var rootNode = new TabDto { Name = portalInfo.PortalName, ImageUrl = IconPortal, TabId = Null.NullInteger.ToString(CultureInfo.InvariantCulture), ChildTabs = new List <TabDto>(), HasChildren = true }; var tabs = new List <TabInfo>(); cultureCode = string.IsNullOrEmpty(cultureCode) ? portalInfo.CultureCode : cultureCode; if (portalId > -1) { tabs = TabController.GetPortalTabs( isMultiLanguage ? TabController.GetTabsBySortOrder(portalId, portalInfo.DefaultLanguage, true) : TabController.GetTabsBySortOrder(portalId, cultureCode, true), Null.NullInteger, false, "<" + Localization.GetString("None_Specified") + ">", true, includeDeleted, true, false, false, includeDeletedChildren) .Where(t => (!t.DisableLink || includeDisabled) && !t.IsSystem) .ToList(); if (userInfo.IsSuperUser && includeHostPages) { tabs.AddRange( TabController.Instance.GetTabsByPortal(-1) .AsList() .Where(t => !t.IsDeleted && !t.DisableLink && !t.IsSystem) .ToList()); } } else { if (userInfo.IsSuperUser) { tabs = TabController.Instance.GetTabsByPortal(-1).AsList().Where(t => !t.IsDeleted && !t.DisableLink && !t.IsSystem).ToList(); } } tabs = excludeAdminTabs ? tabs.Where(tab => tab.Level == 0 && tab.TabID != portalInfo.AdminTabId).ToList() : tabs.Where(tab => tab.Level == 0).ToList(); if (!string.IsNullOrEmpty(validateTab)) { tabs = ValidateModuleInTab(tabs, validateTab).ToList(); } var filterTabs = FilterTabsByRole(tabs, roles, disabledNotSelectable); rootNode.HasChildren = tabs.Count > 0; rootNode.Selectable = SecurityService.Instance.IsPagesAdminUser(); foreach (var tab in tabs) { string tooltip; var nodeIcon = GetNodeIcon(tab, out tooltip); var node = new TabDto { Name = tab.LocalizedTabName, //$"{tab.TabName} {GetNodeStatusIcon(tab)}", TabId = tab.TabID.ToString(CultureInfo.InvariantCulture), ImageUrl = nodeIcon, Tooltip = tooltip, ParentTabId = tab.ParentId, HasChildren = tab.HasChildren, Selectable = filterTabs.Contains(tab.TabID) && TabPermissionController.CanAddPage(tab), ChildTabs = new List <TabDto>() }; rootNode.ChildTabs.Add(node); } rootNode.ChildTabs = ApplySort(rootNode.ChildTabs, sortOrder).ToList(); return(selectedTabId > -1 ? MarkSelectedTab(rootNode, selectedTabId, portalInfo, cultureCode, isMultiLanguage, validateTab) : rootNode); }
/// ----------------------------------------------------------------------------- /// <summary> /// InitialiseUser initialises a "new" user /// </summary> /// <history> /// [cnurse] 03/13/2006 /// </history> /// ----------------------------------------------------------------------------- private UserInfo InitialiseUser() { var newUser = new UserInfo(); if (IsHostMenu && !IsRegister) { newUser.IsSuperUser = true; } else { newUser.PortalID = PortalId; } //Initialise the ProfileProperties Collection string lc = new Localization().CurrentUICulture; newUser.Profile.InitialiseProfile(PortalId); newUser.Profile.PreferredTimeZone = PortalSettings.TimeZone; newUser.Profile.PreferredLocale = lc; //Set default countr string country = Null.NullString; country = LookupCountry(); if (!String.IsNullOrEmpty(country)) { newUser.Profile.Country = country; } //Set AffiliateId int AffiliateId = Null.NullInteger; if (Request.Cookies["AffiliateId"] != null) { AffiliateId = int.Parse(Request.Cookies["AffiliateId"].Value); } newUser.AffiliateID = AffiliateId; return newUser; }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); ddlMode.SelectedIndexChanged += ddlMode_SelectedIndexChanged; ddlUICulture.SelectedIndexChanged += ddlUICulture_SelectedIndexChanged; try { AdminPanel.Visible = false; AdvancedToolsPanel.Visible = false; if (ControlPanel.Visible && IncludeInControlHierarchy) { ClientResourceManager.RegisterStyleSheet(this.Page, "~/admin/ControlPanel/module.css"); jQuery.RequestHoverIntentRegistration(); ClientResourceManager.RegisterScript(this.Page, "~/Resources/ControlPanel/ControlPanel.debug.js"); } jQuery.RequestDnnPluginsRegistration(); Control copyPageButton = CurrentPagePanel.FindControl("CopyPage"); if ((copyPageButton != null)) { copyPageButton.Visible = LocaleController.Instance.IsDefaultLanguage(LocaleController.Instance.GetCurrentLocale(PortalSettings.PortalId).Code); } if ((Request.IsAuthenticated)) { UserInfo user = UserController.GetCurrentUserInfo(); if (((user != null))) { bool isAdmin = user.IsInRole(PortalSettings.Current.AdministratorRoleName); AdminPanel.Visible = isAdmin; } } if (IsPageAdmin()) { ControlPanel.Visible = true; BodyPanel.Visible = true; if ((DotNetNukeContext.Current.Application.Name == "DNNCORP.CE")) { //Hide Support icon in CE AdminPanel.FindControl("SupportTickets").Visible = false; } else { //Show PE/XE tools AdvancedToolsPanel.Visible = true; } Localize(); if (!Page.IsPostBack) { UserInfo objUser = UserController.GetCurrentUserInfo(); if ((objUser != null)) { if (objUser.IsSuperUser) { hypMessage.ImageUrl = Upgrade.UpgradeIndicator(DotNetNukeContext.Current.Application.Version, Request.IsLocal, Request.IsSecureConnection); if (!string.IsNullOrEmpty(hypMessage.ImageUrl)) { hypMessage.ToolTip = Localization.GetString("hypUpgrade.Text", LocalResourceFile); hypMessage.NavigateUrl = Upgrade.UpgradeRedirect(); } } else { if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleName) && Host.DisplayCopyright) { hypMessage.ImageUrl = "~/images/branding/iconbar_logo.png"; hypMessage.ToolTip = DotNetNukeContext.Current.Application.Description; hypMessage.NavigateUrl = Localization.GetString("hypMessageUrl.Text", LocalResourceFile); } else { hypMessage.Visible = false; } if (!TabPermissionController.CanAddContentToPage()) { CommonTasksPanel.Visible = false; } } if (PortalSettings.AllowUserUICulture) { object oCulture = DotNetNuke.Services.Personalization.Personalization.GetProfile("Usability", "UICulture"); string currentCulture; if (oCulture != null) { currentCulture = oCulture.ToString(); } else { Localization l = new Localization(); currentCulture = l.CurrentUICulture; } //Localization.LoadCultureDropDownList(ddlUICulture, CultureDropDownTypes.NativeName, currentCulture); IEnumerable<ListItem> cultureListItems = Localization.LoadCultureInListItems(CultureDropDownTypes.NativeName, currentCulture, "", false); foreach (var cultureItem in cultureListItems) { ddlUICulture.AddItem(cultureItem.Text, cultureItem.Value); } var selectedCultureItem = ddlUICulture.FindItemByValue(currentCulture); if (selectedCultureItem != null) { selectedCultureItem.Selected = true; } //only show language selector if more than one language if (ddlUICulture.Items.Count > 1) { lblUILanguage.Visible = true; ddlUICulture.Visible = true; if (oCulture == null) { SetLanguage(true); } } } } SetMode(false); } } else if (IsModuleAdmin()) { ControlPanel.Visible = true; BodyPanel.Visible = false; adminMenus.Visible = false; if (!Page.IsPostBack) { SetMode(false); } } else { ControlPanel.Visible = false; } } catch (Exception exc) { Exceptions.ProcessModuleLoadException(this, exc); } }
private static string GetNotificationBody(string locale, UserInfo newUser, PortalSettings portalSettings) { const string text = "EMAIL_USER_REGISTRATION_ADMINISTRATOR_BODY"; return(Localization.GetSystemMessage(locale, portalSettings, text, newUser, Localization.GlobalResourceFile, null, "", portalSettings.AdministratorId)); }
protected static ActionResult CompleteUserCreation(UserCreateStatus createStatus, UserInfo newUser, bool notify, bool register) { ActionResult actionResult = new ActionResult(); string strMessage = ""; ModuleMessage.ModuleMessageType message = ModuleMessage.ModuleMessageType.RedError; if (register) { //send notification to portal administrator of new user registration //check the receive notification setting first, but if register type is Private, we will always send the notification email. //because the user need administrators to do the approve action so that he can continue use the website. if (PortalSettings.Current.EnableRegisterNotification || PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.PrivateRegistration) { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationAdmin, PortalController.Instance.GetCurrentSettings() as PortalSettings); SendAdminNotification(newUser, PortalController.Instance.GetCurrentSettings() as PortalSettings); } UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE; //complete registration switch (PortalSettings.Current.UserRegistration) { case (int)Globals.PortalRegistrationType.PrivateRegistration: strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPrivate, PortalController.Instance.GetCurrentSettings() as PortalSettings); //show a message that a portal administrator has to verify the user credentials if (string.IsNullOrEmpty(strMessage)) { strMessage += Localization.GetString("PrivateConfirmationMessage", Localization.SharedResourceFile); message = ModuleMessage.ModuleMessageType.GreenSuccess; } break; case (int)Globals.PortalRegistrationType.PublicRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalController.Instance.GetCurrentSettings() as PortalSettings); UserController.UserLogin(PortalSettings.Current.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.Current.PortalName, "", ref loginStatus, false); break; case (int)Globals.PortalRegistrationType.VerifiedRegistration: Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalController.Instance.GetCurrentSettings() as PortalSettings); UserController.UserLogin(PortalSettings.Current.PortalId, newUser.Username, newUser.Membership.Password, "", PortalSettings.Current.PortalName, "", ref loginStatus, false); break; } //store preferredlocale in cookie Localization.SetLanguage(newUser.Profile.PreferredLocale); if (!(HttpContext.Current.Request.IsAuthenticated && PortalSecurity.IsInRole(PortalSettings.Current.AdministratorRoleName)) && !(HttpContext.Current.Request.IsAuthenticated && (newUser.UserID == (PortalController.Instance.GetCurrentSettings() as PortalSettings).UserInfo.UserID)) && message == ModuleMessage.ModuleMessageType.RedError) { //HS Skin Messages //actionResult.AddError("SendMail_Error", string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), newUser.Email)); Exceptions.LogException(new Exception("Skin Messages : " + string.Format(Localization.GetString("SendMail.Error", Localization.SharedResourceFile), newUser.Email))); actionResult.Message = strMessage; } else { if (message == ModuleMessage.ModuleMessageType.RedError) { actionResult.AddError("CompleteUserCreation", strMessage); } else { actionResult.Message = strMessage; } } } else { if (notify) { //Send Notification to User if (PortalSettings.Current.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration) { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationVerified, PortalController.Instance.GetCurrentSettings() as PortalSettings); } else { strMessage += Mail.SendMail(newUser, MessageType.UserRegistrationPublic, PortalController.Instance.GetCurrentSettings() as PortalSettings); } } } actionResult.Message = strMessage; return(actionResult); }
private void LoadCultureDropDownList() { try { Localization myLoc = new Localization(); Localization.LoadCultureDropDownList(DDLanguage, CultureDropDownTypes.NativeName, myLoc.CurrentCulture); } catch (Exception ex) { Exceptions.LogException(ex); } }
protected override void OnInit(EventArgs e) { base.OnLoad(e); _ipAddress = UserRequestIPAddressController.Instance.GetUserRequestIPAddress(new HttpRequestWrapper(Request)); if (PortalSettings.LoginTabId != -1 && PortalSettings.ActiveTab.TabID != PortalSettings.LoginTabId) { Response.Redirect(ServiceProvider.NavigationManager.NavigateURL(PortalSettings.LoginTabId) + Request.Url.Query); } string ResetToken = string.Empty; Dictionary <string, string> Attributes = new Dictionary <string, string>(); if (HttpContext.Current.Request.QueryString["resetToken"] != null) { ResetToken = HttpContext.Current.Request.QueryString["resetToken"]; } ThemeTemplateResponse response = Render(Attributes); if (response != null) { VJ_PasswordReset.Text = response.Markup; if (response.Scripts != null) { foreach (string script in response.Scripts) { if (!string.IsNullOrEmpty(script)) { WebForms.RegisterClientScriptInclude(Page, script, Page.ResolveUrl(script)); } } } if (response.Styles != null) { foreach (string style in response.Styles) { if (!string.IsNullOrEmpty(style)) { WebForms.LinkCSS(Page, style, Page.ResolveUrl(style)); } } } if (!string.IsNullOrEmpty(response.Script)) { WebForms.RegisterClientScriptBlock(Page, "BlocksScript", response.Script, true); } UserInfo user = UserController.GetUserByPasswordResetToken(PortalId, ResetToken); if (user == null) { VJ_PasswordReset.Text = "<div class=\"alert alert-primary\" role=\"alert\">" + Localization.GetString("ResetLinkExpired", "~/Admin/Security/App_LocalResources/PasswordReset.ascx.resx") + "</div>"; } else { VJ_PasswordReset.Text = response.Markup.Replace("[Token_Username]", user.Username); } } }
protected string GetString(string resourceKey) { return(Localization.GetString(resourceKey, LocalResourceFile)); }