0ae820a1310e05cdd281050c8ff55f2d7792b39d
[squirrelmail.git] / plugins / calendar / event_delete.php
1 <?php
2
3 /**
4 * event_delete.php
5 *
6 * Copyright (c) 2002-2003 The SquirrelMail Project Team
7 * Licensed under the GNU GPL. For full terms see the file COPYING.
8 *
9 * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
10 *
11 * Functions to delete a event.
12 *
13 * $Id$
14 */
15 define('SM_PATH','../../');
16
17 /* Calender plugin required files. */
18 require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
19 require_once(SM_PATH . 'plugins/calendar/functions.php');
20
21 /* SquirrelMail required files. */
22 require_once(SM_PATH . 'include/validate.php');
23 require_once(SM_PATH . 'functions/strings.php');
24 require_once(SM_PATH . 'functions/date.php');
25 require_once(SM_PATH . 'config/config.php');
26 require_once(SM_PATH . 'functions/page_header.php');
27 require_once(SM_PATH . 'include/load_prefs.php');
28 require_once(SM_PATH . 'functions/html.php');
29 /* get globals */
30 if (isset($_GET['month'])) {
31 $month = $_GET['month'];
32 }
33 elseif (isset($_POST['month'])) {
34 $month = $_POST['month'];
35 }
36 if (isset($_GET['year'])) {
37 $year = $_GET['year'];
38 }
39 elseif (isset($_POST['year'])) {
40 $year = $_POST['year'];
41 }
42 if (isset($_GET['day'])) {
43 $day = $_GET['day'];
44 }
45 elseif (isset($_POST['day'])) {
46 $day = $_POST['day'];
47 }
48 if (isset($_GET['dyear'])) {
49 $dyear = $_GET['dyear'];
50 }
51 elseif (isset($_POST['dyear'])) {
52 $dyear = $_POST['dyear'];
53 }
54 if (isset($_GET['dmonth'])) {
55 $dmonth = $_GET['dmonth'];
56 }
57 elseif (isset($_POST['dmonth'])) {
58 $dmonth = $_POST['dmonth'];
59 }
60 if (isset($_GET['dday'])) {
61 $dday = $_GET['dday'];
62 }
63 elseif (isset($_POST['dday'])) {
64 $dday = $_POST['dday'];
65 }
66 if (isset($_GET['dhour'])) {
67 $dhour = $_GET['dhour'];
68 }
69 elseif (isset($_POST['dhour'])) {
70 $dhour = $_POST['dhour'];
71 }
72 if (isset($_GET['dminute'])) {
73 $dminute = $_GET['dminute'];
74 }
75 elseif (isset($_POST['dminute'])) {
76 $dminute = $_POST['dminute'];
77 }
78 if (isset($_POST['confirmed'])) {
79 $confirmed = $_POST['confirmed'];
80 }
81 /* got 'em */
82
83 function confirm_deletion()
84 {
85 global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
86
87 $tmparray = $calendardata["$dmonth$dday$dyear"]["$dhour$dminute"];
88
89 echo html_tag( 'table',
90 html_tag( 'tr',
91 html_tag( 'th', _("Do you really want to delete this event?") . '<br>', '', $color[4], 'colspan="2"' )
92 ) .
93 html_tag( 'tr',
94 html_tag( 'td', _("Date:"), 'right', $color[4] ) .
95 html_tag( 'td', $dmonth.'/'.$dday.'/'.$dyear, 'left', $color[4] )
96 ) .
97 html_tag( 'tr',
98 html_tag( 'td', _("Time:"), 'right', $color[4] ) .
99 html_tag( 'td', $dhour.':'.$dminute, 'left', $color[4] )
100 ) .
101 html_tag( 'tr',
102 html_tag( 'td', _("Title:"), 'right', $color[4] ) .
103 html_tag( 'td', $tmparray['title'], 'left', $color[4] )
104 ) .
105 html_tag( 'tr',
106 html_tag( 'td', _("Message:"), 'right', $color[4] ) .
107 html_tag( 'td', $tmparray['message'], 'left', $color[4] )
108 ) .
109 html_tag( 'tr',
110 html_tag( 'td',
111 " <FORM NAME=\"delevent\" METHOD=POST ACTION=\"$calself\">\n".
112 " <INPUT TYPE=HIDDEN NAME=\"dyear\" VALUE=\"$dyear\">\n".
113 " <INPUT TYPE=HIDDEN NAME=\"dmonth\" VALUE=\"$dmonth\">\n".
114 " <INPUT TYPE=HIDDEN NAME=\"dday\" VALUE=\"$dday\">\n".
115 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
116 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
117 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
118 " <INPUT TYPE=HIDDEN NAME=\"dhour\" VALUE=\"$dhour\">\n".
119 " <INPUT TYPE=HIDDEN NAME=\"dminute\" VALUE=\"$dminute\">\n".
120 " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
121 ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
122 " </FORM>\n" ,
123 'right', $color[4] ) .
124 html_tag( 'td',
125 " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
126 " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
127 " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
128 " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
129 ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
130 " </FORM>\n" ,
131 'left', $color[4] )
132 ) ,
133 '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
134 }
135
136 if ($month <= 0){
137 $month = date( 'm' );
138 }
139 if ($year <= 0){
140 $year = date( 'Y' );
141 }
142 if ($day <= 0){
143 $day = date( 'd' );
144 }
145
146 $calself=basename($PHP_SELF);
147
148 displayPageHeader($color, 'None');
149 //load calendar menu
150 calendar_header();
151
152 echo html_tag( 'tr', '', '', $color[0] ) .
153 html_tag( 'td' ) .
154 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
155 html_tag( 'tr' ) .
156 html_tag( 'td', '', 'left' ) .
157 date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year));
158 if (isset($dyear) && isset($dmonth) && isset($dday) && isset($dhour) && isset($dminute)){
159 if (isset($confirmed)){
160 delete_event("$dmonth$dday$dyear", "$dhour$dminute");
161 echo '<br><br>' . _("Event deleted!") . "<br>\n";
162 echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
163 _("Day View") . "</a>\n";
164 } else {
165 readcalendardata();
166 confirm_deletion();
167 }
168 } else {
169 echo '<br>' . _("Nothing to delete!");
170 }
171
172 ?>
173 </table></td></tr></table>
174 </body></html>