1<?php 2/* $Id: calendar_func.inc.php,v 1.41 2006/04/16 14:40:44 leyeti Exp $ */ 3 4// adding file revision into global array 5if(function_exists("revisionInit")) revisionInit("\$Revision: 1.41 $", __FILE__); 6 7define('CAL1_INC_DIR', ROOTPATH."/modules/calendar/inc/"); 8define('CAL1_DIR', ROOTPATH."/modules/calendar/"); 9 10// Get username from user with id $userid from db 11function getRealUsername($userid) { 12 global $conn; 13 $sql = "SELECT ".$conn->Concat("lastname", "', '", "firstname")." AS name from mgw_users where id = '".$userid."'"; 14 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 15 $row=$res->FetchRow(); 16 return $row["name"]; 17} 18 19///// NATYS ///// 20function str_encode($str){ 21return urlencode($str); 22} 23 24function str_decode($str){ 25return nl2br(StripSlashes(urldecode($str))); 26} 27 28// return Daylight Saving Time in second (summer/winter time shifting according to settings) 29function get_DST($timestamp){ 30 if(date("I",$timestamp)=="1"){ // summer time 31 return $_SESSION["MGW"]->settings["Summer_timezone"]*3600; 32 } 33 else { // winter time 34 return $_SESSION["MGW"]->settings["Winter_timezone"]*3600; 35 } 36} 37 38 39function get_view_rights($id_user_from, $id_user_to){ 40// return 0 : limited view (normal) 41// return 1 : can view all properties 42global $conn; 43 if ($id_user_from==$id_user_to) return 1; 44 $sql = "SELECT view_all FROM mgw_calendar_rights where id_user = '".$id_user_from."' AND id_owner = '".$id_user_to."'"; 45 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 46 if ($res->NumRows() > 0) { 47 $row=$res->FetchRow(); 48 return $row["view_all"]; 49 } 50 else return 0; 51} 52 53 54function get_modify_rights($id_user_from, $id_user_to){ 55// return 0 : can't modify, create or delete (normal) 56// return 1 : can modify, create or delete 57global $conn; 58 if ($id_user_from==$id_user_to) return 1; 59 $sql = "SELECT modify FROM mgw_calendar_rights where id_user = '".$id_user_from."' AND id_owner = '".$id_user_to."'"; 60 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 61 if ($res->NumRows() > 0) { 62 $row=$res->FetchRow(); 63 return $row["modify"]; 64 } 65 else return 0; 66} 67 68function is_displayable_by_current_user($id_appt){ 69global $conn; 70 //current user: 71 $id_user_from = $_SESSION["MGW"]->userid; 72 73 $right = 0; 74 //get id_user of id_appt: 75 $sql = "SELECT userid FROM mgw_calendar where id = '".$id_appt."'"; 76 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 77 while ($row=$res->FetchRow()){ 78 $id_user_to = $row["userid"]; 79 //right "view_all" OR right "modify" : 80 $right = $right || ( get_view_rights($id_user_from,$id_user_to) || get_modify_rights($id_user_from,$id_user_to) ); 81 } 82 83 return $right; 84} 85 86function is_modifiable_by_current_user($id_appt,$id_user=""){ 87global $conn; 88 //current user: 89 $id_user_from = $_SESSION["MGW"]->userid; 90 91 $inituser_right = 0; 92 $simpleuser_right = 0; 93 94 //get id_user of id_appt: 95 $sql = "SELECT inituserid FROM mgw_calendar where id = '".$id_appt."'"; 96 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 97 $row=$res->FetchRow(); 98 $id_user_to = $row["inituserid"]; 99 $inituser_right = get_modify_rights($id_user_from,$id_user_to); 100 101 if ($id_user=="") $id_user = $id_user_from; 102 if (/*$id_user!="" and */$res->NumRows() == 1) { // only for appointments with 1 participant 103 // verify if id_appt belong to id_user: 104 $sql = "SELECT id FROM mgw_calendar where id = '".$id_appt."' AND userid='$id_user'"; 105 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 106 if($res->NumRows() > 0) $simpleuser_right = get_modify_rights($id_user_from,$id_user); 107 } 108 //current user can modify inituser's appt OR the record "id_appt<->id_user" 109 return $inituser_right || $simpleuser_right; 110 111 /* while ($row=$res->FetchRow()){ 112 $id_user_to = $row["userid"]; 113 //right "modify" : 114 $right = $right || get_modify_rights($id_user_from,$id_user_to); 115 } 116 117 return $right; 118 */ 119} 120 121function current_user_can_create_for($id_user){ 122global $conn; 123 //current user: 124 $id_user_from = $_SESSION["MGW"]->userid; 125 126 //right "modify" : 127 return get_modify_rights($id_user_from,$id_user); 128} 129///////////////// 130 131function cal_png_image($imgsrc,$width="",$height="",$alt="",$ahref=0,$border=0){ 132 133if ($width=="") 134 { 135 $size = getimagesize($imgsrc); 136 $width= $size[0]; 137 } 138if ($height=="") 139 { 140 $size = getimagesize($imgsrc); 141 $height= $size[1]; 142 } 143if ($ahref==1) $cursor="hand"; 144else $cursor=""; 145 146/*return "<!-- damn you MSFT and your incompatible hacks!! :( --> 147 <div title=\"{$alt}\" style=\"cursor:$cursor; border-style:solid; border-width: {$border}px; width: {$width}px; height: {$height}px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='{$imgsrc}', sizingMethod='scale');\"></div> 148 "; 149*/ 150 151return "<SCRIPT LANGUAGE=\"javascript\"> 152 var V=navigator.appVersion; 153 if(document.all && document.getElementById) { // it's ie5+ but which version ? 154 ver=V.substring(V.indexOf(\"MSIE\",0)+5,V.indexOf(\";\",V.indexOf(\"MSIE\",0))); 155 } 156 else ver=\"\"; 157 //sorry : for ie 5.01, there's NO solution for displaying PNG correctly 158 if(document.all && document.getElementById && ver!=\"5.01\" ) { //it's ie5.5+ 159 <!-- damn you MSFT and your incompatible hacks!! :( --> 160 document.write(\"<div title=\\\"{$alt}\\\" style=\\\"cursor:{$cursor}; border-style:solid; border-width: {$border}px; width: {$width}px; height: {$height}px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'{$imgsrc}\', sizingMethod=\'scale\');\\\"></div>\"); 161 } 162 else{ //all other browsers 163 document.write(\"<img src=\\\"{$imgsrc}\\\" width=\\\"{$width}\\\" height=\\\"{$height}\\\" alt=\\\"{$alt}\\\" title=\\\"{$alt}\\\" border=\\\"{$border}\\\" >\"); 164 } 165 </SCRIPT>"; 166 167} 168 169function getCalIconStrings() { 170global $appconf; 171 $settings=$_SESSION["MGW"]->settings; 172 173 $Cal_icons = array(); 174 if($settings["iconmode"]==1) { 175 $Cal_icons["editserial"] = cal_png_image($appconf["imgpath"]. "/editserial.png","","",Lang::getLanguageString("temp_row_action_label_serialedit"),1); 176 $Cal_icons["vcal"] = cal_png_image($appconf["imgpath"]. "/vcal.png","","",Lang::getLanguageString("vcal"),1); 177 178 $Cal_icons["validate"] = cal_png_image($appconf["imgpath"]. "/validate.png","","",Lang::getLanguageString("validate_for_me"),1); 179 $Cal_icons["validateforall"] = cal_png_image($appconf["imgpath"]. "/validateforall.png","","",Lang::getLanguageString("validate_for_all"),1); 180 $Cal_icons["abort"] = cal_png_image($appconf["imgpath"]. "/abort.png","","",Lang::getLanguageString("abort_for_me"),1); 181 } 182 else { 183 $Cal_icons["editserial"] = Lang::getLanguageString("temp_row_action_label_serialedit"); 184 $Cal_icons["vcal"] = Lang::getLanguageString("vcal"); 185 186 $Cal_icons["validate"] = Lang::getLanguageString("validate_for_me"); 187 $Cal_icons["validateforall"] = Lang::getLanguageString("validate_for_all"); 188 $Cal_icons["abort"] = Lang::getLanguageString("abort_for_me"); 189 } 190return $Cal_icons; 191} 192 193 194function quoted_printable_encode($input, $tag_len = 0, $line_max = 76) { 195 $lines = preg_split("/(?:\r\n|\r|\n)/", $input); 196 $eol = "\r\n"; 197 $linebreak = "=0D=0A"; 198 $escape = "="; 199 $output = ""; 200 201 for ($j=0;$j<count($lines);$j++) { 202 $line = $lines[$j]; 203 $linlen = strlen($line); 204 $newline = ""; 205 for($i = 0; $i < $linlen; $i++) { 206 $c = substr($line, $i, 1); 207 $dec = ord($c); 208 if ( ($dec == 32) && ($i == ($linlen - 1)) ) { // convert space at eol only 209 $c = $escape."20"; 210 } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required 211 $c = $escape.strtoupper(dechex($dec)); 212 } 213 if ( (strlen($newline.$c)+$tag_len) >= $line_max ) { // CRLF is not counted 214 $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay 215 $newline = ""; 216 $tag_len = 0; //afects only first line 217 } 218 $newline .= $c; 219 } //end of input line 220 221 $output .= $newline; 222 if ($j<count($lines)-1) { 223 if ( strlen($newline.$linebreak) >= $line_max ) $output .= $escape.$eol; 224 $output .= $linebreak; 225 } 226 } 227 return trim($output); 228} 229 230function jsencode($str){ 231 //return strtr($str, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); 232 $str = str_replace("\"","''" ,$str); 233 return strtr($str, array('\\'=>'\\\\',"'"=>"\\'",'"'=>'\\"',"\r"=>'\\r',"\n"=>'\\n','</'=>'<\/')); 234} 235 236// in_array for php < 4.2.0 237function in_array_buggyphp($needle,$haystack) { 238 $ret=FALSE; 239 for ($i=0;$i<count($haystack);$i++) { 240 if ($needle==$haystack[$i]) { 241 $ret=TRUE; 242 break; 243 } 244 } 245 return $ret; 246} 247 248// perhaps we should make it configurable (in settings) 249$max_subject_length=100; 250 251// Return substring of s with length and '...' 252function short_string($s,$length) { 253 if (strlen($s)>$length) { 254 return substr($s,0,$length-3)."..."; 255 } else { 256 return $s; 257 } 258} 259 260// ===================================================== 261// array get_appt_type_legend() 262// get properties of each appointment type for the legend 263// ====================================================== 264function get_appt_type_legend(){ 265 global $conn; 266 267 $appt_types = array(); 268 $sql = "SELECT * FROM mgw_calendar_appt_type"; 269 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 270 while ($row = $res->FetchRow()) { 271 $appt_types []= array( "color" => $row["color"], 272 "text" => Lang::getLanguageString("gentemp_".$row["type"]) 273 ); 274 } 275 return $appt_types; 276} 277 278 279// ====================================================== 280// boolean is_leap_year ( int year ) 281// checks wether a year is a leap year 282// ====================================================== 283function is_leap_year($year){ 284 if ((($year % 4) == 0 and ($year % 100)!=0) or ($year % 400)==0) 285 return 1; 286 else 287 return 0; 288} 289 290// ====================================================== 291// timestamp get_weektimestamp( integer week_number, integer year) 292// returns the timestamp of the first day of the week_number of the year 293// ====================================================== 294function get_weektimestamp ($week_number, $year){ 295if ($week_number>53) { 296 echo "get_weektimestamp : INVALID ARGUMENT : week_number=$week_number !<BR>"; 297 return 0; 298} 299if ($week_number==53) { 300 $t = mktime(0,0,0,12,31,$year); 301 if (get_weeknumber($t)!=53){ 302 echo "get_weektimestamp : INVALID ARGUMENT : week_number=$week_number but there are only 52 weeks in $year !<BR>"; 303 return 0; 304 } 305} 306//timestamp of the 1st january of year: 307$d = 1; 308$ts = mktime(0,0,0,1,$d,$year)+1; 309//be sure to be in week n� 01: 310if (get_weeknumber($ts)!="01") { 311 $d = 8; 312 $ts = mktime(0,0,0,1,$d,$year)+1; 313 } 314//now we are in week n�1 -> we want now to be on the 1st day(MON) of the 1st week: 315$m=1;$y=$year; 316while(date("D",$ts)!="Mon") { // we are between 28/12/(y-1) and 8/01/y 317 $d = (($d-1)>0) ? ($d-1) : 31; 318 $m = ($d==31) ? 12 : $m; 319 $y = ($d==31) ? ($y-1) : $y; 320 $ts = mktime(0,0,0,$m,$d,$y)+1; //decrease per 1 day 321 } 322//debug: echo "1st day of 1st week : $d $m $y<br>"; 323// now $ts is the timestamp of the first day of the week n�01: 324 325return mktime(0,0,0,$m,$d + ($week_number-1)*7,$y)+1; 326} 327 328// ====================================================== 329// Integer get_weeknumber( timestamp timestamp) 330// returns the calendar week number from timestamp according to ISO 8601:1988 331// ====================================================== 332function get_weeknumber($timestamp) { 333 334/*************************** 335* OLD FUNCTION : 336 337 $week = strftime("%W", mktime(0, 0, 0, $m, $d, $y)); 338 339 //last_week of this year: 340 $last_week = strftime("%W", mktime(0, 0, 0, 12, 31, $y)); 341 //day of week of 1st january of this year : 342 $dow0101=getdate(mktime(0, 0, 0, 1, 1, $y)); 343 //day of week of 31 december of this year : 344 $dow3112=getdate(mktime(0, 0, 0, 12, 31, $y)); 345 346 //en: Day : Sun Mon Tue Wed Thu Fri Sat 347 // wday: 0 1 2 3 4 5 6 348 // The week n�1 is the week which contain the 1st january between monday and friday 349 // if the 1st january is a saturday, the week containing this saturday is week n�5x (52 or 53) 350 351 //fr: jour: Dim Lun Mar Mer Jeu Ven Sam 352 // wday: 0 1 2 3 4 5 6 353 // La semaine n�1 est la semaine qui contient le 1er janvier entre lundi et vendredi 354 // si le 1er janvier est un samedi, la semaine contenant ce samedi est la semaine n�5x (52 ou 53) 355 356 //week shifting : 357 if ($dow0101["wday"]>0 && $dow0101["wday"]<6) 358 { 359 // week is last week of the year AND 31/12 is not friday, saturday, sunday 360 // -> so it's that 1st january is in this week and beetween monday and friday -> it's week n�1 361 if ($week==$last_week and $dow3112["wday"]<5 and $dow3112["wday"]!=0 ) 362 $week = 1; 363 else 364 if ($dow0101["wday"]!=1) $week++; 365 } 366***********************************/ 367$y = date("Y",$timestamp); 368$m = date("m",$timestamp); 369$d = date("d",$timestamp); 370 371//Week according to the system : 372$week=strftime("%W", mktime(0, 0, 0, $m, $d, $y)); 373 374//Day of week of 1st january of this year : 375$dow0101=getdate(mktime(0, 0, 0, 1, 1, $y)); 376 377//Day of week of 1st january of next year : 378$next0101=getdate(mktime(0, 0, 0, 1, 1, $y+1)); 379 380 381if ( $dow0101["wday"]>1 && 382 $dow0101["wday"]<5) 383 $week++; 384 385if ( $next0101["wday"]>1 && 386 $next0101["wday"]<5 && 387 $week==53) 388 $week=1; 389 390if ($week==0) 391 $week = get_weeknumber(mktime(0, 0, 0, 12, 31, $y-1)); 392 393return(substr("00" . $week, -2)); 394 395 396} 397 398// ====================================================== 399// Get Easter Date 400// ====================================================== 401function get_easter_date($date) { 402 if(function_exists("easter_date") && date("Y", $date)>=1970 && date("Y", $date)<=2037) return easter_date(date("Y", $date)); 403 404 $ja = date("Y", $date); 405 $m = ($ja < 1900 ? 23 : ($ja < 2100 ? 24 : ($ja < 2200 ? 25 : ($ja < 2300 ? 26 : 27)))); 406 $n = ($ja < 1800 ? 3 : ($ja < 1900 ? 4 : ($ja < 2100 ? 5 : 6))); 407 $a = $ja % 19; 408 $b = $ja % 4; 409 $c = $ja % 7; 410 $d = (19 * $a + $m) % 30; 411 $e = (2 * $b + 4 * $c + 6 * $d + $n) % 7; 412 $om = 3; 413 $ot = 22 + $d + $e; 414 415 if ($ot > 31){ 416 $ot = $ot - 31; 417 $om = 4; 418 if ($ot == 26) $ot = 19; 419 if ($ot == 25 && $d == 28 && $a > 10) $ot = 18; 420 } 421 $ostern = mktime(0,0,0, $om, $ot, $ja); 422 return $ostern; 423} 424 425// ====================================================== 426// Get Weekday On or Before 427// 428// Parameters: 429// weekday: week day as for date() 430// "0" (Sunday) to "6" (Saturday) 431// date: the date to find the first monday before 432// 433// Returns: 434// The first date falling on $weekday on or before $date 435// ====================================================== 436function get_weekday_onorbefore($weekday, $date) { 437 $dayofweek = date("w", $date); 438 439 $day = date("d", $date) + $weekday - $dayofweek; 440 $month = date("m", $date); 441 $year = date("Y", $date); 442 443 return mktime(0,0,0,$month,$day,$year); 444} 445 446// ====================================================== 447// Get First Weekday 448// 449// Parameters: 450// weekday: week day as for date() 451// "0" (Sunday) to "6" (Saturday) 452// month: the month to find the first weekday in 453// "01" (January) to "12" (December) 454// year: the year 455// 456// Returns: 457// The first date falling on $weekday in $month in $year 458// ====================================================== 459function get_first_weekday($weekday, $parm_month, $parm_year) { 460 $firstday = mktime(0,0,0,$parm_month,1,$parm_year); 461 $dayofweek = date("w", $firstday); 462 463 if ($dayofweek != 0) { 464 $day = date("d", $firstday) + $weekday + 7 - $dayofweek; 465 } 466 else { 467 $day = date("d", $firstday) + $weekday - $dayofweek; 468 } 469 $month = date("m", $firstday); 470 $year = date("Y", $firstday); 471 472 return mktime(0,0,0,$month,$day,$year); 473} 474 475// ====================================================== 476// String get_celebrate_days(timestamp date) 477// 478// returns the celebration day label from a timestamp 479// if timestamp is no celebration day function returns empty string 480// ====================================================== 481function get_celebrate_days($date, $lang){ 482 $holiday = ""; 483 $easter = get_easter_date($date); 484 485 $file = "holidays.$lang.inc.php"; 486 if(file_exists(ROOTPATH."/modules/calendar/inc/".$file)) require(ROOTPATH."/modules/calendar/inc/".$file); 487 return $holiday; 488} 489 490// ====================================================== 491// array get_year53_list(Integer year_begin, Integer year_end) 492// 493// returns a list of years (between year_begin and year_end) which contains 53 weeks 494// ====================================================== 495function get_year53_list($year_begin, $year_end){ 496 497 //// WARNING ! ////////////////////////// 498 // PHP native DATE function is limited over 2038 (due to 32 bits integer)!! 499 // after 19 january 2038, we must use adodb_date function (work with 64 bits integer) 500 if ($year_end>=2038) $year_end=2037; 501 ///////////////////////////////////////// 502 503 for ($y=$year_begin;$y<=$year_end;$y++){ 504 $t = mktime(0,0,0,12,31,$y); 505 if (get_weeknumber($t)==53){ 506 $year53_list[]=$y; 507 } 508 } 509 return $year53_list; 510} 511 512 513// ====================================================== 514// String get_monthview_static( timestamp date, Integer year, Integer, month) 515// 516// returns a HTML table representing a calendar month 517// liefert eine HTML-Tabelle zur Darstellung eines Kalendermonats 518// ====================================================== 519function get_monthview_static($date, $year, $month){ 520 global $appconf, $conn, $calendarid, $PHP_SELF; 521 522 $today = date("Ymd", time()); 523 //$today = $conn->DBTimeStamp(time()); 524 525 if ($_SESSION['calendarid']=="all") $sql_owner_part=""; 526 else $sql_owner_part="userid = ".$_SESSION['calendarid']." AND"; 527 528 $zeit = getdate($date); 529 $day = $zeit["mday"]; // Date im aktuellen Monat ? 530 /// NATYS /// 531 // no difference : 532 /* 533 if ($zeit["mon"] == $month && $zeit["year"] == $year) { 534 $header_class = "navlinkon"; // "stand"; 535 } else { 536 $header_class = "edit"; 537 } 538 */ 539 $header_class = "navlinkon"; 540 //// /NATYS //// 541 542 // compute array for actual month holding the weekdays 543 $num_days = date("t",strtotime($month . "/1/". $year)); 544 545 $starts_at = 1; //0=su, 1=mo, ... from settings 546 $trim_month = true; // from settings 547 548 $days_before = $starts_at-date("w",strtotime($month . "/1/". $year))+1; 549 if($days_before>1) $days_before -= 7; 550 551 if($starts_at > 0) $ends_at = $starts_at - 1; 552 else $ends_at = 6; 553 554 $days_after = $ends_at-date("w",strtotime("$month/$num_days/$year")); 555 if($days_after < 0) $days_after += 7; 556 557 $month_days = array(); 558 for($o=$days_before; $o<=$num_days+$days_after; $o++) { 559 $day = array(); 560 $day["timestamp"] = mktime(0,0,1,$month,$o,$year); 561 //$day["sql_tag"] = date("Ymd", $day["timestamp"]); 562 $day["sql_tag"] = $conn->DBTimeStamp($day["timestamp"]); 563 $day["day_number"] = date("j", $day["timestamp"]); 564 $day["day_of_week"] = date("w", $day["timestamp"]); 565 566 $month_days[] = $day; 567 } 568 569 $mymonth = $month; 570 if ($mymonth < 10 and strlen($mymonth) == 2) { $mymonth = substr($mymonth,1); } 571 572 // HTML-Tabelle �berschriften Monat / Jahr 573 $out = "<table border=\"0\" width=\"180\" cellpadding=\"0\" cellspacing=\"0\">\n"; 574 $out .= "<tr><td class=\"lines\" width=\"1\" height=\"1\" colspan=\"10\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td></tr>"; 575 $out .= "<tr class=\"stand\" height=\"20\">"; 576 $out .= " <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 577 $out .= " <td class=\"subnavback\"> <a class=\"$header_class\" href=\"$PHP_SELF?action=mback&date=$date&".SID."\" ><strong><<<</strong></a></td>"; 578 $out .= " <td class=\"subnavback\" colspan=\"6\" align=\"center\">"; 579 $out .= " <a class=\"navlink\" href=\"month.php?date=".mktime(0, 0, 0, $month , 1 , $year )."&".SID."\">".Lang::getLanguageString("gentemp_month_name_".$mymonth)."</a>"; 580 $out .= " </td>"; 581 $out .= " <td class=\"subnavback\"><a class=\"$header_class\" href=\"$PHP_SELF?action=mforw&date=$date&".SID."\"> <strong>>>></strong></a> </td>"; 582 $out .= " <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 583 $out .= "</tr>\n"; 584 $out .= "<tr class=\"stand\" height=\"20\">"; 585 $out .= " <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 586 $out .= " <td class=\"subnavback\"> <a class=\"$header_class\" href=\"$PHP_SELF?action=yback&date=$date&".SID."\"><strong><<<</strong></a></td>"; 587 $out .= " <td class=\"subnavback\" colspan=\"6\" align=\"center\"><strong>$year</strong></td>"; 588 $out .= " <td class=\"subnavback\"><a class=\"$header_class\" href=\"$PHP_SELF?action=yforw&date=$date&".SID."\"> <strong>>>></strong></a> </td>"; 589 $out .= " <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 590 $out .= "</tr>\n"; 591 $out .= "<tr><td class=\"lines\" width=\"1\" height=\"1\" colspan=\"10\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td></tr>"; 592 593 $out .= "<tr class=\"stand\" height=\"20\">"; 594 $out .= " <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 595 $out .= " <td class=\"category\" align=\"center\"> " . Lang::getLanguageString("calweek") . " </td>"; 596 597 for($i=$starts_at; $i<$starts_at+7; $i++) // prints names of days 598 $out .= "<td class=\"category\" align=\"center\"> ". Lang::getLanguageString("temp_weekday_abbr_".$i%7) . " </td>"; 599 600 $out .=" <td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td> 601 </tr>\n"; 602 603 $out .= "<tr><td class=\"lines\" width=\"1\" height=\"1\" colspan=\"10\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td></tr>"; 604 605 for($i=0;$i<count($month_days);$i++) { 606 // today 607 $day_tag = date("Y",$month_days[$i]["timestamp"]).date("m",$month_days[$i]["timestamp"]).date("d",$month_days[$i]["timestamp"]); 608 if($day_tag == $today) $klasse = "heute"; 609 //weekend 610 elseif ($month_days[$i]["day_of_week"]==6 || $month_days[$i]["day_of_week"]==0) $klasse = "wochenende"; 611 //end of last/beginning of next month 612 elseif ($i<(abs($days_before)+1) || $i>abs($days_before)+$num_days) $klasse = "tab"; 613 //holiday 614 elseif (get_celebrate_days($month_days[$i]["timestamp"], $_SESSION["MGW"]->settings["calendar_holiday_system"]) != "") $klasse = "feiertag"; 615 //absolutely ordinary day :)) 616 else $klasse = "tab"; 617 618 if($i%7==0) { 619 $out .= "<tr class=\"tab\" height=20 bgcolor=\"#c8c9d4\">\n"; 620 $out .= "<td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 621 $out .= "<td bgcolor=\"#838899\" align=\"center\"><a class=\"subnavlink\" href=\"week.php?date=".$month_days[$i]["timestamp"]."&".SID."\">" . get_weeknumber($month_days[$i]["timestamp"]) . "</a></td>\n"; 622 } 623 624// if($trim_month &&) 625 //$sqldate = $conn->DBTimeStamp(strtotime($month_days[$i]["sql_tag"])); 626 $sqldate = $month_days[$i]["sql_tag"]; 627 $sqldate_end = $conn->DBTimeStamp(mktime(23,59,59, date("m",$month_days[$i]["timestamp"]), date("d",$month_days[$i]["timestamp"]), date("Y",$month_days[$i]["timestamp"])) ); 628// $sql = "SELECT COUNT(*) AS appointment_count FROM mgw_calendar WHERE ".$sql_owner_part." SUBSTRING(date,1,8) = $sqldate GROUP BY date ORDER BY date"; 629 $sql = "SELECT COUNT(*) AS appointment_count 630 FROM mgw_calendar 631 WHERE ".$sql_owner_part." date >= $sqldate AND 632 date <= $sqldate_end 633 GROUP BY date 634 ORDER BY date"; 635 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 636 $row = $res->FetchRow(); 637 if($row["appointment_count"]>0) $markday = " style=\"font-weight:bold;\" title=\"".$row["appointment_count"]."\" alt=\"".$row["appointment_count"]."\""; 638 else $markday = ""; 639 640 /***************************/ 641 /* *** OLD : 642 if(!$trim_month || ($trim_month && ($i>0 && $i<=$num_days+abs($days_before)))) { 643 $out .= "<td class=\"$klasse\" align=\"center\"$markday>"; 644 $out .= "<a class=\"subnavlink\" href=\"index.php?date=".$month_days[$i]["timestamp"]."&".SID."\">".$month_days[$i]["day_number"]."</a></td>\n"; 645 } else { 646 $out .= "<td class=\"stand\"></td>"; 647 } 648 *** */ 649 650 /* *** NEW : */ 651 //timestamp of 1st day of current month : 652 $ts_curr_month = mktime(0, 0, 0, $month , 1 , $year ); 653 //timestamp of 1st day of next month : 654 $next_month = ($month==12) ? 1 : $month+1; 655 $next_year = ($month==12) ? $year+1 : $year; 656 $ts_next_month = mktime(0, 0, 0, $next_month , 1 , $next_year ); 657 658 if(!$trim_month || ($trim_month && ( ($i>0 or $month_days[$i]["timestamp"]==$ts_curr_month+1) && $i<=$num_days+abs($days_before)) && $month_days[$i]["timestamp"]<$ts_next_month )) { 659 //the day don't belong to the month -> italic 660 if ($month_days[$i]["timestamp"]<$ts_curr_month) { 661 $out .= "<td class=\"stand\">"; 662 $out .= " <a class=\"subnavlink\" href=\"index.php?date=".$month_days[$i]["timestamp"]."&".SID."\"><I>".$month_days[$i]["day_number"]."</I></a></td>\n"; 663 } 664 else { 665 $out .= "<td class=\"$klasse\" align=\"center\"$markday>"; 666 $out .= "<a class=\"subnavlink\" href=\"index.php?date=".$month_days[$i]["timestamp"]."&".SID."\">".$month_days[$i]["day_number"]."</a></td>\n"; 667 } 668 } 669 else { 670 $out .= "<td class=\"stand\"></td>"; 671 } 672 673 /***************************/ 674 675 if(($i+1)%7==0) { 676 $out .= "<td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>\n"; 677 $out .= "</tr>\n"; 678 } 679 } 680 681 //$out .= "<td class=\"lines\" width=\"1\" height=\"1\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td>"; 682 //$out .= "</tr>\n"; 683 $out .= "<tr><td class=\"lines\" width=\"1\" height=\"1\" colspan=\"10\"><img src=\"". $appconf["imgpathgeneral"] ."/space.gif\" alt=\"\" width=\"1\" height=\"1\" /></td></tr>"; 684 $out .= "</table>\n"; 685 686 return $out; 687} 688 689// ====================================================== 690// void db_delete_date( Int id, Int rep_id, Int tn_id) 691// 692// liefert ein Array von Terminen zu einer Kalenderregel 693// ====================================================== 694function db_delete_date_rep($id, $rep_opt, $tn_opt, $userid){ 695 global $conn; 696 697 $sql = "SELECT * FROM mgw_calendar WHERE id = $id AND userid = ".$userid; 698 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 699 $row = $res->FetchRow(); 700 $group_id = $row["dategroup_id"]; 701 $sdate = $row["date"]; 702 if ($group_id == 0){ $rep_opt=0; } 703 704 // only for user 705 if ($rep_opt==0 && $tn_opt==0 && $id > 0 && $userid > 0) $sql2 = "DELETE FROM mgw_calendar WHERE id = $id and userid=$userid"; 706 // for all users 707 elseif ($rep_opt==0 && $tn_opt==1 && $id > 0) $sql2 = "DELETE FROM mgw_calendar WHERE id = $id"; 708 //all timeseries but only for user 709 elseif ($rep_opt==2 && $tn_opt==0 && $group_id > 0 && $userid > 0) $sql2 = "DELETE FROM mgw_calendar WHERE dategroup_id = $group_id and userid=$userid and date >= '$sdate'"; 710 elseif ($rep_opt==2 && $tn_opt==1 && $group_id > 0) $sql2 = "DELETE FROM mgw_calendar WHERE dategroup_id = $group_id and date >= '$sdate'"; 711 //all timeseries for all users 712 elseif ($rep_opt==3 && $tn_opt==0 && $group_id > 0 && $userid > 0) $sql2 = "DELETE FROM mgw_calendar WHERE dategroup_id = $group_id and userid=$userid"; 713 elseif ($rep_opt==3 && $tn_opt==1 && $group_id > 0) $sql2 = "DELETE FROM mgw_calendar WHERE dategroup_id = $group_id"; 714 if($sql2 == "") return; // HACK (or FIX?) for bug 608097 715 if(!$res = $conn->Execute($sql2)) exit(showSQLerror($sql2, $conn->ErrorMsg(), __LINE__, __FILE__)); 716} 717 718// ====================================================== 719// void db_delete_date( Int id, Int userid ) 720// 721// loscht alle Terminen zu einer ID in der Table calendar 722// ====================================================== 723function db_delete_date($id, $userid){ 724 global $conn; 725 $sql = "SELECT * FROM mgw_calendar WHERE id = $id AND userid=".$userid; 726 727 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 728 $row = $res->FetchRow(); 729 $group_id = $row["dategroup_id"]; 730 731 if ($group_id==0 && $id > 0) $sql2 = "DELETE FROM mgw_calendar WHERE id = $id"; 732 elseif ($group_id > 0) $sql2 = "DELETE FROM mgw_calendar WHERE dategroup_id = $group_id"; 733 734 if(!$res = $conn->Execute($sql2)) die(showSQLerror($sql2, $conn->ErrorMsg(), __LINE__, __FILE__)); 735} 736 737// ====================================================== 738// void db_copy_date_from_tmp( Int id) 739// 740// kopiert alle Terminen zu einer ID aus calendar_tmp in die Table calendar 741// ====================================================== 742function db_copy_date_from_tmp($id){ 743 global $conn; 744 745 $sql = "INSERT INTO mgw_calendar SELECT DISTINCT b.* FROM mgw_calendar_tmp a, mgw_calendar_tmp b WHERE a.id = $id AND a.userid = b.userid and ((a.id = b.id and a.dategroup_id = 0) OR (a.dategroup_id = b.dategroup_id and a.dategroup_id > 0))"; 746 if(!$conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 747} 748 749// ====================================================== 750// void db_delete_date_from_tmp 751// 752// l�scht alle Termine zu einer ID aus calendar_tmp 753// ====================================================== 754function db_delete_date_from_tmp($id){ 755 global $conn; 756 757 $sql = "SELECT * FROM mgw_calendar_tmp WHERE id = ".$id; 758 759 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 760 $row = $res->FetchRow(); 761 762 $group_id = $row["dategroup_id"]; 763 764 if ($group_id==0) $sql2 = "DELETE FROM mgw_calendar_tmp WHERE id = $id"; 765 elseif ($group_id!=0) $sql2 = "DELETE FROM mgw_calendar_tmp WHERE dategroup_id = $group_id"; 766 if(!$res = $conn->Execute($sql2)) exit(showSQLerror($sql2, $conn->ErrorMsg(), __LINE__, __FILE__)); 767} 768 769// ====================================================== 770// String select_tag($datum, $name) 771// 772// return HTML <SELECT> object with days... 773// 774// ====================================================== 775function select_tag($datum, $name){ 776 777 echo "SELECT_TAG : obsolete function ! use mSelectBox class"; 778 /* /// NATYS /// 779 for($d=1; $d<=31; $d++){ 780 if ($d==1) $dvon = "<select name=\"$name\">"; 781 782 if ($d==date("d", $datum)) 783 $dvon .= "<option value=\"$d\" Selected>$d </option>"; 784 else 785 $dvon .= "<option value=\"$d\">$d </option>"; 786 787 if ($d==31) $dvon .= "</select>"; 788 } 789 return $dvon; 790 */ 791} 792 793// ====================================================== 794// String select_monat($datum,$name) 795// 796// return HTML <SELECT> object with months... 797// 798// ====================================================== 799function select_monat($datum,$name){ 800 801 echo "SELECT_MONAT : obsolete function ! use mSelectBox class"; 802 /* /// NATYS /// 803 for($d=1; $d<=12; $d++){ 804 if ($d==1) $dvon = "<select name=\"$name\">"; 805 806 if ($d==date("m", $datum)) 807 $dvon .= "<option value=\"$d\" Selected>$d </option>"; 808 else 809 $dvon .= "<option value=\"$d\">$d </option>"; 810 811 if ($d==12) $dvon .= "</select>"; 812 } 813 return $dvon; 814 */ 815} 816 817// ====================================================== 818// String select_jahr($datum, $name) 819// 820// return HTML <SELECT> object with years... 821// 822// ====================================================== 823function select_jahr($datum, $name){ 824 825 echo "SELECT_MONAT : obsolete function ! use mSelectBox class"; 826/* // NATYS // 827 $ende = date("Y", $datum) + 30; // current year + 30 828 ////////// 829 for($d=date("Y", $datum); $d <= $ende; $d++) { 830 if ($d==date("Y", $datum)) $dvon = "<select name=\"$name\">"; 831 $dvon .= "<option value=\"$d\">$d </option>"; 832 if ($d==$ende) $dvon .= "</select>"; 833 } 834 return $dvon; 835*/ 836} 837 838// ====================================================== 839function new_date_notify($id){ 840 global $conn; 841 $concat_c=$conn->Concat("c.firstname", "c.lastname", "'<'", "c.email", "'>'"); 842 843 $sql = "SELECT DISTINCT userid, b.lastname, b.firstname, repeat_mode, rep_until, $concat_c AS initu FROM mgw_users b, mgw_calendar a LEFT OUTER JOIN mgw_users c ON a.inituserid = c.id WHERE NOT(b.level=".UDELETED.") AND a.userid = b.id AND a.id = ".$id; 844 845 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 846 847 while($row = $res->FetchRow()){ 848 if ($row["rep_until"] != "00000000000000") $rep_bis = date("d.m.Y", $res->UnixTimeStamp($row["rep_until"])); 849 850 $teiln[]=trim($row["firstname"])." ".trim($row["lastname"]); 851 852 if ($row["repeat_mode"]==0) $rep_text = Lang::getLanguageString("gentemp_repeater_0"); 853 elseif ($row["repeat_mode"]==1) $rep_text = Lang::getLanguageString("gentemp_repeater_1") . ", " . Lang::getLanguageString("gentemp_from") . " $rep_bis"; 854 elseif ($row["repeat_mode"]==2) $rep_text = Lang::getLanguageString("gentemp_repeater_2") . ", " . Lang::getLanguageString("gentemp_from") . " $rep_bis"; 855 elseif ($row["repeat_mode"]==3) $rep_text = Lang::getLanguageString("gentemp_repeater_3") . ", " . Lang::getLanguageString("gentemp_from") . " $rep_bis"; 856 857 $init_user = $row["initu"]; 858 } 859 860 $sql = "SELECT * FROM mgw_calendar a, mgw_users b WHERE NOT(b.level=".UDELETED.") AND a.userid = b.id AND a.id = ".$id; 861 if(!$res = $conn->Execute($sql)) die(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 862 863 $teiln_text = ""; 864 for($i=0; $i<count($teiln);$i++){ 865 if ($i==0) $teiln_text .= $teiln[$i]; 866 else $teiln_text .= ", ". $teiln[$i]; 867 } 868 869 while($row = $res->FetchRow()){ 870 if($row["userid"] != $_SESSION['MGW']->userid) { 871 $zeit = $res->UnixTimeStamp($row["date"]); 872 873 $text = Lang::getLanguageString("hello").' '.$row['firstname'].",\n\n"; 874 $text .= Lang::getLanguageString("newappointment4you"). ":\n"; 875 $text .= Lang::getLanguageString("date"). " : ". date ( "d.m.Y", $zeit ) . "\n"; 876 $text .= Lang::getLanguageString("temp_time"). " : ". date ( "H:i", $zeit ) . "\n"; 877 $text .= Lang::getLanguageString("duration")." : ". $row["duration"]. "\n"; 878 $text .= Lang::getLanguageString("temp_subject"). " : ". $row["subject"]. "\n"; 879 $text .= Lang::getLanguageString("city"). " : ". $row["location"]. "\n"; 880 $text .= Lang::getLanguageString("temp_participants"). " : ". $teiln_text. "\n"; 881 $text .= Lang::getLanguageString("regulary"). " : ". $rep_text. "\n"; 882 883 if (in_array(NOTIFY_MAIL, $_SESSION['MGW']->settings['calendar_notification']) && strlen($row['email'])) 884 $GLOBALS['notify']->message($text,NOTIFY_MAIL,':'.$row['email'],Lang::getLanguageString("newappointmentmheader")); 885 if (in_array(NOTIFY_MIM, $_SESSION['MGW']->settings['calendar_notification'])) 886 $GLOBALS['notify']->message($text,NOTIFY_MIM,'u:'.$row['userid']); 887 if (in_array(NOTIFY_SCREEN, $_SESSION['MGW']->settings['calendar_notification'])) 888 $GLOBALS['notify']->message(Lang::getLanguageString("newappointment4you"),NOTIFY_SCREEN,'u:'.$row['userid']); 889 } 890 } 891} 892 893// ====================================================== 894// String get_new_id( name, id) 895// 896// ermittelt neue Id aus Tabelle Kalender 897// id == 0 max_id + 1 898// id != 0 $id 899// ====================================================== 900function get_new_id($ridname, $table, $id, $idname){ 901 global $conn; 902 903 if ($id == 0){ 904 $sql = "SELECT MAX($ridname)+1 AS maxid FROM $table"; 905 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 906 $row = $res->FetchRow(); 907 } else { 908 $sql = "SELECT $ridname AS maxid FROM $table WHERE $idname = ".$id; 909 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 910 $row = $res->FetchRow(); 911 } 912 913 if (!isset($row["maxid"])) return 1; 914 else return $row["maxid"]; 915} 916 917// ====================================================== 918// Array get_date_list( timestamp date, Integer year, Integer, month) 919// 920// liefert ein Array von Terminen zu einer Kalenderregel 921// ====================================================== 922function get_appointment_list($art, $von, $bis){ // modified by NATYS 923 global $appointment_list; 924 /* $art : 925 1 : every day 926 2 : every week 927 3 : every month 928 4 : every working day 929 5 : every year 930 */ 931 /* 932 * To avoid daylight shifting problems : we must use mktime for each appointment. NO n*3600... !! 933 */ 934 // 1 -> get d/m/Y hh:mm of the 1st appointment 935 $appt_day = date("d",$von); 936 $appt_month = date("m",$von); 937 $appt_year = date("Y",$von); 938 $appt_hour = date("H",$von); 939 $appt_min = date("i",$von); 940 941 if ($art == 1) { 942 $t=$von; 943 while($t <= $bis){ 944 $appointment_list[] = $t; 945 $appt_day++; 946 $t=mktime($appt_hour,$appt_min,0,$appt_month,$appt_day,$appt_year); 947 } 948 } 949 elseif ($art == 2) { 950 $t=$von; 951 while($t <= $bis){ 952 $appointment_list[] = $t; 953 $appt_day+=7; 954 $t=mktime($appt_hour,$appt_min,0,$appt_month,$appt_day,$appt_year); 955 } 956 } 957 elseif ($art == 3){ 958 $t = $von; 959 while($t <= $bis){ 960 $appointment_list[] = $t; 961 $appt_month++; 962 $t=mktime($appt_hour,$appt_min,0,$appt_month,$appt_day,$appt_year); 963 } 964 } 965 elseif ($art == 4) { 966 $t=$von; 967 while($t <= $bis){ 968 if ( date("w", $t) != 0 && date("w", $t) != 6 && get_celebrate_days($t, $_SESSION["MGW"]->settings["calendar_holiday_system"]) == "") $appointment_list[] = $t; 969 $appt_day++; 970 $t=mktime($appt_hour,$appt_min,0,$appt_month,$appt_day,$appt_year); 971 } 972 } 973 elseif ($art == 5) { 974 $t = $von; 975 while($t <= $bis){ 976 $appointment_list[] = $t; 977 $appt_year++; 978 $t=mktime($appt_hour,$appt_min,0,$appt_month,$appt_day,$appt_year); 979 } 980 } 981 982 983 if (count($appointment_list) == 0) $appointment_list[]=$von; // always at least one 984 return $appointment_list; 985} 986 987// ====================================================== 988// Konflikt-Pr�fung des aktuellen Termins 989// 990// andere Termine des Teilnehmers des Tages selektieren 991// leyeti : TODO : fix bug with PostGreSQL : substring(....) 992// ====================================================== 993function edit_conflict_list($art, $von, $bis, $userid, $nid){ 994 global $conflict_list, $conn; 995 996 $sql_tag = date("Ymd", $von); 997 $concat_b=$conn->Concat("b.lastname", "', '", "b.firstname"); 998 $sql = ($art == "update") ? 999 "SELECT DISTINCT c.*, $concat_b AS name FROM mgw_calendar a, mgw_calendar c, mgw_users b WHERE NOT(b.level=".UDELETED.") AND a.userid = $userid AND a.userid = c.userid AND SUBSTRING(a.date,1,8) = '$sql_tag' AND SUBSTRING(a.date,1,8) = SUBSTRING(c.date,1,8) AND a.userid = b.id AND ((a.id = $nid AND a.id <> c.id AND a.dategroup_id = 0) OR (a.id = $nid AND a.dategroup_id <> c.dategroup_id AND a.dategroup_id > 0)) ORDER BY DATE" 1000 : 1001 "SELECT DISTINCT c.*, $concat_b AS name FROM mgw_calendar a, mgw_calendar c, mgw_users b WHERE NOT(b.level=".UDELETED.") AND a.userid = $userid AND a.userid = c.userid AND SUBSTRING(a.date,1,8) = '$sql_tag' AND SUBSTRING(a.date,1,8) = SUBSTRING(c.date,1,8) AND a.userid = b.id AND ((a.dategroup_id = 0) OR (a.dategroup_id <> c.dategroup_id AND a.dategroup_id > 0)) ORDER BY DATE"; 1002 1003 if(!$res = $conn->Execute($sql)) exit(showSQLerror($sql, $conn->ErrorMsg(), __LINE__, __FILE__)); 1004 1005 while($row = $res->FetchRow()){ 1006 $term_von = $res->UnixTimeStamp($row["date"] ); 1007 $term_bis = $term_von + 60*$row["duration"]; 1008 1009 // does it overlap? 1010/// NATYS /// 1011// if(($von >= $term_von && $von < $term_bis) || ($bis > $term_von && $bis <= $term_bis) || ($von <= $term_von && $bis >= $term_bis) || ($row["day_ind"] == 1)){ 1012 if(($von >= $term_von && $von < $term_bis) || ($bis > $term_von && $bis <= $term_bis) || ($von <= $term_von && $bis >= $term_bis)){ 1013///////////// 1014 if ($row["privat"] == 0) 1015 $conflict_list["$von"][] = array("name" => $row["name"], 1016 "appointment" => date($_SESSION["MGW"]->settings["datefmt"], $res->UnixTimeStamp($row["date"])), 1017 "time_start" => date("H:i", $term_von), 1018 "time_end" => date("H:i", $term_bis), 1019 "topic" => $row["subject"], 1020 "class" => "tab", 1021 "id" => $nid); 1022 else $conflict_list["$von"][] = array("name" => $row["name"], 1023 "appointment" => date($_SESSION["MGW"]->settings["datefmt"], $res->UnixTimeStamp($row["date"])), 1024 "time_start" => date("H : i", $term_von), 1025 "time_end" => date("H : i", $term_bis), 1026 "topic" => Lang::getLanguageString("private"), 1027 "class" => "tab", 1028 "id" => $nid); 1029 } 1030 } 1031} 1032?> 1033