event_edit.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <?php
  2. /**
  3. * event_edit.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 edit an event.
  11. *
  12. * $Id$
  13. * @package plugins
  14. * @subpackage calendar
  15. */
  16. /** @ignore */
  17. define('SM_PATH','../../');
  18. /* Calender plugin required files. */
  19. require_once(SM_PATH . 'plugins/calendar/calendar_data.php');
  20. require_once(SM_PATH . 'plugins/calendar/functions.php');
  21. /* SquirrelMail required files. */
  22. require_once(SM_PATH . 'include/validate.php');
  23. require_once(SM_PATH . 'functions/strings.php');
  24. require_once(SM_PATH . 'functions/date.php');
  25. require_once(SM_PATH . 'config/config.php');
  26. require_once(SM_PATH . 'functions/page_header.php');
  27. require_once(SM_PATH . 'include/load_prefs.php');
  28. require_once(SM_PATH . 'functions/html.php');
  29. /* get globals */
  30. if (isset($_POST['updated'])) {
  31. $updated = $_POST['updated'];
  32. }
  33. if (isset($_POST['event_year'])) {
  34. $event_year = $_POST['event_year'];
  35. }
  36. if (isset($_POST['event_month'])) {
  37. $event_month = $_POST['event_month'];
  38. }
  39. if (isset($_POST['event_day'])) {
  40. $event_day = $_POST['event_day'];
  41. }
  42. if (isset($_POST['event_hour'])) {
  43. $event_hour = $_POST['event_hour'];
  44. }
  45. if (isset($_POST['event_minute'])) {
  46. $event_minute = $_POST['event_minute'];
  47. }
  48. if (isset($_POST['event_length'])) {
  49. $event_length = $_POST['event_length'];
  50. }
  51. if (isset($_POST['event_title'])) {
  52. $event_title = $_POST['event_title'];
  53. }
  54. if (isset($_POST['event_text'])) {
  55. $event_text = $_POST['event_text'];
  56. }
  57. if (isset($_POST['send'])) {
  58. $send = $_POST['send'];
  59. }
  60. if (isset($_POST['event_priority'])) {
  61. $event_priority = $_POST['event_priority'];
  62. }
  63. if (isset($_POST['confirmed'])) {
  64. $confirmed = $_POST['confirmed'];
  65. }
  66. if (isset($_POST['year'])) {
  67. $year = $_POST['year'];
  68. }
  69. elseif (isset($_GET['year'])) {
  70. $year = $_GET['year'];
  71. }
  72. if (isset($_POST['month'])) {
  73. $month = $_POST['month'];
  74. }
  75. elseif (isset($_GET['month'])) {
  76. $month = $_GET['month'];
  77. }
  78. if (isset($_POST['day'])) {
  79. $day = $_POST['day'];
  80. }
  81. elseif (isset($_GET['day'])) {
  82. $day = $_GET['day'];
  83. }
  84. if (isset($_POST['hour'])) {
  85. $hour = $_POST['hour'];
  86. }
  87. elseif (isset($_GET['hour'])) {
  88. $hour = $_GET['hour'];
  89. }
  90. if (isset($_POST['minute'])) {
  91. $minute = $_POST['minute'];
  92. }
  93. elseif (isset($_GET['minute'])) {
  94. $minute = $_GET['minute'];
  95. }
  96. /* got 'em */
  97. // update event info
  98. function update_event_form() {
  99. global $color, $editor_size, $year, $day, $month, $hour, $minute, $calendardata;
  100. $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  101. echo "\n<FORM name=eventupdate action=\"event_edit.php\" METHOD=POST >\n".
  102. " <INPUT TYPE=hidden NAME=\"year\" VALUE=\"$year\">\n".
  103. " <INPUT TYPE=hidden NAME=\"month\" VALUE=\"$month\">\n".
  104. " <INPUT TYPE=hidden NAME=\"day\" VALUE=\"$day\">\n".
  105. " <INPUT TYPE=hidden NAME=\"hour\" VALUE=\"$hour\">\n".
  106. " <INPUT TYPE=hidden NAME=\"minute\" VALUE=\"$minute\">\n".
  107. " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
  108. html_tag( 'tr' ) .
  109. html_tag( 'td', _("Date:"), 'right', $color[4] ) . "\n" .
  110. html_tag( 'td', '', 'left', $color[4] ) .
  111. " <SELECT NAME=\"event_year\">\n";
  112. select_option_year($year);
  113. echo " </SELECT>\n" .
  114. " &nbsp;&nbsp;\n" .
  115. " <SELECT NAME=\"event_month\">\n";
  116. select_option_month($month);
  117. echo " </SELECT>\n".
  118. " &nbsp;&nbsp;\n".
  119. " <SELECT NAME=\"event_day\">\n";
  120. select_option_day($day);
  121. echo " </SELECT>\n".
  122. " </td></tr>\n".
  123. html_tag( 'tr' ) .
  124. html_tag( 'td', _("Time:"), 'right', $color[4] ) . "\n" .
  125. html_tag( 'td', '', 'left', $color[4] ) .
  126. " <SELECT NAME=\"event_hour\">\n";
  127. select_option_hour($hour);
  128. echo " </SELECT>\n".
  129. " &nbsp;:&nbsp;\n".
  130. " <SELECT NAME=\"event_minute\">\n";
  131. select_option_minute($minute);
  132. echo " </SELECT>\n".
  133. " </td></tr>\n".
  134. html_tag( 'tr' ) .
  135. html_tag( 'td', _("Length:"), 'right', $color[4] ) . "\n" .
  136. html_tag( 'td', '', 'left', $color[4] ) .
  137. " <SELECT NAME=\"event_length\">\n";
  138. select_option_length($tmparray['length']);
  139. echo " </SELECT>\n".
  140. " </td></tr>\n".
  141. html_tag( 'tr' ) .
  142. html_tag( 'td', _("Priority:"), 'right', $color[4] ) . "\n" .
  143. html_tag( 'td', '', 'left', $color[4] ) .
  144. " <SELECT NAME=\"event_priority\">\n";
  145. select_option_priority($tmparray['priority']);
  146. echo " </SELECT>\n".
  147. " </td></tr>\n".
  148. html_tag( 'tr' ) .
  149. html_tag( 'td', _("Title:"), 'right', $color[4] ) . "\n" .
  150. html_tag( 'td', '', 'left', $color[4] ) .
  151. " <INPUT TYPE=text NAME=\"event_title\" VALUE=\"$tmparray[title]\" SIZE=30 MAXLENGTH=50><BR>\n".
  152. " </td></tr>\n".
  153. html_tag( 'td',
  154. " <TEXTAREA NAME=\"event_text\" ROWS=5 COLS=\"$editor_size\" WRAP=HARD>$tmparray[message]</TEXTAREA>\n" ,
  155. 'left', $color[4], 'colspan="2"' ) .
  156. '</tr>' . html_tag( 'tr' ) .
  157. html_tag( 'td',
  158. "<INPUT TYPE=SUBMIT NAME=send VALUE=\"" .
  159. _("Update Event") . "\">\n" ,
  160. 'left', $color[4], 'colspan="2"' ) .
  161. "</tr></FORM>\n";
  162. }
  163. // self explenatory
  164. function confirm_update() {
  165. 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;
  166. $tmparray = $calendardata["$month$day$year"]["$hour$minute"];
  167. echo html_tag( 'table',
  168. html_tag( 'tr',
  169. html_tag( 'th', _("Do you really want to change this event from:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
  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', $hour.':'.$minute , 'left', $color[4] ) ."\n"
  178. ) .
  179. html_tag( 'tr',
  180. html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
  181. html_tag( 'td', $tmparray['priority'] , 'left', $color[4] ) ."\n"
  182. ) .
  183. html_tag( 'tr',
  184. html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
  185. html_tag( 'td', $tmparray['title'] , 'left', $color[4] ) ."\n"
  186. ) .
  187. html_tag( 'tr',
  188. html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
  189. html_tag( 'td', $tmparray['message'] , 'left', $color[4] ) ."\n"
  190. ) .
  191. html_tag( 'tr',
  192. html_tag( 'th', _("to:") . "<br>\n", '', $color[4], 'colspan="2"' ) ."\n"
  193. ) .
  194. html_tag( 'tr',
  195. html_tag( 'td', _("Date:") , 'right', $color[4] ) ."\n" .
  196. html_tag( 'td', $event_month.'/'.$event_day.'/'.$event_year , 'left', $color[4] ) ."\n"
  197. ) .
  198. html_tag( 'tr',
  199. html_tag( 'td', _("Time:") , 'right', $color[4] ) ."\n" .
  200. html_tag( 'td', $event_hour.':'.$event_minute , 'left', $color[4] ) ."\n"
  201. ) .
  202. html_tag( 'tr',
  203. html_tag( 'td', _("Priority:") , 'right', $color[4] ) ."\n" .
  204. html_tag( 'td', $event_priority , 'left', $color[4] ) ."\n"
  205. ) .
  206. html_tag( 'tr',
  207. html_tag( 'td', _("Title:") , 'right', $color[4] ) ."\n" .
  208. html_tag( 'td', $event_title , 'left', $color[4] ) ."\n"
  209. ) .
  210. html_tag( 'tr',
  211. html_tag( 'td', _("Message:") , 'right', $color[4] ) ."\n" .
  212. html_tag( 'td', $event_text , 'left', $color[4] ) ."\n"
  213. ) .
  214. html_tag( 'tr',
  215. html_tag( 'td',
  216. " <FORM NAME=\"updateevent\" METHOD=POST ACTION=\"$calself\">\n".
  217. " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
  218. " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
  219. " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
  220. " <INPUT TYPE=HIDDEN NAME=\"hour\" VALUE=\"$hour\">\n".
  221. " <INPUT TYPE=HIDDEN NAME=\"minute\" VALUE=\"$minute\">\n".
  222. " <INPUT TYPE=HIDDEN NAME=\"event_year\" VALUE=\"$event_year\">\n".
  223. " <INPUT TYPE=HIDDEN NAME=\"event_month\" VALUE=\"$event_month\">\n".
  224. " <INPUT TYPE=HIDDEN NAME=\"event_day\" VALUE=\"$event_day\">\n".
  225. " <INPUT TYPE=HIDDEN NAME=\"event_hour\" VALUE=\"$event_hour\">\n".
  226. " <INPUT TYPE=HIDDEN NAME=\"event_minute\" VALUE=\"$event_minute\">\n".
  227. " <INPUT TYPE=HIDDEN NAME=\"event_priority\" VALUE=\"$event_priority\">\n".
  228. " <INPUT TYPE=HIDDEN NAME=\"event_length\" VALUE=\"$event_length\">\n".
  229. " <INPUT TYPE=HIDDEN NAME=\"event_title\" VALUE=\"$event_title\">\n".
  230. " <INPUT TYPE=HIDDEN NAME=\"event_text\" VALUE=\"$event_text\">\n".
  231. " <INPUT TYPE=hidden NAME=\"updated\" VALUE=\"yes\">\n".
  232. " <INPUT TYPE=HIDDEN NAME=\"confirmed\" VALUE=\"yes\">\n".
  233. ' <INPUT TYPE=SUBMIT VALUE="' . _("Yes") . "\">\n".
  234. " </FORM>\n" ,
  235. 'right', $color[4] ) ."\n" .
  236. html_tag( 'td',
  237. " <FORM NAME=\"nodelevent\" METHOD=POST ACTION=\"day.php\">\n".
  238. " <INPUT TYPE=HIDDEN NAME=\"year\" VALUE=\"$year\">\n".
  239. " <INPUT TYPE=HIDDEN NAME=\"month\" VALUE=\"$month\">\n".
  240. " <INPUT TYPE=HIDDEN NAME=\"day\" VALUE=\"$day\">\n".
  241. ' <INPUT TYPE=SUBMIT VALUE="' . _("No") . "\">\n".
  242. " </FORM>\n" ,
  243. 'left', $color[4] ) ."\n"
  244. ) ,
  245. '', $color[0], 'border="0" cellpadding="2" cellspacing="1"' );
  246. }
  247. if ($month <= 0){
  248. $month = date( 'm' );
  249. }
  250. if ($year <= 0){
  251. $year = date( 'Y' );
  252. }
  253. if ($day <= 0){
  254. $day = date( 'd' );
  255. }
  256. if ($hour <= 0){
  257. $hour = '08';
  258. }
  259. $calself=basename($PHP_SELF);
  260. displayPageHeader($color, 'None');
  261. //load calendar menu
  262. calendar_header();
  263. echo html_tag( 'tr', '', '', $color[0] ) .
  264. html_tag( 'td', '', 'left' ) .
  265. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) .
  266. html_tag( 'tr' ) .
  267. html_tag( 'td',
  268. date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
  269. 'left', '', 'colspan="2"' );
  270. if (!isset($updated)){
  271. //get changes to event
  272. readcalendardata();
  273. update_event_form();
  274. } else {
  275. if (!isset($confirmed)){
  276. //confirm changes
  277. readcalendardata();
  278. // strip event text so it fits in one line
  279. $event_text=nl2br($event_text);
  280. $event_text=ereg_replace ("\n", '', $event_text);
  281. $event_text=ereg_replace ("\r", '', $event_text);
  282. confirm_update();
  283. } else {
  284. update_event("$month$day$year", "$hour$minute");
  285. echo html_tag( 'tr',
  286. html_tag( 'td', _("Event updated!"), 'left' )
  287. ) . "\n";
  288. echo html_tag( 'tr',
  289. html_tag( 'td',
  290. "<a href=\"day.php?year=$year&amp;month=$month&amp;day=$day\">" .
  291. _("Day View") ."</a>",
  292. 'left' )
  293. ) . "\n";
  294. $fixdate = date( 'mdY', mktime(0, 0, 0, $event_month, $event_day, $event_year));
  295. //if event has been moved to different year then act accordingly
  296. if ($year==$event_year){
  297. $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
  298. writecalendardata();
  299. } else {
  300. writecalendardata();
  301. $year=$event_year;
  302. $calendardata = array();
  303. readcalendardata();
  304. $calendardata["$fixdate"]["$event_hour$event_minute"] = array("length"=>"$event_length","priority"=>"$event_priority","title"=>"$event_title","message"=>"$event_text");
  305. writecalendardata();
  306. }
  307. }
  308. }
  309. ?>
  310. </table></td></tr></table>
  311. </body></html>