Happy New Year
[squirrelmail.git] / plugins / calendar / event_delete.php
index b771861733b53ced3457fd2ff55ee3ef5a5e6624..12a082d580d0fca3a8e597f2d1348e427925748f 100644 (file)
 <?php
-/*
- *  event_delete.php
- *
- *  Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
- *  Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- *  Functions to delete a event. 
+
+/**
+ * Functions to delete a event.
  *
- * $Id$
+ * @copyright 2002-2020 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+ * @version $Id$
+ * @package plugins
+ * @subpackage calendar
  */
 
-require_once('calendar_data.php');
-require_once('functions.php');
-chdir('..');
-require_once('../src/validate.php');
-require_once('../functions/strings.php');
-require_once('../functions/date.php');
-require_once('../config/config.php');
-require_once('../functions/page_header.php');
-require_once('../src/load_prefs.php');
+/**
+ * Include the SquirrelMail initialization file.
+ */
+require('../../include/init.php');
 
-function confirm_deletion()
-{
-    global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
+/* date_intl() */
+include_once(SM_PATH . 'functions/date.php');
 
-    $tmparray = $calendardata["$dmonth$dday$dyear"]["$dhour$dminute"];
+/* Calendar plugin required files. */
+include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
+include_once(SM_PATH . 'plugins/calendar/functions.php');
 
-    echo "  <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
-         "    <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
-         _("Do you really want to delete this event?") . "<br></th>\n".
-         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
-         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$dmonth/$dday/$dyear</TD></TR>\n".
-         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
-         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$dhour:$dminute</TD></TR>\n".
-         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
-         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n".
-         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
-         "    <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n".
-         "    <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n".
-         "    <FORM NAME=\"delevent\" METHOD=POST ACTION=\"$calself\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"dyear\" VALUE=\"$dyear\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"dmonth\" VALUE=\"$dmonth\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"dday\" VALUE=\"$dday\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"dhour\" VALUE=\"$dhour\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"dminute\" VALUE=\"$dminute\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
-         "       <INPUT TYPE=SUBMIT VALUE=\"Yes\">\n".
-         "    </FORM>\n".
-         "    </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n".
-         "    <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
-         "       <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
-         "       <INPUT TYPE=SUBMIT VALUE=\"No\">\n".
-         "    </FORM>\n".
-         "    </TD></TR>\n".
-         "  </TABLE>\n";
+/* get globals */
+if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
+    unset($month);
+}
+if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
+    unset($year);
+}
+if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
+    unset($day);
+}
+if (! sqGetGlobalVar('dyear',$dyear,SQ_FORM) || ! is_numeric($dyear)) {
+    unset($dyear);
+}
+if (! sqGetGlobalVar('dmonth',$dmonth,SQ_FORM) || ! is_numeric($dmonth)) {
+    unset($dmonth);
+}
+if (! sqGetGlobalVar('dday',$dday,SQ_FORM) || ! is_numeric($dday)) {
+    unset($dday);
+}
+if (! sqGetGlobalVar('dhour',$dhour,SQ_FORM) || ! is_numeric($dhour)) {
+    unset($dhour);
+}
+if (! sqGetGlobalVar('dminute',$dminute,SQ_FORM) || ! is_numeric($dminute)) {
+    unset($dminute);
+}
+sqGetGlobalVar('confirmed',$confirmed,SQ_POST);
+
+/* got 'em */
 
+/**
+ * Displays confirmation form when event is deleted
+ * @return void
+ */
+function confirm_deletion() {
+    global $calself, $dyear, $dmonth, $dday, $dhour, $dminute, $calendardata, $color, $year, $month, $day;
+
+    $tmparray = $calendardata["$dmonth$dday$dyear"]["$dhour$dminute"];
 
+    echo html_tag( 'table',
+               html_tag( 'tr',
+                   html_tag( 'th', _("Do you really want to delete this event?") . '<br />', '', $color[4], 'colspan="2"' )
+               ) .
+               html_tag( 'tr',
+                   html_tag( 'td', _("Date:"), 'right', $color[4] ) .
+                   html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$dmonth,$dday,$dyear)), 'left', $color[4] )
+               ) .
+               html_tag( 'tr',
+                   html_tag( 'td', _("Time:"), 'right', $color[4] ) .
+                   html_tag( 'td', date_intl(_("H:i"),mktime($dhour,$dminute,0,$dmonth,$dday,$dyear)), 'left', $color[4] )
+               ) .
+               html_tag( 'tr',
+                   html_tag( 'td', _("Title:"), 'right', $color[4] ) .
+                   html_tag( 'td', sm_encode_html_special_chars($tmparray['title']), 'left', $color[4] )
+               ) .
+               html_tag( 'tr',
+                   html_tag( 'td', _("Message:"), 'right', $color[4] ) .
+                   html_tag( 'td', nl2br(sm_encode_html_special_chars($tmparray['message'])), 'left', $color[4] )
+               ) .
+               html_tag( 'tr',
+                   html_tag( 'td',
+                       "    <form name=\"delevent\" method=\"post\" action=\"$calself\">\n".
+                       "       <input type=\"hidden\" name=\"dyear\" value=\"$dyear\" />\n".
+                       "       <input type=\"hidden\" name=\"dmonth\" value=\"$dmonth\" />\n".
+                       "       <input type=\"hidden\" name=\"dday\" value=\"$dday\" />\n".
+                       "       <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
+                       "       <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
+                       "       <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
+                       "       <input type=\"hidden\" name=\"dhour\" value=\"$dhour\" />\n".
+                       "       <input type=\"hidden\" name=\"dminute\" value=\"$dminute\" />\n".
+                       "       <input type=\"hidden\" name=\"confirmed\" value=\"yes\" />\n".
+                       '       <input type="submit" value="' . _("Yes") . "\" />\n".
+                       "    </form>\n" ,
+                   'right', $color[4] ) .
+                   html_tag( 'td',
+                       "    <form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n".
+                       "       <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
+                       "       <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
+                       "       <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
+                       '       <input type="submit" value="' . _("No") . "\" />\n".
+                       "    </form>\n" ,
+                   'left', $color[4] )
+               ) ,
+           '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
 }
 
 if ($month <= 0){
@@ -75,27 +119,30 @@ if ($day <= 0){
 
 $calself=basename($PHP_SELF);
 
-displayPageHeader($color, 'None');
+displayPageHeader($color);
 //load calendar menu
 calendar_header();
 
-echo "<TR BGCOLOR=\"$color[0]\"><TD>".
-     "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">".
-     '<tr><td>'.
-     date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year));
+echo html_tag( 'tr', '', '', $color[0] ) .
+           html_tag( 'td' ) .
+               html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
+                   html_tag( 'tr' ) .
+                       html_tag( 'td', '', 'left' ) .
+     date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year));
 if (isset($dyear) && isset($dmonth) && isset($dday) && isset($dhour) && isset($dminute)){
     if (isset($confirmed)){
         delete_event("$dmonth$dday$dyear", "$dhour$dminute");
-        echo '<br><br>' . _("Event deleted!") . "<BR>\n";
-        echo "<A HREF=\"day.php?year=$year&month=$month&day=$day\">Day View</A>\n";
+        echo '<br /><br />' . _("Event deleted!") . "<br />\n";
+        echo "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
+          _("Day View") . "</a>\n";
     } else {
         readcalendardata();
         confirm_deletion();
     }
 } else {
-    echo '<br>' . _("Nothing to delete!");
+    echo '<br />' . _("Nothing to delete!");
 }
 
 ?>
 </table></td></tr></table>
-</body></html>
\ No newline at end of file
+</body></html>