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