<% '################################################################################# '## Copyright (C) 2000 Michael Anderson and Pierre Gorissen '## '## This program is free software; you can redistribute it and/or '## modify it under the terms of the GNU General Public License '## as published by the Free Software Foundation; either version 2 '## of the License, or any later version. '## '## All copyright notices regarding Snitz Forums 2000 '## must remain intact in the scripts and in the outputted HTML '## The "powered by" text/logo with a link back to '## http://forum.snitz.com in the footer of the pages MUST '## remain visible when the pages are viewed on the internet or intranet. '## '## This program is distributed in the hope that it will be useful, '## but WITHOUT ANY WARRANTY; without even the implied warranty of '## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the '## GNU General Public License for more details. '## '## You should have received a copy of the GNU General Public License '## along with this program; if not, write to the Free Software '## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. '## '## Support can be obtained from support forums at: '## http://forum.snitz.com '## '## Correspondence and Marketing Questions can be sent to: '## reinhold@bigfoot.com '## '## or '## '## Snitz Communications '## C/O: Michael Anderson '## PO Box 200 '## Harpswell, ME 04079 '################################################################################# ' This sub checks against the subscriptions table looking for a subscription based ' on the level passed in. If one exists, it builds the link the unsubscribe, ' otherwise it builds the link to subscribe. sub CheckSubscription(SubType, MemberID, CatID, ForumID, TopicID, strBefore, strAfter) if mlev = 0 then exit sub end if if instr(1, SubType, "NOTEXT") > 0 then SubType = Replace(SubType, "NOTEXT", "") Text = "N" end if ' Check for overriding subscriptions if SubType <> "BOARD" then StrSql = "SELECT Count(*) as SubCount from " & strTablePrefix & "SUBSCRIPTIONS S" & _ " WHERE S.MEMBER_ID = " & MemberID & _ " AND ((S.CAT_ID = 0 and S.FORUM_ID = 0 and S.TOPIC_ID = 0)" ' Board Level Subscription if SubType <> "CAT" then StrSql = StrSql & " OR (S.CAT_ID = " & CatID & " and S.FORUM_ID = 0 and S.TOPIC_ID = 0)" ' Cat level subscription end if if SubType = "TOPIC" then StrSql = StrSql & " OR (S.CAT_ID = " & CatID & " and S.FORUM_ID = " & ForumID & " and S.TOPIC_ID = 0)" ' Forum level subscription end if StrSql = StrSql & ")" Set rsCount = Server.CreateObject("ADODB.Recordset") rsCount.open strSql, my_Conn if rsCount.BOF or rsCount.EOF then rsCount.Close set rsCount = nothing ' No Subscriptions found, do nothing else SubCount = rsCount("SubCount") rsCount.Close set rsCount = nothing if SubCount > 0 then ' Higher Level Subscriptions found, exit. Exit Sub end if end if end if ' Can only have subscriptions if email is enabled and user is a member. if (lcase(strEmail) = "1") and mlev <> 0 then dim LinkInfo LinkInfo = "LEVEL=" LinkInfo = LinkInfo & SubType ' Look for a current subscription for this member to determine which icon to display. ' Also start to build the appropriate querystring for the link strSql = "Select Count(*) as MemberCheck " &_ " FROM " & strTablePrefix & "SUBSCRIPTIONS S" &_ " WHERE S.MEMBER_ID = " & MemberID &_ " AND S.TOPIC_ID = " if SubType = "TOPIC" then strSql = strSql & TopicID else strSql = strSql & "0 " end if strSql = strSql & " AND S.FORUM_ID = " if SubType = "CAT" or SubType = "FORUM" or SubType = "TOPIC" then strSql = strSql & ForumID else strSql = strSql & "0 " end if strSql = strSql & " AND S.CAT_ID = " if SubType <> "BOARD" then strSql = strSql & CatID else strSql = strSql & "0 " end if if SubType <> "BOARD" then LinkInfo = LinkInfo & "&CAT_ID=" & CatID if SubType <> "CAT" then LinkInfo = LinkInfo & "&FORUM_ID=" & ForumID if SubType <> "FORUM" then LinkInfo = LinkInfo & "&TOPIC_ID=" & TopicID end if end if end if Set rsWatch = Server.CreateObject("ADODB.Recordset") rsWatch.open strSql, my_Conn ' Complete the LinkInfo by adding the member_id to the link LinkInfo = LinkInfo & "&MEMBER_ID=" & MemberID & "');"">" Response.Write "" If rsWatch("MemberCheck") > 0 then Response.Write strBefore & "" If Text <> "N" then Response.Write " " If Text <> "N" then Response.Write "  "N" then if SubType = "BOARD" then Response.Write "Board" elseif SubType = "CAT" then Response.Write "Category" elseif SubType = "FORUM" then Response.Write "Forum" else Response.Write "Topic" end if else response.write "" end if Response.Write strAfter & "" rsWatch.close set rsWatch = nothing end if end sub sub ProcessSubscriptions (MemberId, CatID, ForumId, TopicId) ' DEM --> Added line to ignore the moderator/admin since they would be approving the post if ' ThisMemberId & MemberID are different.... ThisMemberID = getMemberNumber(strDBNTUserName) ' -- If subscription is not allowed or email is not turned on, exit if strSubscription = 0 or strEmail = 0 then exit sub end if StrSql = "SELECT C.CAT_SUBSCRIPTION, C.CAT_NAME, F.F_SUBJECT, F.F_SUBSCRIPTION " & _ " FROM " & strTablePrefix & "CATEGORY C, " & strTablePrefix & "FORUM F" & _ " WHERE C.CAT_ID = " & CatID & " AND F.FORUM_ID = " & ForumID Set rsSub = Server.CreateObject("ADODB.Recordset") rsSub.open strSql, my_Conn ' -- If No record is found, exit sub if RsSub.Eof or RsSub.BOF then rsSub.close set rsSub = nothing exit sub else CatSubscription = rsSub("CAT_SUBSCRIPTION") CatName = rsSub("CAT_NAME") ForumSubscription = rsSub("F_SUBSCRIPTION") ForumName = rsSub("F_SUBJECT") ' -- If no subscriptions are allowed for the category or forum, exit sub if CatSubscription = 0 or ForumSubscription = 0 then rsSub.close set rsSub = nothing exit sub end if end if ' -- Get the topic title and Author nam strSql = "SELECT T.T_SUBJECT, M.M_NAME FROM " & strTablePrefix & "TOPICS T, " & _ strMemberTablePrefix & "MEMBERS M " &_ " WHERE T.TOPIC_ID = " & TopicId & " " &_ " AND M.MEMBER_ID = " & MemberID Set rsSub = Server.CreateObject("ADODB.Recordset") rsSub.open strSql, my_Conn if rsSub.EOF or rsSub.BOF then TopicName = "" MemberName = "" else TopicName = rsSub("T_SUBJECT") MemberName = rsSub("M_NAME") end if rsSub.Close set rsSub = Nothing ' -- Set highest subscription level to check for... ' strSubscription 1 = whole board, 2 = by category, 3 = by forum, 4 = by topic ' CatSubscription 1 = whole category, 2 = by forum, 3 = by topic ' ForumSubscription 1 = whole forum, 2 = by topic If strSubscription = 4 or CatSubscription = 3 or ForumSubscription = 2 then SubLevel = "TOPIC" Elseif strSubscription = 3 then SubLevel = "FORUM" Elseif strSubscription = 2 then if CatSubscription = 1 then SubLevel = "CATEGORY" else SubLevel = "FORUM" end if Elseif strSubscription = 1 then if CatSubscription = 1 then SubLevel = "ALL" else SubLevel = "FORUM" end if End if '## Emails all users who wish to receive a mail if a topic or reply has been made. This sub will '## check for subscriptions based on the topic, forum, category and across the board. It will '## ignore the posting member. strSql = "SELECT S.Member_ID, " & _ "S.CAT_ID, " & _ "S.FORUM_ID, " & _ "S.TOPIC_ID, " & _ "M.M_NAME, M.M_EMAIL " & _ " FROM " & strTablePrefix & "SUBSCRIPTIONS S" & _ ", " & strMemberTablePrefix & "MEMBERS M" & _ " WHERE S.Member_ID <> " & MemberID & _ " AND M.Member_ID = S.Member_ID" & _ " AND (S.TOPIC_ID = " & TopicId ' Topic specific subscriptions... ' Check for Subscriptions against the Forum if SubLevel <> "TOPIC" then StrSql = StrSql & " OR (S.CAT_ID = " & CatID & _ " AND S.FORUM_ID = " & ForumID & _ " AND S.TOPIC_ID = 0)" end if ' Check for Subscriptions against the Category if SubLevel = "CATEGORY" or SubLevel = "ALL" then StrSql = StrSql & " OR (S.CAT_ID = " & CatID & _ " AND S.FORUM_ID = 0 AND S.TOPIC_ID = 0)" end if ' Check for Subscriptions against the Board if SubLevel = "ALL" then StrSql = StrSql & " OR (S.CAT_ID = 0 AND S.FORUM_ID = 0 AND S.TOPIC_ID = 0)" end if strSql = strSql & ")" Set rsLoop = Server.CreateObject("ADODB.Recordset") rsLoop.open strSql, my_Conn do while (not rsLoop.EOF) and (not rsLoop.BOF) strRecipientsName = rsLoop("M_Name") strRecipients = rsLoop("M_EMAIL") strMessage = "Hello " & rsLoop("M_NAME") & vbNewline & vbNewline ' ## Send the appropriate message depending on the subscription. if rsLoop("CAT_ID") > 0 then if rsLoop("FORUM_ID") > 0 then if rsLoop("TOPIC_ID") > 0 then strSubject = strForumTitle & " - Reply to a posting" strMessage = strMessage & MemberName & " has replied to a topic on " & strForumTitle & " that you requested notification to. " else strSubject = strForumTitle & " - New posting" strMessage = strMessage & MemberName & " has posted to the forum '" & ForumName & "' at " & strForumTitle & " that you requested notification on. " end if else strSubject = strForumTitle & " - New posting" strMessage = strMessage & MemberName & " has posted to the category '" & CatName & "' at " & StrForumTitle & " that you requested notification on. " end if else strSubject = strForumTitle & " - New posting" strMessage = strMessage & MemberName & " has posted to the " & strForumTitle & " board that you requested notification on. " end if strMessage = strMessage & "Regarding the subject - " & TopicName & "." & vbNewline & vbNewline strMessage = strMessage & "You can view the posting at " & strForumURL & "link.asp?TOPIC_ID=" & TopicId & vbNewline %> <% rsLoop.MoveNext loop rsLoop.Close set rsLoop = nothing end sub %>