private string RenderActivity(IActivityStory story) { var group = PublicApi.Groups.Get(story.ContentId.Value); if (group != null && group.Errors.Count() == 0) { User user = PublicApi.Users.Get(new UsersGetOptions() { Id = GetPrimaryUser(story) }); if (user != null) { var attributes = story.ExtendedAttributes.ToLookup(att => att.Key); Guid contentId = attributes.GetGuid("MentioningContentId" , Guid.Empty); Guid contentTypeId = attributes.GetGuid("MentioningContentTypeId", Guid.Empty); var content = PublicApi.Content.Get(contentId, contentTypeId); if (content != null && content.Errors.Count == 0) { return string.Format(_translatablePluginController.GetLanguageResourceValue("GroupMentioned"), PublicApi.Html.EncodeAttribute(user.Url) , user.DisplayName, PublicApi.Html.EncodeAttribute(content.Url), content.HtmlName("web")); } } } return string.Empty; }
public string GetPreviewHtml(IActivityStory story, Target target) { var poll = InternalApi.PollingService.GetPoll(story.ContentId.Value); if (poll == null) { return(_translation.GetLanguageResourceValue("activity_nopermission")); } var userId = GetPrimaryUser(story); if (userId == null) { return(null); } var user = TEApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.HasErrors()) { return(null); } return(string.Format(_translation.GetLanguageResourceValue("activity_preview_format"), user.DisplayName, TEApi.Html.EncodeAttribute(user.ProfileUrl), poll.Name, TEApi.Html.EncodeAttribute(InternalApi.PollingUrlService.PollUrl(poll.Id)) )); }
public int? GetPrimaryUser(IActivityStory story) { var user = story.Actors.FirstOrDefault(); if (user != null) { return user.UserId; } return null; }
public string GetViewHtml(IActivityStory story, Target target) { var poll = InternalApi.PollingService.GetPoll(story.ContentId.Value); if (poll == null) return _translation.GetLanguageResourceValue("activity_nopermission"); var userId = GetPrimaryUser(story); if (userId == null) return null; var user = TEApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.HasErrors()) return null; var group = TEApi.Groups.Get(poll.ApplicationId); if (group == null || group.HasErrors()) return _translation.GetLanguageResourceValue("activity_nopermission"); StringBuilder html = new StringBuilder(); html.Append(@"<div class=""activity-summary""> <a href="""); html.Append(TEApi.Html.EncodeAttribute(user.ProfileUrl)); html.Append(@""">"); html.Append(user.DisplayName); html.Append("</a>"); html.Append(_translation.GetLanguageResourceValue("activity_view_in")); html.Append(@"<a href="""); html.Append(TEApi.Html.EncodeAttribute(group.Url)); html.Append(@"""><span></span>"); html.Append(group.Name); html.Append(@"</a>"); html.Append(string.Format(_translation.GetLanguageResourceValue("activity_view_withvotesformat"), TEApi.Language.FormatNumber(poll.Answers.Sum(x => x.VoteCount)))); html.Append(@" </div> <span class=""activity-title""> <a href="""); html.Append(TEApi.Html.EncodeAttribute(InternalApi.PollingUrlService.PollUrl(poll.Id))); html.Append(@""" class=""internal-link view-poll"" title="""); html.Append(poll.Name); html.Append(@""">"); html.Append(poll.Name); html.Append(@"</a> </span> <div class=""activity-description"">"); html.Append(PublicApi.Polls.UI(poll.Id, false, false)); html.Append(@" </div>"); return html.ToString(); }
public int? GetPrimaryUser(IActivityStory story) { return story.Actors.Where(x => x.Verb == "Add").Select(x => (int?) x.UserId).FirstOrDefault(); }
public string GetPreviewHtml(IActivityStory story, Target target) { var poll = InternalApi.PollingService.GetPoll(story.ContentId.Value); if (poll == null) return _translation.GetLanguageResourceValue("activity_nopermission"); var userId = GetPrimaryUser(story); if (userId == null) return null; var user = TEApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.HasErrors()) return null; return string.Format(_translation.GetLanguageResourceValue("activity_preview_format"), user.DisplayName, TEApi.Html.EncodeAttribute(user.ProfileUrl), poll.Name, TEApi.Html.EncodeAttribute(InternalApi.PollingUrlService.PollUrl(poll.Id)) ); }
public string GetViewHtml(IActivityStory story, Target target) { return RenderActivity(story); }
public string GetViewHtml(IActivityStory story, Target target) { var poll = InternalApi.PollingService.GetPoll(story.ContentId.Value); if (poll == null) { return(_translation.GetLanguageResourceValue("activity_nopermission")); } var userId = GetPrimaryUser(story); if (userId == null) { return(null); } var user = TEApi.Users.Get(new UsersGetOptions { Id = userId }); if (user == null || user.HasErrors()) { return(null); } var group = TEApi.Groups.Get(poll.ApplicationId); if (group == null || group.HasErrors()) { return(_translation.GetLanguageResourceValue("activity_nopermission")); } StringBuilder html = new StringBuilder(); html.Append(@"<div class=""activity-summary""> <a href=""" ); html.Append(TEApi.Html.EncodeAttribute(user.ProfileUrl)); html.Append(@""">"); html.Append(user.DisplayName); html.Append("</a>"); html.Append(_translation.GetLanguageResourceValue("activity_view_in")); html.Append(@"<a href="""); html.Append(TEApi.Html.EncodeAttribute(group.Url)); html.Append(@"""><span></span>"); html.Append(group.Name); html.Append(@"</a>"); html.Append(string.Format(_translation.GetLanguageResourceValue("activity_view_withvotesformat"), TEApi.Language.FormatNumber(poll.Answers.Sum(x => x.VoteCount)))); html.Append(@" </div> <span class=""activity-title""> <a href=""" ); html.Append(TEApi.Html.EncodeAttribute(InternalApi.PollingUrlService.PollUrl(poll.Id))); html.Append(@""" class=""internal-link view-poll"" title="""); html.Append(poll.Name); html.Append(@""">"); html.Append(poll.Name); html.Append(@"</a> </span> <div class=""activity-description"">"); html.Append(PublicApi.Polls.UI(poll.Id, false, false)); html.Append(@" </div>"); return(html.ToString()); }
public int?GetPrimaryUser(IActivityStory story) { return(story.Actors.Where(x => x.Verb == "Add").Select(x => (int?)x.UserId).FirstOrDefault()); }