From: Roger R. <eps...@us...> - 2002-03-27 23:20:55
|
Update of /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar In directory usw-pr-cvs1:/tmp/cvs-serv29315 Modified Files: pnuserapi.php Log Message: Upgrade from 2.6 to 2.6.1 New column added in events and events_queue tables pc_recurrfreq Week view introduced Monthly events should now appear in the calendar correctly JavaScript popups should/might be fixed - not tested TODO: Add new event display logic to blocks Year view Submit Event Search Events Admin Events Index: pnuserapi.php =================================================================== RCS file: /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar/pnuserapi.php,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** pnuserapi.php 27 Mar 2002 22:29:43 -0000 1.24 --- pnuserapi.php 27 Mar 2002 23:20:52 -0000 1.25 *************** *** 872,875 **** --- 872,876 ---- $events_column[barcolor], $events_column[recurrtype], + $events_column[recurrfreq], $events_column[topic] *************** *** 887,891 **** for($e=0; !$result->EOF; $result->MoveNext()) { ! list($eid,$title,$hometext,$eventDate,$endDate,$startTime,$endTime,$barcolor,$recurrtype,$topic) = $result->fields; $events[$e]['eid'] = $eid; $events[$e]['title'] = $title; --- 888,892 ---- for($e=0; !$result->EOF; $result->MoveNext()) { ! list($eid,$title,$hometext,$eventDate,$endDate,$startTime,$endTime,$barcolor,$recurrtype,$recurrfreq,$topic) = $result->fields; $events[$e]['eid'] = $eid; $events[$e]['title'] = $title; *************** *** 897,900 **** --- 898,902 ---- $events[$e]['barcolor'] = $barcolor; $events[$e]['recurrtype'] = $recurrtype; + $events[$e]['recurrfreq'] = $recurrfreq; $events[$e]['topic'] = $topic; $e++; *************** *** 1105,1109 **** list($event_year,$event_month,$event_day) = explode('-',$events[$e]['eventDate']); - /** * Display event on same WEEK DAY each Month --- 1107,1110 ---- *************** *** 1112,1116 **** * of each month for it's duration. */ ! if(1) { //$events[$e]['recurrfreq'] === _RECUR_SAME_DAY) { (not yet implemented) $current_day_of_week = date('w',mktime(0,0,0,$this_month,$this_day,$this_year)); $event_day_of_week = date('w',mktime(0,0,0,$event_month,$event_day,$event_year)); --- 1113,1117 ---- * of each month for it's duration. */ ! if($events[$e]['recurrfreq'] == _RECUR_SAME_DAY) { $current_day_of_week = date('w',mktime(0,0,0,$this_month,$this_day,$this_year)); $event_day_of_week = date('w',mktime(0,0,0,$event_month,$event_day,$event_year)); *************** *** 1151,1154 **** --- 1152,1166 ---- * (this is not yet implemented as it needs DB changes */ + if($events[$e]['recurrfreq'] == _RECUR_SAME_DATE) { + if($this_day === $event_day) { + $output->Text('<tr><td align="left" valign="top">'); + $output->Text(pnModAPIFunc('PostCalendar', + 'user', + 'createEventLink', + array('event'=>$events[$e], + 'dayofweek'=>$i+1))); + $output->Text('</td></tr>'); + } + } } *************** *** 1258,1261 **** --- 1270,1286 ---- } + // this should make things a bit clearer later on + define('_EVENT_DAILY', 0); + define('_EVENT_WEEKLY', 1); + define('_EVENT_MONTHLY', 2); + define('_EVENT_YEARLY', 3); + + define('_IS_SUNDAY', 0); + define('_IS_MONDAY', 1); + define('_IS_SATURDAY', 2); + + define('_RECUR_SAME_DAY', 0); + define('_RECUR_SAME_DATE', 1); + // grab the modules information $modinfo = pnModGetInfo(pnModGetIDFromName('PostCalendar')); *************** *** 1265,1269 **** $useinternationaldates = pnModGetVar('PostCalendar','useinternationaldates'); $eventsopeninnewwindow = pnModGetVar('PostCalendar','eventsopeninnewwindow'); ! $dayhighlightcolor = pnModGetVar('PostCalendar','dayhighlightcolor'); // start the output container $output = new pnHTML(); --- 1290,1296 ---- $useinternationaldates = pnModGetVar('PostCalendar','useinternationaldates'); $eventsopeninnewwindow = pnModGetVar('PostCalendar','eventsopeninnewwindow'); ! $dayhighlightcolor = pnModGetVar('PostCalendar','dayhighlightcolor'); ! $firstdayofweek = pnModGetVar('PostCalendar','firstdayofweek'); ! // start the output container $output = new pnHTML(); *************** *** 1337,1363 **** _CALSATURDAY); ! switch (pnModGetVar('PostCalendar','firstdayofweek')) { ! case '0': // sunday is the first day of the week $pc_array_pos = 0; $first_day = date('w',mktime(0,0,0,$the_month,1,$the_year)); break; ! case '1': // monday is the first day of the week $pc_array_pos = 1; //$Day_of_First_Week = Date("w",$First_Day_of_Month_Date) -1; $first_day = date('w',mktime(0,0,0,$the_month,1-1,$the_year)); - //if ($first_day == 0) { - // $first_day = 7; - //} break; ! case '2': // saturday is the first day of the week $pc_array_pos = 6; $first_day = date('w',mktime(0,0,0,$the_month,1+1,$the_year)); - //if ($first_day == 0) { - // $first_day = 6; - //} break; default: --- 1364,1384 ---- _CALSATURDAY); ! switch ($firstdayofweek) { ! case _IS_SUNDAY: // sunday is the first day of the week $pc_array_pos = 0; $first_day = date('w',mktime(0,0,0,$the_month,1,$the_year)); break; ! case _IS_MONDAY: // monday is the first day of the week $pc_array_pos = 1; //$Day_of_First_Week = Date("w",$First_Day_of_Month_Date) -1; $first_day = date('w',mktime(0,0,0,$the_month,1-1,$the_year)); break; ! case _IS_SATURDAY: // saturday is the first day of the week $pc_array_pos = 6; $first_day = date('w',mktime(0,0,0,$the_month,1+1,$the_year)); break; default: *************** *** 1368,1372 **** } - $sql = "SELECT $events_column[eid], $events_column[title], --- 1389,1392 ---- *************** *** 1378,1381 **** --- 1398,1402 ---- $events_column[barcolor], $events_column[recurrtype], + $events_column[recurrfreq], $events_column[topic] *************** *** 1384,1403 **** WHERE ($events_column[eventDate] <= '$the_year-$the_month-1' OR $events_column[endDate] >= '$the_year-$the_month-$last_day') ! ORDER BY $events_column[eventDate],$events_column[recurrtype] ASC"; ! /* ! OR ($events_column[eventDate] <= '$the_year-$the_month-1' AND $events_column[endDate] >= '$the_year-$the_month-$last_day') ! */ ! $result = $dbconn->Execute($sql); ! // this should make things a bit clearer later on ! define('_PC_DAILY', 0); ! define('_PC_WEEKLY', 1); ! define('_PC_MONTHLY', 2); ! define('_PC_YEARLY', 3); // put the information into an array for easy access $events = array(); for($i=0; !$result->EOF; $result->MoveNext()) { ! list($eid,$title,$hometext,$eventDate,$endDate,$startTime,$endTime,$barcolor,$recurrtype,$topic) = $result->fields; $events[$i]['eid'] = $eid; $events[$i]['title'] = $title; --- 1405,1416 ---- WHERE ($events_column[eventDate] <= '$the_year-$the_month-1' OR $events_column[endDate] >= '$the_year-$the_month-$last_day') ! ORDER BY $events_column[recurrtype] DESC"; ! $result = $dbconn->Execute($sql); // put the information into an array for easy access $events = array(); for($i=0; !$result->EOF; $result->MoveNext()) { ! list($eid,$title,$hometext,$eventDate,$endDate,$startTime,$endTime,$barcolor,$recurrtype,$recurrfreq,$topic) = $result->fields; $events[$i]['eid'] = $eid; $events[$i]['title'] = $title; *************** *** 1409,1412 **** --- 1422,1426 ---- $events[$i]['barcolor'] = $barcolor; $events[$i]['recurrtype'] = $recurrtype; + $events[$i]['recurrfreq'] = $recurrfreq; $events[$i]['topic'] = $topic; $i++; *************** *** 1414,1420 **** ! $monthtableborder = pnModGetVar('PostCalendar','monthtableborder'); ! $monthtablecellspacing = pnModGetVar('PostCalendar','monthtablecellspacing'); ! $monthtablecellpadding = pnModGetVar('PostCalendar','monthtablecellpadding'); //******************************************************************* // START CALENDAR TABLE --- 1428,1434 ---- ! $monthtableborder = pnModGetVar('PostCalendar','monthtableborder'); ! $monthtablecellspacing = pnModGetVar('PostCalendar','monthtablecellspacing'); ! $monthtablecellpadding = pnModGetVar('PostCalendar','monthtablecellpadding'); //******************************************************************* // START CALENDAR TABLE *************** *** 1488,1499 **** $highlight = date('d',mktime(0,0,0,$the_month,$day,$the_year)) == date('d') ? $bgcolor2 : $bgcolor1; - //echo $hightlight; $output->Text('<td height="70" bgcolor="'.$bgcolor1.'" align="left" valign="top">'); - //$output->TableStart(); $output->Text('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr>'); $output->Text('<td bgcolor="'.$highlight.'" align="left" valign="top" nowrap>'); - //$day = (int) $day < 10 ? '0'.$day : $day; - $output->SetOutputMode(_PNH_RETURNOUTPUT); $this_date = date('m/d/Y',mktime(0,0,0,$the_month,$day,$the_year)); --- 1502,1509 ---- *************** *** 1506,1510 **** $week_result = $dbconn->Execute("SELECT WEEK('$week')"); list($week) = $week_result->fields; ! if ($pc_array_pos == 6) { $week++; } --- 1516,1520 ---- $week_result = $dbconn->Execute("SELECT WEEK('$week')"); list($week) = $week_result->fields; ! if ($firstdayofweek == _IS_SATURDAY) { $week++; } *************** *** 1524,1528 **** $output->Text('</td>'); $output->Text('<td bgcolor="'.$highlight.'" align="right" valign="top">'); - //$output->SetOutputMode(_PNH_RETURNOUTPUT); $this_date = date('m/d/Y',mktime(0,0,0,$the_month,$day,$the_year)); --- 1534,1537 ---- *************** *** 1552,1561 **** $output->Text('<a href="'.$submit_url.'" '.$popuptext.'>'.$img_src.'</a>'); - - - //$output->SetOutputMode(_PNH_KEEPOUTPUT); - //$output->Text($submit_link); $output->Text('</td>'); - $output->Text('</tr></table>'); --- 1561,1565 ---- *************** *** 1568,1572 **** switch ($events[$i]['recurrtype']) { ! case _PC_DAILY : // display an event on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { --- 1572,1576 ---- switch ($events[$i]['recurrtype']) { ! case _EVENT_DAILY : // display an event on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { *************** *** 1581,1585 **** break; ! case _PC_WEEKLY : // display an event weekly on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { --- 1585,1589 ---- break; ! case _EVENT_WEEKLY : // display an event weekly on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { *************** *** 1601,1638 **** break; ! case _PC_MONTHLY : // display an event once a month on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { list($event_year,$event_month,$event_day) = explode('-',$events[$i]['eventDate']); ! ! $current_week_day = date('D',mktime(0,0,0,$this_month,$this_day,$this_year)); ! // grab week number using a DB query (does this work everywhere) ! $week = date('Y-m-d',mktime(0,0,0,$this_month,1,$this_year)); ! $week_result = $dbconn->Execute("SELECT WEEK('$week')"); ! list($current_week_start_num) = $week_result->fields; ! $week = date('Y-m-d',mktime(0,0,0,$this_month,$this_day,$this_year)); ! $week_result = $dbconn->Execute("SELECT WEEK('$week')"); ! list($current_week_num) = $week_result->fields; ! // this only works in php 4.1.0+ ! //$current_week_start_num = date('W',mktime(0,0,0,$this_month,1,$this_year)); ! //$current_week_num = date('W',mktime(0,0,0,$this_month,$this_day,$this_year)); ! ! $event_week_day = date('D',mktime(0,0,0,$event_month,$event_day,$event_year)); ! // grab week number using a DB query (does this work everywhere) ! $week = date('Y-m-d',mktime(0,0,0,$event_month,1,$event_year)); ! $week_result = $dbconn->Execute("SELECT WEEK('$week')"); ! list($event_week_start_num) = $week_result->fields; ! $week = date('Y-m-d',mktime(0,0,0,$event_month,$event_day,$event_year)); ! $week_result = $dbconn->Execute("SELECT WEEK('$week')"); ! list($event_week_num) = $week_result->fields; ! // this only works in php 4.1.0+ ! //$event_week_start_num = date('W',mktime(0,0,0,$event_month,1,$event_year)); ! //$event_week_num = date('W',mktime(0,0,0,$event_month,$event_day,$event_year)); ! ! $week_diff = $current_week_num - $current_week_start_num; ! $event_diff = $event_week_num - $event_week_start_num; ! ! if($current_week_day === $event_week_day && $week_diff === $event_diff) { ! $output->Text('<tr><td align="left" valign="top">'); $output->Text(pnModAPIFunc('PostCalendar', 'user', --- 1605,1642 ---- break; ! case _EVENT_MONTHLY : // display an event once a month on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { list($event_year,$event_month,$event_day) = explode('-',$events[$i]['eventDate']); ! ! /** ! * Display event on same WEEK DAY each Month ! * This will cause a monthly event to always show on the same day of the month ! * If an event is started on the 1st Monday, it will always display on the 1st Monday ! * of each month for it's duration. ! */ ! if($events[$i]['recurrfreq'] == _RECUR_SAME_DAY) { ! $current_day_of_week = date('w',mktime(0,0,0,$this_month,$this_day,$this_year)); ! $event_day_of_week = date('w',mktime(0,0,0,$event_month,$event_day,$event_year)); ! ! $event_day_occurance=0; ! for($d=1; $d<=$event_day; $d++) { ! $current_day = date('w',mktime(0,0,0,$event_month,$d,$event_year)); ! if($current_day === $event_day_of_week) { ! $event_day_occurance++; ! } ! } ! ! $curr_day = date('d',mktime(0,0,0,$this_month,$this_day,$this_year)); ! $current_day_occurance=0; ! for($d=1; $d<=$curr_day; $d++) { ! $current_day = date('w',mktime(0,0,0,$this_month,$d,$this_year)); ! if($current_day === $current_day_of_week) { ! $current_day_occurance++; ! } ! } ! ! if($current_day_occurance === $event_day_occurance && $current_day_of_week === $event_day_of_week) { ! $output->Text('<tr><td align="left" valign="top">'); $output->Text(pnModAPIFunc('PostCalendar', 'user', *************** *** 1640,1649 **** array('event'=>$events[$i], 'dayofweek'=>$day_of_week))); ! $output->Text('</td></tr>'); } } ! break; ! ! case _PC_YEARLY : // display an event once a year on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { --- 1644,1674 ---- array('event'=>$events[$i], 'dayofweek'=>$day_of_week))); ! $output->Text('</td></tr>'); ! } ! } ! ! /** ! * Display event on same DATE each Month ! * This will cause a monthly event to always show on the same date of the month ! * If an event is started on the 25th of the Month it will always display ! * on the 25th of each month for its duration ! * (this is not yet implemented as it needs DB changes ! */ ! if($events[$i]['recurrfreq'] == _RECUR_SAME_DATE) { ! if($this_day === $event_day) { ! $output->Text('<tr><td align="left" valign="top">'); ! $output->Text(pnModAPIFunc('PostCalendar', ! 'user', ! 'createEventLink', ! array('event'=>$events[$i], ! 'dayofweek'=>$day_of_week))); ! $output->Text('</td></tr>'); ! } } + } ! break; ! ! case _EVENT_YEARLY : // display an event once a year on a certain day if($events[$i]['eventDate'] <= $compare_to_date && $events[$i]['endDate'] >= $compare_to_date) { |