4 * Display a timebar view of a single day.
7 * id (*) - specify view id in webcal_view table
8 * date - specify the starting date of the view.
9 * If not specified, current date will be used.
10 * friendly - if set to 1, then page does not include links or
15 * Must have "allow view others" enabled ($allow_view_other) in
16 * System Settings unless the user is an admin user ($is_admin).
17 * If the view is not global, the user must be owner of the view.
18 * If the view is global, then and user_sees_only_his_groups is
19 * enabled, then we remove users not in this user's groups
20 * (except for nonuser calendars... which we allow regardless of group).
22 //$start = microtime();
24 include_once $gfplugins.'webcalendar/www/includes/init.php';
27 // Don't allow users to use this feature if "allow view others" is
29 if ( $allow_view_other == "N" && ! $is_admin ) {
31 send_to_preferred_view ();
34 if ( empty ( $id ) ) {
35 do_redirect ( "views.php" );
38 // Find view name in $views[]
40 for ( $i = 0; $i < count ( $views ); $i++ ) {
41 if ( $views[$i]['cal_view_id'] == $id ) {
42 $view_name = $views[$i]['cal_name'];
46 // If view_name not found, then the specified view id does not
47 // belong to current user.
48 if ( empty( $view_name ) ) {
49 $error = translate ( "You are not authorized" );
52 $INC = array ( 'js/view_d.php' );
53 print_header ( $INC );
55 // get users in this view
57 "SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id" );
58 $participants = array ();
61 while ( $row = dbi_fetch_row ( $res ) ) {
62 $participants[] = $row[0];
63 if ( $row[0] == "__all__" )
66 dbi_free_result ( $res );
68 $error = translate ( "Database error" ) . ": " . dbi_error ();
72 $participants = array ();
73 $users = get_my_users ();
74 for ( $i = 0; $i < count ( $users ); $i++ ) {
75 $participants[] = $users[$i]['cal_login'];
78 // Make sure this user is allowed to see all users in this view
79 // If this is a global view, it may include users that this user
80 // is not allowed to see.
81 if ( ! empty ( $user_sees_only_his_groups ) &&
82 $user_sees_only_his_groups == 'Y' ) {
83 $myusers = get_my_users ();
84 if ( ! empty ( $nonuser_enabled ) && $nonuser_enabled == "Y" ) {
85 $myusers = array_merge ( $myusers, get_nonuser_cals () );
87 $userlookup = array ();
88 for ( $i = 0; $i < count ( $myusers ); $i++ ) {
89 $userlookup[$myusers[$i]['cal_login']] = 1;
92 for ( $i = 0; $i < count ( $participants ); $i++ ) {
93 if ( ! empty ( $userlookup[$participants[$i]] ) )
94 $newlist[] = $participants[$i];
96 $participants = $newlist;
99 if ( count ( $participants ) == 0 ) {
100 // This could happen if user_sees_only_his_groups = Y and
101 // this user is not a member of any group assigned to this view
102 $error = translate ( "No users for this view" );
105 if ( ! empty ( $error ) ) {
106 echo "<h2>" . translate ( "Error" ) .
117 $wday = strftime ( "%w", mktime ( 2, 0, 0, $thismonth, $thisday, $thisyear ) );
118 $now = mktime ( 2, 0, 0, $thismonth, $thisday, $thisyear );
119 $nowYmd = date ( "Ymd", $now );
121 $next = mktime ( 2, 0, 0, $thismonth, $thisday + 1, $thisyear );
122 $nextyear = date ( "Y", $next );
123 $nextmonth = date ( "m", $next );
124 $nextday = date ( "d", $next );
125 $nextdate = sprintf ( "%04d%02d%02d", $nextyear, $nextmonth, $nextday );
127 $prev = mktime ( 2, 0, 0, $thismonth, $thisday - 1, $thisyear );
128 $prevyear = date ( "Y", $prev );
129 $prevmonth = date ( "m", $prev );
130 $prevday = date ( "d", $prev );
131 $prevdate = sprintf ( "%04d%02d%02d", $prevyear, $prevmonth, $prevday );
133 $thisdate = sprintf ( "%04d%02d%02d", $thisyear, $thismonth, $thisday );
136 <div style="border-width:0px; width:99%;">
137 <a title="<?php etranslate("Previous")?>" class="prev" href="view_d.php?id=
138 <?php echo $id . "&date=" . $prevdate?>"><img src="leftarrow.gif"
139 class="prevnext" alt="<?php etranslate("Previous")?>" /></a>
141 <a title="<?php etranslate("Next")?>" class="next" href="view_d.php?id=
142 <?php echo $id . "&date=" . $nextdate?>"><img src="rightarrow.gif"
143 class="prevnext" alt="<?php etranslate("Next")?>" /></a>
145 <span class="date"><?php
146 printf ( "%s, %s %d, %d", weekday_name ( $wday ),
147 month_name ( $thismonth - 1 ), $thisday, $thisyear );
149 <span class="viewname"><?php echo $view_name; ?></span>
153 daily_matrix($date,$participants);
157 <!-- Hidden form for booking events -->
158 <form action="edit_entry.php" method="post" name="schedule">
159 <input type="hidden" name="date" value="
160 <?php echo $thisyear.$thismonth.$thisday;?>" />
161 <input type="hidden" name="defusers" value="
162 <?php echo implode ( ",", $participants ); ?>" />
163 <input type="hidden" name="hour" value="" />
164 <input type="hidden" name="minute" value="" />
168 echo "<br /><a title=\"" . translate ( "Generate printer-friendly version" ) .
169 "\" class=\"printer\" href=\"view_d.php?id=$id&";
170 echo ( empty ( $u_url ) ? '' : $u_url ) . "date=$nowYmd";
171 echo ( empty ( $caturl ) ? '' : $caturl );
172 echo "&friendly=1\" target=\"cal_printer_friendly\" " .
173 "onmouseover=\"window.status='" .
174 translate ( "Generate printer-friendly version" ) .
175 "'\">[" . translate ( "Printer Friendly" ) . "]</a>";