PageRenderTime 51ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/virtuoso-opensource-6.1.5/binsrc/tutorial/hosting/ho_s_30/WebCalendar/day.php

#
PHP | 299 lines | 238 code | 37 blank | 24 comment | 76 complexity | 3707ba00b126f7281730a20175ad1a2a MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0, LGPL-2.0
  1. <?php
  2. #
  3. # This file is part of the OpenLink Software Virtuoso Open-Source (VOS)
  4. # project.
  5. #
  6. # Copyright (C) 1998-2012 OpenLink Software
  7. #
  8. # This project is free software; you can redistribute it and/or modify it
  9. # under the terms of the GNU General Public License as published by the
  10. # Free Software Foundation; only version 2 of the License, dated June 1991.
  11. #
  12. # This program is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. # General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License along
  18. # with this program; if not, write to the Free Software Foundation, Inc.,
  19. # 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  20. #
  21. #
  22. ?>
  23. <?php
  24. include "includes/config.php";
  25. include "includes/php-dbi.php";
  26. include "includes/functions.php";
  27. include "includes/$user_inc";
  28. include "includes/validate.php";
  29. include "includes/connect.php";
  30. send_no_cache_header ();
  31. load_global_settings ();
  32. load_user_preferences ();
  33. load_user_layers ();
  34. load_user_categories ();
  35. if ( empty ( $friendly ) && empty ( $user ) )
  36. remember_this_view ();
  37. include "includes/translate.php";
  38. if ( $allow_view_other != "Y" && ! $is_admin )
  39. $user = "";
  40. $view = "day";
  41. $can_add = ( $readonly == "N" || $is_admin == "Y" );
  42. if ( $public_access == "Y" && $login == "__public__" ) {
  43. if ( $public_access_can_add != "Y" )
  44. $can_add = false;
  45. if ( $public_access_others != "Y" )
  46. $user = ""; // security precaution
  47. }
  48. if ( ! empty ( $user ) ) {
  49. $u_url = "user=$user&";
  50. user_load_variables ( $user, "user_" );
  51. } else {
  52. $u_url = "";
  53. $user_fullname = $fullname;
  54. }
  55. if ( ! empty ( $date ) ) {
  56. $thisyear = substr ( $date, 0, 4 );
  57. $thismonth = substr ( $date, 4, 2 );
  58. $thisday = substr ( $date, 6, 2 );
  59. } else {
  60. if ( empty ( $month ) || $month == 0 )
  61. $thismonth = date("m");
  62. else
  63. $thismonth = $month;
  64. if ( empty ( $year ) || $year == 0 )
  65. $thisyear = date("Y");
  66. else
  67. $thisyear = $year;
  68. if ( empty ( $day ) || $day == 0 )
  69. $thisday = date("d");
  70. else
  71. $thisday = $day;
  72. }
  73. $wday = strftime ( "%w", mktime ( 3, 0, 0, $thismonth, $thisday, $thisyear ) );
  74. $now = mktime ( 3, 0, 0, $thismonth, $thisday, $thisyear );
  75. $nowYmd = date ( "Ymd", $now );
  76. $next = mktime ( 3, 0, 0, $thismonth, $thisday + 1, $thisyear );
  77. $nextYmd = date ( "Ymd", $next );
  78. $nextyear = date ( "Y", $next );
  79. $nextmonth = date ( "m", $next );
  80. $nextday = date ( "d", $next );
  81. $month_ago = date ( "Ymd", mktime ( 3, 0, 0, $thismonth - 1, $thisday, $thisyear ) );
  82. $prev = mktime ( 3, 0, 0, $thismonth, $thisday - 1, $thisyear );
  83. $prevYmd = date ( "Ymd", $prev );
  84. $prevyear = date ( "Y", $prev );
  85. $prevmonth = date ( "m", $prev );
  86. $prevday = date ( "d", $prev );
  87. $month_ahead = date ( "Ymd", mktime ( 3, 0, 0, $thismonth + 1, $thisday, $thisyear ) );
  88. if ( $categories_enabled == "Y" && ( !$user || $user == $login ) ) {
  89. if ( isset ( $cat_id ) ) {
  90. $cat_id = $cat_id;
  91. } elseif ( isset ( $CATEGORY_VIEW ) ) {
  92. $cat_id = $CATEGORY_VIEW;
  93. } else {
  94. $cat_id = '';
  95. }
  96. } else {
  97. $cat_id = '';
  98. }
  99. if ( empty ( $cat_id ) )
  100. $caturl = "";
  101. else
  102. $caturl = "&cat_id=$cat_id";
  103. ?>
  104. <HTML>
  105. <HEAD>
  106. <TITLE><?php etranslate($application_name)?></TITLE>
  107. <?php include "includes/styles.php"; ?>
  108. <?php include "includes/js.php"; ?>
  109. <?php
  110. if ( $auto_refresh == "Y" && ! empty ( $auto_refresh_time ) ) {
  111. $refresh = $auto_refresh_time * 60; // convert to seconds
  112. echo "<META HTTP-EQUIV=\"refresh\" content=\"$refresh; URL=day.php?$u_url" .
  113. "date=$nowYmd$caturl\" TARGET=\"_self\">\n";
  114. }
  115. ?>
  116. </HEAD>
  117. <BODY BGCOLOR=<?php echo "\"$BGCOLOR\"";?> CLASS="defaulttext">
  118. <?php
  119. /* Pre-Load the repeated events for quckier access */
  120. $repeated_events = read_repeated_events ( empty ( $user ) ? $login : $user,
  121. $cat_id );
  122. /* Pre-load the non-repeating events for quicker access */
  123. $events = read_events ( empty ( $user ) ? $login : $user, $nowYmd, $nowYmd,
  124. $cat_id );
  125. ?>
  126. <TABLE BORDER="0" WIDTH="100%">
  127. <TR><TD VALIGN="top" WIDTH="70%"><TR><TD>
  128. <TABLE BORDER="0" WIDTH="100%">
  129. <TR>
  130. <?php if ( empty ( $friendly ) ) { ?>
  131. <TD VALIGN="left"><A HREF="day.php?<?php echo $u_url;?>date=<?php echo $prevYmd . $caturl;?>"><img align="left" src="leftarrow.gif" width="36" height="32" border="0" alt="<?php etranslate("Previous"); ?>"></A></TD>
  132. <?php } ?>
  133. <TD ALIGN="middle"><FONT SIZE="+2" COLOR="<?php echo $H2COLOR;?>"><B>
  134. <?php
  135. echo date_to_str ( $nowYmd );
  136. ?>
  137. </B></FONT>
  138. <FONT SIZE="+1" COLOR="<?php echo $H2COLOR;?>">
  139. <?php
  140. // display current calendar's user (if not in single user)
  141. if ( $single_user == "N" ) {
  142. echo "<BR>";
  143. echo $user_fullname;
  144. }
  145. if ( $is_assistant )
  146. echo "<B><BR>-- " . translate("Assistant mode") . " --</B>";
  147. if ( $categories_enabled == "Y" ) {
  148. echo "<BR>\n<BR>\n";
  149. print_category_menu('day', sprintf ( "%04d%02d%02d",$thisyear, $thismonth, $thisday ), $cat_id, $friendly);
  150. }
  151. ?>
  152. </FONT>
  153. </TD>
  154. <?php if ( empty ( $friendly ) ) { ?>
  155. <TD VALIGN="right"><A HREF="day.php?<?php echo $u_url;?>date=<?php echo $nextYmd . $caturl;?>"><img align="right" src="rightarrow.gif" width="36" height="32" border="0" alt="<?php etranslate("Next"); ?>"></A></TD>
  156. <?php } ?>
  157. </TR>
  158. </TABLE>
  159. <?php if ( empty ( $friendly ) || ! $friendly ) { ?>
  160. <TABLE BORDER="0" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">
  161. <TR><TD BGCOLOR="<?php echo $TABLEBG?>">
  162. <TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="2">
  163. <?php } else { ?>
  164. <TABLE BORDER="1" WIDTH="100%" CELLSPACING="0" CELLPADDING="0">
  165. <?php } ?>
  166. <?php
  167. if ( empty ( $TIME_SLOTS ) )
  168. $TIME_SLOTS = 24;
  169. print_day_at_a_glance ( date ( "Ymd", $now ),
  170. empty ( $user ) ? $login : $user, ! empty ( $friendly ), $can_add );
  171. ?>
  172. <?php if ( empty ( $friendly ) || ! $friendly ) { ?>
  173. </TABLE>
  174. </TD></TR></TABLE>
  175. <?php } else { ?>
  176. </TABLE>
  177. <?php } ?>
  178. </TD>
  179. <TD VALIGN="top">
  180. <?php if ( empty ( $friendly ) ) { ?>
  181. <DIV ALIGN="right">
  182. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="0">
  183. <TR><TD BGCOLOR="<?php echo $TABLEBG?>">
  184. <TABLE BORDER="0" WIDTH="100%" CELLSPACING="1" CELLPADDING="2">
  185. <TR><TH COLSPAN="7" BGCOLOR="<?php echo $THBG?>"><FONT SIZE="+4" COLOR="<?php echo $THFG?>"><?php echo $thisday?></FONT></TH></TR>
  186. <TR>
  187. <TD ALIGN="left" BGCOLOR="<?php echo $THBG?>"><A HREF="day.php?<?php echo $u_url; ?>date=<?php echo $month_ago . $caturl?>" CLASS="monthlink"><img src="leftarrowsmall.gif" width="18" height="18" border="0" ALT="<? etranslate("Previous")?>"></A></TD>
  188. <TH COLSPAN="5" BGCOLOR="<?php echo $THBG?>"><FONT COLOR="<?php echo $THFG?>"><?php echo date_to_str ( sprintf ( "%04d%02d01", $thisyear, $thismonth ), $DATE_FORMAT_MY, false ) ?></FONT></TH>
  189. <TD ALIGN="right" BGCOLOR="<?php echo $THBG?>"><A HREF="day.php?<?php echo $u_url; ?>date=<?php echo $month_ahead . $caturl?>" CLASS="monthlink"><img src="rightarrowsmall.gif" width="18" height="18" border="0" alt="<?php etranslate("Next") ?>"></A></TD>
  190. </TR>
  191. <?php
  192. echo "<TR>";
  193. if ( $WEEK_START == 0 ) echo "<TD BGCOLOR=\"$CELLBG\"><FONT SIZE=\"-3\">" .
  194. weekday_short_name ( 0 ) . "</TD>";
  195. for ( $i = 1; $i < 7; $i++ ) {
  196. echo "<TD BGCOLOR=\"$CELLBG\"><FONT SIZE=\"-3\">" .
  197. weekday_short_name ( $i ) . "</TD>";
  198. }
  199. if ( $WEEK_START == 1 ) echo "<TD BGCOLOR=\"$CELLBG\"><FONT SIZE=\"-3\">" .
  200. weekday_short_name ( 0 ) . "</TD>";
  201. echo "</TR>\n";
  202. // generate values for first day and last day of month
  203. $monthstart = mktime ( 3, 0, 0, $thismonth, 1, $thisyear );
  204. $monthend = mktime ( 3, 0, 0, $thismonth + 1, 0, $thisyear );
  205. if ( $WEEK_START == "1" )
  206. $wkstart = get_monday_before ( $thisyear, $thismonth, 1 );
  207. else
  208. $wkstart = get_sunday_before ( $thisyear, $thismonth, 1 );
  209. $wkend = $wkstart + ( 3600 * 24 * 7 );
  210. for ( $i = $wkstart; date ( "Ymd", $i ) <= date ( "Ymd", $monthend );
  211. $i += ( 24 * 3600 * 7 ) ) {
  212. for ( $i = $wkstart; date ( "Ymd", $i ) <= date ( "Ymd", $monthend );
  213. $i += ( 24 * 3600 * 7 ) ) {
  214. echo "<TR ALIGN=\"center\">\n";
  215. for ( $j = 0; $j < 7; $j++ ) {
  216. $date = $i + ( $j * 24 * 3600 );
  217. if ( date ( "Ymd", $date ) >= date ( "Ymd", $monthstart ) &&
  218. date ( "Ymd", $date ) <= date ( "Ymd", $monthend ) ) {
  219. if ( date ( "Ymd", $date ) == date ( "Ymd", $now ) )
  220. echo "<TD BGCOLOR=\"$TODAYCELLBG\">";
  221. else
  222. echo "<TD BGCOLOR=\"$CELLBG\">";
  223. echo "<FONT SIZE=\"-2\">";
  224. echo "<A HREF=\"day.php?";
  225. echo $u_url;
  226. echo "date=" . date ( "Ymd", $date ) . "$caturl\" CLASS=\"monthlink\">" .
  227. date ( "d", $date ) .
  228. "</A></FONT></TD>\n";
  229. } else {
  230. print "<TD BGCOLOR=\"$CELLBG\">&nbsp;</TD>\n";
  231. }
  232. }
  233. echo "</TR>\n";
  234. }
  235. }
  236. ?>
  237. </TABLE>
  238. </TD></TR></TABLE>
  239. </DIV>
  240. <?php } ?>
  241. </TD></TR></TABLE>
  242. <P>
  243. <?php if ( isset ( $eventinfo ) && empty ( $friendly ) ) echo $eventinfo; ?>
  244. <?php if ( empty ( $friendly ) ) {
  245. display_unapproved_events ( $login );
  246. ?>
  247. <P>
  248. <A HREF="day.php?<?php
  249. echo $u_url;
  250. if ( $thisyear ) {
  251. echo "year=$thisyear&month=$thismonth&day=$thisday&";
  252. }
  253. if ( ! empty ( $cat_id ) ) echo "cat_id=$cat_id&";
  254. ?>friendly=1" TARGET="cal_printer_friendly"
  255. onMouseOver="window.status = '<?php etranslate("Generate printer-friendly version")?>'">[<?php etranslate("Printer Friendly")?>]</A>
  256. <?php include "includes/trailer.php"; ?>
  257. <?php } else {
  258. dbi_close ( $c );
  259. }
  260. ?>
  261. </BODY>
  262. </HTML>