event_edit.php 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. <?php
  2. /*
  3. * event_edit.php
  4. *
  5. * Copyright (c) 2001 Michal Szczotka <michal@tuxy.org>
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Functions to edit an event.
  9. *
  10. * $Id$
  11. */
  12. require_once('calendar_data.php');
  13. require_once('functions.php');
  14. chdir('..');
  15. require_once('../src/validate.php');
  16. require_once('../functions/strings.php');
  17. require_once('../functions/date.php');
  18. require_once('../config/config.php');
  19. require_once('../functions/page_header.php');
  20. require_once('../src/load_prefs.php');
  21. // update event info
  22. function show_event_form() {
  23. global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
  24. $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  25. echo "\n<FORM name=eventupdate action=\"event_edit.php\" METHOD=POST >\n".
  26. " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
  27. " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
  28. " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
  29. " <INPUT TYPE=hidden NAME=\"hour\" VALUE=\"$hour\">\n".
  30. " <INPUT TYPE=hidden NAME=\"minute\" VALUE=\"$minute\">\n".
  31. " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
  32. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Date:") . "</TD>\n".
  33. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  34. " <SELECT NAME=\"event_year\">\n";
  35. select_option_year($year);
  36. echo " </SELECT>\n" .
  37. " &nbsp;&nbsp;\n" .
  38. " <SELECT NAME=\"event_month\">\n";
  39. select_option_month($month);
  40. echo " </SELECT>\n".
  41. " &nbsp;&nbsp;\n".
  42. " <SELECT NAME=\"event_day\">\n";
  43. select_option_day($day);
  44. echo " </SELECT>\n".
  45. " </TD></TR>\n".
  46. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Time:") . "</TD>\n".
  47. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  48. " <SELECT NAME=\"event_hour\">\n";
  49. select_option_hour($hour);
  50. echo " </SELECT>\n".
  51. " &nbsp;:&nbsp;\n".
  52. " <SELECT NAME=\"event_minute\">\n";
  53. select_option_minute($minute);
  54. echo " </SELECT>\n".
  55. " </TD></TR>\n".
  56. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n".
  57. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  58. " <SELECT NAME=\"event_length\">\n";
  59. select_option_length($tmparray[length]);
  60. echo " </SELECT>\n".
  61. " </TD></TR>\n".
  62. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n".
  63. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  64. " <SELECT NAME=\"event_priority\">\n";
  65. select_option_priority($tmparray[priority]);
  66. echo " </SELECT>\n".
  67. " </TD></TR>\n".
  68. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n".
  69. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  70. " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
  71. " </TD></TR>\n".
  72. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n".
  73. " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n".
  74. " </TD></TR>\n".
  75. " <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
  76. _("Update Event") . "\"></TD></TR>\n".
  77. "</FORM>\n";
  78. }
  79. // self explenatory
  80. function confirm_update() {
  81. global $calself, $year, $month, $day, $hour, $minute, $calendardata, $color, $event_year, $event_month, $event_day, $event_hour, $event_minute, $event_length, $event_priority, $event_title, $event_text;
  82. $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  83. echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
  84. " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
  85. _("Do you really want to change this event from:") . "<br>\n".
  86. " </TH></TR>\n".
  87. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
  88. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n".
  89. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
  90. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$hour:$minute</TD></TR>\n".
  91. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
  92. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[priority]</TD></TR>\n".
  93. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
  94. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[title]</TD></TR>\n".
  95. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
  96. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$tmparray[message]</TD></TR>\n".
  97. " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
  98. _("to:") . "<br>\n".
  99. " </TH></TR>\n".
  100. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
  101. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_month/$event_day/$event_year</TD></TR>\n".
  102. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . ("Time:") . "</TD>\n".
  103. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</TD></TR>\n".
  104. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Priority:") . "</TD>\n".
  105. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_priority</TD></TR>\n".
  106. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Title:") . "</TD>\n".
  107. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_title</TD></TR>\n".
  108. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Message:") . "</TD>\n".
  109. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_text</TD></TR>\n".
  110. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">\n".
  111. " <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n".
  112. " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
  113. " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
  114. " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
  115. " <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n".
  116. " <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n".
  117. " <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n".
  118. " <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n".
  119. " <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n".
  120. " <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n".
  121. " <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n".
  122. " <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n".
  123. " <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n".
  124. " <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n".
  125. " <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n".
  126. " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
  127. " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
  128. ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
  129. " </FORM>\n".
  130. " </TD><TD ALIGN=LEFT BGCOLOR=\"$color[4]\">\n".
  131. " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
  132. " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
  133. " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
  134. " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
  135. ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
  136. " </FORM>\n".
  137. " </TD></TR>\n".
  138. " </TABLE>\n";
  139. }
  140. if ($month <= 0){
  141. $month = date( 'm' );
  142. }
  143. if ($year <= 0){
  144. $year = date( 'Y' );
  145. }
  146. if ($day <= 0){
  147. $day = date( 'd' );
  148. }
  149. if ($hour <= 0){
  150. $hour = '08';
  151. }
  152. $calself=basename($PHP_SELF);
  153. displayPageHeader($color, 'None');
  154. //load calendar menu
  155. calendar_header();
  156. echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
  157. "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
  158. '<tr><td COLSPAN=2>' .
  159. date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) .
  160. '</td></tr>';
  161. if (!isset($updated)){
  162. //get changes to event
  163. readcalendardata();
  164. show_event_form();
  165. } else {
  166. if (!isset($confirmed)){
  167. //confirm changes
  168. readcalendardata();
  169. // strip event text so it fits in one line
  170. $event_text=nl2br($event_text);
  171. $event_text=ereg_replace ("\n", '', $event_text);
  172. $event_text=ereg_replace ("\r", '', $event_text);
  173. confirm_update();
  174. } else {
  175. update_event("$month$day$year", "$hour$minute");
  176. echo "<tr><td>" . _("Event updated!") . "</td></tr>\n";
  177. echo "<tr><td><A HREF=\"day.php?year=$year&month=$month&day=$day\">" .
  178. _("Day View") ."</A></td></tr>\n";
  179. $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
  180. //if event has been moved to different year then act accordingly
  181. if ($year==$event_year){
  182. $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
  183. writecalendardata();
  184. } else {
  185. writecalendardata();
  186. $year=$event_year;
  187. $calendardata = array();
  188. readcalendardata();
  189. $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
  190. writecalendardata();
  191. }
  192. }
  193. }
  194. ?>
  195. </table></td></tr></table>
  196. </body></html>