event_create.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <?php
  2. /**
  3. * event_create.php
  4. *
  5. * Copyright (c) 2002-2004 The SquirrelMail Project Team
  6. * Licensed under the GNU GPL. For full terms see the file COPYING.
  7. *
  8. * Originally contrubuted by Michal Szczotka <michal@tuxy.org>
  9. *
  10. * functions to create a event for calendar.
  11. *
  12. * $Id$
  13. * @package plugins
  14. * @subpackage calendar
  15. */
  16. /**
  17. * @ignore
  18. */
  19. define('SM_PATH','../../');
  20. /* Calender plugin required files. */
  21. require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
  22. require_once(SM_PATH . 'plugins/calendar/functions.php');
  23. /* SquirrelMail required files. */
  24. require_once(SM_PATH . 'include/validate.php');
  25. require_once(SM_PATH . 'functions/strings.php');
  26. require_once(SM_PATH . 'functions/date.php');
  27. require_once(SM_PATH . 'config/config.php');
  28. require_once(SM_PATH . 'functions/page_header.php');
  29. require_once(SM_PATH . 'include/load_prefs.php');
  30. require_once(SM_PATH . 'functions/html.php');
  31. /* get globals */
  32. if (isset($_POST['year'])) {
  33. $year = $_POST['year'];
  34. }
  35. elseif (isset($_GET['year'])) {
  36. $year = $_GET['year'];
  37. }
  38. if (isset($_POST['month'])) {
  39. $month = $_POST['month'];
  40. }
  41. elseif (isset($_GET['month'])) {
  42. $month = $_GET['month'];
  43. }
  44. if (isset($_POST['day'])) {
  45. $day = $_POST['day'];
  46. }
  47. elseif (isset($_GET['day'])) {
  48. $day = $_GET['day'];
  49. }
  50. if (isset($_POST['hour'])) {
  51. $hour = $_POST['hour'];
  52. }
  53. elseif (isset($_GET['hour'])) {
  54. $hour = $_GET['hour'];
  55. }
  56. if (isset($_POST['event_hour'])) {
  57. $event_hour = $_POST['event_hour'];
  58. }
  59. if (isset($_POST['event_minute'])) {
  60. $event_minute = $_POST['event_minute'];
  61. }
  62. if (isset($_POST['event_length'])) {
  63. $event_length = $_POST['event_length'];
  64. }
  65. if (isset($_POST['event_priority'])) {
  66. $event_priority = $_POST['event_priority'];
  67. }
  68. if (isset($_POST['event_title'])) {
  69. $event_title = $_POST['event_title'];
  70. }
  71. if (isset($_POST['event_text'])) {
  72. $event_text = $_POST['event_text'];
  73. }
  74. if (isset($_POST['send'])) {
  75. $send = $_POST['send'];
  76. }
  77. /* got 'em */
  78. //main form to gather event info
  79. function show_event_form() {
  80. global $color, $editor_size, $year, $day, $month, $hour;
  81. echo "\n<FORM name=eventscreate action=\"event_create.php\" METHOD=POST >\n".
  82. " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
  83. " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
  84. " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
  85. html_tag( 'tr' ) .
  86. html_tag( 'td', _("Start time:"), 'right', $color[4] ) . "\n" .
  87. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  88. " <SELECT NAME=\"event_hour\">\n";
  89. select_option_hour($hour);
  90. echo " </SELECT>\n" .
  91. " &nbsp;:&nbsp;\n" .
  92. " <SELECT NAME=\"event_minute\">\n";
  93. select_option_minute("00");
  94. echo " </SELECT>\n".
  95. " </td></tr>\n".
  96. html_tag( 'tr' ) .
  97. html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
  98. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  99. " <SELECT NAME=\"event_length\">\n";
  100. select_option_length("0");
  101. echo " </SELECT>\n".
  102. " </td></tr>\n".
  103. html_tag( 'tr' ) .
  104. html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
  105. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  106. " <SELECT NAME=\"event_priority\">\n";
  107. select_option_priority("0");
  108. echo " </SELECT>\n".
  109. " </td></tr>\n".
  110. html_tag( 'tr' ) .
  111. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  112. html_tag( 'td', '', 'left', $color[4] ) . "\n" .
  113. " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"\" SIZE=30 MAXLENGTH=50><BR>\n".
  114. " </td></tr>\n".
  115. html_tag( 'tr',
  116. html_tag( 'td',
  117. "<TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD></TEXTAREA>" ,
  118. 'left', $color[4], 'colspan="2"' )
  119. ) ."\n" .
  120. html_tag( 'tr',
  121. html_tag( 'td',
  122. "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
  123. _("Set Event") . "\">" ,
  124. 'left', $color[4], 'colspan="2"' )
  125. ) ."\n";
  126. echo "</FORM>\n";
  127. }
  128. if ( !isset($month) || $month <= 0){
  129. $month = date( 'm' );
  130. }
  131. if ( !isset($year) || $year <= 0){
  132. $year = date( 'Y' );
  133. }
  134. if (!isset($day) || $day <= 0){
  135. $day = date( 'd' );
  136. }
  137. if (!isset($hour) || $hour <= 0){
  138. $hour = '08';
  139. }
  140. $calself=basename($PHP_SELF);
  141. displayPageHeader($color, 'None');
  142. //load calendar menu
  143. calendar_header();
  144. echo html_tag( 'tr', '', '', $color[0] ) .
  145. html_tag( 'td', '', 'left' ) .
  146. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
  147. html_tag( 'tr',
  148. html_tag( 'td', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)), 'left', '', 'colspan="2"' )
  149. );
  150. //if form has not been filled in
  151. if(!isset($event_text)){
  152. show_event_form();
  153. } else {
  154. readcalendardata();
  155. //make sure that event text is fittting in one line
  156. $event_text=nl2br($event_text);
  157. $event_text=ereg_replace ("\n", "", $event_text);
  158. $event_text=ereg_replace ("\r", "", $event_text);
  159. $calendardata["$month$day$year"]["$event_hour$event_minute"] =
  160. array( 'length' => $event_length,
  161. 'priority' => $event_priority,
  162. 'title' => $event_title,
  163. 'message' => $event_text,
  164. 'reminder' => '' );
  165. //save
  166. writecalendardata();
  167. echo html_tag( 'table',
  168. html_tag( 'tr',
  169. html_tag( 'th', _("Event Has been added!") . "<br>\n", '', $color[4], 'colspan="2"' )
  170. ) .
  171. html_tag( 'tr',
  172. html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
  173. html_tag( 'td', $month .'/'.$day.'/'.$year, 'left', $color[4] ) . "\n"
  174. ) .
  175. html_tag( 'tr',
  176. html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
  177. html_tag( 'td', $event_hour.':'.$event_minute, 'left', $color[4] ) . "\n"
  178. ) .
  179. html_tag( 'tr',
  180. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  181. html_tag( 'td', htmlspecialchars($event_title,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
  182. ) .
  183. html_tag( 'tr',
  184. html_tag( 'td', _("Message:"), 'right', $color[4] ) . "\n" .
  185. html_tag( 'td', htmlspecialchars($event_text,ENT_NOQUOTES), 'left', $color[4] ) . "\n"
  186. ) .
  187. html_tag( 'tr',
  188. html_tag( 'td',
  189. "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" . _("Day View") . "</a>\n" ,
  190. 'left', $color[4], 'colspan="2"' ) . "\n"
  191. ) ,
  192. '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n";
  193. }
  194. ?>
  195. </table></td></tr></table>
  196. </body></html>