Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Snitz Forums 2000 MOD-Group
 MOD Add-On Forum (W/O Code)
 Get number of Active Topics function.
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Dan Martin
Average Member

USA
528 Posts

Posted - 30 June 2002 :  17:36:03  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
In my inc_functions.asp, I've added a function using code from active.asp to get the number of active topics. It works, except that it shows the number regardless of whether the user has access to the post. If anyone knows how to accomplish that, or already has done it, please let me know. The idea is that my Active Topics link looks like "Active Topics (4)".

Here's the code I used:

function getActiveCount() 'Returns the number of Active Topics
dim lastDate
if IsEmpty(Session(strCookieURL & "last_here_date")) then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if
lastDate = Session(strCookieURL & "last_here_date")


dim strSql
dim rs_chk

if mlev = 3 then
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
" WHERE MEMBER_ID = " & getNewMemberNumber()

Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSql, my_Conn

if RsMod.EOF or RsMod.BOF then
' Do Nothing - User is not an active moderator
else
modcount = 0
ModOfForums = "("
do until RsMod.EOF
modcount = modcount + 1
if modcount > 1 then
ModOfForums = ModOfForums & ", "
end if
ModOfForums = ModOfForums & rsmod("FORUM_ID")
RsMod.MoveNext
loop
ModOfForums = ModOfForums & ")"
end if
RsMod.close
set RsMod = nothing
end if

'## Forum_SQL
strSql = "SELECT COUNT(*) as activeCount " &_
"FROM " & strMemberTablePrefix & "MEMBERS M, " &_
strTablePrefix & "FORUM F, " &_
strTablePrefix & "TOPICS T, " &_
strTablePrefix & "CATEGORY C, " &_
strMemberTablePrefix & "MEMBERS MEMBERS_1 " &_
"WHERE T.T_LAST_POST_AUTHOR = MEMBERS_1.MEMBER_ID " &_
"AND F.FORUM_ID = T.FORUM_ID " &_
"AND F.CAT_ID = T.CAT_ID " &_
"AND F.CAT_ID = C.CAT_ID " &_
"AND M.MEMBER_ID = T.T_AUTHOR " &_
"AND (T.T_LAST_POST > '" & lastDate & "'"

' DEM --> if not an admin, all unapproved posts should not be viewed.
if mlev <> 4 then
strSql = strSql & " AND ((T.T_AUTHOR <> " & MemberID &_
" AND T.T_STATUS < 2)" ' Ignore unapproved/held posts
if mlev = 3 and ModofForums <> "" then
strSql = strSql & " OR T.FORUM_ID IN " & ModOfForums
end if
strSql = strSql & " OR T.T_AUTHOR = " & MemberID & ")"
end if

strSql = strSql & ") "

Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
If NOT rs.EOF Then
getActiveCount = rs("activeCount")
End If
rs.close
set rs = nothing
end function


Thanks,
Dan

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 June 2002 :  18:06:41  Show Profile  Send ruirib a Yahoo! Message
Check inc_jump_to.asp. There is code there to show only the forums to which the user has access to. Maybe you can get some inspiration to help you with the current problem.

I've also seem the exact same feature in HuwR's and Crash's sites. You can try to download their forum's code and check on how they do it.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

blackinwhite
Average Member

Turkey
657 Posts

Posted - 30 June 2002 :  18:54:08  Show Profile
quote:

Check inc_jump_to.asp. There is code there to show only the forums to which the user has access to. Maybe you can get some inspiration to help you with the current problem.

I've also seem the exact same feature in HuwR's and Crash's sites. You can try to download their forum's code and check on how they do it.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs




Huwr's and Crash's codes use "Slash Mod" and it shows all the active topics regardless of user accesses.

Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 30 June 2002 :  19:05:20  Show Profile  Send ruirib a Yahoo! Message
quote:

Huwr's and Crash's codes use "Slash Mod" and it shows all the active topics regardless of user accesses.


Ok, I wasn't sure about that, thanks for the info.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 14 July 2002 :  20:47:23  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
I think I figured it out. In case anyone else wants to change their Active Topics to look like "Active Topics(4)", the function I ended up with is:

function getActiveCount()  'Returns the number of Active Topics
dim lastDate
if IsEmpty(Session(strCookieURL & "last_here_date")) then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if
lastDate = Session(strCookieURL & "last_here_date")


dim strSql
dim rs_chk

if mlev = 3 then
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
" WHERE MEMBER_ID = " & getNewMemberNumber()

Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSql, my_Conn

if RsMod.EOF or RsMod.BOF then
' Do Nothing - User is not an active moderator
else
modcount = 0
ModOfForums = "("
do until RsMod.EOF
modcount = modcount + 1
if modcount > 1 then
ModOfForums = ModOfForums & ", "
end if
ModOfForums = ModOfForums & rsmod("FORUM_ID")
RsMod.MoveNext
loop
ModOfForums = ModOfForums & ")"
end if
RsMod.close
set RsMod = nothing
end if

