Kahuna
Joined: Aug 2002
Posts: 1,191 |
Josh and Mike Below the update for the Calendar 6.2 modification which uses the Profile Birthdays modification to populate the birthdays automatically. Files altered: postlist_event.php 1. Find <br /> if ($resp > 0) <br /> { <br /> if ($tm == '0') <br /> { <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php? <br /> Cat=$Cat&Board=$Board&Number=$Number&view=$view <br /> &sb=$sb&o=$o&mon=$mon&year=$year&cs=$cs\"> <br /> $Location:<br />$Subject</a>, ($resp responses)";[/] <br /> } <br /> else <br /> { <br /> $tm = strtotime($html -> convert_time($tm, $user['U_TimeOffset'])); <br /> $h = strtolower(strftime ("%I", $tm)); <br /> $m = strtolower(strftime ("%M", $tm)); <br /> $mer = strtolower(strftime ("%p", $tm)); <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php?Cat=$Cat& <br /> Board=$Board&Number=$Number&view=$view&sb=$sb& <br /> o=$o&mon=$mon&year=$year&cs=$cs\"> <br /> $Location, $h:$m $mer:<br /> $Subject</a>, ($resp responses)";[/] <br /> } <br /> } <br /> else <br /> { <br /> if ($tm == '0') <br /> { <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php?Cat=$Cat&Board=$Board <br /> &Number=$Number&view=$view&sb=$sb&o=$o&mon=$mon <br /> &year=$year&cs=$cs\">$Location:<br />$Subject</a>";[/][/] <br /> } <br /> Change it to <br /> if ($resp > 0) <br /> { <br /> if ($tm == '0') <br /> { <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php?Cat=$Cat&Board=$Board <br /> &Number=$Number&view=$view&sb=$sb&o=$o&mon=$mon <br /> &year=$year&cs=$cs\">$Location:<br />$Subject</a>, ($resp responses)";[/] <br /> } <br /> else <br /> { <br /> $tm = strtotime($html -> convert_time($tm, $user['U_TimeOffset'])); <br /> $h = strtolower(strftime ("%I", $tm)); <br /> $m = strtolower(strftime ("%M", $tm)); <br /> $mer = strtolower(strftime ("%p", $tm)); <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php?Cat=$Cat&Board=$Board <br /> &Number=$Number&view=$view&sb=$sb&o=$o&mon=$mon <br /> &year=$year&cs=$cs\">$Location, $h:$m $mer: <br /> <br /> $Subject</a>, ($resp responses)";[/] <br /> } <br /> } <br /> else <br /> { <br /> if ($tm == '0') <br /> { <br />// 20030113 - Birthday Update New Start <br /> if ( $Location == "Birthday" ) <br /> { <br /> $Evnt = $Subject; <br /> } <br /> else <br /> { <br />// 20030113 - Birthday Update New End <br /> [:"blue"]$Evnt = "<a href=\"$config[phpurl]/$mode.php?Cat=$Cat& <br /> Board=$Board&Number=$Number&view=$view&sb=$sb& <br /> o=$o&mon=$mon&year=$year&cs=$cs\"> <br /> $Location:<br />$Subject</a>";[/] <br />// 20030113 - Birthday Update New Start <br /> } <br />// 20030113 - Birthday Update New End <br /> } <br /> 2. Find <br /> // draw horizontal bar before each event except the first <br /> if ( !$first_event_for_day ) <br /> { <br /> $events .= "<hr width=95% align=\"center\" />"; <br /> } <br /> <br /> $events .= "<font color=\"red\"><b>›››</b></font> $Evnt<br />"; <br /> and CHANGE it to <br /> // draw horizontal bar before each event except the first <br />// 20030113 - Birthday Update Old Start <br />// if ( !$first_event_for_day ) <br />// 20030113 - Birthday Update Old End <br />// 20030113 - Birthday Update New Start <br /> if ( (!$first_event_for_day) and ($Location <> "Birthday") ) <br />// 20030113 - Birthday Update New End <br /> { <br /> $events .= "<hr width=95% align=\"center\" />"; <br /> } <br /> <br />// 20030113 - Birthday Update New Start <br /> if ( $Location == "Birthday" ) <br /> { <br /> $events .= "<font color=\"blue\"><b>›</b></font> $Evnt<br />"; <br /> } <br /> else <br /> { <br />// 20030113 - Birthday Update New End <br /> $events .= "<font color=\"red\"><b>›</b></font> $Evnt<br />"; <br />// 20030113 - Birthday Update New Start <br /> } <br />// 20030113 - Birthday Update New End <br /> 3. Find (function get_events_for_month($month, $year)) <br /> [:"blue"]$lowdate = mktime(0, 0, 0, $month, 1, $year) - <br /> $user['U_TimeOffset'] * 3600; // first day of this month, time 00:00:00 <br /> $highdate = mktime(0, 0, 0, $month+1, 1, $year) - <br /> $user['U_TimeOffset'] * 3600; // first day of next month, time 00:00:00 <br /> $birthMonth = mktime( 0, 0, 0, $month, 1, $year );[/] <br /> $Board_q = addslashes($Board); <br /> and CHANGE it to <br /> [:"blue"]$lowdate = mktime(0, 0, 0, $month, 1, $year) - <br /> $user['U_TimeOffset'] * 3600; // first day of this month, time 00:00:00[/] <br /> [:"blue"]$highdate = mktime(0, 0, 0, $month+1, 1, $year) - <br /> $user['U_TimeOffset'] * 3600; // first day of next month, time 00:00:00[/] <br /> <br /> $events_for_month = array(); <br />// 20030113 - Birthday Update New Start <br /> // Construct the query to check for the birthday modification <br /> $strQuery = " <br /> SHOW FIELDS <br /> FROM {$config['tbprefix']}Users <br /> "; <br /> <br /> $result = $dbh -> do_query($strQuery); <br /> <br /> $intFieldsFound = 0; <br /> <br /> // Cycle through the fields and increase the counter where appropriate <br /> while ( $arrDataLine = $dbh -> fetch_array($result) ) <br /> { <br /> if ( $arrDataLine[0] == "U_BirthYear" ) { $intFieldsFound++; }; <br /> if ( $arrDataLine[0] == "U_BirthDay" ) { $intFieldsFound++; }; <br /> if ( $arrDataLine[0] == "U_BirthMonth" ) { $intFieldsFound++; }; <br /> <br /> // Exit the loop if all three fields have been found <br /> if ( $intFieldsFound == 3 ) <br /> { <br /> break; <br /> } <br /> } <br /> <br /> $dbh -> finish_sth($result); <br /> <br /> if ( $intFieldsFound == 3 ) <br /> { <br /> $query = " <br /> SELECT U_Username, U_Birthday, U_BirthYear, U_Number <br /> FROM {$config['tbprefix']}Users <br /> WHERE U_BirthMonth = FROM_UNIXTIME($birthMonth,'%b') <br /> ORDER BY U_Username <br /> "; <br /> $result = $dbh->do_query($query); <br /> while(list($bUsername, $bBirthday, $bBirthYear, $bNumber ) = $dbh->fetch_array($result)) <br /> { <br /> <br /> if ( $bBirthYear > 0 ) <br /> { <br /> $bAge = $year - $bBirthYear; <br /> $bExtra = " ($bAge)"; <br /> } <br /> else <br /> { <br /> $bExtra = ""; <br /> } <br /> <br /> $arrData['E_ID'] = 0; <br /> $arrData['E_Date'] = mktime(0, 0, 0, $month, $bBirthday, $year) - $user['U_TimeOffset'] * 3600; // first day of this month, time 00:00:00 <br /> $arrData['E_Time'] = 0; <br /> $arrData['E_Location'] = "Birthday"; <br /> $arrData['B_Subject'] = "<a href=\"$config[phpurl]/showprofile.php?Cat=$Cat&User=$bNumber&what=\">$bUsername$bExtra</a><br />"; <br /> $arrData['B_Number'] = 0; <br /> $arrData['B_Replies'] = 0; <br /> <br /> $date = getdate($arrData['E_Date'] + $user['U_TimeOffset'] * 3600); <br /> $mday = $date['mday']; <br /> <br /> if (empty($events_for_month[$mday])) <br /> { <br /> $events_for_month[$mday] = array(); <br /> } <br /> array_push($events_for_month[$mday], $arrData); <br /> } <br /> <br /> $dbh->finish_sth($result); <br /> } <br />// 20030113 - Birthday Update New End <br /> <br /> <br /> $Board_q = addslashes($Board); <br /> 4. Find this: <br />// The second parameter MYSQL_ASSOC in the call to sql::to fetch_array() anticipates a <br />// requested change to that method, which will increase efficiency. Until that change <br />// is made, the parameter has no effect, but there's harm in leaving it there. <br /> <br /> $events_for_month = array(); <br /> while($row = $dbh->fetch_array($result, MYSQL_ASSOC)) { <br /> and CHANGE it to this <br />// The second parameter MYSQL_ASSOC in the call to sql::to fetch_array() anticipates a <br />// requested change to that method, which will increase efficiency. Until that change <br />// is made, the parameter has no effect, but there's harm in leaving it there. <br /> <br /> while($row = $dbh->fetch_array($result, MYSQL_ASSOC)) { <br /> NOTE: The code in [:"blue"]BLUE[/] is in ONE line only and has been split for aesthetic purposes only! That should do the trick Warm regards Nikos PS: Sorry that it took me so long to get this thing but I have been awfully busy lately [b]Edit:[b] Fixed small bug with Age calculation when the Age was not set. Added code to check for the Profile Birthday modification and display the birthdays automatically on the calendar. If the modification has not been installed the paricular code will not execute 2002-02-03 - Change to show the correct birthdays for users with time offset
Last edited by dimopoulos; 02/03/2003 5:00 AM.
Nikos
|