$periodlow) { array_push($events, $myrow); } else if ($period == 5 && $test >= 4 && $day+7 < NumDaysInMonth($month, $year)) { if ($test <= ($period-1) && $test > ($periodlow -1)) { array_push($events, $myrow); } } } } $resultID = Calendar_GetMonthly($day); if ($resultID) { $nr = sql_num_rows($resultID, $dbi); for ($k=0;$k<$nr;$k++) { $myrow = sql_fetch_array($resultID, $dbi); array_push($events, $myrow); } } $resultID = Calendar_GetMonthlyRecurring($dayofweek); if ($resultID) { $nr = sql_num_rows($resultID, $dbi); for ($k=0;$k<$nr;$k++) { $myrow = sql_fetch_array($resultID, $dbi); $test = $day / 7; $period = $myrow[recur_period]; if ($period == 5) $period = NumDotWInMonth($dayofweek, $month, $year); $periodlow = $period - 1; if ($test <= $period && $test > $periodlow) { array_push($events, $myrow); } else if ($period == 5 && $test >= 4 && $day+7 < NumDaysInMonth($month, $year)) { if ($test <= ($period-1) && $test > ($periodlow-1)) { array_push($events, $myrow); } } } } $resultID = Calendar_GetWeekly($dayofweek); if ($resultID) { $nr = sql_num_rows($resultID, $dbi); for ($k=0;$k<$nr;$k++) { $myrow = sql_fetch_array($resultID, $dbi); array_push($events, $myrow); } } return $events; } function Calendar_NumEventsOn($month, $day, $year, $dayofweek) { global $dbi; $rtnVal = 0; $resultID = Calendar_GetByDate($month, $day, $year); if ($resultID) { $rtnVal += sql_num_rows($resultID, $dbi); } $resultID = Calendar_GetYearly($month, $day); if ($resultID) { $rtnVal += sql_num_rows($resultID, $dbi); } $resultID = Calendar_GetYearlyRecurring($month, $dayofweek); if ($resultID) { $nr = sql_num_rows($resultID, $dbi); for ($k=0;$k<$nr;$k++) { $myrow = sql_fetch_array($resultID, $dbi); $test = $day / 7; $period = $myrow[recur_period]; if ($period == 5) $period = NumDotWInMonth($dayofweek, $month, $year); $periodlow = $period - 1; if ($test <= $period && $test > $periodlow) { $rtnVal++; } else if ($period == 5 && $test >= 4 && $day+7 < NumDaysInMonth($month, $year)) { if ($test <= ($period-1) && $test > ($periodlow -1)) { $rtnVal++; } } } } $resultID = Calendar_GetMonthly($day); if ($resultID) { $rtnVal += sql_num_rows($resultID, $dbi); } $resultID = Calendar_GetMonthlyRecurring($dayofweek); if ($resultID) { $nr = sql_num_rows($resultID, $dbi); for ($k=0;$k<$nr;$k++) { $myrow = sql_fetch_array($resultID, $dbi); $test = $day / 7; $period = $myrow[recur_period]; if ($period == 5) $period = NumDotWInMonth($dayofweek, $month, $year); $periodlow = $period - 1; if ($test <= $period && $test > $periodlow) { $rtnVal++; } else if ($period == 5 && $test >= 4 && $day+7 < NumDaysInMonth($month, $year)) { if ($test <= ($period-1) && $test > ($periodlow -1)) { $rtnVal++; } } } } $resultID = Calendar_GetWeekly($dayofweek); if ($resultID) { $rtnVal += sql_num_rows($resultID, $dbi); } return $rtnVal; } function Calendar_GetByDate($month, $day, $year, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $chkdate = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)); $query = "SELECT * FROM ".$a." WHERE onetime_date='$chkdate' AND isactive=1 AND isapproved=1 AND isrecurring=0 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_GetYearly($month, $day, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $chkdate = date("2000-m-d", mktime(0, 0, 0, $month, $day, 0)); $query = "SELECT * FROM $a WHERE onetime_date='$chkdate' AND isactive=1 AND isapproved=1 AND isrecurring=0 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_GetMonthly($day, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $chkdate = date("1900-00-d", mktime(0, 0, 0, 0, $day, 0)); $query = "SELECT * FROM $a WHERE onetime_date='$chkdate' AND isactive=1 AND isapproved=1 AND isrecurring=1 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_GetWeekly($weekday, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $query = "SELECT * FROM $a WHERE recur_weekday=$weekday AND recur_schedule='weekly' AND isactive=1 AND isrecurring=1 AND isapproved=1 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_GetYearlyRecurring($month, $weekday, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $query = "SELECT * FROM $a WHERE recur_weekday=$weekday AND recur_schedule='yearly' AND recur_month=$month AND isactive=1 AND isrecurring=1 AND isapproved=1 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_GetMonthlyRecurring($weekday, $otherwhere = "") { global $dbi, $user_prefix; $a = $user_prefix."_calendar_events"; $query = "SELECT * FROM $a WHERE recur_weekday=$weekday AND recur_schedule='monthly' AND isactive=1 AND isrecurring=1 AND isapproved=1 $otherwhere ORDER BY starttime"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_Insert_Row($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month) { global $dbi, $user_prefix; $fulldesc = FixQuotes(filter_text($fulldesc)); $location = FixQuotes(filter_text($location)); $title = FixQuotes(filter_text($title)); $starttime = TimeToMilitaryTime($start_hour, $start_min, $start_pm); $duration = $dur_hour . ":" . $dur_min; $query = "INSERT INTO ".$user_prefix."_calendar_events (title, location, fulldesc, starttime, duration, isactive, isrecurring, categoryid, isapproved, onetime_date, recur_weekday, recur_schedule, recur_period, recur_month) VALUES ('$title', '$location', '$fulldesc', '$starttime', '$duration', '$isactive', '$isrecurring', '$categoryid', '$isapproved', '$onetime_date', '$recur_weekday', '$recur_schedule', '$recur_period', '$recur_month')"; //echo $query . "
"; $resultID = sql_query($query, $dbi); return $resultID; } function Calendar_User_Insert_Row($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month) { $isapproved = 0; global $dbi, $user_prefix; $result = sql_query("SELECT * FROM ".$user_prefix."_calendar_options WHERE 1", $dbi); $row = sql_fetch_array($result, $dbi); if ($row[user_submitted_events_need_admin_aproval] == 0) $isapproved = 1; if ($row[allow_user_submitted_events] == 1) { Calendar_Insert_Row($title, $location, $fulldesc, $start_hour, $start_min, $start_pm, $dur_hour, $dur_min, $isactive, $isrecurring, $categoryid, $isapproved, $onetime_date, $recur_weekday, $recur_schedule, $recur_period, $recur_month); } } ?>