'## Forum_SQL
strSql = "SELECT COUNT(*) as activeCount " &_
"FROM " & strMemberTablePrefix & "MEMBERS M, " &_
strTablePrefix & "FORUM F, " &_
strTablePrefix & "TOPICS T, " &_
strTablePrefix & "CATEGORY C, " &_
strMemberTablePrefix & "MEMBERS MEMBERS_1 " &_
"WHERE T.T_LAST_POST_AUTHOR = MEMBERS_1.MEMBER_ID " &_
"AND F.FORUM_ID = T.FORUM_ID " &_
"AND F.CAT_ID = T.CAT_ID " &_
"AND F.CAT_ID = C.CAT_ID " &_
"AND M.MEMBER_ID = T.T_AUTHOR "
if mlev < 4 then
'Limit to FORUMS that the user has access to.
forumSQL = "SELECT FORUM_ID " & _
" FROM " & strTablePrefix & "FORUM "
set rsForum = my_Conn.Execute (forumSql)

if rsForum.eof or rsForum.bof then
'nothing
else
i = 0
do until rsForum.Eof
ForumID = rsForum("FORUM_ID")
if ChkForumAccess(ForumID, getNewMemberNumber()) then
i = i + 1
if i = 1 Then
strSql = strSql & " AND ("
else
strSql = strSql & " OR "
end If
strSQL = strSQL & "F.FORUM_ID=" & ForumID
end if
rsForum.MoveNext
loop
rsForum.close
set rsForum = Nothing
if i > 0 Then
strSql = strSql & ") "
end If
end if
end If
strSql = strSql & "AND (T.T_LAST_POST > '" & lastDate & "'"

' DEM --> if not an admin, all unapproved posts should not be viewed.
if mlev <> 4 then
strSql = strSql & " AND ((T.T_AUTHOR <> " & MemberID &_
" AND T.T_STATUS < 2)" ' Ignore unapproved/held posts
if mlev = 3 and ModofForums <> "" then
strSql = strSql & " OR T.FORUM_ID IN " & ModOfForums
end if
strSql = strSql & " OR T.T_AUTHOR = " & MemberID & ")"
end if

strSql = strSql & ") "

Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
If NOT rs.EOF Then
getActiveCount = rs("activeCount")
End If
rs.close
set rs = nothing
end function


I was a bit worried about all that occuring on every page hit, but I really haven't noticed an impact. If anyone sees anything wrong with that function, let me know. I honestly hacked it together.

Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 14 July 2002 :  20:52:09  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
Also, thanks go to ruirib for his suggestion. The code from inc_jump_to.asp is what I used to limit the forums to those someone has access to. Well, actually I changed it quite a bit, but it was definitely the starting point.



Edited by - Dan Martin on 14 July 2002 20:56:55
Go to Top of Page

ruirib
Snitz Forums Admin

Portugal
26364 Posts

Posted - 14 July 2002 :  21:41:06  Show Profile  Send ruirib a Yahoo! Message
Well, glad to know that the info was useful to you. And that surely your mod brings an interesting change, because I think the usual versions of similar mods fail exactly where this one does not fail: counting only the topics the user has access to.

-------------------------------------------------
Installation Guide | Do's and Dont's | MODs
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 14 July 2002 :  22:54:48  Show Profile  Visit dayve's Homepage
good job Dan, after looking at your code I then realized that the version I made was innacurate... I am now using your version instead.


http://www.nineinchnailz.com
Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 16 July 2002 :  22:45:46  Show Profile  Visit dayve's Homepage
I don't know if this would be considered a bug, BUT... if you change the active topics dropdown to anything other than Last Visit, the active topics number does not change. would that be considered normal or logical?


http://www.nineinchnailz.com
Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 17 July 2002 :  00:26:15  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
One could argue either way, but why not post both?

function getActiveCount() 'Returns the number of Active Topics
ActiveSince = Request.Cookies(strCookieURL & "ActiveSince")
'## Do Cookie stuffs with show last date
if Request.form("cookie") = "2" then
ActiveSince = Request.Form("ShowSinceDateTime")
if strSetCookieToForum = 1 then
Response.Cookies(strCookieURL & "ActiveSince").Path = strCookieURL
end if
Response.Cookies(strCookieURL & "ActiveSince") = ActiveSince
end if
Select Case ActiveSince
Case "LastVisit"
lastDate = ""
Case "LastFifteen"
lastDate = DateToStr(DateAdd("n",-15,strForumTimeAdjust))
Case "LastThirty"
lastDate = DateToStr(DateAdd("n",-30,strForumTimeAdjust))
Case "LastFourtyFive"
lastDate = DateToStr(DateAdd("n",-45,strForumTimeAdjust))
Case "LastHour"
lastDate = DateToStr(DateAdd("h",-1,strForumTimeAdjust))
Case "TwoHour"
lastDate = DateToStr(DateAdd("h",-2,strForumTimeAdjust))
Case "LastDay"
lastDate = DateToStr(DateAdd("d",-1,strForumTimeAdjust))
Case "LastWeek"
lastDate = DateToStr(DateAdd("ww",-1,strForumTimeAdjust))
Case "LastMonth"
lastDate = DateToStr(DateAdd("m",-1,strForumTimeAdjust))
Case Else
lastDate = ""
End Select
if IsEmpty(Session(strCookieURL & "last_here_date")) then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
end if
if lastDate = "" then
lastDate = Session(strCookieURL & "last_here_date")
end if
if Request.Form("AllRead") = "Y" then
Session(strCookieURL & "last_here_date") = ReadLastHereDate(strDBNTUserName)
lastDate = Session(strCookieURL & "last_here_date")
ActiveSince = ""
end if


