/// <summary> /// Displays user's registration information. /// </summary> protected void LoadRegInfo(UserSettingsInfo settings) { if ((settings.UserRegistrationInfo != null) && (settings.UserRegistrationInfo.ColumnNames != null) && (settings.UserRegistrationInfo.ColumnNames.Count > 0)) { foreach (string column in settings.UserRegistrationInfo.ColumnNames) { Panel grp = new Panel { CssClass = "control-group-inline" }; plcUserLastLogonInfo.Controls.Add(grp); Label lbl = new Label(); grp.Controls.Add(lbl); lbl.Text = HTMLHelper.HTMLEncode(TextHelper.LimitLength((string)settings.UserRegistrationInfo[column], 80, "...")); lbl.ToolTip = HTMLHelper.HTMLEncode(column + " - " + (string)settings.UserRegistrationInfo[column]); } } else { plcUserLastLogonInfo.Controls.Add(new LocalizedLabel { ResourceString = "general.na", CssClass = "form-control-text" }); } }
// for use by SettingsDialog only internal Path <object> GetSettingsPath(string pathName) { string[] pathSegments = pathName.Split(s_delimiters, 16); object[] path = new object[pathSegments.Length + 1]; // first node is the settings tree root Tree <object> node = m_userSettings; path[0] = m_userSettings.Value; // middle nodes are folders for (int i = 1; i < path.Length - 1; i++) { node = GetOrCreateFolder(pathSegments[i - 1], node); path[i] = node.Value; } // leaf node is user settings object foreach (Tree <object> leaf in node.Children) { UserSettingsInfo info = node.Value as UserSettingsInfo; if (info != null && info.Name == pathSegments[pathSegments.Length - 1]) { path[path.Length - 1] = leaf.Value; break; } } return(new Path <object>(path)); }
/// <summary> /// Registers settings that can be presented to the user for editing. These are not /// persisted unless RegisterSettings() is also called.</summary> /// <param name="pathName">Path to settings</param> /// <param name="settings">User editable settings</param> public void RegisterUserSettings(string pathName, params PropertyDescriptor[] settings) { if (string.IsNullOrEmpty(pathName)) { throw new ArgumentException("pathName"); } string[] path = pathName.Split(s_delimiters, 16); // get root folder Tree <object> folder = UserSettings as Tree <object>; if (folder == null) { throw new InvalidOperationException("userSettings"); } // for each subsequent segment of the path, get folder for (int i = 0; i < path.Length - 1; i++) { folder = GetOrCreateFolder(path[i], folder); } // get the node that should hold the settings, if it already exists string name = path[path.Length - 1]; UserSettingsInfo existing = null; int index = 0; foreach (Tree <object> node in folder.Children) { UserSettingsInfo info = node.Value as UserSettingsInfo; if (info != null) { if (info.Name == name) { existing = info; break; } if (info.Name.CompareTo(name) < 0) { index++; } } } // add the settings, either by merging with the existing node or creating a new one if (existing != null) { foreach (PropertyDescriptor pd in settings) { existing.Settings.Add(pd); } } else { Tree <object> node = new Tree <object>(new UserSettingsInfo(name, settings)); folder.Children.Insert(index, node); } }
/// <summary> /// Return list of setting PropertyDescriptors</summary> /// <remarks>For use by SettingsDialog only</remarks> /// <param name="tree">Tree of user editable settings</param> /// <returns>List of setting PropertyDescriptors</returns> protected List <PropertyDescriptor> GetProperties(Tree <object> tree) { UserSettingsInfo info = tree.Value as UserSettingsInfo; if (info != null) { return(info.Settings); } return(null); }
protected void Page_Load(object sender, EventArgs e) { CopyValues(forumEdit); if (IsAdHocForum) { plcHeader.Visible = false; } forumEdit.OnPreview += forumEdit_OnPreview; forumEdit.OnModerationRequired += new EventHandler(forumEdit_OnModerationRequired); // Check whether subscription is for forum or post if (ForumContext.CurrentReplyThread == null) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.NewThread"); if (ForumContext.CurrentPost != null && ForumContext.CurrentMode == ForumMode.Edit) { ltrTitle.Text = GetString("Forums_ForumNewPost_Header.EditPost"); } } else { plcPreview.Visible = true; ltrTitle.Text = GetString("Forums_ForumNewPost_Header.Reply"); ltrAvatar.Text = AvatarImage(ForumContext.CurrentReplyThread); ltrSubject.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostSubject); ltrText.Text = ResolvePostText(ForumContext.CurrentReplyThread.PostText); ltrUserName.Text = HTMLHelper.HTMLEncode(ForumContext.CurrentReplyThread.PostUserName); ltrTime.Text = CMSContext.ConvertDateTime(ForumContext.CurrentReplyThread.PostTime, this).ToString(); UserSettingsInfo usi = UserSettingsInfoProvider.GetUserSettingsInfoByUser(ForumContext.CurrentReplyThread.PostUserID); BadgeInfo bi = null; string badgeName = null; string badgeImageUrl = null; if (usi != null) { bi = BadgeInfoProvider.GetBadgeInfo(usi.UserBadgeID); if (bi != null) { badgeName = HTMLHelper.HTMLEncode(ResHelper.LocalizeString(bi.BadgeDisplayName)); badgeImageUrl = HTMLHelper.HTMLEncode(bi.BadgeImageURL); } } ltrBadge.Text = GetNotEmpty(badgeName, "<div class=\"Badge\">" + badgeName + "</div>", "<div class=\"Badge\">" + GetString("Forums.PublicBadge") + "</div>", ForumActionType.Badge) + GetNotEmpty(badgeImageUrl, "<div class=\"BadgeImage\"><img alt=\"" + badgeName + "\" src=\"" + GetImageUrl(ValidationHelper.GetString(badgeImageUrl, "")) + "\" /></div>", "", ForumActionType.Badge); } }
//Method to Retrieve the password hint private void btnPasswordHint_Click(object sender, EventArgs e) { string value = txtPasswordHint.Text.Trim(); try { if (!String.IsNullOrEmpty(value) && ValidationHelper.IsEmail(value)) { /// This method will return User object if entered email id is present in DBlblHintResult UserInfo user = UserInfoProvider.GetUsers().Columns("UserId").WhereEquals("Email", value).TopN(1); if (user != null) { UserSettingsInfo Usersetting = CMS.Membership.UserSettingsInfoProvider.GetUserSettingsInfoByUser(user.UserID); lblPwdHint.Text = Usersetting.GetStringValue("PasswordHint", ""); lblPwdHint.Visible = true; lblHintResult.Text = string.Format(GetString("Kadena.LogonFrom.pwdHintSuccess"), value); lblHintResult.Visible = true; pnlPasswdRetrieval.Visible = true; } else { lblError.Text = ResHelper.GetString("Kadena.loginForm.EmailNotExists"); lblError.Visible = true; lblHintResult.Visible = false; lblPwdHint.Visible = false; pnlPasswdRetrieval.Visible = true; } //foreach (UserInfo aUser in user.TypedResult) //{ // UserSettingsInfo Usersetting = CMS.Membership.UserSettingsInfoProvider.GetUserSettingsInfoByUser(aUser.UserID); // lblPwdHint.Text = Usersetting.GetStringValue("PasswordHint", ""); // lblPwdHint.Visible = true; //} } else { lblError.Text = String.Format(GetString("LogonForm.EmailNotValid"), value); lblError.Visible = true; pnlPasswdRetrieval.Visible = true; } } catch (Exception ex) { EventLogProvider.LogException("PasswordHintForm", "EXCEPTION", ex); } }
/// <summary> /// Gets item's display information</summary> /// <param name="item">Item being displayed</param> /// <param name="info">Item info, to fill out</param> public void GetInfo(object item, ItemInfo info) { object value = ((Tree <object>)item).Value; if (value is string) { info.Label = (string)value; //info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.FolderImage); info.AllowSelect = false; } else { UserSettingsInfo settingsInfo = value as UserSettingsInfo; info.Label = settingsInfo.Name; info.AllowLabelEdit = false; //info.ImageIndex = info.GetImageList().Images.IndexOfKey(Resources.PreferencesImage); info.IsLeaf = true; } }
/// <summary> /// Displays user's registration information. /// </summary> /// <param name="ui">User info</param> protected void LoadRegInfo(UserSettingsInfo usi) { if ((usi.UserRegistrationInfo != null) && (usi.UserRegistrationInfo.ColumnNames != null)) { plcUserLastLogonInfo.Controls.Add(new LiteralControl("<br />")); foreach (string column in usi.UserRegistrationInfo.ColumnNames) { Label lbl = new Label(); lbl.Text = HTMLHelper.HTMLEncode(TextHelper.LimitLength((string)usi.UserRegistrationInfo[column], 80, "...")) + "<br />"; lbl.ToolTip = HTMLHelper.HTMLEncode(column + " - " + (string)usi.UserRegistrationInfo[column]); plcUserLastLogonInfo.Controls.Add(lbl); } plcUserLastLogonInfo.Controls.Add(new LiteralControl("<br />")); } else { plcUserLastLogonInfo.Controls.Add(new LiteralControl(GetString("general.na") + "<br />")); } }
/// <summary> /// Displays user's registration information. /// </summary> /// <param name="ui">User info</param> protected void LoadRegInfo(UserSettingsInfo usi) { if ((usi.UserRegistrationInfo != null) && (usi.UserRegistrationInfo.ColumnNames != null) && (usi.UserRegistrationInfo.ColumnNames.Count > 0)) { foreach (string column in usi.UserRegistrationInfo.ColumnNames) { Panel grp = new Panel { CssClass = "control-group-inline" }; plcUserLastLogonInfo.Controls.Add(grp); Label lbl = new Label(); grp.Controls.Add(lbl); lbl.Text = HTMLHelper.HTMLEncode(TextHelper.LimitLength((string)usi.UserRegistrationInfo[column], 80, "...")); lbl.ToolTip = HTMLHelper.HTMLEncode(column + " - " + (string)usi.UserRegistrationInfo[column]); } } else { plcUserLastLogonInfo.Controls.Add(new LocalizedLabel { ResourceString = "general.na", CssClass = "form-control-text" }); } }
/// <summary> /// Upload avatars defined in dataset. /// </summary> public static void UploadAvatars() { try { if (!DataHelper.DataSourceIsEmpty(ds)) { foreach (DataRow dr in ds.Tables[0].Rows) { string userPicture = ValidationHelper.GetString(dr["UserPicture"], string.Empty); int userId = ValidationHelper.GetInteger(dr["UserSettingsUserID"], 0); if ((userPicture.Contains("/")) && (userId > 0)) { string[] values = userPicture.Split('/'); if ((values != null) && (values.Length == 2)) { string realFileName = values[0]; string fileName = values[0]; string path = mAvatarsPath + realFileName; if (File.Exists(path)) { AvatarInfo ai = new AvatarInfo(path); ai.AvatarIsCustom = true; ai.AvatarType = "user"; AvatarInfoProvider.SetAvatarInfo(ai); UserSettingsInfo ui = new UserSettingsInfo(dr); ui.UserAvatarID = ai.AvatarID; UserSettingsInfoProvider.SetUserSettingsInfo(ui); } } } } } } catch (Exception ex) { EventLogProvider evp = new EventLogProvider(); evp.LogEvent("Avatar upgrade", "Update", ex); } }