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

Documentation generated on Tue, 17 Apr 2018 04:25:52 +0200 by phpDocumentor 1.4.3