event_create.php 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. require_once('../functions/html.php');
  22. //main form to gather event info
  23. function show_event_form() {
  24. global $color, $editor_size, $year, $day, $month, $hour;
  25. echo "\n<FORM name=eventscreate action=\"event_create.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. html_tag( 'tr' ) .
  30. html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
  31. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  32. " <SELECT NAME=\"event_hour\">\n";
  33. select_option_hour($hour);
  34. echo " </SELECT>\n" .
  35. " &nbsp;:&nbsp;\n" .
  36. " <SELECT NAME=\"event_minute\">\n";
  37. select_option_minute("00");
  38. echo " </SELECT>\n".
  39. " </td></tr>\n".
  40. html_tag( 'tr' ) .
  41. html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
  42. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  43. " <SELECT NAME=\"event_length\">\n";
  44. select_option_length("0");
  45. echo " </SELECT>\n".
  46. " </td></tr>\n".
  47. html_tag( 'tr' ) .
  48. html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
  49. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  50. " <SELECT NAME=\"event_priority\">\n";
  51. select_option_priority("0");
  52. echo " </SELECT>\n".
  53. " </td></tr>\n".
  54. html_tag( 'tr' ) .
  55. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  56. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  57. " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
  58. " </td></tr>\n".
  59. html_tag( 'tr',
  60. html_tag( 'td',
  61. "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" ,
  62. 'left', $color[4], 'colspan="2"' )
  63. ) ."\n" .
  64. html_tag( 'tr',
  65. html_tag( 'td',
  66. "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
  67. _("Set Event") . "\">" ,
  68. 'left', $color[4], 'colspan="2"' )
  69. ) ."\n";
  70. echo "</FORM>\n";
  71. }
  72. if ( !isset($month) || $month <= 0){
  73. $month = date( 'm' );
  74. }
  75. if ( !isset($year) || $year <= 0){
  76. $year = date( 'Y' );
  77. }
  78. if (!isset($day) || $day <= 0){
  79. $day = date( 'd' );
  80. }
  81. if (!isset($hour) || $hour <= 0){
  82. $hour = '08';
  83. }
  84. $calself=basename($PHP_SELF);
  85. displayPageHeader($color, 'None');
  86. //load calendar menu
  87. calendar_header();
  88. echo html_tag( 'tr', '', '', $color[0] ) .
  89. html_tag( 'td', '', 'left' ) .
  90. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
  91. html_tag( 'tr',
  92. html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
  93. );
  94. //if form has not been filled in
  95. if(!isset($event_text)){
  96. show_event_form();
  97. } else {
  98. readcalendardata();
  99. //make sure that event text is fittting in one line
  100. $event_text=nl2br($event_text);
  101. $event_text=ereg_replace ("\n", "", $event_text);
  102. $event_text=ereg_replace ("\r", "", $event_text);
  103. $calendardata["$month$day$year"]["$event_hour$event_minute"] =
  104. array( 'length' => $event_length,
  105. 'priority' => $event_priority,
  106. 'title' => $event_title,
  107. 'message' => $event_text,
  108. 'reminder' => '' );
  109. //save
  110. writecalendardata();
  111. echo html_tag( 'table',
  112. html_tag( 'tr',
  113. html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' )
  114. ) .
  115. html_tag( 'tr',
  116. html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
  117. html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
  118. ) .
  119. html_tag( 'tr',
  120. html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
  121. html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
  122. ) .
  123. html_tag( 'tr',
  124. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  125. html_tag( 'td', $event_title, 'left', $color[4] ) . "\n"
  126. ) .
  127. html_tag( 'tr',
  128. html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
  129. html_tag( 'td', $event_text, 'left', $color[4] ) . "\n"
  130. ) .
  131. html_tag( 'tr',
  132. html_tag( 'td',
  133. "<a href=\"day.php?year=$year&month=$month&day=$day\">" . _("Day View") . "</a>\n" ,
  134. 'left', $color[4], 'colspan="2"' ) . "\n"
  135. ) ,
  136. '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
  137. }
  138. ?>
  139. </table></td></tr></table>
  140. </body></html>