summaryrefslogtreecommitdiff
path: root/forum/utils/calendar.php
blob: 15921950f66c98c58e580fdcdf25011816bf5c7b (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
include_once($UTIL_DIR . "/events.php");
include_once($UTIL_DIR . "/notify.php");

$events = new Events($DATA_DIR . "/calendar.xml");

if(!$date) $date = time() - (date("N", time()) - 1) * 24 * 60 * 60;
else $date = $date - (date("N", $date) - 1) * 24 * 60 * 60; 
//echo $date;

if($action=="addentry") {
  $time = strtotime($txtdate . " " . $txttimefrom . ":00");
  $duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time;
  $eid = time();
  $event = new Event($eid, $title, $time, $duration, $description, $current_user->uid);
  $events->add($event);
  $events->write();
	notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" .
                           $description . "\n" .
			   "http://www.executionroom.com/forum/?mode=calendar&date=" . $time);
}

if($action=="edit") {
	/*
  $event = $events->getEvent($eid);
  $event->duration += 2000;
  $events->write();
	*/
}

?>
<p style="text-align: center;">
<a href="?mode=calendar&amp;date=<?php echo $date - 7 * 24 * 60 * 60 ?>">[&lt;]</a>
&nbsp;&nbsp;
<a href="?mode=calendar&amp;date=<?php echo $date - 31 * 24 * 60 * 60 ?>">[&lt;&lt;]</a> 
&nbsp;&nbsp;
<?php echo date("F Y", $date); ?>
&nbsp;&nbsp;
<a href="?mode=calendar&amp;date=<?php echo $date + 31 * 24 * 60 * 60 ?>">[&gt;&gt;]</a> 
&nbsp;&nbsp;
<a href="?mode=calendar&amp;date=<?php echo $date + 7 * 24 * 60 * 60 ?>">[&gt;]</a><br/>
<a href="?mode=calendar">[Today]</a><br/>
</p>
<?php
if($client_is_mobile_device) {
  for($day = 0; $day < 7; $day++) {
    echo "  <div class=\"mobilecalentry\">\n";
    echo "    <div class=\"mobilecalheader\">\n";
    $t = $date + $day * 24 * 60 * 60;
    echo "      " . date("l j/n", $t) . "\n";
?>
     <a style="text-decoration: none;" href="?mode=calendar&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">[+]</a>
<?php
    echo "    </div>\n";

    $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));
    echo "    <div class=\"mobilecalcontent\"";
    if($t ==  strtotime(date("F j Y", time())))  echo " style=\"background: #113;\"";
    elseif($day > 4) echo " style=\"background: #311;\"";
    echo ">\n";

    $events->show($t, $t + 24 * 60 * 60);

    echo "    </div>\n";
    echo "  </div>\n";

  }
} else {
?>
<table class="week">
  <tr class="day">
<?php
for($day = 0; $day < 7; $day++) {
	echo "    <td class=\"header\">\n";
	$t = $date + $day * 24 * 60 * 60;
	echo "      " . date("l j/n", $t) . "\n";
	echo "    </td>\n";
}
?>
  </tr>
  <tr class="day">
<?php
for($day = 0; $day < 7; $day++) {
        $t = strtotime(date("F j Y", $date + $day * 24 * 60 * 60));

	echo "    <td class=\"content\"";
	if($t ==  strtotime(date("F j Y", time())))  echo " style=\"background: #113;\"";
	elseif($day > 4) echo " style=\"background: #311;\"";
	echo ">\n";
?>
     <a class="button" href="?mode=calendar&amp;date=<?php echo $date; ?>&amp;adddate=<?php echo $t; ?>&amp;action=add">Add</a>
<?php
	$events->show($t, $t + 24 * 60 * 60);
	echo "    </td>\n";
}
?>
  </tr>
</table>
<?php
}
?>
<?php if($adddate != "") { ?>
<form method="post" action="?mode=calendar&amp;action=addentry">
Title: <input name="title" value=""><br/>
Desription: <textarea name="description"></textarea><br/>
Date: <input name="txtdate" value="<?php echo date("F j Y", $adddate); ?>"><br/>
From-Time: <input name="txttimefrom" value="17:00"><br/>
To-Time: <input name="txttimeto" value="20:00"><br/>
<br/>
<button type="submit">Add</button>
</form>
<?php } ?>