From: Roger R. <eps...@us...> - 2002-03-22 21:29:31
|
Update of /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar In directory usw-pr-cvs1:/tmp/cvs-serv21795 Modified Files: pninit.php pnuser.php pnuserapi.php Log Message: added Month view and fixed some other stuff that was broken Index: pninit.php =================================================================== RCS file: /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar/pninit.php,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** pninit.php 22 Mar 2002 00:45:45 -0000 1.5 --- pninit.php 22 Mar 2002 21:29:28 -0000 1.6 *************** *** 218,222 **** pnModDelVar('PostCalendar', 'nexteventsdatedisplay'); pnModDelVar('PostCalendar', 'nebtopicdisplay'); ! pnModSetVar('PostCalendar', 'neblocationdisplay'); // Deletion successful --- 218,222 ---- pnModDelVar('PostCalendar', 'nexteventsdatedisplay'); pnModDelVar('PostCalendar', 'nebtopicdisplay'); ! pnModDelVar('PostCalendar', 'neblocationdisplay'); // Deletion successful Index: pnuser.php =================================================================== RCS file: /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar/pnuser.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pnuser.php 22 Mar 2002 00:45:45 -0000 1.6 --- pnuser.php 22 Mar 2002 21:29:28 -0000 1.7 *************** *** 86,90 **** $output->SetInputMode(_PNH_VERBATIMINPUT); ! $output->Text(PostCalendar_usermenu()); $output->SetInputMode(_PNH_PARSEINPUT); --- 86,92 ---- $output->SetInputMode(_PNH_VERBATIMINPUT); ! if($viewtype != 'details') { ! $output->Text(PostCalendar_usermenu()); ! } $output->SetInputMode(_PNH_PARSEINPUT); *************** *** 93,98 **** $output->SetInputMode(_PNH_PARSEINPUT); ! $output->Text($viewtype.' '.$Date); ! $output->Linebreak(); return $output->GetOutput(); } --- 95,100 ---- $output->SetInputMode(_PNH_PARSEINPUT); ! //$output->Text($viewtype.' '.$Date); ! //$output->Linebreak(); return $output->GetOutput(); } *************** *** 131,137 **** --- 133,144 ---- case 'month': + $output->Text(pnModAPIFunc('PostCalendar','user','buildMonth',array('Date'=>$Date))); break; case 'year': + break; + + case 'details': + $output->Text('detailed view : '.$eid); break; } Index: pnuserapi.php =================================================================== RCS file: /cvsroot/pn-modules/PN_PostCalendar/modules/PostCalendar/pnuserapi.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pnuserapi.php 22 Mar 2002 00:52:38 -0000 1.6 --- pnuserapi.php 22 Mar 2002 21:29:28 -0000 1.7 *************** *** 33,39 **** extract($args); ! if(!isset($pc_month)) { ! $pc_month = '01'; } switch($pc_month) { case '01': --- 33,40 ---- extract($args); ! if(!isset($Date)) { ! return false; } + $pc_month = Date('m',$Date); switch($pc_month) { case '01': *************** *** 220,224 **** if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { ! $link="\"javascript:opencal($eid);\""; } else { $link = pnModURL('PostCalendar','user','view',array('viewtype'=>'detail','eid'=>$eid)); --- 221,225 ---- if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { ! $link='javascript:opencal('.$eid.');'; } else { $link = pnModURL('PostCalendar','user','view',array('viewtype'=>'detail','eid'=>$eid)); *************** *** 434,437 **** --- 435,453 ---- $output->SetInputMode(_PNH_VERBATIMINPUT); $output->SetOutputMode(_PNH_KEEPOUTPUT); + + // just so it looks good in the view source + if(pnModGetVar('PostCalendar','eventsopeninnewwindow')) { + $javascript = " + <script language=\"javascript\"> + <!-- + function opencal(eid) + { window.name='csCalendar'; + w = window.open('index.php?module=PostCalendar&func=view&viewtype=details&eid='+eid,'PostCalendarEvents','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=300'); + } + // --> + </script>"; + $output->Text($javascript); + } + $output->TableStart(); *************** *** 460,464 **** /**** Print Month Name and Year */ $pc_longDayName = pnModAPIFunc('PostCalendar','user','getLongDayName',array('Date'=>$Date)); ! $pc_monthName = pnModAPIFunc('PostCalendar','user','getMonthName',array('Date'=>$Date)); $output->Text('<td align="center">'); if (pnModGetVar('PostCalendar','useinternationaldates')) { --- 476,480 ---- /**** Print Month Name and Year */ $pc_longDayName = pnModAPIFunc('PostCalendar','user','getLongDayName',array('Date'=>$Date)); ! $pc_monthName = pnModAPIFunc('PostCalendar','user','getmonthname',array('Date'=>$Date)); $output->Text('<td align="center">'); if (pnModGetVar('PostCalendar','useinternationaldates')) { *************** *** 665,669 **** if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { ! $link="\"javascript:opencal($eid);\""; } else { $link= pnModURL('PostCalendar','user','view',array('viewtype'=>detail,'eid'=>$eid)); --- 681,685 ---- if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { ! $link='javascript:opencal('.$eid.');'; } else { $link= pnModURL('PostCalendar','user','view',array('viewtype'=>detail,'eid'=>$eid)); *************** *** 699,702 **** --- 715,1253 ---- return $output->GetOutput(); } + + function PostCalendar_userapi_buildMonth($args) + { + // get the theme globals :: is there a better way to do this? + global $bgcolor1, $bgcolor2, $bgcolor3, $bgcolor4, $bgcolor5; + global $textcolor1, $textcolor2; + + extract($args); + if(!isset($Date)) { + $Date = Date("m/d/Y"); + } + $Date_Array = explode('/',$Date); + + // get DB information + pnModDBInfoLoad('PostCalendar'); + list($dbconn) = pnDBGetConn(); + $pntable = pnDBGetTables(); + $events_table = $pntable['postcalendar_events']; + $events_column = &$pntable['postcalendar_events_column']; + $topics_table = $pntable['topics']; + $topics_column = &$pntable['topics_column']; + + // lets get the module's information + $modid = pnModGetIDFromName('PostCalendar'); + $modinfo = pnModGetInfo($modid); + + // let's load the User API so we can use it :) + if(!pnModAPILoad('PostCalendar','user')) { + die('Could not load PostCalendar user API'); + } + + // start the output container + $output = new pnHTML(); + $output->SetInputMode(_PNH_VERBATIMINPUT); + $output->SetOutputMode(_PNH_KEEPOUTPUT); + + if($Date_Array[2] < 1970) { + $output->Text('Sorry! We can\'t interpret dates before 01/01/1970'); + return $output->GetOutput(); + } + + // load the DHTML JavaScript code and insert it into the page + if (!pnModGetVar('PostCalendar','textevents')) { + $output->Text(pnModAPIFunc('PostCalendar','user','loadPopups')); + } + + // just so it looks good in the view source + if(pnModGetVar('PostCalendar','eventsopeninnewwindow')) { + $javascript = " + <script language=\"javascript\"> + <!-- + function opencal(eid) + { window.name='csCalendar'; + w = window.open('index.php?module=PostCalendar&func=view&viewtype=details&eid='+eid,'PostCalendarEvents','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=600,height=300'); + } + // --> + </script>"; + $output->Text($javascript); + } + + $Date = mktime('', '', '', $Date_Array[0], $Date_Array[1], $Date_Array[2]); + + $Prev_Month = strftime("%m/%d/%Y",mktime(0,0,0,$Date_Array[0]-1, 1, $Date_Array[2])); + $Next_Month = strftime("%m/%d/%Y",mktime(0,0,0,$Date_Array[0]+1, 1, $Date_Array[2])); + + //******************************************************************* + // Here we build the month header and navigation + // << Prev MONTH YEAR Next >> + //******************************************************************* + $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor2.'">'); + $output->Text('<table border="0" cellpadding="5" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor1.'">'); + $output->TableStart(); + $output->SetOutputMode(_PNH_RETURNOUTPUT); + + $pc_prev = pnModURL('PostCalendar','user','view',array('viewtype'=>'month','Date'=>$Prev_Month)); + $pc_next = pnModURL('PostCalendar','user','view',array('viewtype'=>'month','Date'=>$Next_Month)); + $pc_prev_url = $output->URL($pc_prev,'<< '._PC_PREV_MONTH); + $pc_next_url = $output->URL($pc_next,_PC_NEXT_MONTH.' >>'); + $pc_month_name = pnModAPIFunc('PostCalendar','user','getmonthname',array('Date'=>$Date)); + $month_link_url = pnModURL('PostCalendar','user','view',array('viewtype'=>'month','Date'=>$Date_Array[0].'/1/'.$Date_Array[2])); + $month_link_text = $pc_month_name.' '.$Date_Array[2]; + $pc_link = $output->URL($month_link_url,$month_link_text); + $row = array(); + $row[0]['content'] = $pc_prev_url; + $row[0]['align'] = 'left'; + $row[0]['valign'] = 'middle'; + + $row[1]['content'] = $pc_link; + $row[1]['align'] = 'center'; + $row[1]['valign'] = 'middle'; + + $row[2]['content'] = $pc_next_url; + $row[2]['align'] = 'right'; + $row[2]['valign'] = 'middle'; + + $output->SetOutputMode(_PNH_KEEPOUTPUT); + $output->TableAddRow($row); + $output->TableEnd(); + $output->Text('</td></tr></table>'); + $output->Text('</td></tr></table>'); + //******************************************************************* + // End of the month header and navigation + // << Prev MONTH YEAR Next >> + //******************************************************************* + + $First_Day_of_Month_Date = mktime("", "", "", $Date_Array[0], 1, $Date_Array[2]); + $Day_of_First_Week = Date("w",$First_Day_of_Month_Date); + + /**** Find the last day of the month */ + $Month = Date("m",$Date); + $day = 27; + do { + $End_of_Month_Date = mktime("", "", "", $Date_Array[0], $day, $Date_Array[2]); + $Test_Month = Date("m",$End_of_Month_Date); + $day += 1; + } while ( $Month == $Test_Month ); + $Last_Day = $day - 2; + + /**** Get todays date */ + $Today_d = Date("d"); + $Today_m = Date("m"); + $Today_y = Date("Y"); + + $sql = "SELECT $topics_column[topicid],$topics_column[topictext] FROM $topics_table"; + $result_topics = $dbconn->Execute($sql); + for(; !$result_topics->EOF; $result_topics->MoveNext()) { + list($topicid,$topictext) = $result_topics->fields; + $topics_array[$topicid] = $topictext; + } + + $count = -1; + $sql = "SELECT $events_column[eid], + $events_column[title], + $events_column[hometext], + $events_column[eventDate], + $events_column[endDate], + $events_column[barcolor], + $events_column[recurrtype], + $events_column[topic] + FROM $events_table + WHERE ((($events_column[eventDate] >= '$Date_Array[2]-$Date_Array[0]-1' + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-$Last_Day') + OR ($events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-1' + AND $events_column[endDate] <= '$Date_Array[2]-$Date_Array[0]-$Last_Day') + OR ($events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-$Last_Day' + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-1')) + AND $events_column[alldayevent]='1') + ORDER BY $events_column[eventDate], $events_column[topic] ASC + "; + $result = $dbconn->Execute($sql); + + for(; !$result->EOF; $result->MoveNext()) { + list($eid, + $title, + $description, + $eventDate, + $endDate, + $barcolor, + $recurrtype, + $topic) = $result->fields; + + $eid_Array[] = $eid; + $title_Array[] = $title; + $eventDate_Array[] = $eventDate; + $endDate_Array[] = $endDate; + $barcolor_Array[] = $barcolor; + $topic_Array[] = $topic; + $recurrtype_Array[] = $recurrtype; + $desc_Array[] = pnModAPIFunc('PostCalendar','user','valueToText',array('tmp'=>$description)); + $count++; + } + $result_topics->Close(); + $result->Close(); + + //******************************************************************* + // Here we build the actual calendar + //******************************************************************* + $day_of_week = 1; + $pc_long_day_names = array(_CALSUNDAY, + _CALMONDAY, + _CALTUESDAY, + _CALWEDNESDAY, + _CALTHURSDAY, + _CALFRIDAY, + _CALSATURDAY); + + switch (pnModGetVar('PostCalendar','firstdayoftheweek')) + { + case 0: + // sunday is the first day of the week + $pc_array_pos = 0; + $Day_of_First_Week = Date("w",$First_Day_of_Month_Date); + 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; + if ($Day_of_First_Week == 0) { $Day_of_First_Week = 7; } + break; + case 2: + // saturday is the first day of the week + $pc_array_pos = 6; + $Day_of_First_Week = Date("w",$First_Day_of_Month_Date) +1; + if ($Day_of_First_Week == 0) { $Day_of_First_Week = 6; } + break; + default: + // sunday is the first day of the week + $pc_array_pos = 0; + $Day_of_First_Week = Date("w",$First_Day_of_Month_Date); + break; + } + // build the long day name header row + $output->SetOutputMode(_PNH_RETURNOUTPUT); + $daynames_row = $output->Text('<tr bgcolor="'.pnModGetVar('PostCalendar','trimbgcolor').'">'); + for($i=0; $i < count($pc_long_day_names); $i++) + { + if($pc_array_pos >= count($pc_long_day_names)) { + $pc_array_pos = 0; + } + $header_width = 100/7; + $daynames_row .= $output->Text('<th width="'.$header_width.'%">'); + $daynames_row .= $output->Text('<font class="pn-sub" color="'.pnModGetVar('PostCalendar','trimtextcolor').'">'.$pc_long_day_names[$pc_array_pos].'</font>'); + $daynames_row .= $output->Text('</th>'); + $pc_array_pos++; + } + $daynames_row .= $output->Text('</tr>'); + $output->SetOutputMode(_PNH_KEEPOUTPUT); + + $output->Text('<table border="0" cellpadding="1" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor2.'">'); + $output->Text('<table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td bgcolor="'.$bgcolor1.'">'); + + $output->Text('<table border="'.pnModGetVar('PostCalendar','monthtableborder').'" + cellspacing="'.pnModGetVar('PostCalendar','monthtablecellspacing').'" + cellpadding="'.pnModGetVar('PostCalendar','monthtablecellpadding').'" + width="100%" + bgcolor="'.$bgcolor2.'">'); + $output->Text($daynames_row); + + /**** Previous Greyed month days ****/ + while ($day_of_week < ($Day_of_First_Week + 1)) { + if ($day_of_week == 1) { + $output->Text('<tr>'); + } + $Tmp_Date = mktime("", "", "", $Date_Array[0], 1 - (($Day_of_First_Week + 1) - $day_of_week), $Date_Array[2]); + $Tmp_Day = Date("d",$Tmp_Date); + $output->Text('<td height="70" bgcolor="'.$bgcolor2.'" align="center" valign="top">'); + $output->Text('<font class="pn-sub" color="'.$textcolor2.'">'.$Tmp_Day.'</font></td>'); + $day_of_week += 1; + } + + $usedcount = 0; + $cellcount = 0; + /**** Build Current Month ****/ + for ($day = 1 ; $day <= $Last_Day ; $day++) { + if ($day_of_week == 1) { + $output->Text("<tr>"); + } + $output->SetOutputMode(_PNH_RETURNOUPUT); + $day_url = pnModURL('PostCalendar','user','view',array('Date'=>$Date_Array[0].'/'.$day.'/'.$Date_Array[2],'viewtype'=>'day')); + $output->SetOutputMode(_PNH_KEEPOUTPUT); + if (($day == $Today_d) && ($Date_Array[0] == $Today_m) && ($Date_Array[2] == $Today_y)) { + $output->Text('<td bgcolor="'.$bgcolor1.'" height="70" align="center" valign="top">'); + $output->Text('<table width="100%" + cellpadding="2" + cellspacing="0" + border="0">'); + $output->Text('<tr>'); + $output->Text('<td bgcolor="'.pnModGetVar('PostCalendar','dayhighlightcolor').'" align="center"><font class="pn-normal">'); + $output->Text('<a href="'.$day_url.'">'); + $output->Text('<b>'.$day.'</b></a></font></td></tr></table>'); + } else { + $output->Text('<td bgcolor="'.$bgcolor1.'" height="70" align="center" valign="top">'); + $output->Text('<table width="100%" + cellpadding="2" + cellspacing="0" + border="0">'); + $output->Text('<tr>'); + $output->Text('<td bgcolor="'.$bgcolor2.'" align="center"><font class="pn-normal">'); + $output->Text('<a href="'.$day_url.'">'); + $output->Text('<b>'.$day.'</b></a></font></td></tr></table>'); + } + + /**** SET UP DATA!!! ****/ + $cellDate = mktime (0, 0, 0, $Date_Array[0], $day, $Date_Array[2]); + for ($i=0;$i <= $cellcount - 1;$i++) { + $tmpEndDate_Array = explode("-", $cellArrayEndDate[$i]); + $tmpEndDate = mktime (0, 0, 0, $tmpEndDate_Array[1], $tmpEndDate_Array[2], $tmpEndDate_Array[0]); + if ($tmpEndDate < $cellDate) { + $cellArray[$i] = "FALSE"; + } + } + /**** Clean out Cell Array */ + if ($cellcount != 0) { + $j = $cellcount; + for ($i=$cellcount - 1;$i >= 0;$i--) { + if ($cellArray[$i] == "FALSE") { + array_pop($cellArray); + array_pop($cellArrayTitle); + array_pop($cellArrayEventDate); + array_pop($cellArrayEndDate); + array_pop($cellArrayBarColor); + array_pop($cellArrayDesc); + $j--; + } else { + break; + } + } + $cellcount = $j; + } + /**** Add neccessary additions to cellArray */ + while ((strtotime($eventDate_Array[$usedcount]) <= strtotime("$Date_Array[2]-$Date_Array[0]-$day")) && ($usedcount <= $count)) { + $added = "FALSE"; + /**** First Try to find a spot in the cell for the event */ + for ($i=0;$i <= $cellcount - 1;$i++) { + if ($cellArray[$i] == "FALSE") { + /**** Found spot in cellArray */ + $cellArray[$i] = $eid_Array[$usedcount]; + $cellArrayTitle[$i] = $title_Array[$usedcount]; + $cellArrayEventDate[$i] = $eventDate_Array[$usedcount]; + $cellArrayEndDate[$i] = $endDate_Array[$usedcount]; + $cellArrayBarColor[$i] = $barcolor_Array[$usedcount]; + $cellArrayTopic[$i] = $topic_Array[$usedcount]; + $cellArrayrecurrtype[$i] = $recurrtype_Array[$usedcount]; + $cellArrayDesc[$i] = $desc_Array[$usedcount]; + $added = "TRUE"; + break 1; + } + } + /**** If all spots are taken in the current cellArray then add it to the end */ + if ($added == "FALSE") { + $cellArray[] = $eid_Array[$usedcount]; + $cellArrayTitle[] = $title_Array[$usedcount]; + $cellArrayEventDate[] = $eventDate_Array[$usedcount]; + $cellArrayEndDate[] = $endDate_Array[$usedcount]; + $cellArrayBarColor[] = $barcolor_Array[$usedcount]; + $cellArrayTopic[] = $topic_Array[$usedcount]; + $cellArrayrecurrtype[] = $recurrtype_Array[$usedcount]; + $cellArrayDesc[] = $desc_Array[$usedcount]; + $cellcount++; /**** Increase cell count since added to the end of the array */ + } + $usedcount++; + } + + /**************************************/ + /**** INSERT DATA INTO CALENDAR!!! ****/ + /**************************************/ + for ($i = 0; $i <= $cellcount - 1; $i++) { + $output->Text('<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr>'); + + if(!preg_match('/[rgby]/',$cellArrayBarColor[$i])) { + $barcolorchar = 'w'; + } else { + $barcolorchar = $cellArrayBarColor[$i]; + } + + // start the actual display of events + $eid=$cellArray[$i]; + if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { + $link = 'javascript:opencal('.$eid.');'; + } else { + $link = pnModURL('PostCalendar','user','view',array('viewtype'=>'detail','eid'=>$eid)); + } + + if ($cellArray[$i] != "FALSE") { + $tmpEventDate_Array = explode("-", $cellArrayEventDate[$i]); + $tmpEventDate = mktime (0, 0, 0, $tmpEventDate_Array[1], $tmpEventDate_Array[2], $tmpEventDate_Array[0]); + $tmpEndDate_Array = explode("-", $cellArrayEndDate[$i]); + $tmpEndDate = mktime (0, 0, 0, $tmpEndDate_Array[1], $tmpEndDate_Array[2], $tmpEndDate_Array[0]); + $tmpRecurrtype=$cellArrayrecurrtype[$i]; + if (pnModGetVar('PostCalendar','textevents')) { + $output->Text("<td><p><font class=\"pn-normal\"><img src=\"modules/$modinfo[directory]/pnimages/ball$barcolorchar.gif\" border=0>"); + $output->Text("<a href=\"$link\"> $cellArrayTitle[$i]</a></font><br>"); + if ( !$old_topic || $cellArrayTopic[$i] !== $old_topic ) { + $output->Text("<font class=\"pn-tiny\">".$topics_array[$cellArrayTopic[$i]]."</font></p></td>"); + } + + } else { + if ($tmpRecurrtype == 0) { + $popuptext = "onmouseover=\"popUp('$cellArrayTitle[$i]','$cellArrayDesc[$i]');\" onmouseout=\"popOut();\""; + if (($cellDate == $tmpEndDate) && ($tmpEndDate == $tmpEventDate)) { + $output->Text("<td><a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/leftbar$barcolorchar.gif\" border=\"0\"></a></td> + <td align=\"right\" width=100% background=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\"> + <a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/mainbar2$barcolorchar.gif\" border=\"0\"></a></td> + <td align=\"right\"><a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/rightbarcap$barcolorchar.gif\" border=\"0\"></a></td>"); + } elseif ($cellDate == $tmpEventDate) { + $output->Text("<td><a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/leftbar$barcolorchar.gif\" border=\"0\"></a></td> + <td align=\"center\" width=100% background=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\"> + <a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/mainbar2$barcolorchar.gif\" border=\"0\"></a></td>"); + } elseif ($cellDate == $tmpEndDate) { + $output->Text("<td align=\"center\" width=100% background=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\"> + <a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/mainbar2$barcolorchar.gif\" border=\"0\"></a></td> + <td><a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/rightbar$barcolorchar.gif\" border=\"0\"></a></td>"); + } else { + if ($day == 1) { + $output->Text("<td><a href=$link $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/leftbar2$barcolorchar.gif\" border=\"0\"></a></td> + <td align=\"center\" width=100% background=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\"> + <a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/mainbar2$barcolorchar.gif\" border=\"0\"></a></td>"); + } else { + $output->Text("<td bgcolor=\"$bgcolor1\" align=\"center\" background=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\"> + <a href=\"$link\" $popuptext> + <img src=\"modules/$modinfo[directory]/pnimages/mainbar$barcolorchar.gif\" border=\"0\"></a></td>"); + } + } + } + } + } else { + if (!pnModGetVar('PostCalendar','textevents')) { + $output->Text("<td width=\"100%\"><img src=\"modules/$modinfo[directory]/pnimages/blankbar.gif\"></td>"); + } + } + $output->Text("</tr></table>"); + $old_topic = $cellArrayTopic[$i]; + } /*** for ($i=0;$i<=$cellcount - 1;$i++) ***/ + unset($old_topic); + $sql = "SELECT $events_column[eid], + $events_column[title], + $events_column[eventDate], + $events_column[endDate], + $events_column[startTime], + $events_column[endTime], + $events_column[alldayevent], + $events_column[barcolor], + $events_column[topic] + FROM $events_table + WHERE ($events_column[recurrtype] = 0 + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-$day' + AND $events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-$day') + + OR ($events_column[recurrtype]=1 + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-$day' + AND $events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-$day' + AND (DAYOFWEEK($events_column[eventDate])=DAYOFWEEK('$Date_Array[2]-$Date_Array[0]-$day'))) + + OR ($events_column[recurrtype]=2 + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-$day' + AND $events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-$day' + AND (DAYOFMONTH($events_column[eventDate])=DAYOFMONTH('$Date_Array[2]-$Date_Array[0]-$day'))) + + OR ($events_column[recurrtype]=3 + AND $events_column[eventDate] <= '$Date_Array[2]-$Date_Array[0]-$day' + AND $events_column[endDate] >= '$Date_Array[2]-$Date_Array[0]-$day' + AND (DAYOFMONTH($events_column[eventDate])=DAYOFMONTH('$Date_Array[2]-$Date_Array[0]-$day')) + AND (MONTH($events_column[eventDate])=MONTH('$Date_Array[2]-$Date_Array[0]-$day'))) + ORDER BY $events_column[topic], + $events_column[alldayevent], + $events_column[startTime], + $events_column[endTime], + $events_column[title] ASC"; + + $resultAPPT = $dbconn->Execute($sql); + + for(; !$resultAPPT->EOF; $resultAPPT->MoveNext()) { + list($eid, + $title, + $eventDate, + $endDate, + $startTime, + $endTime, + $alldayevent, + $barcolor, + $topic) = $resultAPPT->fields; + + if(!preg_match('/[rgby]/',$barcolor)) { + $barcolorchar = 'w'; + } else { + $barcolorchar = $barcolor; + } + + if (pnModGetVar('PostCalendar','time24hours')) { + $time_Array = explode(":",$startTime); + $startTime = $time_Array[0].":".$time_Array[1]; + $time_Array = explode(":",$endTime); + $endTime = $time_Array[0].":".$time_Array[1]; + } else { + $startTime = pnModAPIFunc('PostCalendar','user','getTime',array('time'=>$startTime)); + $endTime = pnModAPIFunc('PostCalendar','user','getTime',array('time'=>$endTime)); + } + + if (pnModGetVar('PostCalendar','eventsopeninnewwindow')) { + $link = 'javascript:opencal('.$eid.');'; + } else { + $link = pnModURL('PostCalendar','user','view',array('viewtype'=>'details','eid'=>$eid)); + } + + if ( !$old_topic || $topic !== $old_topic ) { + if ($alldayevent == 0 ) { + $output->Text("<p align=\"left\"><font class=\"pn-normal\">"); + $output->Text("<img src=\"modules/$modinfo[directory]/pnimages/ball$barcolorchar.gif\" border=0> "); + $output->Text("$startTime - $endTime<br><a href=\"$link\">$title</a></font><br>"); + $output->Text("<font class=\"pn-tiny\" color=$textcolor2>".$topics_array[$topic]."</font></p>"); + $old_topic = $topic; + } + } + unset($old_topic); + } // end of resultAPPT for loop + + $resultAPPT->Close(); + $output->Text("</td>"); + if ($day_of_week == 7) { + $day_of_week = 0; + $output->Text("</tr>"); + } + $day_of_week += 1; + + } // end :: for ($day = 1 ; $day <= $Last_Day ; $day++) + /**** Next Greyed month days */ + $day = 1; + while (($day_of_week <= 7) && ($day_of_week != 1)) { + $output->Text("<TD bgcolor=\"$bgcolor2\" align=\"center\" valign=\"top\"><FONT class=\"pn-sub\" color=\"$textcolor2\">$day</TD>"); + $day_of_week += 1; + $day += 1; + } + //$output->Text("</TR></TABLE></td></tr></table></CENTER>"); + + $output->Text('</tr></table>'); + + $output->Text('</td></tr></table>'); + $output->Text('</td></tr></table>'); + //******************************************************************* + // End of the actual calendar + //******************************************************************* + + /*** RETURN HTML ***/ + return $output->GetOutput(); + } + function PostCalendar_userapi_loadPopups() |