event_create.php 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * functions to create a event for calendar.
  4. *
  5. * @copyright &copy; 2002-2007 The SquirrelMail Project Team
  6. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  7. * @version $Id$
  8. * @package plugins
  9. * @subpackage calendar
  10. */
  11. /**
  12. * Include the SquirrelMail initialization file.
  13. */
  14. require('../../include/init.php');
  15. /* date_intl() */
  16. include_once(SM_PATH . 'functions/date.php');
  17. /* Calendar plugin required files. */
  18. include_once(SM_PATH . 'plugins/calendar/calendar_data.php');
  19. include_once(SM_PATH . 'plugins/calendar/functions.php');
  20. /* get globals */
  21. if (! sqGetGlobalVar('year',$year,SQ_FORM) || ! is_numeric($year)) {
  22. unset($year);
  23. }
  24. if (! sqGetGlobalVar('month',$month,SQ_FORM) || ! is_numeric($month)) {
  25. unset($month);
  26. }
  27. if (! sqGetGlobalVar('day',$day,SQ_FORM) || ! is_numeric($day)) {
  28. unset($day);
  29. }
  30. if (! sqGetGlobalVar('hour',$hour,SQ_FORM) || ! is_numeric($hour)) {
  31. unset($hour);
  32. }
  33. if (! sqGetGlobalVar('event_hour',$event_hour,SQ_POST) || ! is_numeric($event_hour)) {
  34. unset($event_hour);
  35. }
  36. if (! sqGetGlobalVar('event_minute',$event_minute,SQ_POST) || ! is_numeric($event_minute)) {
  37. unset($event_minute);
  38. }
  39. if (! sqGetGlobalVar('event_length',$event_length,SQ_POST) || ! is_numeric($event_length)) {
  40. unset($event_length);
  41. }
  42. if (! sqGetGlobalVar('event_priority',$event_priority,SQ_POST) || ! is_numeric($event_priority)) {
  43. unset($event_priority);
  44. }
  45. sqGetGlobalVar('event_title',$event_title,SQ_POST);
  46. sqGetGlobalVar('event_text',$event_text,SQ_POST);
  47. sqGetGlobalVar('send',$send,SQ_POST);
  48. /* got 'em */
  49. //main form to gather event info
  50. function show_event_form() {
  51. global $color, $editor_size, $year, $day, $month, $hour;
  52. echo "\n<form name=\"eventscreate\" action=\"event_create.php\" method=\"post\">\n".
  53. " <input type=\"hidden\" name=\"year\" value=\"$year\" />\n".
  54. " <input type=\"hidden\" name=\"month\" value=\"$month\" />\n".
  55. " <input type=\"hidden\" name=\"day\" value=\"$day\" />\n".
  56. html_tag( 'tr' ) .
  57. html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
  58. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  59. " <select name=\"event_hour\">\n";
  60. select_option_hour($hour);
  61. echo " </select>\n" .
  62. " &nbsp;:&nbsp;\n" .
  63. " <select name=\"event_minute\">\n";
  64. select_option_minute("00");
  65. echo " </select>\n".
  66. " </td></tr>\n".
  67. html_tag( 'tr' ) .
  68. html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
  69. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  70. " <select name=\"event_length\">\n";
  71. select_option_length("0");
  72. echo " </select>\n".
  73. " </td></tr>\n".
  74. html_tag( 'tr' ) .
  75. html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
  76. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  77. " <select name=\"event_priority\">\n";
  78. select_option_priority("0");
  79. echo " </select>\n".
  80. " </td></tr>\n".
  81. html_tag( 'tr' ) .
  82. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  83. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  84. " <input type=\"text\" name=\"event_title\" value=\"\" size=\"30\" maxlength=\"50\" /><br />\n".
  85. " </td></tr>\n".
  86. html_tag( 'tr',
  87. html_tag( 'td',
  88. "<textarea name=\"event_text\" rows=\"5\" cols=\"$editor_size\"></textarea>" ,
  89. 'left', $color[4], 'colspan="2"' )
  90. ) ."\n" .
  91. html_tag( 'tr',
  92. html_tag( 'td',
  93. '<input type="submit" name="send" value="' .
  94. _("Set Event") . '" />' ,
  95. 'left', $color[4], 'colspan="2"' )
  96. ) ."\n";
  97. echo "</form>\n";
  98. }
  99. if ( !isset($month) || $month <= 0){
  100. $month = date( 'm' );
  101. }
  102. if ( !isset($year) || $year <= 0){
  103. $year = date( 'Y' );
  104. }
  105. if (!isset($day) || $day <= 0){
  106. $day = date( 'd' );
  107. }
  108. if (!isset($hour) || $hour <= 0){
  109. $hour = '08';
  110. }
  111. $calself=basename($PHP_SELF);
  112. displayPageHeader($color);
  113. //load calendar menu
  114. calendar_header();
  115. echo html_tag( 'tr', '', '', $color[0] ) .
  116. html_tag( 'td', '', 'left' ) .
  117. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
  118. html_tag( 'tr',
  119. html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
  120. );
  121. //if form has not been filled in
  122. if(!isset($event_text)){
  123. show_event_form();
  124. } else {
  125. readcalendardata();
  126. $calendardata["$month$day$year"]["$event_hour$event_minute"] =
  127. array( 'length' => $event_length,
  128. 'priority' => $event_priority,
  129. 'title' => $event_title,
  130. 'message' => $event_text,
  131. 'reminder' => '' );
  132. //save
  133. writecalendardata();
  134. echo html_tag( 'table',
  135. html_tag( 'tr',
  136. html_tag( 'th', _("Event Has been added!") . "<br />\n", '', $color[4], 'colspan="2"' )
  137. ) .
  138. html_tag( 'tr',
  139. html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
  140. html_tag( 'td', date_intl(_("m/d/Y"),mktime(0,0,0,$month,$day,$year)), 'left', $color[4] ) . "\n"
  141. ) .
  142. html_tag( 'tr',
  143. html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
  144. html_tag( 'td', date_intl(_("H:i"),mktime($event_hour,$event_minute,0,$month,$day,$year)), 'left', $color[4] ) . "\n"
  145. ) .
  146. html_tag( 'tr',
  147. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  148. html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
  149. ) .
  150. html_tag( 'tr',
  151. html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
  152. html_tag( 'td', nl2br(htmlspecialchars($event_text,ENT_NOQUOTES)), 'left', $color[4] ) . "\n"
  153. ) .
  154. html_tag( 'tr',
  155. html_tag( 'td',
  156. "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
  157. 'left', $color[4], 'colspan="2"' ) . "\n"
  158. ) ,
  159. '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
  160. }
  161. ?>
  162. </table></td></tr></table>
  163. </body></html>