Example #1
0
        // KR - added caching
        public string CheckForumIdsForView(string ForumIds, string UserRoles)
        {
            string    cacheKey = string.Format("AF-Perm-{0}", ForumIds);
            string    sSQL     = "SELECT f.ForumId, ISNULL(CanView,'') as CanView from " + dbPrefix + "Permissions as P INNER JOIN " + dbPrefix + "Forums as f on f.PermissionsID = P.PermissionsId  INNER JOIN " + dbPrefix + "Functions_Split('" + ForumIds + "',':') as ids on ids.id = f.ForumId";
            string    sForums  = string.Empty;
            DataTable dt       = null;

            object data = DataCache.CacheRetrieve(cacheKey);

            if (data != null)
            {
                dt = (DataTable)data;
            }
            else
            {
                dt = DotNetNuke.Common.Globals.ConvertDataReaderToDataTable(SqlHelper.ExecuteReader(_connectionString, CommandType.Text, sSQL));
                DataCache.CacheStore(cacheKey, dt);
            }

            foreach (DataRow row in dt.Rows)
            {
                string canView = row["CanView"].ToString();
                if (Permissions.HasPerm(canView, UserRoles))
                {
                    sForums += row["ForumId"].ToString() + ":";
                }
            }

            return(sForums);
        }
Example #2
0
        private string ParseTemplate()
        {
            string sOut = DisplayTemplate;

            DataCache.CacheStore(InstanceId + "qr", sOut);
            return(sOut);
        }
Example #3
0
        private string ParseTemplate()
        {
            string sOut = DisplayTemplate;

            //sOut = ParseForumData(sOut)
            sOut = ParseTopicControls(sOut);
            sOut = sOut.Replace("[AF:CONTROL:CALLBACK]", string.Empty);
            sOut = sOut.Replace("[/AF:CONTROL:CALLBACK]", string.Empty);

            DataCache.CacheStore(ControlConfig.InstanceId + CurrentView, sOut);
            return(sOut);
        }
Example #4
0
        private string ParseTemplate()
        {
            string tb = DisplayTemplate; //Utilities.ParseToolBar(DisplayTemplate, PageId, InstanceId, UserId, CurrentUserTypes.Admin)

            //tb = tb.Replace
            tb = tb.Replace("[AF:TB:Unanswered]", "<af:link id=\"lnkUnanswered\" NavigateUrl=\"" + Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ViewType + "=grid", "afgt=unanswered" }) + "\" text=\"[RESX:Unanswered]\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:ActiveTopics]", "<af:link id=\"lnkActive\" NavigateURL=\"" + Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ViewType + "=grid", "afgt=activetopics" }) + "\" text=\"[RESX:ActiveTopics]\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:Search]", "<af:link id=\"lnkSearch\" NavigateUrl=\"" + Utilities.NavigateUrl(PageId, "", ParamKeys.ViewType + "=search") + "\" text=\"[RESX:Search]\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:Forums]", "<af:link id=\"lnkForums\" navigateUrl=\"" + Utilities.NavigateUrl(PageId) + "\" text=\"[RESX:FORUMS]\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:NotRead]", "<af:link id=\"lnkNotRead\" NavigateUrl=\"" + Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ViewType + "=grid", "afgt=notread" }) + "\" text=\"[RESX:NotRead]\" AuthRequired=\"True\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:MyTopics]", "<af:link id=\"lnkMyTopics\" NavigateUrl=\"" + Utilities.NavigateUrl(PageId, "", new string[] { ParamKeys.ViewType + "=grid", "afgt=mytopics" }) + "\" text=\"[RESX:MyTopics]\" AuthRequired=\"True\" runat=\"server\" />");
            tb = tb.Replace("[AF:TB:MyProfile]", string.Empty);
            tb = tb.Replace("[AF:TB:MemberList]", string.Empty);
            tb = tb.Replace("[AF:TB:MySettings]", string.Empty);
            tb = tb.Replace("[AF:TB:ControlPanel]", "<af:link id=\"lnkControlPanel\" NavigateUrl=\"" + Utilities.NavigateUrl(PageId, "EDIT", "mid=" + ControlConfig.InstanceId) + "\" EnabledRoles=\"" + ControlConfig.AdminRoles + "\" Text=\"[RESX:ControlPanel]\" runat=\"server\" />");
            //TODO: Check for moderator
            tb = tb.Replace("[AF:TB:ModList]", string.Empty);
            DataCache.CacheStore(ControlConfig.InstanceId + "aftb", tb);
            return(tb);
        }
