authenticate("U_Groups"); $html -> send_header("{$ubbt_lang['CAL_HEAD']}",$Cat,0,$user); // ------------------------------------------------------------------------- // Need to see what forums they have access to, so we don't show events with // topics in private forums // ---------------------------------------------------------------- // If they are logged in then we check their groups, otherwise they // get set to the guest group $Groups = $user['U_Groups']; if (!$Groups) { $Groups = "-4-"; } // -------------------------------------------------------------- // Let's make sure they are supposed to be looking at this board $Grouparray = split("-",$Groups); $gsize = sizeof($Grouparray); $groupquery = "AND ("; $g = 0; for ($i=0; $i<$gsize;$i++) { if (!preg_match("/[0-9]/",$Grouparray[$i])) { continue; }; $g++; if ($g > 1) { $groupquery .= " OR "; } $groupquery .= "Bo_Read_Perm LIKE '%-$Grouparray[$i]-%'"; } $groupquery .= ")"; $canview = array(); $query = " SELECT Bo_Keyword FROM {$config['tbprefix']}Boards WHERE Bo_Active = '1' $groupquery "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $i = 0; while (list($thisboard) = $dbh -> fetch_array($sth)) { $canview[$i] = $thisboard; $i++; } $now = $html -> get_date(); // Show 2 months if (!$month) { $temp = getdate($now); $thismonth = $temp["mon"]; $thisyear = $temp["year"]; } else { $thismonth = $month; $thisyear = $year; } $month1 = make_month($thismonth,$thisyear); $nextmonth = $thismonth + 1; $year = $thisyear; if ($nextmonth == 13) { $nextmonth = 1; $year = $year + 1; } $month2 = make_month($nextmonth,$year); $monthselect = ""; $temp = getdate($now); $tyear = $temp["year"]; $yearselect = ""; if ($user['U_Username']) { $addevent = "
{$ubbt_lang['ADDEVENT']}"; } // ---------------------------------------- // Setup the links for prev and next months $prevmonth = $thismonth - 1; $prevyear = $thisyear; if ($prevmonth < 1) { $prevmonth = 12; $prevyear = $prevyear - 1; } $nextmonth = $thismonth + 1; $nextyear = $thisyear; if ($nextmonth > 12) { $nextmonth = 1; $nextyear= $nextyear + 1; } if (!$debug) { include("$thispath/templates/$tempstyle/calendar.tmpl"); } $html -> send_footer(); // ------------------------------------------------------------ // THIS FUNCTION ACTUALLY CREATES THE CALENDAR AND GRABS EVENTS function make_month($month="",$year="") { global $ubbt_lang,$config,$dbh,$user,$Cat, $debug, $thispath, $tempstyle, $canview; $html = new html; $now = $html -> get_date(); // --------------------------------- // Get some info on the current date $temp = getdate($now); $thismonth = $temp["mon"]; $thisyear = $temp["year"]; $thisday = $temp["mday"]; // ---------------------------------------------------------------- // If we didn't pass month/year then we grab the current month/year if (!$month) { $month = $thismonth; } if (!$year) { $year = $thisyear; } // ----------------------------------------------------------- // Grab all the birthday's for this month if showing birthdays if ($config['cal_bday']) { $query = " SELECT U_Username,U_Birthday,U_CoppaUser FROM {$config['tbprefix']}Users WHERE U_Birthday LIKE '$month/%' AND U_ShowBday = '1' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); $marray[0] = ""; while(list($uname,$birthday,$coppauser) = $dbh -> fetch_array($sth)) { @list($bmonth,$bday,$byear) = @split("/",$birthday); $age = ""; if ($config['showage'] && !$coppauser) { $age = $year - $byear; $age = " ($age)"; } if (!isset($marray[$bday])) { $marray[$bday] = " ( {$ubbt_lang['BDAY']}: $uname $age ) \n"; } else { $marray[$bday] .= " ( {$ubbt_lang['BDAY']}: $uname $age ) \n"; } } } // ------------------------------------------------- // Grab all posts with calendar events for this month $query = " SELECT B_Subject,B_CalDay,B_Board,B_Approved FROM {$config['tbprefix']}Posts WHERE B_CalYear='$year' AND B_CalMonth='$month' "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while(list($subject,$topicday,$board,$approved) = $dbh -> fetch_array($sth)) { if ($approved != "yes") { continue; } if (!in_array($board,$canview)) { continue; } if (!isset($marray[$topicday])) { $marray[$topicday] = " ( {$ubbt_lang['TOPIC']}: $subject ) \n"; } else { $marray[$topicday] .= " ( {$ubbt_lang['TOPIC']}: $subject ) \n "; } } // ---------------------------------- // Now grab all events for this month $query = " SELECT C_Brief,C_Date,C_Month,C_Year,C_Recurring FROM {$config['tbprefix']}Calendar WHERE ( (C_Month = '$month' AND C_Year = '$year' AND C_Recurring='never') OR (C_Month = '$month' AND C_Recurring='yearly') OR (C_Recurring='monthly') ) AND ( (C_Type='public') OR (C_Type='private' AND C_Owner='{$user['U_Number']}') ) "; $sth = $dbh -> do_query($query,__LINE__,__FILE__); while(list($brief,$eday,$emonth,$eyear,$recurring) = $dbh -> fetch_array($sth)) { if (!isset($marray[$eday])) { $marray[$eday] = " ( {$ubbt_lang['EVENT']}: $brief ) \n"; } else { $marray[$eday] .= " ( {$ubbt_lang['EVENT']}: $brief ) \n"; } } // -------------------------------- // get what weekday the first is on $temp = getdate(mktime(0,0,0,$month,1,$year)); $firstweekday = $temp["wday"]; $monthnum = $temp["mon"]; $mname = "MONTH$monthnum"; $monthname = $ubbt_lang[$mname]; // ----------------------------- // get the last day of the month $nextmonth = $month + 1; $tempyear = $year; if ($nextmonth == 13) { $nextmonth = 1; $tempyear = $tempyear + 1; } $temp = getdate(mktime(0,0,0,$nextmonth,0,$tempyear)); $lastday = $temp["mday"]; $currentdate = 1; $firstweek = true; $weekday = 1; $currentweek = 1; // -------------------------------------- // Loop through all the days of the month while ($currentdate <= $lastday) { $days[$currentdate] = ""; $printdate = $currentdate; if (($firstweek) && ($firstweekday)) { $days[$currentdate] .= ""; for ($i=1;$i<=$firstweekday;$i++) { $days[$currentdate] .= " "; $weekday++; } $firstweek = false; }else { $firstweek = false; } if ($weekday == 1) { $days[$currentdate] .= ""; } $class = "lighttable"; $alt = ""; if (($currentdate == $thisday) && ($year == $thisyear) && ($month == $thismonth)) { $class="darktable"; $printdate = "$printdate"; $alt .= "( {$ubbt_lang['TODAY']} )\n"; } // -------------------- // Event for this day? $linkstart = ""; $linkstop = ""; if (isset($marray[$currentdate])) { $class="darktable"; $printdate = "$printdate"; $alt .= "$marray[$currentdate]"; $linkstart = ""; $linkstop = ""; } $alt = "alt=\"$alt\" title=\"$alt\""; $days[$currentdate] .= "$linkstart{$printdate}$linkstop
 
"; if ($weekday == 7) { $days[$currentdate] .= ""; $currentweek++; } $weekday++; if ($weekday > 7) { $weekday = 1; } $currentdate++; } // Fill out the rest of the table if ($weekday > 1) { for ($i=$weekday;$i<=7;$i++) { $days[$currentdate] = " "; $currentdate = $currentdate + 1; } $currentdate = $currentdate - 1; $days[$currentdate] .= ""; } if (!$debug) { list($tbopen,$tbclose) = $html -> table_wrapper("full"); include("$thispath/templates/$tempstyle/calendar_makemonth.tmpl"); } return $template; } ?>