public GetForumPost ( int portalId, int moduleId, int contentId ) : |
||
portalId | int | |
moduleId | int | |
contentId | int | |
return |
private XmlRpcStruct GetQuote(string postIds) { var aftContext = ActiveForumsTapatalkModuleContext.Create(Context); if (aftContext == null || aftContext.Module == null) throw new XmlRpcFaultException(100, "Invalid Context"); Context.Response.AddHeader("Mobiquo_is_login", aftContext.UserId > 0 ? "true" : "false"); var portalId = aftContext.Module.PortalID; var forumModuleId = aftContext.ModuleSettings.ForumModuleId; var fc = new AFTForumController(); // Load our forum settings var mainSettings = new SettingsInfo { MainSettings = new Entities.Modules.ModuleController().GetModuleSettings(forumModuleId) }; // Get our quote template info var postedByTemplate = Utilities.GetSharedResource("[RESX:PostedBy]") + " {0} {1} {2}"; var sharedOnText = Utilities.GetSharedResource("On.Text"); var contentIds = postIds.Split('-').Select(int.Parse).ToList(); if (contentIds.Count > 25) // Let's be reasonable throw new XmlRpcFaultException(100, "Bad Request"); var postContent = new StringBuilder(); foreach (var contentId in contentIds) { // Retrieve the forum post var forumPost = fc.GetForumPost(portalId, forumModuleId, contentId); if (forumPost == null) throw new XmlRpcFaultException(100, "Bad Request"); // Verify read permissions - Need to do this for every content id as we can not assume they are all from the same forum (even though they probably should be) var fp = fc.GetForumPermissions(forumPost.ForumId); if (!ActiveForums.Permissions.HasPerm(aftContext.ForumUser.UserRoles, fp.CanRead)) continue; // Build our sanitized quote var postedBy = string.Format(postedByTemplate, GetAuthorName(mainSettings, forumPost), sharedOnText, GetServerDateTime(mainSettings, forumPost.DateCreated)); postContent.Append(HtmlToTapatalkQuote(postedBy, forumPost.Body)); postContent.Append("\r\n"); // add the result } return new XmlRpcStruct { {"post_id", postIds}, {"post_title", string.Empty.ToBytes()}, {"post_content", postContent.ToString().ToBytes()} }; }