All this document.write stuff is overkill when we already have checkForJavascript...
[squirrelmail.git] / plugins / calendar / event_delete.php
CommitLineData
d61a01d4 1<?php
7c67a5e8 2
3/**
91e0dccc 4 * Functions to delete a event.
d61a01d4 5 *
4b5049de 6 * @copyright &copy; 2002-2007 The SquirrelMail Project Team
4b4abf93 7 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
8 * @version $Id$
ea5f4b8e 9 * @package plugins
10 * @subpackage calendar
11 */
12
202bcbcc 13/**
14 * Include the SquirrelMail initialization file.
15 */
16require('../../include/init.php');
cf1efdce 17
1c7143ad 18/* date_intl() */
19include_once(SM_PATH . 'functions/date.php');
20
21/* Calendar plugin required files. */
22include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
23include_once(SM_PATH . 'plugins/calendar/functions.php');
24
95dcee50 25/* get globals */
1c7143ad 26if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
27 unset($month);
95dcee50 28}
1c7143ad 29if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
30 unset($year);
95dcee50 31}
1c7143ad 32if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
33 unset($day);
95dcee50 34}
1c7143ad 35if (! sqGetGlobalVar('dyear',$dyear,SQ_FORM) || ! is_numeric($dyear)) {
36 unset($dyear);
95dcee50 37}
1c7143ad 38if (! sqGetGlobalVar('dmonth',$dmonth,SQ_FORM) || ! is_numeric($dmonth)) {
39 unset($dmonth);
95dcee50 40}
1c7143ad 41if (! sqGetGlobalVar('dday',$dday,SQ_FORM) || ! is_numeric($dday)) {
42 unset($dday);
95dcee50 43}
1c7143ad 44if (! sqGetGlobalVar('dhour',$dhour,SQ_FORM) || ! is_numeric($dhour)) {
45 unset($dhour);
95dcee50 46}
1c7143ad 47if (! sqGetGlobalVar('dminute',$dminute,SQ_FORM) || ! is_numeric($dminute)) {
48 unset($dminute);
95dcee50 49}
1c7143ad 50sqGetGlobalVar('confirmed',$confirmed,SQ_POST);
51
95dcee50 52/* got 'em */
d61a01d4 53
1c7143ad 54/**
55 * Displays confirmation form when event is deleted
56 * @return void
57 */
58function confirm_deletion() {
d61a01d4 59 global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
60
61 $tmparray = $calendardata["$dmonth$dday$dyear"]["$dhour$dminute"];
62
b01b21d0 63 echo html_tag( 'table',
64 html_tag( 'tr',
6fd95361 65 html_tag( 'th', _("Do you really want to delete this event?") . '<br />', '', $color[4], 'colspan="2"' )
b01b21d0 66 ) .
67 html_tag( 'tr',
68 html_tag( 'td', _("Date:"), 'right', $color[4] ) .
f1d482ae 69 html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$dmonth,$dday,$dyear)), 'left', $color[4] )
b01b21d0 70 ) .
71 html_tag( 'tr',
72 html_tag( 'td', _("Time:"), 'right', $color[4] ) .
f1d482ae 73 html_tag( 'td', date_intl(_("H:i"),mktime($dhour,$dminute,0,$dmonth,$dday,$dyear)), 'left', $color[4] )
b01b21d0 74 ) .
75 html_tag( 'tr',
76 html_tag( 'td', _("Title:"), 'right', $color[4] ) .
1c7143ad 77 html_tag( 'td', htmlspecialchars($tmparray['title']), 'left', $color[4] )
b01b21d0 78 ) .
79 html_tag( 'tr',
80 html_tag( 'td', _("Message:"), 'right', $color[4] ) .
1c7143ad 81 html_tag( 'td', nl2br(htmlspecialchars($tmparray['message'])), 'left', $color[4] )
b01b21d0 82 ) .
83 html_tag( 'tr',
84 html_tag( 'td',
6fd95361 85 " <form name=\"delevent\" method=\"post\" action=\"$calself\">\n".
86 " <input type=\"hidden\" name=\"dyear\" value=\"$dyear\" />\n".
87 " <input type=\"hidden\" name=\"dmonth\" value=\"$dmonth\" />\n".
88 " <input type=\"hidden\" name=\"dday\" value=\"$dday\" />\n".
89 " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
90 " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
91 " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
92 " <input type=\"hidden\" name=\"dhour\" value=\"$dhour\" />\n".
93 " <input type=\"hidden\" name=\"dminute\" value=\"$dminute\" />\n".
94 " <input type=\"hidden\" name=\"confirmed\" value=\"yes\" />\n".
95 ' <input type="submit" value="' . _("Yes") . "\" />\n".
96 " </form>\n" ,
b01b21d0 97 'right', $color[4] ) .
98 html_tag( 'td',
6fd95361 99 " <form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n".
100 " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
101 " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
102 " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
103 ' <input type="submit" value="' . _("No") . "\" />\n".
104 " </form>\n" ,
b01b21d0 105 'left', $color[4] )
106 ) ,
107 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
d61a01d4 108}
109
110if ($month <= 0){
111 $month = date( 'm' );
112}
113if ($year <= 0){
114 $year = date( 'Y' );
115}
116if ($day <= 0){
117 $day = date( 'd' );
118}
119
120$calself=basename($PHP_SELF);
121
122displayPageHeader($color, 'None');
123//load calendar menu
124calendar_header();
125
b01b21d0 126echo html_tag( 'tr', '', '', $color[0] ) .
127 html_tag( 'td' ) .
128 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
129 html_tag( 'tr' ) .
130 html_tag( 'td', '', 'left' ) .
f3409980 131 date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year));
d61a01d4 132if (isset($dyear) && isset($dmonth) && isset($dday) && isset($dhour) && isset($dminute)){
133 if (isset($confirmed)){
134 delete_event("$dmonth$dday$dyear", "$dhour$dminute");
6fd95361 135 echo '<br /><br />' . _("Event deleted!") . "<br />\n";
1ba8cd6b 136 echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
b01b21d0 137 _("Day View") . "</a>\n";
d61a01d4 138 } else {
139 readcalendardata();
140 confirm_deletion();
141 }
142} else {
6fd95361 143 echo '<br />' . _("Nothing to delete!");
d61a01d4 144}
145
146?>
147</table></td></tr></table>
91e0dccc 148</body></html>