day.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. /**
  3. * day.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. * Displays the day page (day view).
  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($_GET['year'])) {
  31. $year = $_GET['year'];
  32. }
  33. elseif (isset($_POST['year'])) {
  34. $year = $_POST['year'];
  35. }
  36. if (isset($_GET['month'])) {
  37. $month = $_GET['month'];
  38. }
  39. elseif (isset($_POST['month'])) {
  40. $month = $_POST['month'];
  41. }
  42. if (isset($_GET['day'])) {
  43. $day = $_GET['day'];
  44. }
  45. elseif (isset($_POST['day'])) {
  46. $day = $_POST['day'];
  47. }
  48. /* got 'em */
  49. //displays head of day calendar view
  50. function day_header() {
  51. global $color, $month, $day, $year, $prev_year, $prev_month, $prev_day,
  52. $prev_date, $next_month, $next_day, $next_year, $next_date;
  53. echo html_tag( 'tr', '', '', $color[0] ) . "\n".
  54. html_tag( 'td', '', 'left' ) .
  55. html_tag( 'table', '', '', $color[0], 'width="100%" border="0" cellpadding="2" cellspacing="1"' ) ."\n" .
  56. html_tag( 'tr',
  57. html_tag( 'th',
  58. "<a href=\"day.php?year=$prev_year&amp;month=$prev_month&amp;day=$prev_day\">&lt;&nbsp;".
  59. date_intl('D',$prev_date)."</a>",
  60. 'left' ) .
  61. html_tag( 'th', date_intl( _("l, F j Y"), mktime(0, 0, 0, $month, $day, $year)) ,
  62. '', '', 'width="75%"' ) .
  63. html_tag( 'th',
  64. "<a href=\"day.php?year=$next_year&amp;month=$next_month&amp;day=$next_day\">".
  65. date_intl('D',$next_date)."&nbsp;&gt;</a>" ,
  66. 'right' )
  67. );
  68. }
  69. //events for specific day are inserted into "daily" array
  70. function initialize_events() {
  71. global $daily_events, $calendardata, $month, $day, $year;
  72. for ($i=7;$i<23;$i++){
  73. if ($i<10){
  74. $evntime = '0' . $i . '00';
  75. } else {
  76. $evntime = $i . '00';
  77. }
  78. $daily_events[$evntime] = 'empty';
  79. }
  80. $cdate = $month . $day . $year;
  81. if (isset($calendardata[$cdate])){
  82. while ( $calfoo = each($calendardata[$cdate])){
  83. $daily_events["$calfoo[key]"] = $calendardata[$cdate][$calfoo['key']];
  84. }
  85. }
  86. }
  87. //main loop for displaying daily events
  88. function display_events() {
  89. global $daily_events, $month, $day, $year, $color;
  90. ksort($daily_events,SORT_STRING);
  91. $eo=0;
  92. while ($calfoo = each($daily_events)){
  93. if ($eo==0){
  94. $eo=4;
  95. } else {
  96. $eo=0;
  97. }
  98. $ehour = substr($calfoo['key'],0,2);
  99. $eminute = substr($calfoo['key'],2,2);
  100. if (!is_array($calfoo['value'])){
  101. echo html_tag( 'tr',
  102. html_tag( 'td', $ehour . ':' . $eminute, 'left' ) .
  103. html_tag( 'td', '&nbsp;', 'left' ) .
  104. html_tag( 'td',
  105. "<font size=\"-1\"><a href=\"event_create.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."\">".
  106. _("ADD") . "</a></font>" ,
  107. 'center' ) ,
  108. '', $color[$eo]);
  109. } else {
  110. $calbar=$calfoo['value'];
  111. if ($calbar['length']!=0){
  112. $elength = '-'.date('H:i',mktime($ehour,$eminute+$calbar['length'],0,1,1,0));
  113. } else {
  114. $elength='';
  115. }
  116. echo html_tag( 'tr', '', '', $color[$eo] ) .
  117. html_tag( 'td', $ehour . ':' . $eminute . $elength, 'left' ) .
  118. html_tag( 'td', '', 'left' ) . '[';
  119. echo ($calbar['priority']==1) ? "<font color=\"$color[1]\">$calbar[title]</font>" : "$calbar[title]";
  120. echo"] $calbar[message]&nbsp;" .
  121. html_tag( 'td',
  122. "<font size=\"-1\"><nobr>\n" .
  123. "<a href=\"event_edit.php?year=$year&amp;month=$month&amp;day=$day&amp;hour=".substr($calfoo['key'],0,2)."&amp;minute=".substr($calfoo['key'],2,2)."\">".
  124. _("EDIT") . "</a>&nbsp;|&nbsp;\n" .
  125. "<a href=\"event_delete.php?dyear=$year&amp;dmonth=$month&amp;dday=$day&amp;dhour=".substr($calfoo['key'],0,2)."&amp;dminute=".substr($calfoo['key'],2,2)."&amp;year=$year&amp;month=$month&amp;day=$day\">" .
  126. _("DEL") . '</a>' .
  127. "</nobr></font>\n" ,
  128. 'center' );
  129. }
  130. }
  131. }
  132. if ($month <= 0){
  133. $month = date( 'm');
  134. }
  135. if ($year <= 0){
  136. $year = date( 'Y');
  137. }
  138. if ($day <= 0){
  139. $day = date( 'd');
  140. }
  141. $prev_date = mktime(0, 0, 0, $month , $day - 1, $year);
  142. $next_date = mktime(0, 0, 0, $month , $day + 1, $year);
  143. $prev_day = date ('d',$prev_date);
  144. $prev_month = date ('m',$prev_date);
  145. $prev_year = date ('Y',$prev_date);
  146. $next_day = date ('d',$next_date);
  147. $next_month = date ('m',$next_date);
  148. $next_year = date ('Y',$next_date);
  149. $calself=basename($PHP_SELF);
  150. $daily_events = array();
  151. displayPageHeader($color, 'None');
  152. calendar_header();
  153. readcalendardata();
  154. day_header();
  155. initialize_events();
  156. display_events();
  157. ?>
  158. </table></td></tr></table>
  159. </body></html>