<?php
##########################################################################
# Please refer to the README file for licensing and contact information.
#
# This file has been updated for version 0.8.20071118
#
# If you like this application, do support me in its development
# by sending any contributions at www.calendarix.com.
#
#
# Copyright © 2002-2007 Vincent Hor
##########################################################################
require_once ('cal_header.inc.php');
include_once ("cal_utils.php") ;
if (isset($_GET['isdelete']))
$isdelete = $_GET['isdelete'];
else
$isdelete = "n" ;
// Check if login , in case of public view, before look for passed username to prevent hacking.
if ((isset($_SESSION["login"]))&&(isset($_GET['uname']))) $uname = $_GET['uname'];
else $uname = "" ;
// used in delete event call
if (!isset($_GET['delev'])) $delev = 0 ;
else $delev = $_GET['delev'] ;
// Close window and refresh calendar if copy event was done, which calls this page with "reload".
if (isset($_GET['reload'])) {
echo "<script language=\"JavaScript\">\n" ;
echo "<!--\n" ;
echo "top.opener.window.location.reload();\n" ;
echo "self.window.close();\n" ;
echo "//-->\n" ;
echo "</script>\n\n" ;
}
if (isset($_GET['op'])) $op = $_GET['op'];
?>
<html>
<head>
<title>Event</title>
</head>
<body>
<?php
// Close window and refresh calendar if copy event was done, which calls this page with "reload".
if (isset($_GET['reload'])) {
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">\n" ;
echo "top.opener.window.location.reload() ;\n" ;
echo "window.close();\n" ;
echo "</script>\n" ;
}
if ($allowuserdel==1) {
// Delete event portion
if ($delev==1) {
$dquery = "delete from ".$EVENTS_TB." where id='$id'";
mysql_query($dquery);
echo "<h4>".translate("Deleting event")." ...</h4>" ;
echo "<!-- javascript redirect -->\n" ;
echo "<script language=\"JavaScript\" type=\"text/JavaScript\">\n" ;
echo "top.opener.window.location.reload();\n" ;
echo "window.close();\n" ;
echo "</script>\n\n" ;
}
}
$query = "select id,user,title,GroupName, calendar_events.description, starttime,endtime,day,month,year,approved,url,email from ".$EVENTS_TB." left join groups on ".$EVENTS_TB.".cat=groups.GroupID where id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_object($result);
echo "<div class=popupeventtitlefont>".stripslashes($row->title)."</div><br/>\n";
echo "\n<div class=popupeventfont>" ;
$weekday = mktime(0,0,0,$row->month,$row->day,$row->year);
$weekday = strftime("%w",$weekday);
$weekday++;
echo "<b>".translate("Date")." : </b>".$row->day ." ".$mth[ltrim($row->month, 0)]." ".$row->year." (".$week[$weekday].")\n";
if ($notimeentry==0)
showtime($row->starttime,$row->endtime,2);
echo "<br/><b>Group : </b>".stripslashes($row->GroupName)."\n";
echo "<br/><br/><b>".translate("Event Description")." : </b><br/>\n";
echo "<blockquote>".stripslashes($row->description)."</blockquote>";
echo "\n";
if ($row->email)
echo "<br/><b>".translate("Email")." : </b><a href=mailto:".$row->email.">".$row->email."</a>\n";
if ($row->url){
echo "<br/><b>".translate("More info")." : </b><a href=";
// for compatibility with up to 0.5 version
if (strtolower(substr($row->url,0,4))<>"http") echo "http://".$row->url." target=_blank>http://".$row->url."</a>\n";
else echo $row->url." target=_blank>".$row->url."</a>\n";
}
if (($showuserentry==1)&&($uname!=""))
echo "<br/><br/><b>".translate("User")." : </b>".$row->user ;
echo "</div><hr/><div align=center class=menufont>" ;
$query = "select * from vote where userid =".$userid. " and EventID=".$id;
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($rows > 0 )
{
echo "You have voted for this event.";
$query = "select * from vote where userid =".$userid. " and EventID=".$id;
$result = mysql_query($query);
$rows = mysql_num_rows($result);
while($row = mysql_fetch_object($result))
{
if($row->Decision == '0')
echo "<br>You voted NO.";
else if($row->Decision == '1')
echo "<br>You voted YES.";
}
}
else
{
if ($op != 'vote')
{
echo "You have not voted for this event yet.";
echo "<br><a href=cal_popup.php?op=vote&id=".$id."&uname=".$uname."&vote=0>Vote No</a><br>";
echo "<a href=cal_popup.php?op=vote&id=".$id."&uname=".$uname."&vote=1>Vote Yes</a><br>";
}
}
if($op == 'vote')
{
echo "<br>You have voted ";
$query = "select * from vote where userid =".$userid." and EventID=".$id;
$result = mysql_query($query);
$rows = mysql_num_rows($result);
if($_GET['vote'] == '0' and $rows == 0)
{
echo "no";
$query = "insert into vote (userid, eventid, decision) values ($userid,$id,0)";
$result = mysql_query($query);
echo "<meta http-equiv=\"refresh\" content=\"2;url=cal_popup.php?op=view&id=".$id."&uname=".$uname."\">";
}
if($_GET['vote'] == '1' and $rows == 0)
{
echo "yes";
$query = "insert into vote (userid, eventid, decision) values ($userid,$id,1)";
$result = mysql_query($query);
echo "<meta http-equiv=\"refresh\" content=\"0;url=cal_popup.php?op=view&id=".$id."&uname=".$uname."\">";
}
}
$query = "select * from vote where EventID=".$id." and decision=0";
$result = mysql_query($query);
$no = mysql_num_rows($result);
$query = "select * from vote where EventID=".$id." and decision=1";
$result = mysql_query($query);
$yes = mysql_num_rows($result);
if($yes == '0' && $no == '0')
echo "<br>No votes have been made for this event yet.";
else if($yes > $no)
echo "<br>More people have voted YES for this event.";
else if($yes < $no)
echo "<br>More people have voted NO for this event";
else if($yes == $no)
echo "<br>The votes are TIED for this event.";
?>
<script type="text/javascript" src="wz_jsgraphics.js"></script>
<script type="text/javascript" src="pie.js"></script>
<div id="pieCanvas" style="overflow: auto; position:relative;height:350px;width:380px;"></div>
<script type="text/javascript">
var p = new pie();
<?php
if($yes == '0' && $no == '0')
echo ";";
else
echo "p.add(\"Yes\",".$yes.");\n p.add(\"No\",".$no.");\n";
?>
p.render("pieCanvas", "Pie Graph")
</script>
<?php
if ((($publicview==1)&&($uname!=""))||($publicview==0)) {
if (($addeventok==1)&&($isdelete!="y")){
echo "<a href='#' onclick=\"Javascript:wopen('cal_addevent.php?op=eventform&id=$id','popupwin',".$addeventwin_w.",".$addeventwin_h.",'yes');\">".translate("Copy Event")."</a> ";
}
// readded query as stopped query for voting
$query = "select id,user,title,GroupName, calendar_events.description, starttime,endtime,day,month,year,approved,url,email from ".$EVENTS_TB." left join groups on ".$EVENTS_TB.".cat=groups.GroupID where id='$id'";
$result = mysql_query($query);
$row = mysql_fetch_object($result);
if (($allowuserdel==1)&&($uname==$row->user)) {
if (($addeventok==1)&&($isdelete!="y")) echo " - " ;
if ($isdelete!="y") {
echo "<a class=menufont href='Javascript:void(0);' onclick=\"Javascript:wopen('cal_addevent.php?op=upeventform&id=$id','popupwin',".$addeventwin_w.",".$addeventwin_h.",'yes');\">".ucwords(translate("Edit event"))."</a>";
echo " - <a href='cal_popup.php?op=view&isdelete=y&uname=$uname&id=".$id."' >".ucwords(translate("Delete event"))."</a> ";
}
else
echo "<a href='cal_popup.php?op=view&id=".$id."&delev=1' >".ucwords(translate("Confirm delete?"))."</a> ";
}
echo "</div><hr/><div align=center class=menufont><b><h3>Messages Posted to this event</h3></b>" ;
echo "</div><hr/><div align=center class=menufont>";
$query = "select username, Subject, Body from message inner join calendar_users on message.FromUserID = calendar_users.user_id where EventID= ".$id;
$result = mysql_query($query);
while($row = mysql_fetch_object($result))
{
echo $row->username.": ".$row->Subject."<BR>".$row->Body;
echo "</div><hr/><div align=center class=menufont>" ;
}
}
echo "<br/><br/></div>\n<div class=titlefont>Post Message</div><br/><form name=evfrm action=cal_message.php?op=addmessage&event=".$id." method=post><div class=normalfont>
Message Subject<br/>
<input type=text name=Subject size=20 value='' ><br/>
Message Body<br/>
<textarea name=body cols=70 rows=7></textarea><br/>
<br/><input type=submit value=\"Send Message\">
<input type=button value=\"Cancel\" onclick='Javascript:window.history.go(-1);'>
<br/>
";
?>
<?php
include ('cal_functions.inc.php');
include ('cal_footer.inc.php');
?>
</body>
</html>