<%
' ********************************************************************************************
' SHOW NUMBER OF NEW MESSAGES IN TITLE IF LOGGED IN (MORE THAN 20, WILL OUTPUT +20)
' Built in: 26th May 2007 by Bruno Alexandre <bruno.in.dk@gmail.com>
' version: 0.0.2 | (29th May 2007) | updated with TopSQL() so it runs in mySQL as well (>4.x)
' version: 0.0.1 | (26th May 2007) | Mod Start
' ********************************************************************************************
strNewMessages = ""
intNewMessages = 0
' We only see the messages if the user is Logged In
if strDBNTUserName <> "" then
' Get the last 20 messages order by Date
sqlstr = "SELECT M_NAME FROM ( " & _
"SELECT " & strTablePrefix & "TOPICS.CAT_ID, " & strTablePrefix & "TOPICS.FORUM_ID, " & strTablePrefix & "TOPICS.TOPIC_ID, " & strTablePrefix & "TOPICS.T_SUBJECT, '' AS MSG_ID, " & strTablePrefix & "TOPICS.T_MESSAGE AS MSG, " & strTablePrefix & "TOPICS.T_DATE AS MSG_DATE, " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_NAME " & _
"FROM " & strTablePrefix & "MEMBERS INNER JOIN " & strTablePrefix & "TOPICS ON " & strTablePrefix & "MEMBERS.MEMBER_ID = " & strTablePrefix & "TOPICS.T_AUTHOR " & _
"UNION ALL " & _
"SELECT " & strTablePrefix & "TOPICS.CAT_ID, " & strTablePrefix & "TOPICS.FORUM_ID, " & strTablePrefix & "TOPICS.TOPIC_ID, " & strTablePrefix & "TOPICS.T_SUBJECT, " & strTablePrefix & "REPLY.REPLY_ID AS MSG_ID, " & strTablePrefix & "REPLY.R_MESSAGE as MSG, " & strTablePrefix & "REPLY.R_DATE as MSG_DATE, " & strTablePrefix & "MEMBERS.MEMBER_ID, " & strTablePrefix & "MEMBERS.M_NAME " & _
"FROM (" & strTablePrefix & "TOPICS INNER JOIN " & strTablePrefix & "REPLY ON " & strTablePrefix & "TOPICS.TOPIC_ID = " & strTablePrefix & "REPLY.TOPIC_ID) INNER JOIN " & strTablePrefix & "MEMBERS ON " & strTablePrefix & "REPLY.R_AUTHOR = " & strTablePrefix & "MEMBERS.MEMBER_ID " & _
") a " & _
"ORDER BY MSG_DATE DESC;"
Set objRec = Server.CreateObject ("ADODB.Recordset")
objRec.Open TopSQL(sqlstr, 20), My_Conn
objRec.moveFirst()
do until objRec.EOF
if objRec.fields("M_NAME") = strDBNTUserName then
' Found a message from the CurrentUser, so Get out!
exit do
else
' The message is not from the Current User, so let's Add it to the variable
intNewMessages = intNewMessages + 1
end if
objRec.moveNext()
loop
if intNewMessages > 0 then
' if the are new messages, let's surround it with curve brackets
if objRec.EOF then
' there are more than 20, so, instead of looping all we show +20
strNewMessages = "(+" & intNewMessages & ")"
else
strNewMessages = "(" & intNewMessages & ")"
end if
strNewMessages = "(" & intNewMessages & ")"
strScriptName = strScriptName & strNewMessages
end if
objRec.close
set objRec = Nothing
end if
%>