Example #5
0
        public Permissions GetForumPermissions(int forumId)
        {
            var cacheKey = string.Format("aftfp:{0}", forumId);

            var result = DataCache.CacheRetrieve(cacheKey) as Permissions;

            if (result == null)
            {
                using (var ctx = DataContext.Instance())
                {
                    result = ctx.ExecuteSingleOrDefault <Permissions>(CommandType.StoredProcedure, "{databaseOwner}{objectQualifier}activeforumstapatalk_Forum_Permissions", forumId);
                }

                if (result != null)
                {
                    DataCache.CacheStore(cacheKey, result, DateTime.Now.AddMinutes(5));
                }
            }

            return(result);
        }
Example #6
0
        protected override void Render(HtmlTextWriter writer)
        {
            if (RequestTabID == DefaultTabID || RequestModuleID == DefaultModuleID || !Settings.RSSEnabled)
            {
                return;
            }

            // Attempt to load from cache if it's enabled
            var rss = (Settings.RSSCacheTimeout > 0) ? DataCache.CacheRetrieve(CacheKey) as string : null;

            // Build the RSS if needed
            rss = rss ?? BuildRSS();

            // Save the rss to cache if it's enabled
            if (Settings.RSSCacheTimeout > 0)
            {
                DataCache.CacheStore(CacheKey, rss);
            }

            // Render the output
            writer.Write(rss);
            base.Render(writer);
        }
        public ForumCollection Forums_List(int PortalId, int ModuleId)
        {
            ForumCollection f   = new ForumCollection();
            object          obj = DataCache.CacheRetrieve(string.Format(CacheKeys.ForumList, ModuleId));

            if (obj != null)
            {
                f = (ForumCollection)obj;
            }
            else
            {
                using (IDataReader dr = SqlHelper.ExecuteReader(_connectionString, dbPrefix + "ForumsList", PortalId, ModuleId))
                {
                    Forum          fi = null;
                    ForumGroupInfo gi = null;
                    while (dr.Read())
                    {
                        fi               = new Forum();
                        gi               = new ForumGroupInfo();
                        fi.ModuleId      = int.Parse(dr["ModuleId"].ToString());
                        fi.ForumID       = Convert.ToInt32(dr["ForumId"].ToString());
                        fi.Active        = bool.Parse(dr["Active"].ToString());
                        fi.ForumDesc     = dr["ForumDesc"].ToString();
                        fi.ForumGroupId  = int.Parse(dr["ForumGroupId"].ToString());
                        fi.ForumID       = int.Parse(dr["ForumId"].ToString());
                        fi.ForumName     = dr["ForumName"].ToString();
                        fi.GroupName     = dr["GroupName"].ToString();
                        fi.Hidden        = bool.Parse(dr["Hidden"].ToString());
                        fi.ParentForumId = Convert.ToInt32(dr["ParentForumId"].ToString());
                        DateTime postTime;
                        if (!(DateTime.TryParse(dr["LastPostDate"].ToString(), out postTime)))
                        {
                            fi.LastPostDateTime = new DateTime();
                        }
                        else
                        {
                            fi.LastPostDateTime = postTime;
                        }

                        fi.LastTopicId         = int.Parse(dr["LastTopicId"].ToString());
                        fi.LastReplyId         = int.Parse(dr["LastReplyId"].ToString());
                        fi.LastPostSubject     = dr["LastPostSubject"].ToString();
                        fi.LastPostDisplayName = dr["LastPostAuthorName"].ToString();
                        fi.LastPostUserID      = int.Parse(dr["LastPostAuthorId"].ToString());
                        fi.LastPostUserName    = fi.LastPostDisplayName;
                        fi.LastRead            = DateTime.Parse(dr["LastRead"].ToString());
                        gi.Active       = bool.Parse(dr["GroupActive"].ToString());
                        gi.Hidden       = bool.Parse(dr["GroupHidden"].ToString());
                        gi.GroupName    = fi.GroupName;
                        gi.ForumGroupId = fi.ForumGroupId;
                        gi.PrefixURL    = dr["GroupPrefixURL"].ToString();
                        //gi.SEO = dr("GroupSEO").ToString
                        fi.ForumGroup          = gi;
                        fi.Security.Announce   = dr["CanAnnounce"].ToString();
                        fi.Security.Attach     = dr["CanAttach"].ToString();
                        fi.Security.Create     = dr["CanCreate"].ToString();
                        fi.Security.Delete     = dr["CanDelete"].ToString();
                        fi.Security.Edit       = dr["CanEdit"].ToString();
                        fi.Security.Lock       = dr["CanLock"].ToString();
                        fi.Security.ModApprove = dr["CanModApprove"].ToString();
                        fi.Security.ModDelete  = dr["CanModDelete"].ToString();
                        fi.Security.ModEdit    = dr["CanModEdit"].ToString();
                        fi.Security.ModLock    = dr["CanModLock"].ToString();
                        fi.Security.ModMove    = dr["CanModMove"].ToString();
                        fi.Security.ModPin     = dr["CanModPin"].ToString();
                        fi.Security.ModSplit   = dr["CanModSplit"].ToString();
                        fi.Security.ModUser    = dr["CanModUser"].ToString();
                        fi.Security.Pin        = dr["CanPin"].ToString();
                        fi.Security.Poll       = dr["CanPoll"].ToString();
                        fi.Security.Block      = dr["CanBlock"].ToString();
                        fi.Security.Read       = dr["CanRead"].ToString();
                        fi.Security.Reply      = dr["CanReply"].ToString();
                        fi.Security.Subscribe  = dr["CanSubscribe"].ToString();
                        fi.Security.Trust      = dr["CanTrust"].ToString();
                        fi.Security.View       = dr["CanView"].ToString();
                        fi.ForumSettings       = LoadSettings(dr);
                        fi.PrefixURL           = dr["PrefixURL"].ToString();
                        //.SEO = dr("ForumSEO").ToString
                        fi.TotalTopics  = int.Parse(dr["TotalTopics"].ToString());
                        fi.TotalReplies = int.Parse(dr["TotalReplies"].ToString());
                        f.Add(fi);
                    }
                    dr.Close();
                }

                DataCache.CacheStore(string.Format(CacheKeys.ForumList, ModuleId), f);
            }
            return(f);
        }
        public XmlDocument ForumListXML(int SiteId, int InstanceId)
        {
            XmlDocument xDoc = new XmlDocument();
            object      obj  = DataCache.CacheRetrieve(InstanceId + "fv");

            if (obj == null)
            {
                Data.ForumsDB   db = new Data.ForumsDB();
                ForumCollection fc = db.Forums_List(SiteId, InstanceId);
                //Dim ds As DataSet = SqlHelper.ExecuteDataset(connectionString, databaseOwner & objectQualifier & "activeforums_UI_ForumDisplay", SiteId, InstanceId, UserId, -1, ForumIds)
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<?xml version=\"1.0\" encoding=\"utf-8\" ?>");
                sb.AppendLine();
                sb.Append("<root>");
                sb.AppendLine();
                int groupId = -1;
                System.Text.StringBuilder groups = new System.Text.StringBuilder();
                System.Text.StringBuilder forums = new System.Text.StringBuilder();
                foreach (Forum f in fc)
                {
                    if (groupId != f.ForumGroupId)
                    {
                        groups.Append("<group groupid=\"" + f.ForumGroupId.ToString() + "\" active=\"" + f.ForumGroup.Active.ToString().ToLowerInvariant() + "\" hidden=\"" + f.ForumGroup.Hidden.ToString().ToLowerInvariant() + "\">");
                        groups.Append("<name><![CDATA[" + f.GroupName.ToString() + "]]></name>");
                        //If Not String.IsNullOrEmpty(f.ForumGroup.SEO) Then
                        //    groups.Append(f.ForumGroup.SEO)
                        //End If
                        groups.Append("</group>");
                        sb.AppendLine();
                        groupId = f.ForumGroupId;
                    }
                }
                sb.Append("<groups>");
                sb.AppendLine();
                sb.Append(groups.ToString());
                sb.Append("</groups>");
                sb.AppendLine();
                foreach (Forum f in fc)
                {
                    forums.Append("<forum groupid=\"" + f.ForumGroupId.ToString() + "\" forumid=\"" + f.ForumID.ToString() + "\"");
                    //forums.Append(" name=""" & HttpUtility.UrlEncode(f.ForumName) & """")
                    //forums.Append(" desc=""" & HttpUtility.UrlEncode(Utilities.HTMLEncode(f.ForumDesc.ToString)) & """")
                    forums.Append(" active=\"" + f.Active.ToString().ToLowerInvariant() + "\"");
                    forums.Append(" hidden=\"" + f.Hidden.ToString().ToLowerInvariant() + "\"");
                    forums.Append(" totaltopics=\"" + f.TotalTopics.ToString() + "\"");
                    forums.Append(" totalreplies=\"" + f.TotalReplies.ToString() + "\"");
                    forums.Append(" lasttopicid=\"" + f.LastTopicId.ToString() + "\"");
                    forums.Append(" lastreplyid=\"" + f.LastReplyId.ToString() + "\"");
                    //forums.Append(" lastpostsubject=""" & f.LastPostSubject & """")
                    //forums.Append(" lastpostauthorname=""" & f.LastPostDisplayName & """")
                    forums.Append(" lastpostauthorid=\"" + f.LastPostUserID + "\"");
                    forums.Append(" lastpostdate=\"" + f.LastPostDateTime.ToString() + "\"");
                    forums.Append(" lastread=\"" + f.LastRead.ToString() + "\"");
                    forums.Append(" allowrss=\"" + f.ForumSettings["ALLOWRSS"].ToString() + "\"");
                    forums.Append(" parentforumid=\"" + f.ParentForumId.ToString() + "\"");
                    forums.Append(" viewroles=\"" + f.Security.View.ToString() + "\"");
                    forums.Append(" readroles=\"" + f.Security.Read.ToString() + "\"");
                    forums.Append(" replyroles=\"" + f.Security.Reply.ToString() + "\"");
                    forums.Append(" modroles=\"" + f.Security.ModApprove.ToString() + "\"");
                    forums.Append(" modmove=\"" + f.Security.ModMove.ToString() + "\"");
                    forums.Append(">");
                    forums.Append("<name><![CDATA[" + f.ForumName + "]]></name>");
                    forums.Append("<description><![CDATA[" + f.ForumDesc + "]]></description>");
                    forums.Append("<security>");
                    forums.Append("<view>" + f.Security.View + "</view>");
                    forums.Append("<read>" + f.Security.Read + "</read>");
                    forums.Append("<create>" + f.Security.Create + "</create>");
                    forums.Append("<reply>" + f.Security.Reply + "</reply>");
                    forums.Append("<edit>" + f.Security.Edit + "</edit>");
                    forums.Append("<delete>" + f.Security.Delete + "</delete>");
                    forums.Append("<lock>" + f.Security.Lock + "</lock>");
                    forums.Append("<pin>" + f.Security.Pin + "</pin>");
                    forums.Append("<modapprove>" + f.Security.ModApprove + "</modapprove>");
                    forums.Append("<modedit>" + f.Security.ModEdit + "</modedit>");
                    forums.Append("<moddelete>" + f.Security.ModDelete + "</moddelete>");
                    forums.Append("<modlock>" + f.Security.ModLock + "</modlock>");
                    forums.Append("<modpin>" + f.Security.ModPin + "</modpin>");
                    forums.Append("<modmove>" + f.Security.ModMove + "</modmove>");
                    forums.Append("</security>");
                    //If Not String.IsNullOrEmpty(f.SEO) Then
                    //    forums.Append(f.SEO)
                    //End If

                    forums.Append("</forum>");
                    sb.AppendLine();
                }
                sb.Append("<forums>");
                sb.AppendLine();
                sb.Append(forums.ToString());
                sb.Append("</forums>");
                sb.AppendLine();
                sb.Append("<topics />");
                sb.AppendLine();
                sb.Append("<replies />");
                sb.AppendLine();
                sb.Append("</root>");
                sb.AppendLine();


                //Dim sXML As String = ds.GetXml()
                xDoc.LoadXml(sb.ToString());
                DataCache.CacheStore(InstanceId + "fv", xDoc);
            }
            else
            {
                xDoc = (XmlDocument)obj;
            }
            //Logger.Log(xDoc.OuterXml)
            return(xDoc);
        }