dim strSql
dim rs_chk

if mlev = 3 then
strSql = "SELECT FORUM_ID FROM " & strTablePrefix & "MODERATOR " & _
" WHERE MEMBER_ID = " & getNewMemberNumber()

Set rsMod = Server.CreateObject("ADODB.Recordset")
rsMod.open strSql, my_Conn

if RsMod.EOF or RsMod.BOF then
' Do Nothing - User is not an active moderator
else
modcount = 0
ModOfForums = "("
do until RsMod.EOF
modcount = modcount + 1
if modcount > 1 then
ModOfForums = ModOfForums & ", "
end if
ModOfForums = ModOfForums & rsmod("FORUM_ID")
RsMod.MoveNext
loop
ModOfForums = ModOfForums & ")"
end if
RsMod.close
set RsMod = nothing
end if

'## Forum_SQL
strSql = "SELECT COUNT(*) as activeCount " &_
"FROM " & strMemberTablePrefix & "MEMBERS M, " &_
strTablePrefix & "FORUM F, " &_
strTablePrefix & "TOPICS T, " &_
strTablePrefix & "CATEGORY C, " &_
strMemberTablePrefix & "MEMBERS MEMBERS_1 " &_
"WHERE T.T_LAST_POST_AUTHOR = MEMBERS_1.MEMBER_ID " &_
"AND F.FORUM_ID = T.FORUM_ID " &_
"AND F.CAT_ID = T.CAT_ID " &_
"AND F.CAT_ID = C.CAT_ID " &_
"AND M.MEMBER_ID = T.T_AUTHOR "
if mlev < 4 then
'Limit to FORUMS that the user has access to.
forumSQL = "SELECT FORUM_ID " & _
" FROM " & strTablePrefix & "FORUM "
set rsForum = my_Conn.Execute (forumSql)

if rsForum.eof or rsForum.bof then
'nothing
else
i = 0
do until rsForum.Eof
ForumID = rsForum("FORUM_ID")
if ChkForumAccess(ForumID, getNewMemberNumber()) then
i = i + 1
if i = 1 Then
strSql = strSql & " AND ("
else
strSql = strSql & " OR "
end If
strSQL = strSQL & "F.FORUM_ID=" & ForumID
end if
rsForum.MoveNext
loop
rsForum.close
set rsForum = Nothing
if i > 0 Then
strSql = strSql & ") "
end If
end if
end If
strSql = strSql & "AND (T.T_LAST_POST > '" & lastDate & "'"

' DEM --> if not an admin, all unapproved posts should not be viewed.
if mlev <> 4 then
strSql = strSql & " AND ((T.T_AUTHOR <> " & MemberID &_
" AND T.T_STATUS < 2)" ' Ignore unapproved/held posts
if mlev = 3 and ModofForums <> "" then
strSql = strSql & " OR T.FORUM_ID IN " & ModOfForums
end if
strSql = strSql & " OR T.T_AUTHOR = " & MemberID & ")"
end if

strSql = strSql & ") "

Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSql, my_Conn
If NOT rs.EOF Then
getActiveCount = rs("activeCount")
End If
rs.close
set rs = nothing
end function



Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 17 July 2002 :  00:27:44  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
Do you think I should re-post this in the MOD W/Code forum?

Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 17 July 2002 :  00:35:52  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
Wow, that works even better than I had relized. Once you change the "Active Topics Since" dropdown, the function continues to show the new count. Even if you view other pages, and even if you leave the site, and come back.

I guess it makes sense that way? I think it does now that I'm using it.

Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 17 July 2002 :  00:46:42  Show Profile  Visit dayve's Homepage
Perfecto!


http://www.nineinchnailz.com
Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 17 July 2002 :  00:52:34  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
LOL, I check Burning Souls and the code is running 20 minutes after I posted. I knew you had it there before I saw your reply here.

Go to Top of Page

dayve
Forum Moderator

USA
5820 Posts

Posted - 17 July 2002 :  00:55:25  Show Profile  Visit dayve's Homepage
quote:

LOL, I check Burning Souls and the code is running 20 minutes after I posted. I knew you had it there before I saw your reply here.





hey, I know what I like :)


http://www.nineinchnailz.com
Go to Top of Page

Dan Martin
Average Member

USA
528 Posts

Posted - 18 July 2002 :  02:29:20  Show Profile  Visit Dan Martin's Homepage  Send Dan Martin an AOL message  Send Dan Martin an ICQ Message  Send Dan Martin a Yahoo! Message
Just in case anyone reads this thread. If you want to use this code, it's now in a "MOD" here: http://forum.snitz.com/forum/topic.asp?TOPIC_ID=31252

The MOD will be kept up to date. This thread won't.

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000 Version 3.4.07