[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 /* 3 * $Id: view_t.php,v 1.38 2005/03/06 23:06:21 umcesrjones Exp $ 4 * 5 * Page Description: 6 * This page will display a timebar for a week or month as 7 * specified by timeb 8 * 9 * Input Parameters: 10 * id (*) - specify view id in webcal_view table 11 * date - specify the starting date of the view. 12 * If not specified, current date will be used. 13 * friendly - if set to 1, then page does not include links or 14 * trailer navigation. 15 * timeb - 1 = week, else month 16 * (*) required field 17 * 18 * Security: 19 * Must have "allow view others" enabled ($allow_view_other) in 20 * System Settings unless the user is an admin user ($is_admin). 21 * If the view is not global, the user must be owner of the view. 22 * If the view is global, then and user_sees_only_his_groups is 23 * enabled, then we remove users not in this user's groups 24 * (except for nonuser calendars... which we allow regardless of group). 25 */ 26 include_once 'includes/init.php'; 27 28 $error = ""; 29 $USERS_PER_TABLE = 6; 30 31 if ( $allow_view_other == "N" && ! $is_admin ) { 32 // not allowed... 33 send_to_preferred_view (); 34 } 35 36 if ( empty ( $id ) ) { 37 do_redirect ( "views.php" ); 38 } 39 40 // Find view name in $views[] 41 $view_name = ""; 42 for ( $i = 0; $i < count ( $views ); $i++ ) { 43 if ( $views[$i]['cal_view_id'] == $id ) { 44 $view_name = $views[$i]['cal_name']; 45 } 46 } 47 48 // If view_name not found, then the specified view id does not 49 // belong to current user. 50 if ( empty ( $view_name ) ) { 51 $error = translate ( "You are not authorized" ); 52 } 53 54 $INC = array('js/popups.php'); 55 print_header($INC); 56 57 // Initialize date to first of current month 58 if ( $timeb == 0 ) { 59 $date = substr($date,0,6)."01"; 60 } 61 62 set_today($date); 63 64 // Week timebar 65 if ( $timeb == 1 ) { 66 $next = mktime ( 3, 0, 0, $thismonth, $thisday + 7, $thisyear ); 67 } else { 68 $next = mktime ( 3, 0, 0, $thismonth + 1, $thisday, $thisyear ); 69 } 70 $nextyear = date ( "Y", $next ); 71 $nextmonth = date ( "m", $next ); 72 $nextday = date ( "d", $next ); 73 $nextdate = sprintf ( "%04d%02d%02d", $nextyear, $nextmonth, $nextday ); 74 75 if ( $timeb == 1 ) { 76 $prev = mktime ( 3, 0, 0, $thismonth, $thisday - 7, $thisyear ); 77 } else { 78 $prev = mktime ( 3, 0, 0, $thismonth - 1, $thisday, $thisyear ); 79 } 80 $prevyear = date ( "Y", $prev ); 81 $prevmonth = date ( "m", $prev ); 82 $prevday = date ( "d", $prev ); 83 $prevdate = sprintf ( "%04d%02d%02d", $prevyear, $prevmonth, $prevday ); 84 85 // We add 2 hours on to the time so that the switch to DST doesn't 86 // throw us off. So, all our dates are 2AM for that day. 87 if ( $timeb == 1 ) { 88 if ( $WEEK_START == 1 ) { 89 $wkstart = get_monday_before ( $thisyear, $thismonth, $thisday ); 90 } else { 91 $wkstart = get_sunday_before ( $thisyear, $thismonth, $thisday ); 92 } 93 } else { 94 $wkstart = mktime ( 3, 0, 0, $thismonth, 1, $thisyear ); 95 } 96 97 if ( $timeb == 1 ) { 98 $wkend = $wkstart + ( 3600 * 24 * 6 ); 99 } else { 100 $wkend = mktime ( 3, 0, 0, $thismonth + 1, 0, $thisyear ); 101 } 102 $startdate = date ( "Ymd", $wkstart ); 103 $enddate = date ( "Ymd", $wkend ); 104 105 $thisdate = $startdate; 106 107 if ( $timeb == 1 ) { 108 $val_boucle = 7; 109 } else { 110 $val_boucle = date("t", $wkstart); 111 } 112 for ( $i = 0; $i < $val_boucle; $i++ ) { 113 $days[$i] = $wkstart + ( 24 * 3600 ) * $i; 114 $weekdays[$i] = weekday_short_name ( ( $i + $WEEK_START ) % $val_boucle ); 115 $header[$i] = $weekdays[$i] . "<br />\n" . 116 month_short_name ( date ( "m", $days[$i] ) - 1 ) . 117 " " . date ( "d", $days[$i] ); 118 } 119 120 // get users in this view 121 $res = dbi_query ( 122 "SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id" ); 123 $viewusers = array (); 124 $all_users = false; 125 if ( $res ) { 126 while ( $row = dbi_fetch_row ( $res ) ) { 127 $viewusers[] = $row[0]; 128 if ( $row[0] == "__all__" ) { 129 $all_users = true; 130 } 131 } 132 dbi_free_result ( $res ); 133 } else { 134 $error = translate ( "Database error" ) . ": " . dbi_error (); 135 } 136 137 if ( $all_users ) { 138 $viewusers = array (); 139 $users = get_my_users (); 140 for ( $i = 0; $i < count ( $users ); $i++ ) { 141 $viewusers[] = $users[$i]['cal_login']; 142 } 143 } else { 144 // Make sure this user is allowed to see all users in this view 145 // If this is a global view, it may include users that this user 146 // is not allowed to see. 147 if ( ! empty ( $user_sees_only_his_groups ) && 148 $user_sees_only_his_groups == 'Y' ) { 149 $myusers = get_my_users (); 150 if ( ! empty ( $nonuser_enabled ) && $nonuser_enabled == "Y" ) { 151 $myusers = array_merge ( $myusers, get_nonuser_cals () ); 152 } 153 $userlookup = array(); 154 for ( $i = 0; $i < count ( $myusers ); $i++ ) { 155 $userlookup[$myusers[$i]['cal_login']] = 1; 156 } 157 $newlist = array (); 158 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 159 if ( ! empty ( $userlookup[$viewusers[$i]] ) ) { 160 $newlist[] = $viewusers[$i]; 161 } 162 } 163 $viewusers = $newlist; 164 } 165 } 166 if ( count ( $viewusers ) == 0 ) { 167 // This could happen if user_sees_only_his_groups = Y and 168 // this user is not a member of any group assigned to this view 169 $error = translate ( "No users for this view" ); 170 } 171 172 if ( ! empty ( $error ) ) { 173 echo "<h2>" . translate ( "Error" ) . 174 "</h2>\n" . $error; 175 print_trailer (); 176 exit; 177 } 178 179 ?> 180 181 <div style="border-width:0px; width:99%;"> 182 <a title="<?php etranslate("Previous")?>" class="prev" href="view_t.php?timeb= 183 <?php echo $timeb?>&id=<?php echo $id?>&date= 184 <?php echo $prevdate?>"><img src="leftarrow.gif" alt=" 185 <?php etranslate("Previous")?>" /></a> 186 187 <a title="<?php etranslate("Next")?>" class="next" href="view_t.php?timeb= 188 <?php echo $timeb?>&id=<?php echo $id?>&date= 189 <?php echo $nextdate?>"><img src="rightarrow.gif" alt=" 190 <?php etranslate("Next")?>" /></a> 191 <div class="title"> 192 <span class="date"><?php 193 echo date_to_str ( date ( "Ymd", $wkstart ), false ) . 194 " - " . 195 date_to_str ( date ( "Ymd", $wkend ), false ); 196 ?></span><br /> 197 <span class="viewname"><?php 198 echo $view_name 199 ?></span> 200 </div> 201 </div><br /><br /> 202 203 <?php 204 // The table has names across the top and dates for rows. Since we need 205 // to spit out an entire row before we can move to the next date, we'll 206 // save up all the HTML for each cell and then print it out when we're 207 // done.. 208 // Additionally, we only want to put at most 6 users in one table since 209 // any more than that doesn't really fit in the page. 210 211 212 $e_save = array (); 213 $re_save = array (); 214 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 215 /* Pre-Load the repeated events for quckier access */ 216 $repeated_events = read_repeated_events ( $viewusers[$i], "", $startdate ); 217 $re_save = array_merge($re_save, $repeated_events); 218 /* Pre-load the non-repeating events for quicker access */ 219 $events = read_events ( $viewusers[$i], $startdate, $enddate ); 220 $e_save = array_merge($e_save, $events); 221 } 222 $events = $e_save; 223 $repeated_events = $re_save; 224 ?> 225 226 <table class="viewt"> 227 <?php 228 for ( $date = $wkstart, $h = 0; 229 date ( "Ymd", $date ) <= date ( "Ymd", $wkend ); 230 $date += ( 24 * 3600 ), $h++ ) { 231 $wday = strftime ( "%w", $date ); 232 $weekday = weekday_short_name ( $wday ); 233 if ( date ( "Ymd", $date ) == date ( "Ymd", $today ) ) { 234 echo "<tr><th class=\"today\">"; 235 } else { 236 echo "<tr><th class=\"row\">"; 237 } 238 if ( empty ( $add_link_in_views ) || $add_link_in_views != "N" ) { 239 echo html_for_add_icon ( date ( "Ymd", $date ), "", "", $user ); 240 } 241 echo $weekday . " " . round ( date ( "d", $date ) ) . "</th>\n"; 242 243 //start the container cell for each day, with its appropriate style 244 if ( date ( "Ymd", $date ) == date ( "Ymd", $today ) ) { 245 echo "<td class=\"today\">"; 246 } else { 247 if ( $wday == 0 || $wday == 6 ) { 248 echo "<td class=\"weekend\">"; 249 } else { 250 echo "<td class=\"reg\">"; 251 } 252 } 253 254 // Default settings 255 if ( ! isset ($prefarray["WORK_DAY_START_HOUR"] ) || 256 ! isset ( $prefarray["WORK_DAY_END_HOUR"] ) ) { 257 $val = dbi_fetch_row ( dbi_query ( "SELECT cal_value FROM webcal_config 258 where cal_setting='WORK_DAY_START_HOUR'" )); 259 $prefarray["WORK_DAY_START_HOUR"]=$val[0]; 260 $val = dbi_fetch_row ( dbi_query ( "SELECT cal_value FROM webcal_config 261 where cal_setting='WORK_DAY_END_HOUR'" )); 262 $prefarray["WORK_DAY_END_HOUR"]=$val[0]; 263 } 264 265 print_header_timebar($prefarray["WORK_DAY_START_HOUR"], 266 $prefarray["WORK_DAY_END_HOUR"]); 267 print_date_entries_timebar ( date ( "Ymd", $date ), $GLOBALS["login"], true ); 268 echo "</td>"; 269 echo "</tr>\n"; 270 } 271 272 echo "</table>\n<br />\n"; 273 274 $user = ""; // reset 275 276 if ( ! empty ( $eventinfo ) ) { 277 echo $eventinfo; 278 } 279 280 echo "<a title=\"" . translate("Generate printer-friendly version") . "\" " . 281 "class=\"printer\" href=\"view_t.php?timeb=$timeb&id=$id&date=" . 282 "$thisdate&friendly=1\" target=\"cal_printer_friendly\" " . 283 "onmouseover=\"window.status='" . 284 translate("Generate printer-friendly version") . 285 "'\">[" . translate("Printer Friendly") . "]</a>\n"; 286 287 print_trailer (); 288 ?> 289 </body> 290 </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 |
![]() |