Example #9
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            AppRelativeVirtualPath = "~/";

            try
            {
                if (CurrentUserId == -1)
                {
                    CurrentUserId = UserId;
                }
                string sOutput = string.Empty;
                try
                {
                    int defaultTemplateId = MainSettings.ForumTemplateID;
                    if (DefaultForumViewTemplateId >= 0)
                    {
                        defaultTemplateId = DefaultForumViewTemplateId;
                    }
                    sOutput = BuildForumView(defaultTemplateId, CurrentUserId, Page.ResolveUrl("~/DesktopModules/ActiveForums/themes/" + MainSettings.Theme + "/"));
                }
                catch (Exception ex)
                {
                    //sOutput = ex.Message
                    //DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(Me, ex)
                }

                if (sOutput != string.Empty)
                {
                    try
                    {
                        if (sOutput.Contains("[TOOLBAR"))
                        {
                            var    lit      = new LiteralControl();
                            object sToolbar = null; //DataCache.CacheRetrieve("aftb" & ModuleId)
                            sToolbar = Utilities.GetFileContent(SettingKeys.TemplatePath + "ToolBar.txt");
                            DataCache.CacheStore("aftb" + ModuleId, sToolbar);
                            sToolbar = Utilities.ParseToolBar(sToolbar.ToString(), TabId, ModuleId, UserId, CurrentUserType);
                            lit.Text = sToolbar.ToString();
                            sOutput  = sOutput.Replace("[TOOLBAR]", sToolbar.ToString());
                        }
                        Control tmpCtl = null;
                        try
                        {
                            tmpCtl = ParseControl(sOutput);
                        }
                        catch (Exception ex)
                        {
                        }
                        if (tmpCtl != null)
                        {
                            try
                            {
                                Controls.Add(tmpCtl);
                                LinkControls(Controls);
                                if (!SubsOnly)
                                {
                                    var plh = (PlaceHolder)(tmpCtl.FindControl("plhQuickJump"));
                                    if (plh != null)
                                    {
                                        ctlForumJump = new af_quickjump {
                                            MOID = ModuleId, dtForums = ForumTable, ModuleId = ModuleId
                                        };
                                        plh.Controls.Add(ctlForumJump);
                                    }
                                    plh = (PlaceHolder)(tmpCtl.FindControl("plhUsersOnline"));
                                    if (plh != null)
                                    {
                                        ForumBase ctlWhosOnline;
                                        ctlWhosOnline = (ForumBase)(LoadControl("~/Desktopmodules/ActiveForums/controls/af_usersonline.ascx"));
                                        ctlWhosOnline.ModuleConfiguration = ModuleConfiguration;
                                        plh.Controls.Add(ctlWhosOnline);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
                    }
                }
            }
            catch (Exception ex)
            {
                Services.Exceptions.Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Example #10
0
        private string ParseTemplate()
        {
            SettingsInfo MainSettings = DataCache.MainSettings(ControlConfig.InstanceId);
            string       sOut         = DisplayTemplate;
            //sOut = ParseForumData(sOut)
            string sort = SortColumns.ReplyCreated;

            if (sOut.Contains("[AF:SORT:TOPICCREATED]"))
            {
                sort = SortColumns.TopicCreated;
                sOut = sOut.Replace("[AF:SORT:TOPICCREATED]", string.Empty);
            }
            int    Replies           = 0;
            int    Views             = 0;
            string Subject           = string.Empty;
            string summary           = string.Empty;
            string body              = string.Empty;
            int    replyCount        = 0;
            int    viewCount         = 0;
            int    topicid           = 0;
            string topicIcon         = string.Empty;
            int    UserLastTopicRead = 0;
            int    UserLastReplyRead = 0;
            int    topicRating       = 0;
            int    LastReplyId       = 0;
            bool   isLocked          = false;
            bool   isPinned          = false;
            int    AuthorId          = -1;
            string AuthorName        = string.Empty;
            string AuthorFirstName   = string.Empty;
            string AuthorLastName    = string.Empty;
            string AuthorUserName    = string.Empty;
            string AuthorDisplayName = string.Empty;
            string LastPostData      = string.Empty;

            System.DateTime LastPostDate = default(System.DateTime);
            System.DateTime DateCreated  = default(System.DateTime);
            string          sTopicURL    = string.Empty;
            string          sBodyTitle   = string.Empty;
            int             statusId     = -1;
            bool            isAnnounce   = false;

            System.DateTime AnnounceStart = default(System.DateTime);
            System.DateTime AnnounceEnd   = default(System.DateTime);
            int             topicType     = 0;
            Author          la            = null;
            string          ModApprove    = string.Empty;
            string          ModDelete     = string.Empty;
            string          ModEdit       = string.Empty;
            string          ModPin        = string.Empty;
            string          ModLock       = string.Empty;
            string          ModMove       = string.Empty;
            string          ModSplit      = string.Empty;
            string          Reply         = string.Empty;
            string          Lock          = string.Empty;
            string          Pin           = string.Empty;
            string          Delete        = string.Empty;
            string          Edit          = string.Empty;
            string          groupName     = string.Empty;
            //Dim t As New Data.Topics
            string topics = TemplateUtils.GetTemplateSection(sOut, "[TOPICS]", "[/TOPICS]");

            System.Text.StringBuilder sb      = new System.Text.StringBuilder();
            System.Xml.XmlNodeList    xTopics = null;

            xTopics = topicsData.SelectNodes("//topics/topic");
            int rowCount = 0;

            foreach (System.Xml.XmlNode xNode in xTopics)
            {
                string ForumName = string.Empty;

                ForumId   = int.Parse(xNode.Attributes["forumid"].Value.ToString());
                ForumName = xNode["forumname"].InnerText;
                groupName = xNode["groupname"].InnerText;

                topicid       = int.Parse(xNode.Attributes["topicid"].Value.ToString());
                LastReplyId   = int.Parse(xNode.Attributes["lastreplyid"].Value.ToString());
                viewCount     = int.Parse(xNode.Attributes["viewcount"].Value.ToString());
                replyCount    = int.Parse(xNode.Attributes["replycount"].Value.ToString());
                isLocked      = bool.Parse(xNode.Attributes["islocked"].Value.ToString());
                isPinned      = bool.Parse(xNode.Attributes["ispinned"].Value.ToString());
                topicIcon     = xNode.Attributes["topicicon"].Value.ToString();
                statusId      = int.Parse(xNode.Attributes["statusid"].Value.ToString());
                isAnnounce    = bool.Parse(xNode.Attributes["isannounce"].Value.ToString());
                AnnounceStart = Convert.ToDateTime(xNode.Attributes["announcestart"].Value.ToString());
                AnnounceEnd   = Convert.ToDateTime(xNode.Attributes["announceend"].Value.ToString());
                topicType     = int.Parse(xNode.Attributes["topictype"].Value.ToString());
                AuthorId      = int.Parse(xNode.Attributes["authorid"].Value.ToString());
                DateCreated   = Convert.ToDateTime(xNode.Attributes["datecreated"].Value.ToString());
                if (!string.IsNullOrEmpty(xNode.Attributes["lastpostdate"].Value.ToString()))
                {
                    LastPostDate = Convert.ToDateTime(xNode.Attributes["lastpostdate"].Value.ToString());
                }
                else
                {
                    LastPostDate = DateCreated;
                }
                UserLastReplyRead = int.Parse(xNode.Attributes["userlastreplyread"].Value.ToString());
                UserLastTopicRead = int.Parse(xNode.Attributes["userlasttopicread"].Value.ToString());
                topicRating       = int.Parse(xNode.Attributes["topicrating"].Value.ToString());
                Subject           = xNode["subject"].InnerText;
                Subject           = Utilities.StripHTMLTag(Subject);
                Subject           = Subject.Replace("&#91;", "[");
                Subject           = Subject.Replace("&#93;", "]");
                summary           = xNode["summary"].InnerText;
                body              = xNode["body"].InnerText;
                AuthorName        = xNode["authorname"].InnerText;
                AuthorUserName    = xNode["username"].InnerText;
                AuthorFirstName   = xNode["firstname"].InnerText;
                AuthorLastName    = xNode["lastname"].InnerText;
                AuthorDisplayName = xNode["displayname"].InnerText;
                XmlNode secNode = xNode["security"];
                ModApprove = secNode["modapprove"].InnerText;
                ModDelete  = secNode["moddelete"].InnerText;
                ModEdit    = secNode["modedit"].InnerText;
                ModPin     = secNode["modpin"].InnerText;
                ModLock    = secNode["modlock"].InnerText;
                ModMove    = secNode["modmove"].InnerText;
                Reply      = secNode["reply"].InnerText;
                Lock       = secNode["lock"].InnerText;
                Pin        = secNode["pin"].InnerText;
                Delete     = secNode["delete"].InnerText;
                Edit       = secNode["edit"].InnerText;
                if ((xNode["lastpost"] != null))
                {
                    LastPostData = xNode["lastpost"].OuterXml;
                }
                else
                {
                    LastPostData = string.Empty;
                }

                if (!string.IsNullOrEmpty(LastPostData))
                {
                    la = new Author();
                    System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
                    xDoc.LoadXml(LastPostData);
                    System.Xml.XmlNode xLast = xDoc.SelectSingleNode("//lastpost");
                    if ((xLast != null))
                    {
                        var _with1 = la;
                        _with1.AuthorId    = int.Parse(xLast["authorid"].InnerText.ToString());
                        _with1.DisplayName = xLast["displayname"].InnerText;
                        _with1.FirstName   = xLast["firstname"].InnerText;
                        _with1.LastName    = xLast["lastname"].InnerText;
                        _with1.Username    = xLast["username"].InnerText;
                    }
                }
                int    BodyLength = -1;
                string BodyTrim   = "";
                sTopicURL = URL.ForTopic(TabId, PortalId, ForumId, topicid, groupName, ForumName, Subject, 1);
                string tmp       = topics;
                string sLastPost = TemplateUtils.GetTemplateSection(tmp, "[LASTPOST]", "[/LASTPOST]");
                if ((la != null))
                {
                    sLastPost = sLastPost.Replace("[LASTPOSTDISPLAYNAME]", UserProfiles.GetDisplayName(ModuleId, ProfileVisibility, false, la.AuthorId, UserNameDisplay, DisableUserProfiles, la));
                    sLastPost = sLastPost.Replace("[AF:PROFILE:AVATAR]", UserProfiles.GetAvatar(la.AuthorId, PortalId, ThemePath, MainSettings.Theme, string.Empty, 0, MainSettings.AvatarWidth, MainSettings.ProfileType, MainSettings.AvatarDefault));

                    sLastPost = sLastPost.Replace("[LASTPOSTDATE]", Utilities.GetDate(LastPostDate, ModuleId));
                    if (bRead)
                    {
                        //TODO: Replace with link
                        sLastPost = sLastPost.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty);
                    }
                    else
                    {
                        sLastPost = sLastPost.Replace("[AF:ICONLINK:LASTREPLY]", string.Empty);
                    }
                    tmp = TemplateUtils.ReplaceSubSection(tmp, sLastPost, "[LASTPOST]", "[/LASTPOST]");
                }
                else
                {
                    tmp = TemplateUtils.ReplaceSubSection(tmp, string.Empty, "[LASTPOST]", "[/LASTPOST]");
                }

                //Dim sLastReplyURL As String = NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & topicid, ParamKeys.ViewType & "=topic", ParamKeys.ContentJumpId & "=" & LastReplyId})
                string sLastReadURL = string.Empty;
                string sUserJumpUrl = string.Empty;
                //If UserLastReplyRead > 0 Then
                //sLastReadURL = NavigateUrl(TabId, "", New String() {ParamKeys.ForumId & "=" & ForumId, ParamKeys.TopicId & "=" & topicid, ParamKeys.ViewType & "=topic", ParamKeys.FirstNewPost & "=" & UserLastReplyRead})
                //End If

                //If UserPrefJumpLastPost And sLastReadURL <> String.Empty Then
                //    '   sTopicURL = sLastReadURL
                //    sUserJumpUrl = sLastReadURL
                //End If
                if (tmp.Contains("[BODY:"))
                {
                    int    inStart = Strings.InStr(tmp, "[BODY:") + 5;
                    int    inEnd   = Strings.InStr(inStart, tmp, "]") - 1;
                    string sLength = tmp.Substring(inStart, inEnd - inStart);
                    BodyLength = Convert.ToInt32(sLength);
                    BodyTrim   = "[BODY:" + BodyLength.ToString() + "]";
                }
                if (!(BodyTrim == string.Empty))
                {
                    string BodyPlain = body.Replace("<br>", Constants.vbCrLf);
                    BodyPlain = BodyPlain.Replace("<br />", Constants.vbCrLf);
                    BodyPlain = Utilities.StripHTMLTag(BodyPlain);
                    if (BodyLength > 0 & BodyPlain.Length > BodyLength)
                    {
                        BodyPlain = BodyPlain.Substring(0, BodyLength);
                    }
                    BodyPlain = BodyPlain.Replace(Constants.vbCrLf, "<br />");
                    tmp       = tmp.Replace(BodyTrim, BodyPlain);
                }
                if (isLocked)
                {
                    tmp = tmp.Replace("[RESX:LockTopic]", "[RESX:UnLockTopic]");
                    tmp = tmp.Replace("[RESX:Confirm:Lock]", "[RESX:Confirm:UnLock]");
                }
                if (isPinned)
                {
                    tmp = tmp.Replace("[RESX:PinTopic]", "[RESX:UnPinTopic]");
                    tmp = tmp.Replace("[RESX:Confirm:Pin]", "[RESX:Confirm:UnPin]");
                }
                tmp = tmp.Replace("[BODY]", GetBody(body, AuthorId));
                tmp = tmp.Replace("[BODYTITLE]", GetTitle(body, AuthorId));
                tmp = tmp.Replace("[AUTHORID]", AuthorId.ToString());
                tmp = tmp.Replace("[USERID]", UserId.ToString);
                if (string.IsNullOrEmpty(Subject))
                {
                    Subject = "(no subject)";
                }
                string LastSubject = Subject;
                if (LastReplyId > 0)
                {
                    LastSubject = "[RESX:RE]" + LastSubject;
                }

                tmp = tmp.Replace("[SUBJECT]", Subject);
                string sSubjectLink    = GetTopic(topicid, Subject, sBodyTitle, UserId, AuthorId, replyCount, -1, sUserJumpUrl, groupName, ForumName);
                string lastSubjectLink = GetTopic(topicid, Subject, string.Empty, UserId, AuthorId, replyCount, -1, sUserJumpUrl, groupName, ForumName);
                tmp = tmp.Replace("[SUBJECTLINK]", sSubjectLink);
                tmp = tmp.Replace("[THEMEPATH]", ThemePath);
                tmp = tmp.Replace("[TOPICID]", topicid.ToString());
                tmp = tmp.Replace("[MODEDIT]", string.Empty);
                tmp = tmp.Replace("[MODDELETE]", string.Empty);
                tmp = tmp.Replace("[MODMOVE]", string.Empty);
                tmp = tmp.Replace("[MODLOCK]", string.Empty);
                tmp = tmp.Replace("[MODPIN]", string.Empty);
                tmp = tmp.Replace("[REPLIES]", replyCount.ToString());
                tmp = tmp.Replace("[VIEWS]", viewCount.ToString());
                tmp = tmp.Replace("[POSTICONIMAGE]", GetIcon(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, topicIcon, isPinned, isLocked));

                tmp = tmp.Replace("[POSTICONCSS]", GetIconCSS(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, topicIcon, isPinned, isLocked));
                if (tmp.Contains("[STATUSCSS]"))
                {
                    string sImg = string.Empty;
                    if (statusId == -1)
                    {
                        tmp = tmp.Replace("[STATUSCSS]", string.Empty);
                    }
                    else
                    {
                        sImg = "<span title=\"[RESX:PostStatus" + statusId.ToString() + "]\" class=\"afstatus afstatus" + statusId.ToString() + "\"></span>";
                    }
                    tmp = tmp.Replace("[STATUSCSS]", sImg);
                }
                tmp = tmp.Replace("[STARTEDBY]", UserProfiles.GetDisplayName(ModuleId, ProfileVisibility, false, AuthorId, UserNameDisplay, DisableUserProfiles, AuthorUserName, AuthorFirstName, AuthorLastName, AuthorDisplayName));
                tmp = tmp.Replace("[DATECREATED]", Utilities.GetDate(DateCreated, ModuleId));
                tmp = tmp.Replace("[TOPICURL]", sTopicURL);
                //TODO: Still need to process
                tmp = tmp.Replace("[AF:ICONLINK:LASTREAD]", string.Empty);
                tmp = tmp.Replace("[AF:URL:LASTREAD]", string.Empty);
                if (tmp.Contains("[STATUS]"))
                {
                    string sImg = string.Empty;
                    if (statusId == -1)
                    {
                        tmp = tmp.Replace("[STATUS]", string.Empty);
                    }
                    else
                    {
                        sImg = "<img alt=\"[RESX:PostStatus" + statusId.ToString() + "]\" src=\"" + Utilities.AppPath + "themes/images/status" + statusId.ToString() + ".png\" />";
                    }
                    tmp = tmp.Replace("[STATUS]", sImg);
                }


                //sTopicsTemplate = sTopicsTemplate.Replace("[AF:UI:MINIPAGER]", GetSubPages(TabId, ModuleId, ReplyCount, ForumId, TopicId))
                tmp = tmp.Replace("[AF:UI:MINIPAGER]", string.Empty);
                tmp = tmp.Replace("[POSTRATINGDISPLAY]", string.Empty);
                tmp = tmp.Replace("[TOPICRATING]", topicRating.ToString());
                tmp = tmp.Replace("[ROWCSS]", GetRowCSS(UserLastTopicRead, UserLastReplyRead, topicid, LastReplyId, rowCount));

                tmp = tmp.Replace("[AF:TOPIC:FRIENDLYDATE]", Utilities.HumanFriendlyDate(DateCreated, ModuleId));
                tmp = tmp.Replace("[AF:REPLY:FRIENDLYDATE]", Utilities.HumanFriendlyDate(LastPostDate, ModuleId));
                tmp = tmp.Replace("[AF:TOPIC:FORUMNAME]", ForumName);
                tmp = tmp.Replace("[AF:TOPIC:LASTSUBJECT:LINK]", lastSubjectLink);
                tmp = tmp.Replace("[AF:TOPIC:LASTSUBJECT]", LastSubject);
                tmp = tmp.Replace("[AF:TOPIC:FORUMNAME:LINK]", "<a href=\"" + URL.ForForum(PageId, ForumId, groupName[ForumId], ForumName) + "\" title=\"" + ForumName + "\">" + ForumName + "</a>");
                tmp = tmp.Replace("AF:SECURITY:MODROLES]", "AF:SECURITY:MODROLES:" + ModApprove + "]");
                tmp = tmp.Replace("AF:SECURITY:MODAPPROVE]", "AF:SECURITY:MODAPPROVE:" + ModApprove + "]");
                tmp = tmp.Replace("AF:SECURITY:DELETE]", "AF:SECURITY:DELETE:" + Delete + ModDelete + "]");
                tmp = tmp.Replace("AF:SECURITY:EDIT]", "AF:SECURITY:EDIT:" + Edit + ModEdit + "]");
                tmp = tmp.Replace("AF:SECURITY:LOCK]", "AF:SECURITY:LOCK:" + Lock + ModLock + "]");
                tmp = tmp.Replace("AF:SECURITY:MOVE]", "AF:SECURITY:MOVE:" + ModMove + "]");
                tmp = tmp.Replace("AF:SECURITY:PIN]", "AF:SECURITY:PIN:" + Pin + ModPin + "]");
                tmp = tmp.Replace("AF:SECURITY:SPLIT]", "AF:SECURITY:SPLIT:" + ModSplit + "]");
                tmp = tmp.Replace("AF:SECURITY:REPLY]", "AF:SECURITY:REPLY:" + Reply + "]");

                sb.Append(tmp);
                rowCount += 1;
            }

            sOut = TemplateUtils.ReplaceSubSection(sOut, sb.ToString(), "[TOPICS]", "[/TOPICS]");
            sOut = sOut.Replace("[TOPICS]", string.Empty);
            sOut = sOut.Replace("[/TOPICS]", string.Empty);

            DataCache.CacheStore(ModuleId + "topicsview", sOut);
            return(sOut);
        }