From aa558b57b90b85a5ff9b14a3572d07913e7cfd8d Mon Sep 17 00:00:00 2001 From: James Cox Date: Mon, 28 Jan 2002 21:53:06 +0000 Subject: [PATCH] new fields to the calender. Changes primarily by georg@php.net - Georg Richter. Blame him if it breaks :) --- cal.php | 152 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 113 insertions(+), 39 deletions(-) diff --git a/cal.php b/cal.php index c321813c3..5add222c2 100644 --- a/cal.php +++ b/cal.php @@ -63,7 +63,7 @@ CREATE TABLE phpcal ( * -2 = second-last */ function weekday($year, $month, $day, $which) { - $ts = mktime(12,0,0,$month+(($which>0)?0:1),($which>0)?1:0,$year); + $ts = mktime(12,0,0,$month+(($which>0)?0:1),($which>0)?1:0,$year); $done = false; $match = 0; $inc = 3600*24; @@ -80,22 +80,22 @@ CREATE TABLE phpcal ( function load_unapproved_events() { global $re; $days = days(); - $result = mysql_query("select * from phpcal where approved=0 order by sdato"); + $result = mysql_query("select phpcal.*, country.name as name from phpcal, country where phpcal.country=country.id and approved=0 order by sdato"); if(!$result) echo mysql_error(); else { while($row = mysql_fetch_array($result)) { switch($row['tipo']) { case 1: - $events[] = array($row['id'],$row['sdato'],$row['sdesc'],$row['ldesc'],$row['url']); + $events[] = array($row['id'],$row['sdato'],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']); break; case 2: - $events[] = array($row['id'],$row['sdato'].' to '.$row['edato'],$row['sdesc'],$row['ldesc'],$row['url']); + $events[] = array($row['id'],$row['sdato'].' to '.$row['edato'],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']); break; case 3: list($which,$day) = explode(':',$row['recur']); - $events[] = array($row['id'],'Every '.$re[(int)$which].' '.$days[$day],$row['sdesc'],$row['ldesc'],$row['url']); + $events[] = array($row['id'],'Every '.$re[(int)$which].' '.$days[$day],$row['sdesc'],$row['ldesc'],$row['url'], $row['name'], $row['category']); break; - } + } } } return $events; @@ -192,7 +192,7 @@ CREATE TABLE phpcal ( ?> @@ -210,10 +210,10 @@ CREATE TABLE phpcal ( if($j==0) echo '\n"; else { if($j==1 && ($i-1)==$start) $day = 1; - if($day && $day<=$last) { - $label=$day; - $col = '#f0f0f0'; - $bcol=$col; + if($day && $day<=$last) { + $label=$day; + $col = '#f0f0f0'; + $bcol=$col; $data = ' '; if(is_array($events[$day])) { $data = ''; @@ -229,18 +229,18 @@ CREATE TABLE phpcal ( } if($day) $day++; } - echo "\n"; + echo "\n"; } ?>
- +
'.$days[$i]."
->.(($a)? add event'; +>.(($a)? add event'; else echo "$err"; echo "\n"; if($a) draw_add();?> ->.(($ap)? approve events' . " ($c event(s) pending)"; +>.(($ap)? approve events' . " ($c event(s) pending)"; else echo "$aerr"; if($ap) draw_app(); echo "\n"; @@ -248,15 +248,43 @@ echo "\n"; function draw_event($ev) { global $re; - - $result = mysql_query("select * from phpcal where id=$ev"); + $stmt = "select phpcal.*,country.name as cname from phpcal,country where phpcal.country = country.id and phpcal.id=$ev"; + $result = mysql_query($stmt); if(!$result) echo mysql_error(); else $event = mysql_fetch_array($result); $days=days(); + $cat = $event['category']; + switch($cat) { + case 1: + $category = "regional"; + break; + case 2: + $category = "national"; + break; + case 3: + $category = "international"; + break; + default: + $category = "unknown"; + } ?> - + + - +
URL: ".$event['url']."\n";?>
+Country: ". $event['cname'] : "" ; + +echo ((!isset($category)) || ($category != "unknown")) ? "
Event Type: ". $category : "" ; + +if(strlen($event['url'])) { + echo "
URL: ".$event['url']."\n"; +} +?> +
App. by:
Approved by:
- +\n"; + echo '\n"; $i++; } - echo ""; + echo ""; } ?> @@ -308,7 +336,7 @@ function draw_add() { global $smonth, $sday, $syear; global $emonth, $eday, $eyear; global $recur, $recur_day, $type; - global $url, $sdesc, $ldesc, $ap, $re, $cm, $cy; + global $url, $sdesc, $ldesc, $ap, $re, $cm, $cy, $country, $category; ?> +
 WhenLabelDescriptionURL
 WhenLabelDescriptionCountryURL
$e[1]$e[2]".(ini_get('magic_quotes_gpc')?stripslashes($e[3]):$e[3])."$e[4]
$e[5]$e[4]
  CVS Login: CVS Passwd:
  CVS Login:  CVS Password:
@@ -317,9 +345,9 @@ function draw_add() { ".$months[$smonth-1]."\n"; - foreach($months as $m) { - if($i!=$smonth) echo "\n"; - $i++; + foreach($months as $m) { + if($i!=$smonth) echo "\n"; + $i++; } ?> @@ -332,9 +360,9 @@ function draw_add() { ".$months[$emonth-1]."\n"; - foreach($months as $m) { - if($i!=$emonth) echo "\n"; - $i++; + foreach($months as $m) { + if($i!=$emonth) echo "\n"; + $i++; } ?> @@ -355,8 +383,8 @@ foreach($re as $k=>$v) { ".$days[$recur_day]."\n"; - foreach($days as $i=>$d) { - if($i!=$recur_day) echo "\n"; + foreach($days as $i=>$d) { + if($i!=$recur_day) echo "\n"; } ?> @@ -365,12 +393,32 @@ foreach($re as $k=>$v) {
Short
Description
Country
Event Category
URL
Long
Description
-$v) { $ldesc = nl2br($ldesc); if(empty($sdesc)) { $err = "You must provide a short description for your event - please correct this
\n"; - $a=1; + $a = 1; + } else + if (!$country) { + $err = "You must specify a country - please correct this
\n"; + $a = 1; + } else + if (!$category){ + $err = "You must specifiy the event category - please correct this
\n"; + $a = 1; } else switch($type) { case 'single': @@ -393,7 +449,9 @@ foreach($re as $k=>$v) { $err = "Invalid start date - please correct it
\n"; $a=1; } else { - mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,'$syear-$smonth-$sday',NULL,NULL,'$sdesc','$url','$ldesc',1,0,NULL)") or $err=mysql_error(); + + mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,'$syear-$smonth-$sday',NULL,NULL,'$sdesc','$url','$ldesc',1,0,NULL,'$country','$category')") or $err=mysql_error(); + } break; case 'multi': @@ -408,14 +466,18 @@ foreach($re as $k=>$v) { } elseif($smonth==$emonth && $sday==$eday && $syear==$eyear) { $err = "Your start and end dates are identical - please correct this
\n"; $a=1; } else { - mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,'$syear-$smonth-$sday','$eyear-$emonth-$eday',NULL,'$sdesc','$url','$ldesc',2,0,NULL)") or $err=mysql_error(); + + mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,'$syear-$smonth-$sday','$eyear-$emonth-$eday',NULL,'$sdesc','$url','$ldesc',2,0,NULL,'$country','$category')") or $err=mysql_error(); + } break; case 'recur': if(!is_numeric($recur) || !is_numeric($recur_day)) { $err = "Recurring event sequence is invalid - please correct it
\n"; $a=1; } else { - mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by) values (0,NULL,NULL,'$recur:$recur_day','$sdesc','$url','$ldesc',3,0,NULL)") or $err=mysql_error(); + + mysql_query("insert into phpcal (id,sdato,edato,recur,sdesc,url,ldesc,tipo,approved,app_by,country,category) values (0,NULL,NULL,'$recur:$recur_day','$sdesc','$url','$ldesc',3,0,NULL,'$country','$category')") or $err=mysql_error(); + } break; } @@ -435,7 +497,7 @@ foreach($re as $k=>$v) { if(!$result) echo mysql_error(); } } - + } else { echo "

The username or password you supplied was incorrect.

\n"; $ap = 1; @@ -469,7 +531,7 @@ foreach($re as $k=>$v) { if($data) $data.="\n"; $data .= "$i,$cm,$cy,\"http://php.net/cal.php?cm=$cm&cy=$cy&ev=".$row['id']."\",\"".addslashes($row['sdesc']).'"'; } - } + } $nm--; $cd = 1; if($nm) { @@ -479,5 +541,17 @@ foreach($re as $k=>$v) { } echo $data; break; - } + } ?> + + + + + + + + + + + +