/// <summary> /// Informs the core journal that the user has commented on a post. /// </summary> /// <param name="objEntry"></param> /// <param name="objComment"></param> /// <param name="title"></param> /// <param name="portalId"></param> /// <param name="journalUserId"></param> /// <param name="url"></param> internal void AddCommentToJournal(AlbumInfo objEntry, CommentInfo objComment, string title, int portalId, int journalUserId, string url) { var objectKey = Constants.ContentTypeName + "_" + Constants.JournalCommentTypeName + "_" + string.Format("{0}:{1}", objEntry.PostId, objComment.CommentId); var ji = JournalController.Instance.GetJournalItemByKey(portalId, objectKey); if ((ji != null)) { JournalController.Instance.DeleteJournalItemByKey(portalId, objectKey); } ji = new JournalItem { PortalId = portalId, ProfileId = journalUserId, UserId = journalUserId, ContentItemId = objEntry.ContentItemId, Title = title, ItemData = new ItemData { Url = url }, Summary = "", // objComment.Comment, Body = null, JournalTypeId = GetCommentJournalTypeID(portalId), ObjectKey = objectKey, SecuritySet = "E," }; JournalController.Instance.SaveJournalItem(ji, objEntry.TabID); }
internal string GetCommentRow(CommentInfo comment) { var sb = new StringBuilder(); string pic = string.Format(Globals.UserProfilePicFormattedUrl(), comment.UserId, 32, 32); sb.AppendFormat("<li id=\"cmt-{0}\">", comment.CommentId); if (comment.UserId == CurrentUser.UserID || isAdmin) { sb.Append("<div class=\"miniclose\"></div>"); } sb.AppendFormat("<img src=\"{0}\" />", pic); sb.Append("<p>"); string userUrl = Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + comment.UserId }); sb.AppendFormat("<a href=\"{1}\">{0}</a>", comment.DisplayName, userUrl); sb.Append(comment.Comment.Replace("\n","<br />")); var timeFrame = DateUtils.CalculateDateForDisplay(comment.DateCreated); comment.DateCreated = CurrentUser.LocalTime(comment.DateCreated); sb.AppendFormat("<abbr title=\"{0}\">{1}</abbr>", comment.DateCreated, timeFrame); sb.Append("</p>"); sb.Append("</li>"); return sb.ToString(); }
public void SaveComment(CommentInfo comment) { var portalSecurity = new PortalSecurity(); if (!String.IsNullOrEmpty(comment.Comment)) { comment.Comment = HttpUtility.HtmlDecode(portalSecurity.InputFilter(comment.Comment, PortalSecurity.FilterFlag.NoScripting)); } //TODO: enable once the profanity filter is working properly. //objCommentInfo.Comment = portalSecurity.Remove(objCommentInfo.Comment, DotNetNuke.Security.PortalSecurity.ConfigType.ListController, "ProfanityFilter", DotNetNuke.Security.PortalSecurity.FilterScope.PortalList); string xml = null; if (comment.CommentXML != null) { xml = comment.CommentXML.OuterXml; } comment.CommentId = _dataService.Journal_Comment_Save(comment.JournalId, comment.CommentId, comment.UserId, comment.Comment, xml, Null.NullDate); var newComment = GetComment(comment.CommentId); comment.DateCreated = newComment.DateCreated; comment.DateUpdated = newComment.DateUpdated; }
public HttpResponseMessage CommentSave(CommentSaveDTO postData) { try { var ci = new CommentInfo { JournalId = postData.JournalId, Comment = HttpUtility.UrlDecode(postData.Comment) }; if (ci.Comment.Length > 2000) { ci.Comment = ci.Comment.Substring(0, 1999); ci.Comment = Utilities.RemoveHTML(ci.Comment); } ci.UserId = UserInfo.UserID; JournalController.Instance.SaveComment(ci); var ji = JournalController.Instance.GetJournalItem(ActiveModule.OwnerPortalID, UserInfo.UserID, postData.JournalId); var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo); return Request.CreateResponse(HttpStatusCode.OK, jp.GetCommentRow(ci), "text/html"); } catch (Exception exc) { Logger.Error(exc); return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc); } }
public string CommentSave(int journalId, string comment) { try { var ci = new CommentInfo { JournalId = journalId, Comment = HttpUtility.UrlDecode(comment) }; if (ci.Comment.Length > 2000) { ci.Comment = ci.Comment.Substring(0, 1999); ci.Comment = Utilities.RemoveHTML(ci.Comment); } ci.UserId = UserInfo.UserID; InternalJournalController.Instance.SaveComment(ci); var ji = JournalController.Instance.GetJournalItem(PortalSettings.PortalId, UserInfo.UserID, journalId); var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo); return jp.GetCommentRow(ci); } catch (Exception exc) { DnnLog.Error(exc); return string.Empty; } }
public HttpResponseMessage CommentSave(CommentSaveDTO postData) { try { var comment = HttpUtility.UrlDecode(postData.Comment); IDictionary<string, UserInfo> mentionedUsers = new Dictionary<string, UserInfo>(); var originalComment = comment; comment = ParseMentions(comment, postData.Mentions, ref mentionedUsers); var ci = new CommentInfo { JournalId = postData.JournalId, Comment = comment }; ci.UserId = UserInfo.UserID; ci.DisplayName = UserInfo.DisplayName; JournalController.Instance.SaveComment(ci); var ji = JournalController.Instance.GetJournalItem(ActiveModule.OwnerPortalID, UserInfo.UserID, postData.JournalId); var jp = new JournalParser(PortalSettings, ActiveModule.ModuleID, ji.ProfileId, -1, UserInfo); SendMentionNotifications(mentionedUsers, ji, originalComment, "Comment"); return Request.CreateResponse(HttpStatusCode.OK, jp.GetCommentRow(ji, ci), "text/html"); } catch (Exception exc) { Logger.Error(exc); return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, exc); } }
internal string GetCommentRow(JournalItem journal, CommentInfo comment) { var sb = new StringBuilder(); string pic = string.Format(Globals.UserProfilePicRelativeUrl(), comment.UserId, 32, 32); sb.AppendFormat("<li id=\"cmt-{0}\">", comment.CommentId); if (comment.UserId == CurrentUser.UserID || journal.UserId == CurrentUser.UserID || isAdmin) { sb.Append("<div class=\"miniclose\"></div>"); } sb.AppendFormat("<img src=\"{0}\" />", pic); sb.Append("<p>"); string userUrl = Globals.NavigateURL(PortalSettings.UserTabId, string.Empty, new[] { "userId=" + comment.UserId }); sb.AppendFormat("<a href=\"{1}\">{0}</a>", comment.DisplayName, userUrl); if (comment.CommentXML != null && comment.CommentXML.SelectSingleNode("/root/comment") != null) { string text; var regex = new Regex(@"\<\!\[CDATA\[(?<text>[^\]]*)\]\]\>"); if (regex.IsMatch(comment.CommentXML.SelectSingleNode("/root/comment").InnerText)) { var match = regex.Match(comment.CommentXML.SelectSingleNode("/root/comment").InnerText); text = match.Groups["text"].Value; } else { text = comment.CommentXML.SelectSingleNode("/root/comment").InnerText; } sb.Append(text.Replace("\n", "<br />")); } else { sb.Append(comment.Comment.Replace("\n", "<br />")); } var timeFrame = DateUtils.CalculateDateForDisplay(comment.DateCreated); comment.DateCreated = CurrentUser.LocalTime(comment.DateCreated); sb.AppendFormat("<abbr title=\"{0}\">{1}</abbr>", comment.DateCreated, timeFrame); sb.Append("</p>"); sb.Append("</li>"); return sb.ToString(); }