Source for file event_edit.php

Documentation is available at event_edit.php

  1. <?php
  2.  
  3. /**
  4.  * Functions to edit an event.
  5.  *
  6.  * @copyright 2002-2020 The SquirrelMail Project Team
  7.  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  8.  * @version $Id: event_edit.php 14845 2020-01-07 08:09:34Z pdontthink $
  9.  * @package plugins
  10.  * @subpackage calendar
  11.  */
  12.  
  13. /**
  14.  * Include the SquirrelMail initialization file.
  15.  */
  16. require('../../include/init.php');
  17.  
  18. /* SquirrelMail required files. */
  19.  
  20. /* date_intl() */
  21. include_once(SM_PATH . 'functions/date.php');
  22. /* form functions */
  23. include_once(SM_PATH . 'functions/forms.php');
  24.  
  25. /* Calendar plugin required files. */
  26. include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
  27. include_once(SM_PATH . 'plugins/calendar/functions.php');
  28.  
  29. /* get globals */
  30.  
  31. sqGetGlobalVar('updated',$updated,SQ_POST);
  32.  
  33. /* get date values and make sure that they are numeric */
  34. if (! sqGetGlobalVar('event_year',$event_year,SQ_POST) || ! is_numeric($event_year)) {
  35.     unset($event_year);
  36. }
  37. if (! sqGetGlobalVar('event_month',$event_month,SQ_POST) || ! is_numeric($event_month)) {
  38.     unset($event_month);
  39. }
  40. if (! sqGetGlobalVar('event_day',$event_day,SQ_POST) || ! is_numeric($event_day)) {
  41.     unset($event_day);
  42. }
  43. if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST) || ! is_numeric($event_hour)) {
  44.     unset($event_hour);
  45. }
  46. if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST) || ! is_numeric($event_minute)) {
  47.     unset($event_minute);
  48. }
  49. if (! sqGetGlobalVar('event_length',$event_length,SQ_POST) || ! is_numeric($event_length)) {
  50.     unset($event_length);
  51. }
  52. sqGetGlobalVar('event_title',$event_title,SQ_POST);
  53. sqGetGlobalVar('event_text',$event_text,SQ_POST);
  54. sqGetGlobalVar('send',$send,SQ_POST);
  55.  
  56. if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST) || ! is_numeric($event_priority)) {
  57.     unset($event_priority);
  58. }
  59.  
  60. sqGetGlobalVar('confirmed',$confirmed,SQ_POST);
  61.  
  62. if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
  63.     unset($year);
  64. }
  65. if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
  66.     unset($month);
  67. }
  68. if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
  69.     unset($day);
  70. }
  71. if (! sqGetGlobalVar('hour',$hour,SQ_FORM) || ! is_numeric($hour)) {
  72.     unset($hour);
  73. }
  74. if (! sqGetGlobalVar('minute',$minute,SQ_FORM) || ! is_numeric($minute)) {
  75.     unset($minute);
  76. }
  77. /* got 'em */
  78.  
  79. /**
  80.  * update event info
  81.  * @return void 
  82.  * @access private
  83.  */
  84. function update_event_form() {
  85.     global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
  86.  
  87.     $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  88.     $tab = '    ';
  89.     echo "\n<form name=\"eventupdate\" action=\"event_edit.php\" method=\"post\">\n".
  90.          $tab . addHidden('year',$year).
  91.          $tab . addHidden('month',$month).
  92.          $tab . addHidden('day',$day).
  93.          $tab . addHidden('hour',$hour).
  94.          $tab . addHidden('minute',$minute).
  95.          $tab . addHidden('updated','yes').
  96.          html_tag( 'tr' ) .
  97.          html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
  98.          html_tag( 'td', '', 'left', $color[4] ) .
  99.          "      <select name=\"event_year\">\n";
  100.     select_option_year($year);
  101.     echo "      </select>\n" .
  102.          "      &nbsp;&nbsp;\n" .
  103.          "      <select name=\"event_month\">\n";
  104.     select_option_month($month);
  105.     echo "      </select>\n".
  106.          "      &nbsp;&nbsp;\n".
  107.          "      <select name=\"event_day\">\n";
  108.     select_option_day($day);
  109.     echo "      </select>\n".
  110.          "      </td></tr>\n".
  111.          html_tag( 'tr' ) .
  112.          html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
  113.          html_tag( 'td', '', 'left', $color[4] ) .
  114.          "      <select name=\"event_hour\">\n";
  115.     select_option_hour($hour);
  116.     echo "      </select>\n".
  117.          "      &nbsp;:&nbsp;\n".
  118.          "      <select name=\"event_minute\">\n";
  119.     select_option_minute($minute);
  120.     echo "      </select>\n".
  121.          "      </td></tr>\n".
  122.          html_tag( 'tr' ) .
  123.          html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
  124.          html_tag( 'td', '', 'left', $color[4] ) .
  125.          "      <select name=\"event_length\">\n";
  126.     select_option_length($tmparray['length']);
  127.     echo "      </select>\n".
  128.          "      </td></tr>\n".
  129.          html_tag( 'tr' ) .
  130.          html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
  131.          html_tag( 'td', '', 'left', $color[4] ) .
  132.          "      <select name=\"event_priority\">\n";
  133.     select_option_priority($tmparray['priority']);
  134.     echo "      </select>\n".
  135.          "      </td></tr>\n".
  136.          html_tag( 'tr' ) .
  137.          html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  138.          html_tag( 'td', addInput('event_title',$tmparray['title'],30,50), 'left', $color[4]) .
  139.              "\n</tr>\n".
  140.          html_tag( 'tr' ) .
  141.          html_tag( 'td', addTextArea('event_text',$tmparray['message'],$editor_size,5),
  142.                    'left', $color[4], 'colspan="2"' ) .
  143.          '</tr>' . html_tag( 'tr' ) .
  144.          html_tag( 'td', addSubmit(_("Update Event"),'send'), 'left', $color[4], 'colspan="2"' ) .
  145.          "</tr></form>\n";
  146. }
  147.  
  148. /**
  149.  * Confirms event update
  150.  * @return void 
  151.  * @access private
  152.  */
  153. function confirm_update() {
  154.     global $calself, $year, $month, $day, $hour, $minute, $calendardata,
  155.         $color, $event_year, $event_month, $event_day, $event_hour,
  156.         $event_minute, $event_length, $event_priority, $event_title, $event_text;
  157.  
  158.     $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  159.     $tab = '    ';
  160.  
  161.     echo html_tag( 'table',
  162.                 html_tag( 'tr',
  163.                     html_tag( 'th', _("Do you really want to change this event from:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
  164.                 ) .
  165.                 html_tag( 'tr',
  166.                     html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
  167.                     html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) ."\n"
  168.                 ) .
  169.                 html_tag( 'tr',
  170.                     html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
  171.                     html_tag( 'td', date_intl(_("H:i"),mktime($hour,$minute,0,$month,$day,$year)) , 'left', $color[4] ) ."\n"
  172.                 ) .
  173.                 html_tag( 'tr',
  174.                     html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
  175.                     html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n"
  176.                 ) .
  177.                 html_tag( 'tr',
  178.                     html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
  179.                     html_tag( 'td', sm_encode_html_special_chars($tmparray['title']) , 'left', $color[4] ) ."\n"
  180.                 ) .
  181.                 html_tag( 'tr',
  182.                     html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
  183.                     html_tag( 'td', nl2br(sm_encode_html_special_chars($tmparray['message'])) , 'left', $color[4] ) ."\n"
  184.                 ) .
  185.                 html_tag( 'tr',
  186.                     html_tag( 'th', _("to:") . "<br />\n", '', $color[4], 'colspan="2"' ) ."\n"
  187.                 ) .
  188.  
  189.                 html_tag( 'tr',
  190.                     html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
  191.                     html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
  192.                 ) .
  193.                 html_tag( 'tr',
  194.                     html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
  195.                     html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$event_month,$event_day,$event_year)), 'left', $color[4] ) ."\n"
  196.                 ) .
  197.                 html_tag( 'tr',
  198.                     html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
  199.                     html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
  200.                 ) .
  201.                 html_tag( 'tr',
  202.                     html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
  203.                     html_tag( 'td', sm_encode_html_special_chars($event_title) , 'left', $color[4] ) ."\n"
  204.                 ) .
  205.                 html_tag( 'tr',
  206.                     html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
  207.                     html_tag( 'td', nl2br(sm_encode_html_special_chars($event_text)) , 'left', $color[4] ) ."\n"
  208.                 ) .
  209.                 html_tag( 'tr',
  210.                     html_tag( 'td',
  211.                         "<form name=\"updateevent\" method=\"post\" action=\"$calself\">\n".
  212.                         $tab . addHidden('year',$year).
  213.                         $tab . addHidden('month',$month).
  214.                         $tab . addHidden('day',$day).
  215.                         $tab . addHidden('hour',$hour).
  216.                         $tab . addHidden('minute',$minute).
  217.                         $tab . addHidden('event_year',$event_year).
  218.                         $tab . addHidden('event_month',$event_month).
  219.                         $tab . addHidden('event_day',$event_day).
  220.                         $tab . addHidden('event_hour',$event_hour).
  221.                         $tab . addHidden('event_minute',$event_minute).
  222.                         $tab . addHidden('event_priority',$event_priority).
  223.                         $tab . addHidden('event_length',$event_length).
  224.                         $tab . addHidden('event_title',$event_title).
  225.                         $tab . addHidden('event_text',$event_text).
  226.                         $tab . addHidden('updated','yes').
  227.                         $tab . addHidden('confirmed','yes').
  228.                         $tab . addSubmit(_("Yes")).
  229.                         "</form>\n" ,
  230.                     'right', $color[4] ) ."\n" .
  231.                     html_tag( 'td',
  232.                         "<form name=\"nodelevent\" method=\"post\" action=\"day.php\">\n".
  233.                         $tab . addHidden('year',$year).
  234.                         $tab . addHidden('month',$month).
  235.                         $tab . addHidden('day',$day).
  236.                         $tab . addSubmit(_("No")).
  237.                         "</form>\n" ,
  238.                     'left', $color[4] ) ."\n"
  239.                 ) ,
  240.             '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
  241. }
  242.  
  243. if ($month <= 0){
  244.     $month = date( 'm' );
  245. }
  246. if ($year <= 0){
  247.     $year = date( 'Y' );
  248. }
  249. if ($day <= 0){
  250.     $day = date( 'd' );
  251. }
  252. if ($hour <= 0){
  253.     $hour = '08';
  254. }
  255.  
  256. $calself=basename($PHP_SELF);
  257.  
  258. //load calendar menu
  259.  
  260. echo html_tag( 'tr', '', '', $color[0] ) .
  261.             html_tag( 'td', '', 'left' ) .
  262.                 html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
  263.                     html_tag( 'tr' ) .
  264.                         html_tag( 'td',
  265.                             date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
  266.                         'left', '', 'colspan="2"' );
  267. if (!isset($updated)){
  268.     //get changes to event
  269.     readcalendardata();
  270.     update_event_form();
  271. } else {
  272.     if (!isset($confirmed)){
  273.         //confirm changes
  274.         readcalendardata();
  275.         confirm_update();
  276.     } else {
  277.         update_event("$month$day$year", "$hour$minute");
  278.         echo html_tag( 'tr',
  279.                    html_tag( 'td', _("Event updated!"), 'left' )
  280.                 ) . "\n";
  281.         echo html_tag( 'tr',
  282.                    html_tag( 'td',
  283.                        "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
  284.                        _("Day View") ."</a>",
  285.                    'left' )
  286.                 ) . "\n";
  287.  
  288.         $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
  289.         //if event has been moved to different year then act accordingly
  290.         if ($year==$event_year){
  291.             $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length'   => $event_length,
  292.                                                                           'priority' => $event_priority,
  293.                                                                           'title'    => $event_title,
  294.                                                                           'message'  => $event_text);
  295.             writecalendardata();
  296.         } else {
  297.             writecalendardata();
  298.             $year=$event_year;
  299.             $calendardata = array();
  300.             readcalendardata();
  301.             $calendardata["$fixdate"]["$event_hour$event_minute"] = array('length'   => $event_length,
  302.                                                                           'priority' => $event_priority,
  303.                                                                           'title'    => $event_title,
  304.                                                                           'message'  => $event_text);
  305.             writecalendardata();
  306.         }
  307.     }
  308. }
  309.  
  310. ?>
  311. </table></td></tr></table>
  312. </body></html>

Documentation generated on Mon, 13 Jan 2020 04:22:26 +0100 by phpDocumentor 1.4.3