summaryrefslogtreecommitdiff
path: root/forum/utils/calendar.php
blob: 318f4587c7dc108c4e742b4adae526ed088a0184 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?php
include_once($UTIL_DIR . "/events.php");
include_once($UTIL_DIR . "/notify.php");
if($ZEND_DIR != "") include_once($UTIL_DIR . "/googlecalendar.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") {
  $title = stripslashes($title);
  $description = stripslashes($description);

  $time = strtotime($txtdate . " " . $txttimefrom . ":00");
	if($time !== FALSE) {
		$duration = strtotime($txtdate . " " . $txttimeto . ":00") - $time;
		$eid = time();
		$event = new Event($eid, $title, $time, $duration, $description, $current_user->uid);
		$events->add($event);
		$events->write();
	
		if($ZEND_DIR != "") googleCalendarEvent($event);

		if($DOKUWIKI_CALENDAR != "") {
			$file = $DOKUWIKI_CALENDAR;
			$fp = fopen($file, "w");
			
			fprintf($fp, "=====DIEs calendar=====\n");
			fprintf($fp, "Do not edit this file - it is automatically generated by the ExecutionRoom CMS.\n\n");
			fprintf($fp, "====Events====\n");
			foreach($events->events as $event) {
				fprintf($fp, "  * %s - %s %s: %s\n",
								date("j.n.Y G:i", $event->starttime),
								date("j.n.Y G:i", $event->starttime + $event->duration),
								$event->title, $event->description);
			}
			fclose($fp);
		}

		notify("calendar", "New calendar entry:\n" . $title . "\n" . date("r", $time) . "\n" .
					 $description . "\n" .
					 $FORUM_URL . "/?mode=calendar&date=" . $time);
?>
		<meta http-equiv="refresh" content="0; URL=?mode=calendar&amp;date=<?php echo $time; ?>" />
<?php

	} else {
		echo "<div class=\"error\">ERROR: Date is not in the correct format! It was NOT posted. Please try again.</div>\n";
	}

}

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 } ?>