[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 /* 3 * $Id: view_m.php,v 1.41 2005/03/06 23:26:35 umcesrjones Exp $ 4 * 5 * Page Description: 6 * Display a month view with users side by side. 7 * 8 * Input Parameters: 9 * id (*) - specify view id in webcal_view table 10 * date - specify the starting date of the view. 11 * If not specified, current date will be used. 12 * friendly - if set to 1, then page does not include links or 13 * trailer navigation. 14 * (*) required field 15 * 16 * Security: 17 * Must have "allow view others" enabled ($allow_view_other) in 18 * System Settings unless the user is an admin user ($is_admin). 19 * If the view is not global, the user must be owner of the view. 20 * If the view is global, then and user_sees_only_his_groups is 21 * enabled, then we remove users not in this user's groups 22 * (except for nonuser calendars... which we allow regardless of group). 23 */ 24 include_once 'includes/init.php'; 25 26 $error = ""; 27 28 $USERS_PER_TABLE = 6; 29 30 if ( $allow_view_other == "N" && ! $is_admin ) { 31 // not allowed... 32 send_to_preferred_view (); 33 } 34 35 if ( empty ( $id ) ) { 36 do_redirect ( "views.php" ); 37 } 38 39 // Find view name in $views[] 40 $view_name = ""; 41 for ( $i = 0; $i < count ( $views ); $i++ ) { 42 if ( $views[$i]['cal_view_id'] == $id ) { 43 $view_name = $views[$i]['cal_name']; 44 } 45 } 46 47 // If view_name not found, then the specified view id does not 48 // belong to current user. 49 if ( $view_name == "" ) { 50 $error = translate ( "You are not authorized" ); 51 } 52 53 $INC = array('js/popups.php'); 54 print_header($INC); 55 56 set_today($date); 57 58 $next = mktime ( 3, 0, 0, $thismonth + 1, 1, $thisyear ); 59 $nextyear = date ( "Y", $next ); 60 $nextmonth = date ( "m", $next ); 61 $nextdate = sprintf ( "%04d%02d01", $nextyear, $nextmonth ); 62 63 $prev = mktime ( 3, 0, 0, $thismonth - 1, 1, $thisyear ); 64 $prevyear = date ( "Y", $prev ); 65 $prevmonth = date ( "m", $prev ); 66 $prevdate = sprintf ( "%04d%02d01", $prevyear, $prevmonth ); 67 68 $startdate = sprintf ( "%04d%02d01", $thisyear, $thismonth ); 69 $enddate = sprintf ( "%04d%02d31", $thisyear, $thismonth ); 70 $monthstart = mktime ( 3, 0, 0, $thismonth, 1, $thisyear ); 71 $monthend = mktime ( 3, 0, 0, $thismonth + 1, 0, $thisyear ); 72 $thisdate = $startdate; 73 ?> 74 75 <div style="border-width:0px; width:99%;"> 76 <a title="<?php etranslate("Previous")?>" class="prev" href="view_m.php?id=<?php echo $id?>&date=<?php echo $prevdate?>"><img src="leftarrow.gif" alt="<?php etranslate("Previous")?>" /></a> 77 <a title="<?php etranslate("Next")?>" class="next" href="view_m.php?id=<?php echo $id?>&date=<?php echo $nextdate?>"><img src="rightarrow.gif" alt="<?php etranslate("Next")?>" /></a> 78 <div class="title"> 79 <span class="date"><?php 80 printf ( "%s %d", month_name ( $thismonth - 1 ), $thisyear ); 81 ?></span><br /> 82 <span class="viewname"><?php echo $view_name ?></span> 83 </div> 84 </div><br /> 85 86 <?php 87 // The table has names across the top and dates for rows. Since we need 88 // to spit out an entire row before we can move to the next date, we'll 89 // save up all the HTML for each cell and then print it out when we're 90 // done.... 91 // Additionally, we only want to put at most 6 users in one table since 92 // any more than that doesn't really fit in the page. 93 94 // get users in this view 95 $res = dbi_query ( 96 "SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id" ); 97 $viewusers = array (); 98 $all_users = false; 99 if ( $res ) { 100 while ( $row = dbi_fetch_row ( $res ) ) { 101 $viewusers[] = $row[0]; 102 if ( $row[0] == "__all__" ) { 103 $all_users = true; 104 } 105 } 106 dbi_free_result ( $res ); 107 } else { 108 $error = translate ( "Database error" ) . ": " . dbi_error (); 109 } 110 111 if ( $all_users ) { 112 $viewusers = array (); 113 $users = get_my_users (); 114 for ( $i = 0; $i < count ( $users ); $i++ ) { 115 $viewusers[] = $users[$i]['cal_login']; 116 } 117 } else { 118 // Make sure this user is allowed to see all users in this view 119 // If this is a global view, it may include users that this user 120 // is not allowed to see. 121 if ( ! empty ( $user_sees_only_his_groups ) && 122 $user_sees_only_his_groups == 'Y' ) { 123 $myusers = get_my_users (); 124 if ( ! empty ( $nonuser_enabled ) && $nonuser_enabled == "Y" ) { 125 $myusers = array_merge ( $myusers, get_nonuser_cals () ); 126 } 127 $userlookup = array(); 128 for ( $i = 0; $i < count ( $myusers ); $i++ ) { 129 $userlookup[$myusers[$i]['cal_login']] = 1; 130 } 131 $newlist = array (); 132 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 133 if ( ! empty ( $userlookup[$viewusers[$i]] ) ) { 134 $newlist[] = $viewusers[$i]; 135 } 136 } 137 $viewusers = $newlist; 138 } 139 } 140 if ( count ( $viewusers ) == 0 ) { 141 // This could happen if user_sees_only_his_groups = Y and 142 // this user is not a member of any group assigned to this view 143 $error = translate ( "No users for this view" ); 144 } 145 146 if ( ! empty ( $error ) ) { 147 echo "<h2>" . translate ( "Error" ) . 148 "</h2>\n" . $error; 149 print_trailer (); 150 exit; 151 } 152 153 $e_save = array (); 154 $re_save = array (); 155 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 156 /* Pre-Load the repeated events for quckier access */ 157 $repeated_events = read_repeated_events ( $viewusers[$i], "", $startdate ); 158 $re_save[$i] = $repeated_events; 159 /* Pre-load the non-repeating events for quicker access */ 160 $events = read_events ( $viewusers[$i], $startdate, $enddate ); 161 $e_save[$i] = $events; 162 } 163 164 for ( $j = 0; $j < count ($viewusers); $j += $USERS_PER_TABLE ) { 165 // since print_date_entries is rather stupid, we can swap the event data 166 // around for users by changing what $events points to. 167 168 // Calculate width of columns in this table. 169 $num_left = count ($viewusers) - $j; 170 if ($num_left > $USERS_PER_TABLE) { 171 $num_left = $USERS_PER_TABLE; 172 } 173 if ($num_left > 0) { 174 if ($num_left < $USERS_PER_TABLE) { 175 $tdw = (int) (90 / $num_left); 176 } else { 177 $tdw = (int) (90 / $USERS_PER_TABLE); 178 } 179 } else { 180 $tdw = 5; 181 } 182 ?> 183 <br /><br /> 184 185 <table class="main" cellspacing="0" cellpadding="0"> 186 <tr><th class="empty"> </th> 187 <?php 188 // $j points to start of this table/row 189 // $k is counter starting at 0 190 // $i starts at table start and goes until end of this table/row. 191 for ( $i = $j, $k = 0; 192 $i < count ($viewusers) && $k < $USERS_PER_TABLE; $i++, $k++ ) { 193 $user = $viewusers[$i]; 194 user_load_variables ($user, "temp"); 195 echo "<th style=\"width:$tdw%;\">$tempfullname</th>\n"; 196 } //end for 197 echo "</tr>\n"; 198 199 for ( $date = $monthstart; date ("Ymd", $date) <= date ("Ymd", $monthend); 200 $date += (24 * 3600), $wday++ ) { 201 $wday = strftime ("%w", $date); 202 $weekday = weekday_short_name ($wday); 203 echo "<tr><th"; 204 if ( date ("Ymd", $date) == date ("Ymd", $today) ) { 205 echo " class=\"today\">"; 206 } else { 207 if ($wday == 0 || $wday == 6) { 208 echo " class=\"weekend\">"; 209 } else { 210 echo " class=\"row\">"; 211 } 212 } 213 //non-breaking space below keeps event from wrapping prematurely 214 echo $weekday . " " . 215 round ( date ("d", $date) ) . "</th>\n"; 216 for ( $i = $j, $k = 0; 217 $i < count ($viewusers) && $k < $USERS_PER_TABLE; $i++, $k++ ) { 218 $user = $viewusers[$i]; 219 $events = $e_save[$i]; 220 $repeated_events = $re_save[$i]; 221 if ( date ("Ymd", $date) == date ("Ymd", $today) ) { 222 echo "<td class=\"today\""; 223 } else { 224 if ($wday == 0 || $wday == 6) { 225 echo "<td class=\"weekend\""; 226 } else { 227 echo "<td"; 228 } 229 } 230 echo " style=\"width:$tdw%;\">"; 231 //echo date ( "D, m-d-Y H:i:s", $date ) . "<br />"; 232 if ( empty ($add_link_in_views) || $add_link_in_views != "N" ) { 233 echo html_for_add_icon ( date ("Ymd", $date), "", "", $user ); 234 } 235 print_date_entries ( date ("Ymd", $date), $user, true ); 236 echo "</td>"; 237 } //end for 238 echo "</tr>\n"; 239 } 240 241 echo "</table>\n<br /><br />\n"; 242 } 243 244 $user = ""; // reset 245 246 if ( ! empty ( $eventinfo ) ) { 247 echo $eventinfo; 248 } 249 250 echo "<a title=\"" . 251 translate("Generate printer-friendly version") . "\" class=\"printer\" " . 252 "href=\"view_m.php?id=$id&date=$thisdate&friendly=1\" " . 253 "target=\"cal_printer_friendly\" onmouseover=\"window.status='" . 254 translate("Generate printer-friendly version") . "'\">[" . 255 translate("Printer Friendly") . "]</a>\n"; 256 257 print_trailer (); ?> 258 </body> 259 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Nov 30 19:09:19 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |