event_create.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <?php
  2. /*
  3. * event_create.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 create a event for calendar.
  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. //main form to gather event info
  22. function show_event_form() {
  23. global $color, $editor_size, $year, $day, $month, $hour;
  24. echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n".
  25. " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
  26. " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
  27. " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
  28. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Start time:") . "</TD>\n".
  29. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  30. " <SELECT NAME=\"event_hour\">\n";
  31. select_option_hour($hour);
  32. echo " </SELECT>\n" .
  33. " &nbsp;:&nbsp;\n" .
  34. " <SELECT NAME=\"event_minute\">\n";
  35. select_option_minute("00");
  36. echo " </SELECT>\n".
  37. " </TD></TR>\n".
  38. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Length:") . "</TD>\n".
  39. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  40. " <SELECT NAME=\"event_length\">\n";
  41. select_option_length("0");
  42. echo " </SELECT>\n".
  43. " </TD></TR>\n".
  44. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Priority:") . "</TD>\n".
  45. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  46. " <SELECT NAME=\"event_priority\">\n";
  47. select_option_priority("0");
  48. echo " </SELECT>\n".
  49. " </TD></TR>\n".
  50. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=RIGHT>" . _("Title:") . "</TD>\n".
  51. " <TD BGCOLOR=\"$color[4]\" ALIGN=LEFT>\n".
  52. " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
  53. " </TD></TR>\n".
  54. " <TR><TD BGCOLOR=\"$color[4]\" ALIGN=LEFT COLSPAN=2>\n".
  55. " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>\n".
  56. " </TD></TR>\n".
  57. " <TR><TD ALIGN=LEFT BGCOLOR=\"$color[4]\" COLSPAN=2><INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
  58. _("Set Event") . "\"></TD></TR>\n";
  59. echo "</FORM>\n";
  60. }
  61. if ( !isset($month) || $month <= 0){
  62. $month = date( 'm' );
  63. }
  64. if ( !isset($year) || $year <= 0){
  65. $year = date( 'Y' );
  66. }
  67. if (!isset($day) || $day <= 0){
  68. $day = date( 'd' );
  69. }
  70. if (!isset($hour) || $hour <= 0){
  71. $hour = '08';
  72. }
  73. $calself=basename($PHP_SELF);
  74. displayPageHeader($color, 'None');
  75. //load calendar menu
  76. calendar_header();
  77. echo "<TR BGCOLOR=\"$color[0]\"><TD>" .
  78. "<TABLE WIDTH=100% BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">" .
  79. '<tr><td COLSPAN=2>' .
  80. date_intl( 'l, F d Y', mktime(0, 0, 0, $month, $day, $year)) .
  81. '</td></tr>';
  82. //if form has not been filled in
  83. if(!isset($event_text)){
  84. show_event_form();
  85. } else {
  86. readcalendardata();
  87. //make sure that event text is fittting in one line
  88. $event_text=nl2br($event_text);
  89. $event_text=ereg_replace ("\n", "", $event_text);
  90. $event_text=ereg_replace ("\r", "", $event_text);
  91. $calendardata["$month$day$year"]["$event_hour$event_minute"] =
  92. array( 'length' => $event_length,
  93. 'priority' => $event_priority,
  94. 'title' => $event_title,
  95. 'message' => $event_text,
  96. 'reminder' => '' );
  97. //save
  98. writecalendardata();
  99. echo " <TABLE BORDER=0 CELLPADDING=2 CELLSPACING=1 BGCOLOR=\"$color[0]\">\n".
  100. " <TR><TH COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
  101. _("Event Has been added!") . "<br>\n".
  102. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Date:") . "</TD>\n".
  103. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$month/$day/$year</TD></TR>\n".
  104. " <TR><TD ALIGN=RIGHT BGCOLOR=\"$color[4]\">" . _("Time:") . "</TD>\n".
  105. " <TD ALIGN=LEFT BGCOLOR=\"$color[4]\">$event_hour:$event_minute</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 COLSPAN=2 BGCOLOR=\"$color[4]\">\n".
  111. "<A HREF=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</A>\n".
  112. " </TD></TR>\n".
  113. " </TABLE>\n";
  114. }
  115. ?>
  116. </table></td></tr></table>
  117. </body></html>