[ Index ] |
|
Code source de WebCalendar 1.0.5 |
1 <?php 2 /* 3 * $Id: view_l.php,v 1.33 2005/03/21 22:16:07 umcesrjones Exp $ 4 * 5 * Page Description: 6 * This page will display the month "view" with all users's events 7 * on the same calendar. (The other month "view" displays each user 8 * calendar in a separate column, side-by-side.) This view gives you 9 * the same effect as enabling layers, but with layers you can only 10 * have one configuration of users. 11 * 12 * Input Parameters: 13 * id (*) - specify view id in webcal_view table 14 * date - specify the starting date of the view. 15 * If not specified, current date will be used. 16 * friendly - if set to 1, then page does not include links or 17 * trailer navigation. 18 * (*) required field 19 * 20 * Security: 21 * Must have "allow view others" enabled ($allow_view_other) in 22 * System Settings unless the user is an admin user ($is_admin). 23 * If the view is not global, the user must be owner of the view. 24 * If the view is global, then and user_sees_only_his_groups is 25 * enabled, then we remove users not in this user's groups 26 * (except for nonuser calendars... which we allow regardless of group). 27 */ 28 29 include_once 'includes/init.php'; 30 31 $error = ""; 32 33 if ( $allow_view_other == "N" && ! $is_admin ) { 34 // not allowed... 35 send_to_preferred_view (); 36 } 37 if ( empty ( $id ) ) { 38 do_redirect ( "views.php" ); 39 } 40 41 // Find view name in $views[] 42 $view_name = ""; 43 for ( $i = 0; $i < count ( $views ); $i++ ) { 44 if ( $views[$i]['cal_view_id'] == $id ) { 45 $view_name = $views[$i]['cal_name']; 46 } 47 } 48 49 // If view_name not found, then the specified view id does not 50 // belong to current user. 51 if ( empty ( $view_name ) ) { 52 $error = translate ( "You are not authorized" ); 53 } 54 55 $INC = array('js/popups.php'); 56 print_header($INC); 57 58 set_today($date); 59 60 $next = mktime ( 3, 0, 0, $thismonth + 1, 1, $thisyear ); 61 $nextyear = date ( "Y", $next ); 62 $nextmonth = date ( "m", $next ); 63 $nextdate = sprintf ( "%04d%02d01", $nextyear, $nextmonth ); 64 65 $prev = mktime ( 3, 0, 0, $thismonth - 1, 1, $thisyear ); 66 $prevyear = date ( "Y", $prev ); 67 $prevmonth = date ( "m", $prev ); 68 $prevdate = sprintf ( "%04d%02d01", $prevyear, $prevmonth ); 69 70 if ( ! empty ( $bold_days_in_year ) && $bold_days_in_year == 'Y' ) { 71 $boldDays = true; 72 $startdate = sprintf ( "%04d%02d01", $prevyear, $prevmonth ); 73 $enddate = sprintf ( "%04d%02d31", $nextyear, $nextmonth ); 74 } else { 75 $boldDays = false; 76 $startdate = sprintf ( "%04d%02d01", $thisyear, $thismonth ); 77 $enddate = sprintf ( "%04d%02d31", $thisyear, $thismonth ); 78 } 79 80 $monthstart = mktime ( 3, 0, 0, $thismonth, 1, $thisyear ); 81 $monthend = mktime ( 3, 0, 0, $thismonth + 1, 0, $thisyear ); 82 83 $thisdate = $startdate; 84 85 // get users in this view 86 $res = dbi_query ( 87 "SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id" ); 88 $viewusers = array (); 89 $all_users = false; 90 if ( $res ) { 91 while ( $row = dbi_fetch_row ( $res ) ) { 92 $viewusers[] = $row[0]; 93 if ( $row[0] == "__all__" ) { 94 $all_users = true; 95 } 96 } 97 dbi_free_result ( $res ); 98 } else { 99 $error = translate ( "Database error" ) . ": " . dbi_error (); 100 } 101 if ( $all_users ) { 102 $viewusers = array (); 103 $users = get_my_users (); 104 for ( $i = 0; $i < count ( $users ); $i++ ) { 105 $viewusers[] = $users[$i]['cal_login']; 106 } 107 } else { 108 // Make sure this user is allowed to see all users in this view 109 // If this is a global view, it may include users that this user 110 // is not allowed to see. 111 if ( ! empty ( $user_sees_only_his_groups ) && 112 $user_sees_only_his_groups == 'Y' ) { 113 $myusers = get_my_users (); 114 if ( ! empty ( $nonuser_enabled ) && $nonuser_enabled == "Y" ) { 115 $myusers = array_merge ( $myusers, get_nonuser_cals () ); 116 } 117 $userlookup = array(); 118 for ( $i = 0; $i < count ( $myusers ); $i++ ) { 119 $userlookup[$myusers[$i]['cal_login']] = 1; 120 } 121 $newlist = array (); 122 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 123 if ( ! empty ( $userlookup[$viewusers[$i]] ) ) { 124 $newlist[] = $viewusers[$i]; 125 } 126 } 127 $viewusers = $newlist; 128 } 129 } 130 if ( count ( $viewusers ) == 0 ) { 131 // This could happen if user_sees_only_his_groups = Y and 132 // this user is not a member of any group assigned to this view 133 $error = translate ( "No users for this view" ); 134 } 135 136 if ( ! empty ( $error ) ) { 137 echo "<h2>" . translate ( "Error" ) . 138 "</h2>\n" . $error; 139 print_trailer (); 140 exit; 141 } 142 143 $e_save = array (); 144 $re_save = array (); 145 for ( $i = 0; $i < count ( $viewusers ); $i++ ) { 146 /* Pre-Load the repeated events for quckier access */ 147 $repeated_events = read_repeated_events ( $viewusers[$i], "", $startdate ); 148 $re_save = array_merge($re_save, $repeated_events); 149 /* Pre-load the non-repeating events for quicker access */ 150 $events = read_events ( $viewusers[$i], $startdate, $enddate ); 151 $e_save = array_merge($e_save, $events); 152 } 153 $events = array (); 154 $repeated_events = array (); 155 156 for ( $i = 0; $i < count ( $e_save ); $i++ ) { 157 $should_add = 1; 158 for ( $j = 0; $j < count ( $events ) && $should_add; $j++ ) { 159 if ( $e_save[$i]['cal_id'] == $events[$j]['cal_id'] ) { 160 $should_add = 0; 161 } 162 } 163 if ( $should_add ) { 164 array_push ( $events, $e_save[$i] ); 165 } 166 } 167 168 for ( $i = 0; $i < count ( $re_save ); $i++ ) { 169 $should_add = 1; 170 for ( $j = 0; $j < count ( $repeated_events ) && $should_add; $j++ ) { 171 if ( $re_save[$i]['cal_id'] == $repeated_events[$j]['cal_id'] ) { 172 $should_add = 0; 173 } 174 } 175 if ( $should_add ) { 176 array_push ( $repeated_events, $re_save[$i] ); 177 } 178 } 179 180 display_small_month ( $prevmonth, $prevyear, true, true, "prevmonth", 181 "view_l.php?id=$id&" ); 182 display_small_month ( $nextmonth, $nextyear, true, true, "nextmonth", 183 "view_l.php?id=$id&" ); 184 ?> 185 186 <div class="title"> 187 <span class="date"><br /><?php 188 echo date_to_str ( sprintf ( "%04d%02d01", $thisyear, $thismonth ), 189 $DATE_FORMAT_MY, false, false ); 190 ?></span> 191 <span class="viewname"><br /><?php echo $view_name; ?></span></div> 192 <br /><br /><br /><br /> 193 194 <table class="main" style="clear:both;" cellspacing="0" cellpadding="0"> 195 <tr> 196 <?php if ( $WEEK_START == 0 ) { ?> 197 <th class="weekend"><?php etranslate("Sun")?></th> 198 <?php } ?> 199 <th><?php etranslate("Mon")?></th> 200 <th><?php etranslate("Tue")?></th> 201 <th><?php etranslate("Wed")?></th> 202 <th><?php etranslate("Thu")?></th> 203 <th><?php etranslate("Fri")?></th> 204 <th class="weekend"><?php etranslate("Sat")?></th> 205 <?php if ( $WEEK_START == 1 ) { ?> 206 <th class="weekend"><?php etranslate("Sun")?></th> 207 <?php } ?> 208 </tr> 209 <?php 210 // We add 2 hours on to the time so that the switch to DST doesn't 211 // throw us off. So, all our dates are 2AM for that day. 212 //$sun = get_sunday_before ( $thisyear, $thismonth, 1 ); 213 if ( $WEEK_START == 1 ) { 214 $wkstart = get_monday_before ( $thisyear, $thismonth, 1 ); 215 } else { 216 $wkstart = get_sunday_before ( $thisyear, $thismonth, 1 ); 217 } 218 // generate values for first day and last day of month 219 $monthstart = mktime ( 3, 0, 0, $thismonth, 1, $thisyear ); 220 $monthend = mktime ( 3, 0, 0, $thismonth + 1, 0, $thisyear ); 221 222 // debugging 223 //echo "<br />sun = " . date ( "D, m-d-Y", $sun ) . "<br />"; 224 //echo "<br />monthstart = " . date ( "D, m-d-Y", $monthstart ) . "<br />"; 225 //echo "<br />monthend = " . date ( "D, m-d-Y", $monthend ) . "<br />"; 226 227 //NOTE: if you make HTML changes to this table, make the same changes 228 //to the example table in pref.php. 229 for ( $i = $wkstart; date ( "Ymd", $i ) <= date ( "Ymd", $monthend ); 230 $i += ( 24 * 3600 * 7 ) ) { 231 print "<tr>\n"; 232 for ( $j = 0; $j < 7; $j++ ) { 233 $date = $i + ( $j * 24 * 3600 ); 234 if ( date ( "Ymd", $date ) >= date ( "Ymd", $monthstart ) && 235 date ( "Ymd", $date ) <= date ( "Ymd", $monthend ) ) { 236 $thiswday = date ( "w", $date ); 237 $is_weekend = ( $thiswday == 0 || $thiswday == 6 ); 238 if ( empty ( $WEEKENDBG ) ) $is_weekend = false; 239 print "<td"; 240 $class = ""; 241 if ( date ( "Ymd", $date ) == date ( "Ymd", $today ) ) { 242 $class = "today"; 243 } 244 if ( $is_weekend ) { 245 if ( strlen ( $class ) ) $class .= " "; 246 $class .= "weekend"; 247 } 248 if ( strlen ( $class ) ) echo " class=\"$class\""; 249 echo ">"; 250 //echo date ( "D, m-d-Y H:i:s", $date ) . "<br />"; 251 print_date_entries ( date ( "Ymd", $date ), 252 ( ! empty ( $user ) ) ? $user : $login, false ); 253 print "</td>\n"; 254 } else { 255 print "<td> </td>\n"; 256 } 257 } 258 print "</tr>\n"; 259 } 260 ?> 261 </table><br /> 262 263 <?php 264 if ( ! empty ( $eventinfo ) ) { 265 echo $eventinfo; 266 } 267 268 display_unapproved_events ( ( $is_assistant || 269 $is_nonuser_admin ? $user : $login ) ); 270 ?> 271 272 <br /> 273 <a title="<?php 274 etranslate("Generate printer-friendly version") 275 ?>" class="printer" href="view_l.php?id=<?php echo $id?>&<?php 276 if ( $thisyear ) { 277 echo "year=$thisyear&month=$thismonth&"; 278 } 279 if ( ! empty ( $user ) ) echo "user=$user&"; 280 if ( ! empty ( $cat_id ) ) echo "cat_id=$cat_id&"; 281 ?>friendly=1" target="cal_printer_friendly" onmouseover="window.status = '<?php 282 etranslate("Generate printer-friendly version")?>'">[<?php 283 etranslate("Printer Friendly")?>]</a> 284 285 <?php print_trailer ();?> 286 </body> 287 </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 |
![]() |