[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jali.@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_plugins/calendar_menu/event.php,v $ 14 | $Revision: 1.30 $ 15 | $Date: 2006/11/16 10:24:14 $ 16 | $Author: e107coders $ 17 | 18 | 09.11.06 - Started next batch of mods 19 +----------------------------------------------------------------------------+ 20 */ 21 require_once ("../../class2.php"); 22 require_once(e_PLUGIN."calendar_menu/calendar_shortcodes.php"); 23 24 if (isset($_POST['viewallevents'])) 25 { // Triggered from NAV_BUT_ALLEVENTS 26 Header("Location: ".e_PLUGIN."calendar_menu/calendar.php?".$_POST['enter_new_val']); 27 } 28 29 if (isset($_POST['doit'])) 30 { // Triggered from NAV_BUT_ENTEREVENT 31 Header("Location: ".e_PLUGIN."calendar_menu/event.php?ne.".$_POST['enter_new_val']); 32 } 33 34 if (isset($_POST['subs'])) 35 { 36 Header("Location: ".e_PLUGIN."calendar_menu/subscribe.php"); 37 } 38 39 @include_lan(e_PLUGIN."calendar_menu/languages/".e_LANGUAGE.".php"); 40 define("PAGE_NAME", EC_LAN_80); 41 42 require_once(e_PLUGIN.'calendar_menu/ecal_class.php'); 43 global $ecal_class; 44 $ecal_class = new ecal_class; 45 $cal_super = $ecal_class->cal_super; 46 47 require_once(e_HANDLER."calendar/calendar_class.php"); 48 $cal = new DHTML_Calendar(true); 49 50 $category_filter = ""; 51 if ((isset($_POST['event_cat_ids']) && $_POST['event_cat_ids'] != "all")) 52 { 53 $category_filter = " AND (e.event_category = '".$_POST['event_cat_ids']."') "; 54 } 55 56 /* 57 // enter new category into db 58 if (isset($_POST['ne_cat_create'])) 59 { 60 if ($_POST['ne_new_category'] != "") 61 { 62 $sql->db_Insert("event_cat", "0, '".$tp->toDB($_POST['ne_new_category'])."', '".$tp->toDB($_POST['ne_new_category_icon'])."', '0', '0', '0', '0', '', '', '0', '0', '0', '".time()."', '0' "); 63 header("location:event.php?".$_POST['qs'].".m1"); 64 } 65 else 66 { 67 header("location:event.php?".$_POST['qs'].".m3"); 68 } 69 } 70 */ 71 // Event to add or update 72 if ((isset($_POST['ne_insert']) || isset($_POST['ne_update'])) && USER == true) 73 { 74 if (($_POST['ne_event'] == "") || !isset($_POST['qs'])) 75 { // Problem - tell user to go away 76 header("location:event.php?".$ev_start.".m3"); 77 } 78 else 79 { 80 $ev_start = $ecal_class->make_date($_POST['ne_hour'], $_POST['ne_minute'],$_POST['start_date']); 81 $ev_end = $ecal_class->make_date($_POST['end_hour'], $_POST['end_minute'],$_POST['end_date']); 82 $ev_title = $tp->toDB($_POST['ne_title']); 83 $ev_location = $tp->toDB($_POST['ne_location']); 84 $ev_event = $tp->toDB($_POST['ne_event']); 85 $temp_date = getdate($ecal_class->make_date(0,0,$_POST['start_date'])); 86 if ($_POST['recurring'] == 1) 87 { 88 $rec_m = $temp_date['mday']; // Day of month 89 $rec_y = $temp_date['mon']; // Month number 90 } 91 else 92 { 93 $rec_m = ""; 94 $rec_y = ""; 95 } 96 97 $report_msg = '.m3'; 98 if (isset($_POST['ne_insert'])) 99 { // Bits specific to inserting a new event 100 $qry = " 0, '".intval($ev_start)."', '".intval($ev_end)."', '".intval($_POST['allday'])."', '".intval($_POST['recurring'])."', '".time()."', '$ev_title', '$ev_location', '$ev_event', '".USERID.".".USERNAME."', '".$tp -> toDB($_POST['ne_email'])."', '".intval($_POST['ne_category'])."', '".$tp -> toDB($_POST['ne_thread'])."', '".intval($rec_m)."', '".intval($rec_y)."' "; 101 $sql->db_Insert("event", $qry); 102 $ecal_class->cal_log(1,'db_Insert',$qry, $ev_start); 103 $qs = preg_replace("/ne./i", "", $_POST['qs']); 104 $report_msg = '.m4'; 105 } 106 107 if (isset($_POST['ne_update'])) 108 { // Bits specific to updating an existing event 109 $qry = "event_start='".intval($ev_start)."', event_end='".intval($ev_end)."', event_allday='".intval($_POST['allday'])."', event_recurring='".intval($_POST['recurring'])."', event_datestamp= '".time()."', event_title= '$ev_title', event_location='$ev_location', event_details='$ev_event', event_contact='".$tp -> toDB($_POST['ne_email'])."', event_category='".intval($_POST['ne_category'])."', event_thread='".$tp -> toDB($_POST['ne_thread'])."', event_rec_m='".intval($rec_m)."', event_rec_y='".intval($rec_y)."' WHERE event_id='".intval($_POST['id'])."' "; 110 $sql->db_Update("event", $qry); 111 $ecal_class->cal_log(2,'db_Update',$qry, $ev_start); 112 $qs = preg_replace("/ed./i", "", $_POST['qs']); 113 $report_msg = '.m5'; 114 } 115 // Now clear cache - just do the lot for now - get clever later 116 $e107cache->clear('nq_event_cal'); 117 header("location:event.php?".$ev_start.".".$qs.$report_msg); 118 } 119 } 120 121 $action = ""; // Remove notice 122 123 require_once(HEADERF); 124 125 if (isset($_POST['jump'])) 126 { 127 $smarray = getdate(mktime(0, 0, 0, $_POST['jumpmonth'], 1, $_POST['jumpyear'])); 128 $month = $smarray['mon']; 129 $year = $smarray['year']; 130 } 131 else 132 { 133 if(e_QUERY) 134 { 135 $qs = explode(".", e_QUERY); 136 $action = $qs[0]; // Often a date if just viewing 137 $ds = (isset($qs[1]) ? $qs[1] : ""); 138 $eveid = (isset($qs[2]) ? $qs[2] : ""); 139 } 140 141 if ($action == "") 142 { 143 $month = $ecal_class->cal_date['mon']; 144 $year = $ecal_class->cal_date['year']; 145 } 146 else 147 { 148 $smarray = getdate($action); 149 $month = $smarray['mon']; 150 $year = $smarray['year']; 151 } 152 } 153 154 155 if (isset($_POST['confirm'])) 156 { 157 $qry = "event_id='".intval($_POST['existing'])."' "; 158 if ($sql->db_Delete("event", $qry)) 159 { 160 $message = EC_LAN_51; //Event Deleted 161 $ecal_class->cal_log(3,'db_Delete',$qry,$ev_start); 162 } 163 else 164 { 165 $message = EC_LAN_109; //Unable to Delete event for some mysterious reason 166 } 167 } 168 169 170 if ($action == "de") 171 { // Delete event - show confirmation form 172 $text = "<div style='text-align:center'> 173 <b>".EC_LAN_48."</b> 174 <br /><br /> 175 <form method='post' action='".e_SELF."' id='calformz' > 176 <input class='button' type='submit' name='cancel' value='".EC_LAN_49."' /> 177 <input class='button' type='submit' name='confirm' value='".EC_LAN_50."' /> 178 <input type='hidden' name='existing' value='".$qs[1]."' /> 179 <input type='hidden' name='subbed' value='no' /> 180 </form> 181 </div>"; 182 $ns->tablerender(EC_LAN_46, $text); // Confirm Delete Event 183 require_once(FOOTERF); 184 exit; 185 } 186 187 188 189 if (isset($_POST['cancel'])) 190 { // Delete Cancelled 191 $message = EC_LAN_47; 192 } 193 194 195 // set up data arrays ---------------------------------------------------------------------------------- 196 // (some of these are only used in the shortcodes) 197 if ($pref['eventpost_weekstart'] == 'sun') 198 { 199 $days = Array(EC_LAN_25, EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24); 200 } 201 else 202 { 203 $days = Array(EC_LAN_19, EC_LAN_20, EC_LAN_21, EC_LAN_22, EC_LAN_23, EC_LAN_24, EC_LAN_25); 204 } 205 $dayslo = array('1.', '2.', '3.', '4.', '5.', '6.', '7.', '8.', '9.', '10.', '11.', '12.', '13.', '14.', '15.', '16.', '17.', '18.', '19.', '20.', '21.', '22.', '23.', '24.', '25.', '26.', '27.', '28.', '29.', '30.', '31.'); 206 $monthabb = Array(EC_LAN_JAN, EC_LAN_FEB, EC_LAN_MAR, EC_LAN_APR, EC_LAN_MAY, EC_LAN_JUN, EC_LAN_JUL, EC_LAN_AUG, EC_LAN_SEP, EC_LAN_OCT, EC_LAN_NOV, EC_LAN_DEC); 207 $months = array(EC_LAN_0, EC_LAN_1, EC_LAN_2, EC_LAN_3, EC_LAN_4, EC_LAN_5, EC_LAN_6, EC_LAN_7, EC_LAN_8, EC_LAN_9, EC_LAN_10, EC_LAN_11); 208 // ---------------------------------------------------------------------------------------------------------- 209 210 // Messages acknowledging actions 211 $poss_message = array('m1' => EC_LAN_41, 'm2' => EC_LAN_42, 'm3' => EC_LAN_43, 'm4' => EC_LAN_44, 'm5' => EC_LAN_45); 212 if (isset($qs[2])) if (isset($poss_message[$qs[2]])) $message = $poss_message[$qs[2]]; 213 214 if (isset($message)) 215 { 216 $ns->tablerender("", "<div style='text-align:center'><b>".$message."</b></div>"); 217 } 218 219 220 // enter new event form 221 if ($action == "ne" || $action == "ed") 222 { 223 if ($ecal_class->cal_super || check_class($pref['eventpost_admin'])) 224 { 225 function make_calendar($boxname, $boxvalue) 226 { 227 global $ecal_class, $cal; 228 229 unset($cal_options); 230 unset($cal_attrib); 231 $cal_options['firstDay'] = 0; 232 $cal_options['showsTime'] = false; 233 $cal_options['showOthers'] = true; 234 $cal_options['weekNumbers'] = false; 235 $cal_options['ifFormat'] = $ecal_class->dcal_format_string; 236 $cal_attrib['class'] = "tbox"; 237 $cal_attrib['size'] = "12"; 238 $cal_attrib['name'] = $boxname; 239 $cal_attrib['value'] = $boxvalue; 240 return $cal->make_input_field($cal_options, $cal_attrib); 241 } 242 243 244 function make_hourmin($boxname,$cur_hour,$cur_minute) 245 { 246 global $pref; 247 if (isset($pref['eventpost_fivemins'])) $incval = 5; else $incval = 1; 248 $retval = " <select name='{$boxname}hour' id='{$boxname}hour' class='tbox'>\n"; 249 for($count = "00"; $count <= "23"; $count++) 250 { 251 $val = sprintf("%02d", $count); 252 $retval .= "<option value='{$val}' ".(isset($cur_hour) && $count == $cur_hour ? "selected='selected'" :"")." >".$val."</option>\n"; 253 } 254 $retval .= "</select>\n 255 <select name='{$boxname}minute' class='tbox'>\n"; 256 for($count = "00"; $count <= "59"; $count+= $incval) 257 { 258 $val = sprintf("%02d", $count); 259 $retval .= "<option ".(isset($cur_minute) && $count == $cur_minute ? "selected='selected'" :"")." value='{$val}'>".$val."</option>\n"; 260 } 261 $retval .= "</select>\n"; 262 return $retval; 263 } 264 265 266 if ($action == "ed") 267 { // Editing existing event - read from database 268 $sql->db_Select("event", "*", "event_id='".intval($qs[1])."' "); 269 list($null, $ne_start, $ne_end, $allday, $recurring, $ne_datestamp, $ne_title, $ne_location, $ne_event, $ne_author, $ne_email, $ne_category, $ne_thread) = $sql->db_Fetch(); 270 271 $smarray = getdate($ne_start); 272 $ne_hour = $smarray['hours']; 273 $ne_minute = $smarray['minutes']; 274 $ne_startdate = $ecal_class->full_date($ne_start); 275 276 $smarray = getdate($ne_end); 277 $end_hour = $smarray['hours']; 278 $end_minute = $smarray['minutes']; 279 $ne_enddate = $ecal_class->full_date($ne_end); 280 } 281 else 282 { // New event - initialise everything 283 $smarray = getdate($qs[1]); 284 $month = $smarray['mon']; 285 $year = $smarray['year']; 286 $ne_startdate = $ecal_class->full_date($qs[1]); 287 288 $ne_hour = $smarray['hours']; 289 $ne_minute = $smarray['minutes']; 290 291 $end_hour = $smarray['hours']; 292 $end_minute = $smarray['minutes']; 293 $ne_enddate = $ecal_class->full_date($qs[1]); 294 } 295 296 $text = " 297 <script type=\"text/javascript\"> 298 <!-- 299 function calcheckform(thisform, submitted,arrstr) 300 { 301 var testresults=true; 302 303 //category create check 304 if(submitted == 'ne_cat_create'){ 305 if(thisform.ne_new_category.value == ''){ 306 alert('".EC_LAN_134."'); 307 return FALSE; 308 }else{ 309 return TRUE; 310 } 311 } 312 313 function calcdate(thisval) 314 { 315 var temp1; 316 temp1 = thisval.split(\"-\"); 317 switch (arrstr) 318 { 319 case 2 : return temp1[2]+temp1[1]+temp1[0]; 320 case 3 : return temp1[2]+temp1[0]+temp1[1]; 321 default : return temp1[0]+temp1[1]+temp1[2]; 322 } 323 return 'Error'; 324 } 325 //event check - dates are text strings 326 var sdate = calcdate(thisform.start_date.value); 327 var edate = calcdate(thisform.end_date.value); 328 if (edate < sdate) 329 { // Update end date if its before start date 330 thisform.end_date.value = thisform.start_date.value; 331 // alert('End date changed'); 332 } 333 sdate = calcdate(thisform.start_date.value) + thisform.ne_hour.options[thisform.ne_hour.selectedIndex].value + thisform.ne_minute.options[thisform.ne_minute.selectedIndex].value; 334 edate = calcdate(thisform.end_date.value) + thisform.end_hour.options[thisform.end_hour.selectedIndex].value + thisform.end_minute.options[thisform.end_minute.selectedIndex].value; 335 // alert('Format: ' + arrstr + ' Start date: '+ sdate + ' End date: ' + edate); 336 337 testresults=true; 338 339 if (edate <= sdate && !thisform.allday.checked && testresults ) 340 { 341 alert('".EC_LAN_99."'); 342 testresults=false; 343 } 344 if ((thisform.ne_title.value=='' || thisform.ne_event.value=='') && testresults) 345 { 346 alert('".EC_LAN_98."'); 347 testresults=false; 348 } 349 350 if (testresults) 351 { 352 if (thisform.subbed.value=='no') 353 { 354 thisform.subbed.value='yes'; 355 testresults=true; 356 } 357 else 358 { 359 alert('".EC_LAN_113."'); 360 return false; 361 } 362 } 363 return testresults; 364 } 365 --> 366 </script>"; 367 368 $text .= " 369 <form method='post' action='".e_SELF."' id='linkform' onsubmit='return calcheckform(this, submitted,{$ecal_class->java_format_code})'> 370 <table style='width:98%' class='fborder' >"; 371 372 if ($action == "ed") 373 { 374 $caption = EC_LAN_66; // edit Event 375 376 } elseif ($action == "ne") 377 { 378 $caption = EC_LAN_28; // Enter New Event 379 } 380 else 381 { 382 $caption = EC_LAN_83; 383 } 384 385 $text .= " 386 <tr> 387 <td class='forumheader3' style='width:20%'>".EC_LAN_72." </td> 388 <td class='forumheader3' style='width:80%'> ".EC_LAN_67." "; 389 390 391 $text .= make_calendar("start_date",$ne_startdate)." ".EC_LAN_73." ".make_calendar("end_date",$ne_enddate); 392 $text .= " 393 </td> 394 </tr> 395 <tr> 396 <td class='forumheader3' style='width:20%'>".EC_LAN_71." </td> 397 <td class='forumheader3' style='width:80%'> 398 ".EC_LAN_67; 399 400 401 $text .= make_hourmin("ne_",$ne_hour,$ne_minute)." ".EC_LAN_73.make_hourmin('end_',$end_hour,$end_minute); 402 $text .= "<br /><input type='checkbox' name='allday' value='1' ".(isset($allday) && $allday == 1 ? "checked='checked'" :"")." />"; 403 $text .= EC_LAN_64." 404 </td> 405 </tr> 406 <tr> 407 <td class='forumheader3' style='width:20%'>".EC_LAN_65."</td> 408 <td class='forumheader3' style='width:80%'>"; 409 $text .= "<input type='checkbox' name='recurring' value='1' ".(isset($recurring) && $recurring == 1 ? "checked='checked'" : "")." />"; 410 $text .= EC_LAN_63." 411 </td> 412 </tr> 413 <tr> 414 <td class='forumheader3' style='width:20%'>".EC_LAN_70." *</td> 415 <td class='forumheader3' style='width:80%'> 416 <input class='tbox' type='text' name='ne_title' size='75' value='".(isset($ne_title) ? $ne_title : "")."' maxlength='200' style='width:95%' /> 417 </td> 418 </tr> 419 <tr> 420 <td class='forumheader3' style='width:20%'>".EC_LAN_52." </td> 421 <td class='forumheader3' style='width:80%'> 422 <select name='ne_category' class='tbox'>"; 423 // Check if supervisor, if so get all categories, otherwise just get those the user is allowed to see 424 $cal_arg = ($ecal_class->cal_super ? "" : "find_in_set(event_cat_addclass,'".USERCLASS_LIST."')"); 425 if ($sql->db_Select("event_cat", "*", $cal_arg)) 426 { 427 while ($row = $sql->db_Fetch()) 428 { 429 $text .= "<option value='{$row['event_cat_id']}' ".(isset($ne_category) && $ne_category == $row['event_cat_id'] ? "selected='selected'" :"")." >".$row['event_cat_name']."</option>"; 430 } 431 } 432 else 433 { 434 $text .= "<option value=''>".EC_LAN_91."</option>"; 435 } 436 $text .= "</select> 437 </td> 438 </tr>"; 439 // * *BK* Check if the add class is appropriate for adding new categories 440 // * *BK* It will default to everybody class when created. Need to go in to admin categories if 441 // * *BK* you want to change read class. 442 if (FALSE && check_class($pref['eventpost_addcat']) && $action != "ed") 443 { 444 require_once(e_HANDLER."file_class.php"); 445 $fi = new e_file; 446 $imagelist = $fi->get_files(e_PLUGIN."calendar_menu/images", "\.\w{3}$"); 447 $text .= "<tr> 448 <td class='forumheader3' style='width:20%' rowspan='2'>".EC_LAN_53." </td> 449 <td class='forumheader3' style='width:80%'>".EC_LAN_54." 450 <input class='tbox' type='text' name='ne_new_category' size='30' value='".(isset($ne_new_category) ? $ne_new_category : "")."' maxlength='100' style='width:95%' /> "; 451 $text .= "</td></tr> 452 <tr><td class='forumheader3' style='width:80%'>".EC_LAN_55; 453 $text .= " <input class='tbox' style='width:150px' type='text' id='ne_new_category_icon' name='ne_new_category_icon' />"; 454 $text .= " <input class='button' type='button' style='width: 45px; cursor:hand;' value='".EC_LAN_90."' onclick='expandit(\"cat_icons\")' />"; 455 $text .= "<div style='display:none' id='cat_icons'>"; 456 457 foreach($imagelist as $img){ 458 if ($img['fname']){ 459 $text .= "<a href=\"javascript:insertext('".$img['fname']."','ne_new_category_icon','cat_icons')\"><img src='".e_PLUGIN."calendar_menu/images/".$img['fname']."' style='border:0px' alt='' /></a> "; 460 } 461 } 462 $text .= "</div>"; 463 $text .= "<div style='text-align:center'> 464 <input class='button' type='submit' name='ne_cat_create' value='".EC_LAN_56."' onclick='submitted=this.name' /></div> 465 </td> 466 </tr>"; 467 } 468 469 $text .= " 470 <tr> 471 <td class='forumheader3' style='width:20%'>".EC_LAN_32." </td> 472 <td class='forumheader3' style='width:80%'> 473 <input class='tbox' type='text' name='ne_location' size='60' value='".(isset($ne_location) ? $ne_location : "")."' maxlength='200' style='width:95%' /> 474 </td> 475 </tr> 476 477 <tr> 478 <td class='forumheader3' style='width:20%'>".EC_LAN_57." *</td> 479 <td class='forumheader3' style='width:80%'> 480 <textarea class='tbox' name='ne_event' cols='59' rows='8' style='width:95%'>".(isset($ne_event) ? $ne_event : "")."</textarea> 481 </td> 482 </tr>"; 483 // * *BK* 484 // * *BK* Only display for forum thread if it is required. No point in being in if not wanted 485 // * *BK* or if forums are inactive 486 // * *BK* 487 if (isset($pref['eventpost_forum']) && $pref['eventpost_forum'] == 1) 488 { 489 $text .= " 490 <tr> 491 <td class='forumheader3' style='width:20%'>".EC_LAN_58." </td> 492 <td class='forumheader3' style='width:80%'> 493 <input class='tbox' type='text' name='ne_thread' size='60' value='".(isset($ne_thread) ? $ne_thread : "")."' maxlength='100' style='width:95%' /> 494 </td> 495 </tr>"; 496 } 497 // * *BK* 498 // * *BK* If the user is logged in and has their email set plus the field is empty then put in 499 // * *BK* their email address. They can always take it out if they want, its not a required field 500 if (empty($ne_email) && ($action == "ne") && defined('USEREMAIL')) 501 { 502 $ne_email = USEREMAIL; 503 } 504 $text .= " 505 <tr> 506 <td class='forumheader3' style='width:20%'>".EC_LAN_59." </td> 507 <td class='forumheader3' style='width:80%'> 508 <input class='tbox' type='text' name='ne_email' size='60' value='$ne_email' maxlength='150' style='width:95%' /> 509 </td></tr> 510 <tr> 511 <td class='forumheader3' colspan='2' >".EC_LAN_105." </td> 512 </tr> 513 514 <tr> 515 <td class='forumheader' colspan='2' style='text-align:center'>"; 516 if ($action == "ed") 517 { 518 $text .= "<input class='button' type='submit' name='ne_update' value='".EC_LAN_60."' onclick='submitted=this.name' /> 519 <input type='hidden' name='id' value='".$qs[1]."' />"; 520 } 521 else 522 { 523 $text .= "<input class='button' type='submit' name='ne_insert' value='".EC_LAN_28."' onclick='submitted=this.name' />"; 524 } 525 $text .= "<input type='hidden' name='qs' value='".e_QUERY."' /></td> 526 </tr> 527 </table> 528 </form>"; 529 530 $ns->tablerender($caption, $text); 531 require_once(FOOTERF); 532 exit; 533 } 534 else 535 { 536 header("location:".e_PLUGIN."calendar_menu/event.php"); 537 exit; 538 } 539 } // End of "Enter New Event 540 541 //----------------------------------------------- 542 // show events 543 // $month, $year have the month required 544 //----------------------------------------------- 545 $monthstart = mktime(0, 0, 0, $month, 1, $year); 546 $firstdayarray = getdate($monthstart); 547 $monthend = mktime(0, 0, 0, $month + 1, 1, $year) -1 ; 548 $lastdayarray = getdate($monthend); 549 550 $prevmonth = ($month-1); 551 $prevyear = $year; 552 if ($prevmonth == 0) 553 { 554 $prevmonth = 12; 555 $prevyear = ($year-1); 556 } 557 $previous = mktime(0, 0, 0, $prevmonth, 1, $prevyear); 558 559 $nextmonth = ($month + 1); 560 $nextyear = $year; 561 if ($nextmonth == 13) 562 { 563 $nextmonth = 1; 564 $nextyear = ($year + 1); 565 } 566 567 $prop = mktime(0, 0, 0, $month, 1, $year); // Sets start date for new event entry 568 $next = mktime(0, 0, 0, $nextmonth, 1, $nextyear); // Used by nav buttons 569 $nowmonth = $ecal_class->cal_date['mon']; 570 $nowyear = $ecal_class->cal_date['year']; 571 572 573 $py = $year-1; 574 $prevlink = mktime(0, 0, 0, $month, 1, $py); 575 $ny = $year + 1; 576 $nextlink = mktime(0, 0, 0, $month, 1, $ny); 577 578 if (is_readable(THEME."calendar_template.php")) 579 { // Has to be require 580 require (THEME."calendar_template.php"); 581 } 582 else 583 { 584 require(e_PLUGIN."calendar_menu/calendar_template.php"); 585 } 586 587 $text2 = ""; 588 // time switch buttons 589 $text2 .= $tp -> parseTemplate($CALENDAR_TIME_TABLE, FALSE, $calendar_shortcodes); 590 591 // navigation buttons 592 $text2 .= $tp -> parseTemplate($CALENDAR_NAVIGATION_TABLE, FALSE, $calendar_shortcodes); 593 594 595 // ****** CAUTION - the category dropdown also used $sql object - take care to avoid interference! 596 597 $event = array(); 598 $extra = ''; 599 600 if ($ds == "event") 601 { // Show single event 602 $qry = " 603 SELECT e.*, ec.* 604 FROM #event as e 605 LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id 606 WHERE e.event_id='".intval($eveid)."' 607 {$ecal_class->extra_query} 608 "; 609 $sql2->db_Select_gen($qry); 610 $row = $sql2->db_Fetch(); 611 if ($row['event_recurring']=='1') // Single event, selected by ID. So day/month must match 612 { 613 $row['event_start'] = mktime(0,0,0,$row['event_rec_y'],$row['event_rec_m'],$year); 614 $row['event_end'] = $row['event_start']; 615 } 616 $event[] = $row; 617 $next10_start = $event[0]['event_start']; 618 $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_START, FALSE, $calendar_shortcodes); 619 $text2 .= show_event($event); 620 $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE_END, FALSE, $calendar_shortcodes); 621 622 } 623 else 624 { 625 if ($ds == 'one') 626 { // Show events from one day 627 $tmp = getdate($action); 628 $selected_day = $tmp['mday']; 629 $selected_mon = $tmp['mon']; 630 $start_time = $action; 631 $end_time = $action + 86399; 632 $next10_start = $end_time + 1; 633 $cap_title = " - ".$months[$selected_mon-1]." ".$selected_day; 634 $extra = " OR (e.event_rec_y = ".intval($selected_mon)." AND e.event_rec_m = ".intval($selected_day).") "; 635 } 636 else 637 { // Display whole of selected month 638 $start_time = $monthstart; 639 $end_time = $monthend; 640 $next10_start = $end_time + 1; 641 $cap_title = ''; 642 $extra = " OR e.event_rec_y = ".intval($month)." "; 643 } 644 645 646 $qry = " 647 SELECT e.*, ec.* 648 FROM #event as e 649 LEFT JOIN #event_cat as ec ON e.event_category = ec.event_cat_id WHERE (e.event_recurring = '0' AND 650 ((e.event_start >= ".intval($start_time)." AND e.event_start <= ".intval($end_time).") 651 OR (e.event_end >= ".intval($start_time)." AND e.event_end <= ".intval($end_time).") 652 OR (e.event_start <= ".intval($start_time)." AND e.event_end >= ".intval($end_time).") ) 653 {$extra}) 654 {$category_filter} 655 {$ecal_class->extra_query} 656 ORDER BY e.event_start ASC 657 "; 658 659 // Query generates a list of event IDs in $idarray which meet the criteria. 660 // $idarray has one primary index location for each day of month, then secondary for events. 661 if ($cal_count=$sql->db_Select_gen($qry)) 662 { 663 while ($row = $sql->db_Fetch()) 664 { 665 if ($row['event_recurring']=='1') // Recurring events 666 { 667 if (($row['event_rec_y'] == $month) && (!in_array($row['event_id'], $idArray))) // Only allow one instance of each recurring event 668 { 669 $tmp = getdate($row['event_start']); 670 $row['event_start'] = mktime($tmp['hours'],$tmp['minutes'],0,$row['event_rec_y'],$row['event_rec_m'],$year); 671 $row['event_end'] = $row['event_start']; 672 $events[$row['event_rec_m']][] = $row; 673 $idArray[] = $row['event_id']; 674 } 675 } 676 else 677 { 678 if ($ds == 'one') 679 { 680 if (!isset($idArray) || !is_array($idArray) || !in_array($row['event_id'], $idArray)) 681 { 682 $events[$selected_day][] = $row; 683 $idArray[] = $row['event_id']; 684 } 685 } 686 else 687 { // Multiple events 688 if ($row['event_start'] < intval($start_time)) 689 { 690 $start_day = "1"; // Event starts before this month 691 } 692 else 693 { 694 $tmp = getdate($row['event_start']); 695 $start_day = $tmp['mday']; 696 } 697 if ($row['event_end'] < $row['event_start']) 698 { // End date before start date 699 $end_day = $start_day; 700 } 701 else 702 { 703 if ($row['event_end'] > intval($end_time)) 704 { 705 $end_day = "31"; // Event ends after this month 706 } 707 else 708 { 709 $tmp = getdate($row['event_end']); 710 $end_day = $tmp['mday']; 711 } 712 } 713 for ($i = $start_day; $i <= $end_day; $i++) 714 { 715 if (!isset($idArray) || !is_array($idArray) || !in_array($row['event_id'], $idArray)) 716 { 717 $events[$i][] = $row; 718 $idArray[] = $row['event_id']; 719 } 720 } 721 } 722 } 723 } 724 } 725 } 726 727 728 // event list 729 if(isset($events) && is_array($events)) 730 { 731 $text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_START, FALSE, $calendar_shortcodes); 732 foreach ($events as $dom => $event){ 733 $text2 .= show_event($event); 734 } 735 $text2 .= $tp -> parseTemplate($EVENT_EVENTLIST_TABLE_END, FALSE, $calendar_shortcodes); 736 } 737 738 739 /* 740 $nextmonth = mktime(0, 0, 0, $month + 1, 1, $year)-1; 741 if (!isset($next10_start)) 742 { 743 $next10_start = $nextmonth; 744 } 745 */ 746 747 // Show next 10 events after current event/day/month (doesn't show recurring events) 748 $qry = " 749 SELECT e.* FROM #event AS e 750 LEFT JOIN #event_cat AS ec ON e.event_category = ec.event_cat_id 751 WHERE e.event_start > '".intval($next10_start)."' {$ecal_class->extra_query} {$category_filter} 752 ORDER BY e.event_start ASC 753 LIMIT 0, 10 754 "; 755 756 $num = $sql->db_Select_gen($qry); 757 if ($num != 0) 758 { 759 $gen = new convert; 760 $archive_events = ""; 761 // while ($events = $sql->db_Fetch()) 762 while ($thisevent = $sql->db_Fetch()) 763 { 764 $archive_events .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE, FALSE, $calendar_shortcodes); 765 } 766 } 767 else 768 { 769 $archive_events = $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_EMPTY, FALSE, $calendar_shortcodes); 770 } 771 772 $text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_START, FALSE, $calendar_shortcodes); 773 $text2 .= $archive_events; 774 $text2 .= $tp -> parseTemplate($EVENT_ARCHIVE_TABLE_END, FALSE, $calendar_shortcodes); 775 776 777 $caption = EC_LAN_80; // "Event List"; 778 $ns->tablerender($caption.(isset($cap_title) ? $cap_title : ""), $text2); 779 require_once(FOOTERF); 780 781 782 // Display one event in a form which can be expanded. 783 function show_event($day_events) 784 { 785 global $tp, $cal_super, $_POST, $ds, $thisevent, $EVENT_ID, $EVENT_EVENT_TABLE, $calendar_shortcodes, $event_author_id, $event_author_name; 786 $text2 = ""; 787 foreach($day_events as $event) 788 { 789 $thisevent = $event; 790 $gen = new convert; 791 $lp = explode(".", $thisevent['event_author'],2); 792 if (preg_match("/[0-9]+/", $lp[0])) 793 { 794 $event_author_id = $lp[0]; 795 $event_author_name = $lp[1]; 796 } 797 $text2 .= $tp -> parseTemplate($EVENT_EVENT_TABLE, FALSE, $calendar_shortcodes); 798 } 799 return $text2; 800 } 801 802 803 function headerjs() 804 { 805 global $cal; 806 $script = $cal->load_files(); 807 /* 808 $script .= " 809 <script type=\"text/javascript\"> 810 <!-- 811 function calcheckform(thisform) 812 { 813 var testresults=true; 814 var temp; 815 temp = thisform.start_date.value.split(\"-\"); 816 var sdate = temp[0] + temp[1] + temp[2] + thisform.ne_hour.options[thisform.ne_hour.selectedIndex].value + thisform.ne_minute.options[thisform.ne_minute.selectedIndex].value 817 temp = thisform.end_date.value.split(\"-\"); 818 var edate = temp[0] + temp[1] + temp[2] + thisform.end_hour.options[thisform.end_hour.selectedIndex].value + thisform.end_minute.options[thisform.end_minute.selectedIndex].value 819 820 testresults=true; 821 822 if (edate <= sdate && !thisform.allday.checked && testresults ) 823 { 824 alert('".EC_LAN_99."'); 825 testresults=false; 826 } 827 if ((thisform.ne_title.value=='' || thisform.ne_event.value=='') && testresults) 828 { 829 alert('".EC_LAN_98."'); 830 testresults=false; 831 } 832 833 if (testresults) 834 { 835 if (thisform.subbed.value=='no') 836 { 837 thisformm.subbed.value='yes'; 838 testresults=true; 839 } 840 else 841 { 842 alert('".EC_LAN_113."'); 843 return false; 844 } 845 } 846 return testresults; 847 } 848 --> 849 </script>"; 850 */ 851 return $script; 852 } 853 854 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |