Hi there...this is a mod on a mod by Red1, by myself, which changes the way Red1 Calendar Mod works.
Instead of showing a static number of upcoming/recent events on cal_default.asp, it will display only those events which will take place in the upcoming period (for instance n days).
Next to that, it groups them by day in the overview of upcoming/recent events.
Changed files:
cal_default.asp
cal_functions.asp
cal_constants.asp
What did I do ?
Basically I took the sub WriteUpcomingEvents, and copied it into a new sub named WriteUpcomingEventsPeriod
The code below is the modded version; just copy it into cal_functions.asp, at the bottom, before the %>
'*****************************************************************
Sub WriteUpcomingEventsPeriod
'*****************************************************************
strSql = "SELECT "
strSql = strSql & "T.TOPIC_ID, " & _
"T.T_SUBJECT, " & _
"T.T_MESSAGE, " & _
"T.FORUM_ID, " & _
"T.T_STATUS, " & _
"T.T_EVENT_DATE, " & _
"C.CAT_MODERATION, " & _
"F.F_MODERATION " & _
"FROM " & strTablePrefix & "TOPICS T, " & _
strTablePrefix & "CATEGORY C, " & _
strTablePrefix & "FORUM F " & _
"WHERE T.T_ISEVENT=1 " & _
"AND T_EVENT_DATE > '" & datetostr(DateValue(strForumTimeAdjust)) & "' " & _
"AND T_EVENT_DATE < '" & datetostr(DateValue(strForumTimeAdjust)+intUpcomingPeriod) & "' " & _
"AND F.FORUM_ID = T.FORUM_ID " & _
"AND C.CAT_ID = T.CAT_ID " & _
"ORDER BY T.T_EVENT_DATE Asc"
set rs = Server.CreateObject("ADODB.Recordset")
if strDBtype = "mysql" then rs.MaxRecords = intEventstoDisplay
rs.open StrSql, My_conn
If rs.EOF then
Response.Write "<DIV class=""listitem"">" & strCalNoUpcoming & "</DIV>" & vbnewline
else do while not rs.eof
Topic_ID = rs("TOPIC_ID")
Topic_Subject = rs("T_SUBJECT")
Forum_ID = rs("FORUM_ID")
Topic_Status = rs("T_STATUS")
Event_Date = StrToDate(rs("T_EVENT_DATE"))
Cat_Moderation = rs("CAT_MODERATION")
Forum_Moderation = rs("F_MODERATION")
Topic_Message = rs("T_MESSAGE")
'*****************************************************************
'Code for Topic Moderation and Private Forums
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 ForumChkSkipAllowed <> "1" then
forumAccess = ChkForumAccess(Forum_ID, MemberID, false)
else
forumAccess = true
end if
if strModeration > 0 and Cat_Moderation > 0 and Forum_Moderation > 0 and AdminAllowed = 0 then
Moderation = "Y"
else
Moderation = "N"
end if
'*****************************************************************
if forumAccess and not(Moderation = "Y" and Topic_Status > 1 and Topic_Author <> MemberID) then
if Event_Date <> Previous_Event_Date then
Response.Write "<DIV class=""listitem"">" & Day(Event_Date) & " " & MonthName(Month(Event_Date)) & " " & Year(Event_Date) & "<DIV>" & vbnewline
end if
Response.Write "<DIV class=""indented""><SPAN class=""spnMessageText""><b>·</b> <A href=""topic.asp?TOPIC_ID=" & Topic_ID & """title=""" & ChkString(left(RemoveForumCode(RemoveHTML(Topic_Message)), 1000), "tooltip") & """>" & Topic_Subject & "</A></SPAN></DIV>"
end if
Previous_Event_Date = Event_Date
rs.movenext
loop
end if
rs.close
set rs = nothing
End Sub 'WriteUpcomingEventsPeriod
Ok, for defining the period, I have added a constant to cal_constants.asp:
Added this code at line 24:
'### Length in days of upcoming period ###
Const intUpcomingPeriod = 31
Ok, now the work is nearly done:
Change cal_default.asp, at the place the current sub is requested (line 119)
Added the bold parts:
Response.Write " <TD width=""33%"" bgcolor=""" & strForumCellColor & """ valign=""top"" class=""smallfont""><b>" & strCalUpcoming & "</b><br><small>within the next " & intUpcomingPeriod & " days</small><br /> " & vbNewLine
WriteUpcomingEventsPeriod
That's it!
The same could be done for the recent events, limiting it to a period of days to show recent events.
Just call for WriteUpcomingEventsPeriod instead of WriteUpcomingEvents where you want to use this code.
Hope this one is usefull to anyone. If anyone's interested, I could post the fully modded files here, which has these changes in all functions.