%@ CodePage=65001 Language="VBScript"%>
<% Option Explicit %>
<% sBBSLangPage = "calendar"
BBS.SetupBBS
BBS.SetScheme(0)
dim iCAcalendarid, iYear, iMonth, vCalendarInfo, dCurrentDate, dStartDate, dEndDate, vDateInfo, dPrevious, dForward, iUpper, iCurrentWeekday, sOutput, index
iCAcalendarid = request("calendarid")
iMonth = BBS.ValidateNumeric(request("month"))
iYear = BBS.ValidateNumeric(request("year"))
if (iMonth) = 0 then iMonth = month(now)
if (iYear) = 0 then iYear = year(now)
dStartDate = dateSerial(iYear, iMonth, 1)
dEndDate = dateSerial(iYear, iMonth+1, 0)
dPrevious = dateAdd("m", -1, dStartDate)
dForward = dateAdd("m", 1, dStartDate)
vCalendarInfo = Calendar.GetCalendarInfo(iCAcalendarid)
if vCalendarInfo(CI_CalendarID) <= 0 then response.redirect "calendar-list.asp"
if dictConfiguration("bENABLECALENDAR") = 0 then response.redirect "../category-view.asp"
if not(BBS.HasPermission(PERM_calendarview, iCAcalendarid)) then response.redirect sBBSForumRoot & "/restricted-page.asp"
' Generate the calendar
' Create padding at the beginning of the calendar
sOutput = "
"
iCurrentWeekday = weekday(dStartDate)
for index=1 to iCurrentWeekday-1
sOutput = sOutput & "| | "
next
' Get a list of all events during this month
vDateInfo = Calendar.ListDateEvents(iCAcalendarid, dStartDate, dEndDate, iUpper)
dCurrentDate = dStartDate
' Loop through each month of the calendar
do until dCurrentDate > dEndDate
' Each day contains a mini-table
if iCurrentWeekday = 8 then
sOutput = sOutput & "
"
iCurrentWeekday = 1
end if
sOutput = sOutput & ""
sOutput = sOutput & " "
else
sOutput = sOutput & day(dCurrentDate) & "
"
end if
for index=0 to (iUpper-1)
if cDate(vDateInfo(index)(CEV_META_Date)) = dCurrentDate then
sOutput = sOutput & ""
if vDateInfo(index)(CEV_recurrence) <> "none" then
sOutput = sOutput & " "
elseif vDateInfo(index)(CEV_private) = 1 then
sOutput = sOutput & " "
else
sOutput = sOutput & "-"
end if
sOutput = sOutput & " | " & BBS.ValidateField(vDateInfo(index)(CEV_Shortdesc)) & "
| "
end if
next
sOutput = sOutput & "
| "
' End minitable
' Move to the next day
dCurrentDate = DateAdd("d", 1, dCurrentDate)
iCurrentWeekday = iCurrentWeekday + 1
loop
' Fill in any remaining days
iCurrentWeekday = weekday(dCurrentDate)
if iCurrentWeekday <> 1 then
for index=iCurrentWeekday to 7
sOutput = sOutput & " | "
next
end if
dictEnvironment("V-DAYSLIST") = sOutput
sOutput = ""
dictEnvironment("U-FORWARD") = "calendar-view.asp?calendarid=" & vCalendarInfo(CI_CalendarID) & "&year=" & year(dForward) & "&month=" & month(dForward)
dictEnvironment("U-PREVIOUS") = "calendar-view.asp?calendarid=" & vCalendarInfo(CI_CalendarID) & "&year=" & year(dPrevious) & "&month=" & month(dPrevious)
dictEnvironment("V-MONTH") = BBS.Months(month(dStartDate))
dictEnvironment("V-YEAR") = year(dStartDate)
dictEnvironment.add "C-SHOWRANDOMQUOTES", dictConfiguration("bDISPLAYBBSQUOTES")
if iBBSUserLevel >= USERLEVEL_SupportAdministrator then dictEnvironment.add "C-SHOWADMINLINK", 1
dictEnvironment.add "V-TITLE", dictLanguage("CALENDAR-TITLE")
%>
<% Filesystem.ExecuteBBSTemplate("/calendar/calendar-view.asp") %>
Calendar