public static string ParseProfile(int portalId, int userId, string template, CurrentUserTypes currentUserType, int currentUserId) { var objuser = Entities.Users.UserController.GetUser(portalId, userId, true); var s = template ?? string.Empty; const string pattern = "(\\[DNN:PROFILE:(.+?)\\])"; foreach (Match match in Regex.Matches(s, pattern)) { var sReplace = string.Empty; var sResource = string.Empty; if (objuser != null) { var profproperties = objuser.Profile.ProfileProperties; var profprop = profproperties.GetByName(match.Groups[2].Value); sResource = "ProfileProperties_{0}"; if (profprop != null) { sResource = string.Format(sResource, match.Groups[2].Value); if (profprop.Visibility == Entities.Users.UserVisibilityMode.AdminOnly && (currentUserType != CurrentUserTypes.Anon || currentUserType != CurrentUserTypes.Auth)) { sReplace = profprop.PropertyValue; } else if (profprop.Visibility == Entities.Users.UserVisibilityMode.MembersOnly && currentUserType != CurrentUserTypes.Anon) { sReplace = profprop.PropertyValue; } else if (profprop.Visibility == Entities.Users.UserVisibilityMode.AllUsers) { sReplace = profprop.PropertyValue; } else { sReplace = "[RESX:Private]"; } sResource = Services.Localization.Localization.GetString(sResource, "~/admin/users/app_localresources/profile.ascx.resx"); } } s = s.Replace(match.Value, sReplace); s = s.Replace("[RESX:DNNProfile:" + match.Groups[2].Value + "]", sResource); } return(s); }
public static string GetPostInfo(int portalId, int moduleId, int userId, string username, User up, string imagePath, bool isMod, string ipAddress, bool isUserOnline, CurrentUserTypes currentUserType, int currentUserId, bool userPrefHideAvatar, int timeZoneOffset) { var sPostInfo = ParseProfileInfo(portalId, moduleId, userId, username, up, imagePath, isMod, ipAddress, currentUserType, currentUserId, userPrefHideAvatar, timeZoneOffset); if (sPostInfo.ToLower().Contains("<br")) return sPostInfo; var sr = new StringReader(sPostInfo); var sTrim = string.Empty; while (sr.Peek() != -1) { var tmp = sr.ReadLine(); if (tmp != null && tmp.Trim() != string.Empty) { sTrim += tmp.Trim() + "<br />"; } } return sTrim; }
public static string PreviewTopic(int topicTemplateID, int portalId, int moduleId, int tabId, Forum forumInfo, int userId, string body, string imagePath, User up, DateTime postDate, CurrentUserTypes currentUserType, int currentUserId, int timeZoneOffset) { var sTemplate = GetTopicTemplate(topicTemplateID, moduleId); try { var mainSettings = DataCache.MainSettings(moduleId); var sTopic = GetTemplateSection(sTemplate, "[TOPIC]", "[/TOPIC]"); sTopic = sTopic.Replace("[ACTIONS:ALERT]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:EDIT]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:DELETE]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:QUOTE]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:REPLY]", string.Empty); sTopic = sTopic.Replace("[POSTDATE]", Utilities.GetDate(postDate, moduleId, timeZoneOffset)); sTopic = sTopic.Replace("[POSTINFO]", GetPostInfo(portalId, moduleId, userId, up.UserName, up, imagePath, false, HttpContext.Current.Request.UserHostAddress, true, currentUserType, currentUserId, false, timeZoneOffset)); sTemplate = ParsePreview(portalId, sTopic, body, moduleId); sTemplate = "<table class=\"afgrid\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"1\">" + sTemplate; sTemplate = sTemplate + "</table>"; sTemplate = Utilities.LocalizeControl(sTemplate); sTemplate = Utilities.StripTokens(sTemplate); } catch (Exception ex) { sTemplate = ex.ToString(); } return sTemplate; }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, bool userPrefHideAvatar, bool userPrefHideSignature, string ipAddress, int currentUserId, int timeZoneOffset) { try { if (legacyTemplate) profileTemplate = CleanTemplate(profileTemplate); if (up.Profile == null) up = new UserController().FillProfile(portalId, -1, up); // TODO figure out why/if this recurion is possible. Seems a bit scary as it could create a loop. if (profileTemplate.Contains("[POSTINFO]")) { var sPostInfo = GetPostInfo(portalId, moduleId, up.UserId, up.UserName, up, imagePath, false, ipAddress, up.Profile.IsUserOnline, currentUserType, currentUserId, userPrefHideAvatar, timeZoneOffset); profileTemplate = profileTemplate.Replace("[POSTINFO]", sPostInfo); } var mainSettings = DataCache.MainSettings(moduleId); // Parse DNN profile fields if needed var pt = profileTemplate; if (pt.IndexOf("[DNN:PROFILE:", StringComparison.Ordinal) >= 0) pt = ParseProfile(portalId, up.UserId, pt, currentUserType, currentUserId); // Parse Roles if (pt.Contains("[ROLES:")) pt = ParseRoles(pt, (up.UserId == -1) ? string.Empty : up.Profile.Roles); var result = new StringBuilder(pt); // Used in a few places to determine if info should be shown or removed. var isMod = (currentUserType == CurrentUserTypes.Admin || currentUserType == CurrentUserTypes.ForumMod || currentUserType == CurrentUserTypes.SuperUser); // Used in a few places to determine if info should be shown or removed. var isAdmin = (currentUserType == CurrentUserTypes.Admin || currentUserType == CurrentUserTypes.SuperUser); var isAuthethenticated = currentUserType != CurrentUserTypes.Anon; // IP Address result.Replace("[MODIPADDRESS]", isMod ? ipAddress : string.Empty); // User Edit result.Replace("[AF:BUTTON:EDITUSER]", isAdmin && up.UserId > 0 ? string.Format("<button class='af-button af-button-edituser' data-id='{0}' data-name='{1}'>[RESX:Edit]</button>", up.UserId, Utilities.JSON.EscapeJsonString(up.DisplayName)) : string.Empty); // Points var totalPoints = up.PostCount; if (mainSettings.EnablePoints && up.UserId > 0 && up.Profile != null) { totalPoints = (up.Profile.TopicCount * mainSettings.TopicPointValue) + (up.Profile.ReplyCount * mainSettings.ReplyPointValue) + (up.Profile.AnswerCount * mainSettings.AnswerPointValue) + up.Profile.RewardPoints; result.Replace("[AF:PROFILE:TOTALPOINTS]", totalPoints.ToString()); result.Replace("[AF:POINTS:VIEWCOUNT]", up.Profile.ViewCount.ToString()); result.Replace("[AF:POINTS:ANSWERCOUNT]", up.Profile.AnswerCount.ToString()); result.Replace("[AF:POINTS:REWARDPOINTS]", up.Profile.RewardPoints.ToString()); } else { result.Replace("[AF:PROFILE:TOTALPOINTS]", string.Empty); result.Replace("[AF:POINTS:VIEWCOUNT]", string.Empty); result.Replace("[AF:POINTS:ANSWERCOUNT]", string.Empty); result.Replace("[AF:POINTS:REWARDPOINTS]", string.Empty); } // User Status var sUserStatus = string.Empty; if (mainSettings.UsersOnlineEnabled && up.UserId > 0 && up.Profile != null) sUserStatus = UserProfiles.UserStatus(imagePath, up.Profile.IsUserOnline, up.UserId, moduleId, "[RESX:UserOnline]", "[RESX:UserOffline]"); result.Replace("[AF:PROFILE:USERSTATUS]", sUserStatus); result.Replace("[AF:PROFILE:USERSTATUS:CSS]", sUserStatus.Contains("online") ? "af-status-online" : "af-status-offline"); // Rank result.Replace("[AF:PROFILE:RANKDISPLAY]", (up.UserId > 0) ? UserProfiles.GetUserRank(portalId, moduleId, up.UserId, totalPoints, 0) : string.Empty); result.Replace("[AF:PROFILE:RANKNAME]", (up.UserId > 0) ? UserProfiles.GetUserRank(portalId, moduleId, up.UserId, totalPoints, 1) : string.Empty); // PM Image/link var pmUrl = string.Empty; var pmLink = string.Empty; if (up.UserId > 0 && currentUserId >= 0 && up.UserId != currentUserId) { switch (mainSettings.PMType) { case PMTypes.Core: pmLink = "<img class='ComposeMessage' data-recipient='{ \"id\": \"user-" + up.UserId + "\", \"name\": \"" + HttpUtility.JavaScriptStringEncode(up.DisplayName) + "\"}' src='" + imagePath + "/images/icon_pm.png' alt=\"[RESX:SendPM]\" title=\"[RESX:SendPM]\" border=\"0\" /></a>"; break; case PMTypes.Ventrian: pmUrl = Common.Globals.NavigateURL(mainSettings.PMTabId, string.Empty, new[] {"type=compose", "sendto=" + up.UserId}); pmLink = "<a href=\"" + pmUrl + "\"><img src=\"" + imagePath + "/images/icon_pm.png\" alt=\"[RESX:SendPM]\" border=\"0\" /></a>"; break; } } result.Replace("[AF:PROFILE:PMLINK]", pmLink); result.Replace("[AF:PROFILE:PMURL]", pmUrl); // Signature var sSignature = string.Empty; if (mainSettings.AllowSignatures != 0 && ! userPrefHideSignature && up.Profile != null && !up.Profile.SignatureDisabled) { sSignature = up.Profile.Signature; if (sSignature != string.Empty) sSignature = Utilities.ManageImagePath(sSignature); switch (mainSettings.AllowSignatures) { case 1: sSignature = Utilities.HTMLEncode(sSignature); sSignature = sSignature.Replace(System.Environment.NewLine, "<br />"); break; case 2: sSignature = Utilities.HTMLDecode(sSignature); break; } } result.Replace("[AF:PROFILE:SIGNATURE]", sSignature); // Avatar var sAvatar = string.Empty; if (! userPrefHideAvatar && !up.Profile.AvatarDisabled) sAvatar = UserProfiles.GetAvatar(up.UserId, mainSettings.AvatarWidth, mainSettings.AvatarHeight); result.Replace("[AF:PROFILE:AVATAR]", sAvatar); // Display Name result.Replace("[AF:PROFILE:DISPLAYNAME]", UserProfiles.GetDisplayName(moduleId, true, isMod, isAdmin, up.UserId, up.UserName, up.FirstName, up.LastName, up.DisplayName)); // These fields are no longer used result.Replace("[AF:PROFILE:LOCATION]", string.Empty); result.Replace("[AF:PROFILE:WEBSITE]", string.Empty); result.Replace("[AF:PROFILE:YAHOO]", string.Empty); result.Replace("[AF:PROFILE:MSN]", string.Empty); result.Replace("[AF:PROFILE:ICQ]", string.Empty); result.Replace("[AF:PROFILE:AOL]", string.Empty); result.Replace("[AF:PROFILE:OCCUPATION]", string.Empty); result.Replace("[AF:PROFILE:INTERESTS]", string.Empty); result.Replace("[AF:CONTROL:AVATAREDIT]", string.Empty); result.Replace("[AF:BUTTON:PROFILEEDIT]", string.Empty); result.Replace("[AF:BUTTON:PROFILESAVE]", string.Empty); result.Replace("[AF:BUTTON:PROFILECANCEL]", string.Empty); result.Replace("[AF:PROFILE:BIO]", string.Empty); result.Replace("[MODUSERSETTINGS]", string.Empty); // Date Created var sDateCreated = string.Empty; var sDateCreatedReplacement = "[AF:PROFILE:DATECREATED]"; if (up.UserId > 0 && up.Profile != null && up.Profile.DateCreated != null) { if (pt.Contains("[AF:PROFILE:DATECREATED:")) { var sFormat = pt.Substring(pt.IndexOf("[AF:PROFILE:DATECREATED:", StringComparison.Ordinal) + (sDateCreatedReplacement.Length), 1); sDateCreated = up.Profile.DateCreated.ToString(sFormat); sDateCreatedReplacement = "[AF:PROFILE:DATECREATED:" + sFormat + "]"; } else sDateCreated = Utilities.GetDate(up.Profile.DateCreated, moduleId, timeZoneOffset); } result.Replace(sDateCreatedReplacement, sDateCreated); // Last Activity var sDateLastActivity = string.Empty; var sDateLastActivityReplacement = "[AF:PROFILE:DATELASTACTIVITY]"; if (up.Profile.DateLastActivity != null && up.UserId > 0) { if (pt.Contains("[AF:PROFILE:DATELASTACTIVITY:")) { string sFormat = pt.Substring(pt.IndexOf("[AF:PROFILE:DATELASTACTIVITY:", StringComparison.Ordinal) + (sDateLastActivityReplacement.Length), 1); sDateLastActivity = up.Profile.DateLastActivity.ToString(sFormat); sDateLastActivityReplacement = "[AF:PROFILE:DATELASTACTIVITY:" + sFormat + "]"; } else sDateLastActivity = Utilities.GetDate(up.Profile.DateLastActivity, moduleId, timeZoneOffset); } result.Replace(sDateLastActivityReplacement, sDateLastActivity); // Post Count result.Replace("[AF:PROFILE:POSTCOUNT]", (up.PostCount == 0) ? string.Empty : up.PostCount.ToString()); result.Replace("[AF:PROFILE:USERCAPTION]", up.Profile.UserCaption); result.Replace("[AF:PROFILE:USERID]", up.UserId.ToString()); result.Replace("[AF:PROFILE:USERNAME]", Utilities.HTMLEncode(up.UserName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:FIRSTNAME]", Utilities.HTMLEncode(up.FirstName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:LASTNAME]", Utilities.HTMLEncode(up.LastName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:DATELASTPOST]", (up.Profile.DateLastPost == DateTime.MinValue) ? string.Empty : Utilities.GetDate(up.Profile.DateLastPost, moduleId, timeZoneOffset)); result.Replace("[AF:PROFILE:TOPICCOUNT]", up.Profile.TopicCount.ToString()); result.Replace("[AF:PROFILE:REPLYCOUNT]", up.Profile.ReplyCount.ToString()); result.Replace("[AF:PROFILE:ANSWERCOUNT]", up.Profile.AnswerCount.ToString()); result.Replace("[AF:PROFILE:REWARDPOINTS]", up.Profile.RewardPoints.ToString()); return result.ToString(); } catch (Exception ex) { return ex.Message; } }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, bool userPrefHideAvatar, bool userPrefHideSignature, string ipAddress, int timeZoneOffset) { return ParseProfileTemplate(profileTemplate, up, portalId, moduleId, imagePath, currentUserType, legacyTemplate, userPrefHideAvatar, userPrefHideSignature, ipAddress, -1, timeZoneOffset); }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, int timeZoneOffset) { return ParseProfileTemplate(profileTemplate, up, portalId, moduleId, imagePath, currentUserType, false, false, false, string.Empty, -1, timeZoneOffset); }
public static string ParseProfileInfo(int portalId, int moduleId, int userId, string username, User up, string imagePath, bool isMod, string ipAddress, CurrentUserTypes currentUserType, int currentUserId, bool userPrefHideAvatar, int timeZoneOffset) { var mainSettings = DataCache.MainSettings(moduleId); var cacheKey = string.Format(CacheKeys.PostInfo, moduleId); var myTemplate = Convert.ToString(DataCache.CacheRetrieve(cacheKey)); if (string.IsNullOrEmpty(myTemplate)) { var objTemplateInfo = GetTemplateByName("ProfileInfo", moduleId, portalId); myTemplate = objTemplateInfo.TemplateHTML; if (cacheKey != string.Empty) DataCache.CacheStore(cacheKey, myTemplate); } myTemplate = ParseProfileTemplate(myTemplate, up, portalId, moduleId, imagePath, currentUserType, true, userPrefHideAvatar, false, ipAddress, currentUserId, timeZoneOffset); return myTemplate; }
public static string ParseProfile(int portalId, int userId, string template, CurrentUserTypes currentUserType, int currentUserId) { var objuser = Entities.Users.UserController.GetUser(portalId, userId, true); var s = template ?? string.Empty; const string pattern = "(\\[DNN:PROFILE:(.+?)\\])"; foreach (Match match in Regex.Matches(s, pattern)) { var sReplace = string.Empty; var sResource = string.Empty; if (objuser != null) { var profproperties = objuser.Profile.ProfileProperties; var profprop = profproperties.GetByName(match.Groups[2].Value); sResource = "ProfileProperties_{0}"; if (profprop != null) { sResource = string.Format(sResource, match.Groups[2].Value); if (profprop.Visibility == Entities.Users.UserVisibilityMode.AdminOnly && (currentUserType != CurrentUserTypes.Anon || currentUserType != CurrentUserTypes.Auth)) sReplace = profprop.PropertyValue; else if (profprop.Visibility == Entities.Users.UserVisibilityMode.MembersOnly && currentUserType != CurrentUserTypes.Anon) sReplace = profprop.PropertyValue; else if (profprop.Visibility == Entities.Users.UserVisibilityMode.AllUsers) sReplace = profprop.PropertyValue; else sReplace = "[RESX:Private]"; sResource = Services.Localization.Localization.GetString(sResource, "~/admin/users/app_localresources/profile.ascx.resx"); } } s = s.Replace(match.Value, sReplace); s = s.Replace("[RESX:DNNProfile:" + match.Groups[2].Value + "]", sResource); } return s; }
public static string PreviewTopic(int topicTemplateID, int portalId, int moduleId, int tabId, Forum forumInfo, int userId, string body, string imagePath, User up, DateTime postDate, CurrentUserTypes currentUserType, int currentUserId, int timeZoneOffset) { var sTemplate = GetTopicTemplate(topicTemplateID, moduleId); try { var mainSettings = DataCache.MainSettings(moduleId); var sTopic = GetTemplateSection(sTemplate, "[TOPIC]", "[/TOPIC]"); sTopic = sTopic.Replace("[ACTIONS:ALERT]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:EDIT]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:DELETE]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:QUOTE]", string.Empty); sTopic = sTopic.Replace("[ACTIONS:REPLY]", string.Empty); sTopic = sTopic.Replace("[POSTDATE]", Utilities.GetDate(postDate, moduleId, timeZoneOffset)); sTopic = sTopic.Replace("[POSTINFO]", GetPostInfo(portalId, moduleId, userId, up.UserName, up, imagePath, false, HttpContext.Current.Request.UserHostAddress, true, currentUserType, currentUserId, false, timeZoneOffset)); sTemplate = ParsePreview(portalId, sTopic, body, moduleId); sTemplate = "<table class=\"afgrid\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\" border=\"1\">" + sTemplate; sTemplate = sTemplate + "</table>"; sTemplate = Utilities.LocalizeControl(sTemplate); sTemplate = Utilities.StripTokens(sTemplate); } catch (Exception ex) { sTemplate = ex.ToString(); } return(sTemplate); }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, bool userPrefHideAvatar, bool userPrefHideSignature, string ipAddress, int timeZoneOffset) { return(ParseProfileTemplate(profileTemplate, up, portalId, moduleId, imagePath, currentUserType, legacyTemplate, userPrefHideAvatar, userPrefHideSignature, ipAddress, -1, timeZoneOffset)); }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, bool userPrefHideAvatar, bool userPrefHideSignature, string ipAddress, int currentUserId, int timeZoneOffset) { try { if (legacyTemplate) { profileTemplate = CleanTemplate(profileTemplate); } if (up.Profile == null) { up = new UserController().FillProfile(portalId, -1, up); } // TODO figure out why/if this recurion is possible. Seems a bit scary as it could create a loop. if (profileTemplate.Contains("[POSTINFO]")) { var sPostInfo = GetPostInfo(portalId, moduleId, up.UserId, up.UserName, up, imagePath, false, ipAddress, up.Profile.IsUserOnline, currentUserType, currentUserId, userPrefHideAvatar, timeZoneOffset); profileTemplate = profileTemplate.Replace("[POSTINFO]", sPostInfo); } var mainSettings = DataCache.MainSettings(moduleId); // Parse DNN profile fields if needed var pt = profileTemplate; if (pt.IndexOf("[DNN:PROFILE:", StringComparison.Ordinal) >= 0) { pt = ParseProfile(portalId, up.UserId, pt, currentUserType, currentUserId); } // Parse Roles if (pt.Contains("[ROLES:")) { pt = ParseRoles(pt, (up.UserId == -1) ? string.Empty : up.Profile.Roles); } var result = new StringBuilder(pt); // Used in a few places to determine if info should be shown or removed. var isMod = (currentUserType == CurrentUserTypes.Admin || currentUserType == CurrentUserTypes.ForumMod || currentUserType == CurrentUserTypes.SuperUser); // Used in a few places to determine if info should be shown or removed. var isAdmin = (currentUserType == CurrentUserTypes.Admin || currentUserType == CurrentUserTypes.SuperUser); var isAuthethenticated = currentUserType != CurrentUserTypes.Anon; // IP Address result.Replace("[MODIPADDRESS]", isMod ? ipAddress : string.Empty); // User Edit result.Replace("[AF:BUTTON:EDITUSER]", isAdmin && up.UserId > 0 ? string.Format("<button class='af-button af-button-edituser' data-id='{0}' data-name='{1}'>[RESX:Edit]</button>", up.UserId, Utilities.JSON.EscapeJsonString(up.DisplayName)) : string.Empty); // Points var totalPoints = up.PostCount; if (mainSettings.EnablePoints && up.UserId > 0 && up.Profile != null) { totalPoints = (up.Profile.TopicCount * mainSettings.TopicPointValue) + (up.Profile.ReplyCount * mainSettings.ReplyPointValue) + (up.Profile.AnswerCount * mainSettings.AnswerPointValue) + up.Profile.RewardPoints; result.Replace("[AF:PROFILE:TOTALPOINTS]", totalPoints.ToString()); result.Replace("[AF:POINTS:VIEWCOUNT]", up.Profile.ViewCount.ToString()); result.Replace("[AF:POINTS:ANSWERCOUNT]", up.Profile.AnswerCount.ToString()); result.Replace("[AF:POINTS:REWARDPOINTS]", up.Profile.RewardPoints.ToString()); } else { result.Replace("[AF:PROFILE:TOTALPOINTS]", string.Empty); result.Replace("[AF:POINTS:VIEWCOUNT]", string.Empty); result.Replace("[AF:POINTS:ANSWERCOUNT]", string.Empty); result.Replace("[AF:POINTS:REWARDPOINTS]", string.Empty); } // User Status var sUserStatus = string.Empty; if (mainSettings.UsersOnlineEnabled && up.UserId > 0 && up.Profile != null) { sUserStatus = UserProfiles.UserStatus(imagePath, up.Profile.IsUserOnline, up.UserId, moduleId, "[RESX:UserOnline]", "[RESX:UserOffline]"); } result.Replace("[AF:PROFILE:USERSTATUS]", sUserStatus); result.Replace("[AF:PROFILE:USERSTATUS:CSS]", sUserStatus.Contains("online") ? "af-status-online" : "af-status-offline"); // Rank result.Replace("[AF:PROFILE:RANKDISPLAY]", (up.UserId > 0) ? UserProfiles.GetUserRank(portalId, moduleId, up.UserId, totalPoints, 0) : string.Empty); result.Replace("[AF:PROFILE:RANKNAME]", (up.UserId > 0) ? UserProfiles.GetUserRank(portalId, moduleId, up.UserId, totalPoints, 1) : string.Empty); // PM Image/link var pmUrl = string.Empty; var pmLink = string.Empty; if (up.UserId > 0 && currentUserId >= 0 && up.UserId != currentUserId) { switch (mainSettings.PMType) { case PMTypes.Core: pmLink = "<img class='ComposeMessage' data-recipient='{ \"id\": \"user-" + up.UserId + "\", \"name\": \"" + HttpUtility.JavaScriptStringEncode(up.DisplayName) + "\"}' src='" + imagePath + "/images/icon_pm.png' alt=\"[RESX:SendPM]\" title=\"[RESX:SendPM]\" border=\"0\" /></a>"; break; case PMTypes.Ventrian: pmUrl = Common.Globals.NavigateURL(mainSettings.PMTabId, string.Empty, new[] { "type=compose", "sendto=" + up.UserId }); pmLink = "<a href=\"" + pmUrl + "\"><img src=\"" + imagePath + "/images/icon_pm.png\" alt=\"[RESX:SendPM]\" border=\"0\" /></a>"; break; } } result.Replace("[AF:PROFILE:PMLINK]", pmLink); result.Replace("[AF:PROFILE:PMURL]", pmUrl); // Signature var sSignature = string.Empty; if (mainSettings.AllowSignatures != 0 && !userPrefHideSignature && up.Profile != null && !up.Profile.SignatureDisabled) { sSignature = up.Profile.Signature; if (sSignature != string.Empty) { sSignature = Utilities.ManageImagePath(sSignature); } switch (mainSettings.AllowSignatures) { case 1: sSignature = Utilities.HTMLEncode(sSignature); sSignature = sSignature.Replace(System.Environment.NewLine, "<br />"); break; case 2: sSignature = Utilities.HTMLDecode(sSignature); break; } } result.Replace("[AF:PROFILE:SIGNATURE]", sSignature); // Avatar var sAvatar = string.Empty; if (!userPrefHideAvatar && !up.Profile.AvatarDisabled) { sAvatar = UserProfiles.GetAvatar(up.UserId, mainSettings.AvatarWidth, mainSettings.AvatarHeight); } result.Replace("[AF:PROFILE:AVATAR]", sAvatar); // Display Name result.Replace("[AF:PROFILE:DISPLAYNAME]", UserProfiles.GetDisplayName(moduleId, true, isMod, isAdmin, up.UserId, up.UserName, up.FirstName, up.LastName, up.DisplayName)); // These fields are no longer used result.Replace("[AF:PROFILE:LOCATION]", string.Empty); result.Replace("[AF:PROFILE:WEBSITE]", string.Empty); result.Replace("[AF:PROFILE:YAHOO]", string.Empty); result.Replace("[AF:PROFILE:MSN]", string.Empty); result.Replace("[AF:PROFILE:ICQ]", string.Empty); result.Replace("[AF:PROFILE:AOL]", string.Empty); result.Replace("[AF:PROFILE:OCCUPATION]", string.Empty); result.Replace("[AF:PROFILE:INTERESTS]", string.Empty); result.Replace("[AF:CONTROL:AVATAREDIT]", string.Empty); result.Replace("[AF:BUTTON:PROFILEEDIT]", string.Empty); result.Replace("[AF:BUTTON:PROFILESAVE]", string.Empty); result.Replace("[AF:BUTTON:PROFILECANCEL]", string.Empty); result.Replace("[AF:PROFILE:BIO]", string.Empty); result.Replace("[MODUSERSETTINGS]", string.Empty); // Date Created var sDateCreated = string.Empty; var sDateCreatedReplacement = "[AF:PROFILE:DATECREATED]"; if (up.UserId > 0 && up.Profile != null && up.Profile.DateCreated != null) { if (pt.Contains("[AF:PROFILE:DATECREATED:")) { var sFormat = pt.Substring(pt.IndexOf("[AF:PROFILE:DATECREATED:", StringComparison.Ordinal) + (sDateCreatedReplacement.Length), 1); sDateCreated = up.Profile.DateCreated.ToString(sFormat); sDateCreatedReplacement = "[AF:PROFILE:DATECREATED:" + sFormat + "]"; } else { sDateCreated = Utilities.GetDate(up.Profile.DateCreated, moduleId, timeZoneOffset); } } result.Replace(sDateCreatedReplacement, sDateCreated); // Last Activity var sDateLastActivity = string.Empty; var sDateLastActivityReplacement = "[AF:PROFILE:DATELASTACTIVITY]"; if (up.Profile.DateLastActivity != null && up.UserId > 0) { if (pt.Contains("[AF:PROFILE:DATELASTACTIVITY:")) { string sFormat = pt.Substring(pt.IndexOf("[AF:PROFILE:DATELASTACTIVITY:", StringComparison.Ordinal) + (sDateLastActivityReplacement.Length), 1); sDateLastActivity = up.Profile.DateLastActivity.ToString(sFormat); sDateLastActivityReplacement = "[AF:PROFILE:DATELASTACTIVITY:" + sFormat + "]"; } else { sDateLastActivity = Utilities.GetDate(up.Profile.DateLastActivity, moduleId, timeZoneOffset); } } result.Replace(sDateLastActivityReplacement, sDateLastActivity); // Post Count result.Replace("[AF:PROFILE:POSTCOUNT]", (up.PostCount == 0) ? string.Empty : up.PostCount.ToString()); result.Replace("[AF:PROFILE:USERCAPTION]", up.Profile.UserCaption); result.Replace("[AF:PROFILE:USERID]", up.UserId.ToString()); result.Replace("[AF:PROFILE:USERNAME]", Utilities.HTMLEncode(up.UserName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:FIRSTNAME]", Utilities.HTMLEncode(up.FirstName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:LASTNAME]", Utilities.HTMLEncode(up.LastName).Replace("&#", "&#")); result.Replace("[AF:PROFILE:DATELASTPOST]", (up.Profile.DateLastPost == DateTime.MinValue) ? string.Empty : Utilities.GetDate(up.Profile.DateLastPost, moduleId, timeZoneOffset)); result.Replace("[AF:PROFILE:TOPICCOUNT]", up.Profile.TopicCount.ToString()); result.Replace("[AF:PROFILE:REPLYCOUNT]", up.Profile.ReplyCount.ToString()); result.Replace("[AF:PROFILE:ANSWERCOUNT]", up.Profile.AnswerCount.ToString()); result.Replace("[AF:PROFILE:REWARDPOINTS]", up.Profile.RewardPoints.ToString()); return(result.ToString()); } catch (Exception ex) { return(ex.Message); } }
public static string ParseProfileTemplate(string profileTemplate, User up, int portalId, int moduleId, string imagePath, CurrentUserTypes currentUserType, bool legacyTemplate, int timeZoneOffset) { return(ParseProfileTemplate(profileTemplate, up, portalId, moduleId, imagePath, currentUserType, false, false, false, string.Empty, -1, timeZoneOffset)); }
public static string ParseProfileInfo(int portalId, int moduleId, int userId, string username, User up, string imagePath, bool isMod, string ipAddress, CurrentUserTypes currentUserType, int currentUserId, bool userPrefHideAvatar, int timeZoneOffset) { var mainSettings = DataCache.MainSettings(moduleId); var cacheKey = string.Format(CacheKeys.PostInfo, moduleId); var myTemplate = Convert.ToString(DataCache.CacheRetrieve(cacheKey)); if (string.IsNullOrEmpty(myTemplate)) { var objTemplateInfo = GetTemplateByName("ProfileInfo", moduleId, portalId); myTemplate = objTemplateInfo.TemplateHTML; if (cacheKey != string.Empty) { DataCache.CacheStore(cacheKey, myTemplate); } } myTemplate = ParseProfileTemplate(myTemplate, up, portalId, moduleId, imagePath, currentUserType, true, userPrefHideAvatar, false, ipAddress, currentUserId, timeZoneOffset); return(myTemplate); }
public static string GetPostInfo(int portalId, int moduleId, int userId, string username, User up, string imagePath, bool isMod, string ipAddress, bool isUserOnline, CurrentUserTypes currentUserType, int currentUserId, bool userPrefHideAvatar, int timeZoneOffset) { var sPostInfo = ParseProfileInfo(portalId, moduleId, userId, username, up, imagePath, isMod, ipAddress, currentUserType, currentUserId, userPrefHideAvatar, timeZoneOffset); if (sPostInfo.ToLower().Contains("<br")) { return(sPostInfo); } var sr = new StringReader(sPostInfo); var sTrim = string.Empty; while (sr.Peek() != -1) { var tmp = sr.ReadLine(); if (tmp != null && tmp.Trim() != string.Empty) { sTrim += tmp.Trim() + "<br />"; } } return(sTrim); }
internal static string ParseToolBar(string template, int tabId, int moduleId, int userId, CurrentUserTypes currentUserType, int forumId = 0) { //var mainSettings = DataCache.MainSettings(moduleId); var ctlUtils = new ControlUtils(); if (HttpContext.Current.Request.IsAuthenticated) { template = template.Replace("[AF:TB:NotRead]", string.Format("<a href=\"{0}\">[RESX:NotRead]</a>", ctlUtils.BuildUrl(tabId, moduleId, string.Empty, string.Empty, -1, -1, -1, -1, "notread", 1, -1, -1))); template = template.Replace("[AF:TB:MyTopics]", string.Format("<a href=\"{0}\">[RESX:MyTopics]</a>", ctlUtils.BuildUrl(tabId, moduleId, string.Empty, string.Empty, -1, -1, -1, -1, "mytopics", 1, -1, -1))); if (currentUserType == CurrentUserTypes.Admin || currentUserType == CurrentUserTypes.SuperUser) template = template.Replace("[AF:TB:ControlPanel]", string.Format("<a href=\"{0}\">[RESX:ControlPanel]</a>", NavigateUrl(tabId, "EDIT", "mid=" + moduleId))); else template = template.Replace("[AF:TB:ControlPanel]", string.Empty); if (currentUserType == CurrentUserTypes.ForumMod || currentUserType == CurrentUserTypes.SuperUser || currentUserType == CurrentUserTypes.Admin) template = template.Replace("[AF:TB:ModList]", string.Format("<a href=\"{0}\">[RESX:Moderate]</a>", NavigateUrl(tabId, "", ParamKeys.ViewType + "=modtopics"))); else template = template.Replace("[AF:TB:ModList]", string.Empty); } else { template = template.Replace("[AF:TB:NotRead]", string.Empty); template = template.Replace("[AF:TB:MyTopics]", string.Empty); template = template.Replace("[AF:TB:ModList]", string.Empty); template = template.Replace("[AF:TB:ControlPanel]", string.Empty); } template = template.Replace("[AF:TB:Unanswered]", string.Format("<a href=\"{0}\">[RESX:Unanswered]</a>", ctlUtils.BuildUrl(tabId, moduleId, string.Empty, string.Empty, -1, -1, -1, -1, "unanswered", 1, -1, -1))); template = template.Replace("[AF:TB:ActiveTopics]", string.Format("<a href=\"{0}\">[RESX:ActiveTopics]</a>", ctlUtils.BuildUrl(tabId, moduleId, string.Empty, string.Empty, -1, -1, -1, -1, "activetopics", 1, -1, -1))); template = template.Replace("[AF:TB:Forums]", string.Format("<a href=\"{0}\">[RESX:FORUMS]</a>", NavigateUrl(tabId))); // Search popup var searchUrl = NavigateUrl(tabId, string.Empty, new[] {ParamKeys.ViewType + "=search", "f=" + forumId}); var advancedSearchUrl = NavigateUrl(tabId, string.Empty, new[] {ParamKeys.ViewType + "=searchadvanced", "f=" + forumId}); var searchText = forumId > 0 ? "[RESX:SearchSingleForum]" : "[RESX:SearchAllForums]"; template = template.Replace("[AF:TB:Search]", string.Format(@"<span class='aftb-search' data-searchUrl='{0}'><span class='aftb-search-link'><span>{2}</span><span class='ui-icon ui-icon-triangle-1-s'></span></span><span class='aftb-search-popup'><input type='text' placeholder='Search for...' maxlength='50'><button>[RESX:Search]</button><br /><a href='{1}'>[RESX:SearchAdvanced]</a><input type='radio' name='afsrt' value='0' checked='checked' />[RESX:SearchByTopics]<input type='radio' name='afsrt' value='1' />[RESX:SearchByPosts]</span></span>", HttpUtility.HtmlEncode(searchUrl), HttpUtility.HtmlEncode(advancedSearchUrl), searchText)); // These are no longer used in 5.0 template = template.Replace("[AF:TB:MyProfile]", string.Empty); template = template.Replace("[AF:TB:MySettings]", string.Empty); template = template.Replace("[AF:TB:MemberList]", string.Empty); return template; }
private string GetTabsSection(string Template) { string sOut = string.Empty; sOut = TemplateUtils.GetTemplateSection(Template, "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]"); string pattern = "(\\[AM:CONTROLS:TAB:(.+?)\\])"; Regex regExp = new Regex(pattern); MatchCollection matches = null; matches = regExp.Matches(sOut); amTabs = new DotNetNuke.Modules.ActiveForums.Controls.ActiveTabs(); foreach (Match match in matches) { bool bAddTab = false; string matchValue = match.Groups[2].Value; CurrentUserTypes access = CurrentUserTypes.Anon; if (matchValue.Contains(":")) { string sec = matchValue.Split(':')[1].ToLowerInvariant(); if (sec == "private") { if (!(CurrentUserType == CurrentUserTypes.Anon)) { if (UserId == UID || (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser)) { bAddTab = true; access = CurrentUserTypes.Admin; } } } else { switch (sec) { case "auth": access = CurrentUserTypes.Auth; break; case "forummod": access = CurrentUserTypes.ForumMod; break; case "admin": access = CurrentUserTypes.Admin; break; case "superuser": access = CurrentUserTypes.SuperUser; break; } switch (access) { case CurrentUserTypes.Anon: bAddTab = true; break; case CurrentUserTypes.Auth: if (!(CurrentUserType == CurrentUserTypes.Anon)) { bAddTab = true; } break; case CurrentUserTypes.ForumMod: if (!(CurrentUserType == CurrentUserTypes.Anon) && !(CurrentUserType == CurrentUserTypes.Auth)) { bAddTab = true; } break; case CurrentUserTypes.Admin: if (CurrentUserType == CurrentUserTypes.Admin || CurrentUserType == CurrentUserTypes.SuperUser) { bAddTab = true; } break; case CurrentUserTypes.SuperUser: if (CurrentUserType == CurrentUserTypes.SuperUser) { bAddTab = true; } break; } } matchValue = matchValue.Split(':')[0]; } else { bAddTab = true; } if (bAddTab) { DotNetNuke.Modules.ActiveForums.Controls.Tab tb = new DotNetNuke.Modules.ActiveForums.Controls.Tab(); tb.ControlKey = matchValue; tb.Text = "[RESX:Label:" + matchValue + "]"; if (sOut.Contains(match.Value.Replace("[AM", "[/AM"))) { DotNetNuke.Modules.ActiveForums.Controls.TabContent tbc = new DotNetNuke.Modules.ActiveForums.Controls.TabContent(); string tmp = TemplateUtils.GetTemplateSection(sOut, match.Value, match.Value.Replace("[AM", "[/AM")); if (tmp.Contains("<dnn:")) { tmp = "<%@ Register TagPrefix=\"dnn\" Assembly=\"DotNetNuke\" Namespace=\"DotNetNuke.UI.WebControls\"%>" + tmp; } if (tmp.Contains("<social:")) { tmp = Globals.SocialRegisterTag + tmp; } Control ctl = this.ParseControl(tmp); tbc.Controls.Add(ctl); tb.Content = tbc; } amTabs.Tabs.Add(tb); } } Template = TemplateUtils.ReplaceSubSection(Template, "<asp:placeholder id=\"plhTabs\" runat=\"server\" />", "[AM:CONTROLS:TABS]", "[/AM:CONTROLS:TABS]"); return(Template); }