I have been asked to post the code for this mod. Once I do, perhaps one of the moderators will transfer the thread to the W/Code forum.
On a difficulty scale of 1-10 (1- easy, 10 - difficult), I would rate this one as a 6 or 7, mainly because the data base changes are not automated and there is no administrative interface.
FORUM CLUBS MOD
Adds club icons to the member information column in TOPIC.ASP. A club membership is defined as active if the member has posted in one of the specific club forums within the last seven days. Whenever a forum member posts into a forum which is defined as a club, the corresponding club icon is included in their topics.asp display, and will remain there for seven days (hard-coded, but only in one place in the code). So long as a member posts in a club forum at least once each seven days, their club icon will remain in place.
DATABASE ADDITIONS
You must add two tables to the FORUMS data base, and populate the CLUBS table by hand (the CLUB_MEMBERS table is updated as needed by the MOD).
The table structure is as follows (assuming that FORUM is your table prefix; if not, change your prefix appropriately):
FORUM_CLUBS
CLUB_ID integer primary key
FORUM_ID integer default 0
CLUB_NAME nvarchar(120) default ''
CLUB_ICON nvarchar(120) default ''
CLUB_ACTIVE tinyint default 0
Create primary key index on CLUB_ID
Create index on FORUM_ID
FORUM_CLUB_MEMBERS
SEQUENCE_ID integer auto-increment primary key
CLUB_ID integer default 0
MEMBER_ID integer default 0
LAST_POST nvarchar(14) default ''
Create index on CLUB_ID
Create index on MEMBER_ID
Notes:
1. The club icon is assumed to be located in the forum icon directory defined by strImageURL.
2. The CLUB_ACTIVE flag is not currently used, but is intended to allow selective disabling of individual clubs. Adding this capability is a simple matter of adding one more WHERE clause to the SELECT statement in TOPIC.ASP.
3. The CLUB_ID value is immaterial so long as it is unique. Once establised, it should not be changed. I included CLUB_ID rather than simply using FORUM_ID to allow for moving a club from one forum to another. Potentially you could even assign multiple clubs to a forum, but that really doesn't make a lot of sense.
INC_FUNC_COUNT.ASP
Insert this code at any convenient place (not in-line with other code):
'## FORUM CLUBS MOD
sub doUClubMembership(cForumID,cMemberID)
strSql = "SELECT CLUB_ID FROM " & strTablePrefix & "CLUBS WHERE FORUM_ID=" & cForumID
'Response.Write strSql & "<br>"
set rsClub = my_conn.Execute (strSql)
if rsClub.Eof or rsClub.Bof then
rsClub.Close
set rsClub = NOTHING
Exit sub
end if
club_id = cINT(rsClub("CLUB_ID"))
rsClub.Close
' forum is a club - update member
strSql = "SELECT COUNT(*) AS NUM FROM " & strTablePrefix & "CLUB_MEMBERS WHERE CLUB_ID=" & club_id & " AND MEMBER_ID=" & cMemberID
set rsClub = my_conn.Execute (strSql)
club_count = cINT(rsClub("NUM"))
rsClub.Close
set rsClub = nothing
if club_count = 0 then
strSql = "INSERT INTO " & strTablePrefix & "CLUB_MEMBERS (CLUB_ID, MEMBER_ID) VALUES (" & club_id & ", " & cMemberID & ")"
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
end if
strSql = "UPDATE " & strTablePrefix & "CLUB_MEMBERS SET LAST_POST = '" & DateToStr(strForumTimeAdjust) & "' "
strSql = strSql & " WHERE CLUB_ID=" & club_id & " AND MEMBER_ID=" & cMemberID
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
end sub
POST_INFO.ASP
Around 748, find the code shown, and insert the code in red
'Huw -- Update member count
if (AutoApprove = "Yes") and blnTStatus = 2 and blnTopicMoved then
doUCount(strAuthor)
'## FORUM CLUBS MOD
doUClubMemberShip Forum_ID, MemberID
'Response.Write "1 F/M: " & Forum_ID & "/" & MemberID & "<br>"
doULastPost(strAuthor)
end if
Around line 1900, insert the code shown in red
case "Reply", "ReplyQuote", "TopicQuote"
' DEM --> If moderated post, the counts should not be updated until after approval
' Combined the Reply, ReplyQuote and TopicQuote because the basic code was the same.
if Moderation = "Yes" then
Response.Write("New Reply Posted! It will appear once approved by a moderator")
else
Response.Write("New Reply Posted!")
DoPCount
if ForumCountMPosts <> 0 then
DoUCount Request.Form("UserName")
'## FORUM CLUBS MOD
doUClubMemberShip Forum_ID, MemberID
'Response.Write "2 F/M: " & Forum_ID & "/" & MemberID & "<br>"
end if
end if
DoULastPost Request.Form("UserName")
Around line 1915, add the code shown in red
case "Topic"
' DEM --> If moderated post, the counts should not be updated until after approval
if Moderation = "Yes" then
Response.Write("New Topic Posted! It will appear once approved by a moderator")
else
Response.Write("New Topic Posted!")
DoTCount
DoPCount
if ForumCountMPosts <> 0 then
DoUCount Request.Form("UserName")
'## FORUM CLUBS MOD
doUClubMemberShip Forum_ID, MemberID
'Response.Write "3 F/M: " & Forum_ID & "/" & MemberID & "<br>"
end if
end if
DoULastPost Request.Form("UserName")
TOPIC.ASP
Around 280, add the code shown in red. Note that I have (among several others) the Poll Mod installed. If you do not, then much of the quoted code will not be present in your file. I have shown lines 209-327 of my TOPIC.ASP.
if CanShowSignature = 1 then
Topic_MemberSig = trim(rsTopic("M_SIG"))
end if
'############## Poll Mod ##################
IsPoll = rsTopic("T_ISPOLL")
Forum_Polls = rsTopic("F_POLLS")
Poll_Status = rsTopic("T_POLLSTATUS")
if IsPoll = 1 then
strSql = "SELECT P.P_LASTVOTE, P.P_WHOVOTES"
For i = 1 To 15
strSql = strSql & ", P.ANSWER" & CStr(i)
strSql = strSql & ", P.COUNT" & CStr(i)
Next
strSql = strSql & " FROM " & strTablePrefix & "POLLS P"
strSql = strSql & " WHERE P.TOPIC_ID = " & Topic_ID
set rsPoll = Server.CreateObject("ADODB.Recordset")
rsPoll.Open strSql, my_Conn, adOpenForwardOnly, adLockReadOnly, adCmdText
if not(rsPoll.EOF) or not(rsPoll.BOF) then
Last_Vote = rsPoll("P_LASTVOTE")
strWhoVotes = rsPoll("P_WHOVOTES")
For nCount = 1 to 15
'Loop through answer and count fields for the poll
'and store them in arrays
vAnswers(nCount) = rsPoll("ANSWER" & CStr(nCount))
vCount(nCount) = rsPoll("COUNT" & CStr(nCount))
Next
end if
rsPoll.Close
set rsPoll = nothing
end if
if IsPoll = 1 then
pollLink = "poll=1&"
else
pollLink = ""
end if
'##########################################
end if
rsTopic.close
set rsTopic = nothing
if recTopicCount = "" then
if ArchiveView <> "true" then
Response.Redirect("topic.asp?ARCHIVE=true&" & ChkString(Request.QueryString,"SQLString"))
else
Response.Redirect("default.asp")
end if
end if
'## Forum_SQL - Get original topic and check for the Category, Forum or Topic Status and existence
'## PHOTO ALBUM LINK
strSql = "SELECT U.M_NAME AS ANAME"
strSql = strSql & ", COUNT(A.PHOTO_ID) AS PICTURES"
strSql = strSql & " FROM " & strMemberTablePrefix & "ALBUM_USERS U"
strSql = strSQL & ", " & strMemberTablePrefix & "ALBUM A"
strSql = strSql & " WHERE U.MEMBER_ID=" & TMEMBER_ID
strSql = strSql & " AND U.MEMBER_ID = A.MEMBER_ID"
strSql = strSql & " GROUP BY U.M_NAME"
set albrs = my_Conn.Execute(strSql)
if albrs.BOF or albrs.EOF then
A_HAS_ALBUM = FALSE
A_NUM_PICS = 0
else
A_HAS_ALBUM = TRUE
A_NUM_PICS = albrs("PICTURES")
end if
set albrs = NOTHING
'## FORUM CLUBS MOD
strSql = "SELECT C.* FROM " & strTablePrefix & "CLUB_MEMBERS M, " & strTablePrefix & "CLUBS C WHERE "
strSql = strSql & "M.CLUB_ID=C.CLUB_ID AND M.MEMBER_ID=" & TMember_ID
strSql = strSql & " AND M.LAST_POST > '" & DateToStr(DateAdd("d",-7,strForumTimeAdjust)) & "'"
set clubrs = my_Conn.Execute(strSql)
club_links = ""
do while not clubrs.EOF
club_links = club_links & "<a href=""forum.asp?FORUM_ID=" & clubrs("FORUM_ID") & """> "
club_links = club_links & "<img src=""" & strImageURL & clubrs("CLUB_ICON") & """ border=""0"""
club_links = club_links & "alt=""" & clubrs("CLUB_NAME") & " Club"" title=""" & clubrs("CLUB_NAME") & " Club"" /></a>" & vbNewLine
clubrs.MoveNext
loop
clubrs.Close
set clubrs=NOTHING
'################ Poll Mod ##############
if IsPoll = 1 then
'Check to see if user has voted
Voted = GetVote(Topic_ID)
end if
'########################################
if mLev = 4 then
AdminAllowed = 1
ForumChkSkipAllowed = 1
elseif mLev = 3 then
if chkForumModerator(Forum_ID, chkString(strDBNTUserName,"decode")) = "1" then
AdminAllowed = 1
ForumChkSkipAllowed = 1
else
if lcase(strNoCookies) = "1" then
AdminAllowed = 1
ForumChkSkipAllowed = 0
else
AdminAllowed = 0
ForumChkSkipAllowed = 0
end if
end if
elseif lcase(strNoCookies) = "1" then
AdminAllowed = 1
ForumChkSkipAllowed = 0
else
AdminAllowed = 0
ForumChkSkipAllowed = 0
end if
if strPrivateForums = "1" and (Request.Form("Method_Type") <> "login") and (Request.Form("Method_Type") <> "logout") and ForumChkSkipAllowed = 0 then
result = ChkForumAccess(Forum_ID, MemberID, true)
end if
Around 850, add the code shown in red:
'## FORUM CLUBS MOD
strSql = "SELECT C.* FROM " & strTablePrefix & "CLUB_MEMBERS M, " & strTablePrefix & "CLUBS C WHERE "
strSql = strSql & "M.CLUB_ID=C.CLUB_ID AND M.MEMBER_ID=" & Reply_MemberID
strSql = strSql & " AND M.LAST_POST > '" & DateToStr(DateAdd("d",-7,strForumTimeAdjust)) & "'"
set clubrs = my_Conn.Execute(strSql)
rclub_links = ""
do while not clubrs.EOF
rclub_links = rclub_links & "<a href=""forum.asp?FORUM_ID=" & clubrs("FORUM_ID") & """> "
rclub_links = rclub_links & "<img src=""" & strImageURL & clubrs("CLUB_ICON") & """ border=""0"""
rclub_links = rclub_links & "alt=""" & clubrs("CLUB_NAME") & " Club"" title=""" & clubrs("CLUB_NAME") & " Club"" /></a>" & vbNewLine
clubrs.MoveNext
loop
clubrs.Close
set clubrs=NOTHING
if intI = 0 then
CColor = strAltForumCellColor
else
CColor = strForumCellColor
end if
Response.Write " <tr>" & vbNewLine & _
" <td bgcolor=""" & CColor & """ valign=""top"" width=""" & strTopicWidthLeft & """"
if lcase(strTopicNoWrapLeft) = "1" then Response.Write(" nowrap")
Response.Write ">" & vbNewLine & _
" <p><font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """><b><span class=""spnMessageText"">" & profileLink(ChkString(Reply_MemberName,"display"),Reply_Author) & "</span></b></font><br />" & vbNewLine
if strShowRank = 1 or strShowRank = 3 then
Response.Write " <font color=""" & strForumFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><small>" & ChkString(getMember_Level(Reply_MemberTitle, Reply_MemberLevel, Reply_MemberPosts),"display") & "</small></font><br />" & vbNewLine
end if
if strShowRank = 2 or strShowRank = 3 then
Response.Write " " & getStar_Level(Reply_MemberLevel, Reply_MemberPosts) & "<br />" & vbNewLine
end if
Around 942, add the code shown in red
Response.Write " <font color=""" & strForumFontColor & """ face=""" & strDefaultFontFace & """ size=""" & strFooterFontSize & """><small>" & Reply_MemberPosts & " Posts</small></font></p>" & rclub_links & "</td>" & vbNewLine & _
" <td bgcolor=""" & CColor & """ height=""100%"" width=""" & strTopicWidthRight & """"
if lcase(strTopicNoWrapRight) = "1" then Response.Write(" nowrap")
if (AdminAllowed = 1) and (maxpages > 1) then
Response.Write (" colspan=""3"" ")
else
Response.Write (" colspan=""2"" ")
end if
Response.Write "valign=""top""><a name=""" & Reply_ReplyID & """></a>" & vbNewLine & _
" <table width=""100%"" height=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td valign=""top"">" & vbNewLine
' DEM --> Start of Code altered for moderation
Don't forget to populate your FORUM_CLUBS table!