C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs\webcalendar\view_m.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/*
 * $Id: view_m.php,v 1.41 2005/03/06 23:26:35 umcesrjones Exp $
 *
 * Page Description:
 * Display a month view with users side by side.
 *
 * Input Parameters:
 * id (*) - specify view id in webcal_view table
 * date - specify the starting date of the view.
 *   If not specified, current date will be used.
 * friendly - if set to 1, then page does not include links or
 *   trailer navigation.
 * (*) required field
 *
 * Security:
 * Must have "allow view others" enabled ($allow_view_other) in
 *   System Settings unless the user is an admin user ($is_admin).
 * If the view is not global, the user must be owner of the view.
 * If the view is global, then and user_sees_only_his_groups is
 * enabled, then we remove users not in this user's groups
 * (except for nonuser calendars... which we allow regardless of group).
 */
include_once 'includes/init.php';

$error "";

$USERS_PER_TABLE 6;

if ( 
$allow_view_other == "N" && ! $is_admin ) {
  
// not allowed...
  
send_to_preferred_view ();
}

if ( empty ( 
$id ) ) {
  
do_redirect "views.php" );
}

// Find view name in $views[]
$view_name "";
for ( 
$i 0$i count $views ); $i++ ) {
  if ( 
$views[$i]['cal_view_id'] == $id ) {
    
$view_name $views[$i]['cal_name'];
  }
}

// If view_name not found, then the specified view id does not
// belong to current user. 
if ( $view_name == "" ) {
  
$error translate "You are not authorized" );
}

$INC = array('js/popups.php');
print_header($INC);

set_today($date);

$next mktime 300$thismonth 11$thisyear );
$nextyear date "Y"$next );
$nextmonth date "m"$next );
$nextdate sprintf "%04d%02d01"$nextyear$nextmonth );

$prev mktime 300$thismonth 11$thisyear );
$prevyear date "Y"$prev );
$prevmonth date "m"$prev );
$prevdate sprintf "%04d%02d01"$prevyear$prevmonth );

$startdate sprintf "%04d%02d01"$thisyear$thismonth );
$enddate sprintf "%04d%02d31"$thisyear$thismonth );
$monthstart mktime 300$thismonth1$thisyear );
$monthend mktime 300$thismonth 10$thisyear );
$thisdate $startdate;
?>

<div style="border-width:0px; width:99%;">
<a title="<?php etranslate("Previous")?>" class="prev" href="view_m.php?id=<?php echo $id?>&amp;date=<?php echo $prevdate?>"><img src="leftarrow.gif" alt="<?php etranslate("Previous")?>" /></a>
<a title="<?php etranslate("Next")?>" class="next" href="view_m.php?id=<?php echo $id?>&amp;date=<?php echo $nextdate?>"><img src="rightarrow.gif" alt="<?php etranslate("Next")?>" /></a>
<div class="title">
<span class="date"><?php
  printf 
"%s %d"month_name $thismonth ), $thisyear );
?></span><br />
<span class="viewname"><?php echo $view_name ?></span>
</div>
</div><br />

<?php
// The table has names across the top and dates for rows.  Since we need
// to spit out an entire row before we can move to the next date, we'll
// save up all the HTML for each cell and then print it out when we're
// done....
// Additionally, we only want to put at most 6 users in one table since
// any more than that doesn't really fit in the page.

// get users in this view
$res dbi_query (
  
"SELECT cal_login FROM webcal_view_user WHERE cal_view_id = $id);
$viewusers = array ();
$all_users false;
if ( 
$res ) {
  while ( 
$row dbi_fetch_row $res ) ) {
    
$viewusers[] = $row[0];
    if ( 
$row[0] == "__all__" ) {
      
$all_users true;
    }
  }
  
dbi_free_result $res );
} else {
  
$error translate "Database error" ) . ": " dbi_error ();
}

if ( 
$all_users ) {
  
$viewusers = array ();
  
$users get_my_users ();
  for ( 
$i 0$i count $users ); $i++ ) {
    
$viewusers[] = $users[$i]['cal_login'];
  }
} else {
  
// Make sure this user is allowed to see all users in this view
  // If this is a global view, it may include users that this user
  // is not allowed to see.
  
if ( ! empty ( $user_sees_only_his_groups ) &&
    
$user_sees_only_his_groups == 'Y' ) {
    
$myusers get_my_users ();
    if ( ! empty ( 
$nonuser_enabled ) && $nonuser_enabled == "Y" ) {
      
$myusers array_merge $myusersget_nonuser_cals () );
    }
    
$userlookup = array();
    for ( 
$i 0$i count $myusers ); $i++ ) {
      
$userlookup[$myusers[$i]['cal_login']] = 1;
    }
    
$newlist = array ();
    for ( 
$i 0$i count $viewusers ); $i++ ) {
      if ( ! empty ( 
$userlookup[$viewusers[$i]] ) ) {
        
$newlist[] = $viewusers[$i];
      }
    }
    
$viewusers $newlist;
  }
}
if ( 
count $viewusers ) == ) {
  
// This could happen if user_sees_only_his_groups  = Y and
  // this user is not a member of any  group assigned to this view
  
$error translate "No users for this view" );
}

if ( ! empty ( 
$error ) ) {
  echo 
"<h2>" translate "Error" ) .
    
"</h2>\n" $error;
  
print_trailer ();
  exit;
}

$e_save = array ();
$re_save = array ();
for ( 
$i 0$i count $viewusers ); $i++ ) {
  
/* Pre-Load the repeated events for quckier access */
  
$repeated_events read_repeated_events $viewusers[$i], ""$startdate );
  
$re_save[$i] = $repeated_events;
  
/* Pre-load the non-repeating events for quicker access */
  
$events read_events $viewusers[$i], $startdate$enddate );
  
$e_save[$i] = $events;
}

for ( 
$j 0$j count ($viewusers); $j += $USERS_PER_TABLE ) {
  
// since print_date_entries is rather stupid, we can swap the event data
  // around for users by changing what $events points to.

  // Calculate width of columns in this table.
  
$num_left count ($viewusers) - $j;
  if (
$num_left $USERS_PER_TABLE) {
    
$num_left $USERS_PER_TABLE;
  }
  if (
$num_left 0) {
    if (
$num_left $USERS_PER_TABLE) {
      
$tdw = (int) (90 $num_left);
    } else {
      
$tdw = (int) (90 $USERS_PER_TABLE);
    }
  } else {
    
$tdw 5;
  }
?>
<br /><br />

<table class="main" cellspacing="0" cellpadding="0">
<tr><th class="empty">&nbsp;</th>
<?php
  
// $j points to start of this table/row
  // $k is counter starting at 0
  // $i starts at table start and goes until end of this table/row.
  
for ( $i $j$k 0;
    
$i count ($viewusers) && $k $USERS_PER_TABLE$i++, $k++ ) {
 
$user $viewusers[$i];
 
user_load_variables ($user"temp");
 echo 
"<th style=\"width:$tdw%;\">$tempfullname</th>\n";
  } 
//end for
  
echo "</tr>\n";

  for ( 
$date $monthstartdate ("Ymd"$date) <= date ("Ymd"$monthend);
    
$date += (24 3600), $wday++ ) {
 
$wday strftime ("%w"$date);
 
$weekday weekday_short_name ($wday);
 echo 
"<tr><th";
 if ( 
date ("Ymd"$date) == date ("Ymd"$today) ) {
   echo 
" class=\"today\">";
 } else {
  if (
$wday == || $wday == 6) {
    echo 
" class=\"weekend\">";
  } else {
    echo 
" class=\"row\">";
  }
 }
 
//non-breaking space below keeps event from wrapping prematurely
 
echo $weekday "&nbsp;" .
  
round date ("d"$date) ) . "</th>\n";
    for ( 
$i $j$k 0;
      
$i count ($viewusers) && $k $USERS_PER_TABLE$i++, $k++ ) {
 
$user $viewusers[$i];
 
$events $e_save[$i];
 
$repeated_events $re_save[$i];
 if ( 
date ("Ymd"$date) == date ("Ymd"$today) ) {
  echo 
"<td class=\"today\"";
 } else {
  if (
$wday == || $wday == 6) {
   echo 
"<td class=\"weekend\"";
  } else {
   echo 
"<td";
  }
 }
 echo 
" style=\"width:$tdw%;\">";
 
//echo date ( "D, m-d-Y H:i:s", $date ) . "<br />";
      
if ( empty ($add_link_in_views) || $add_link_in_views != "N" ) {
        echo 
html_for_add_icon date ("Ymd"$date), """"$user );
      }
      
print_date_entries date ("Ymd"$date), $usertrue );
      echo 
"</td>";
    } 
//end for
    
echo "</tr>\n";
  }

  echo 
"</table>\n<br /><br />\n";
}

$user ""// reset

if ( ! empty ( $eventinfo ) ) {
  echo 
$eventinfo;
}

echo 
"<a title=\"" 
  
translate("Generate printer-friendly version") . "\" class=\"printer\" " .
  
"href=\"view_m.php?id=$id&amp;date=$thisdate&amp;friendly=1\" " .
  
"target=\"cal_printer_friendly\" onmouseover=\"window.status='" .
  
translate("Generate printer-friendly version") . "'\">[" 
  
translate("Printer Friendly") . "]</a>\n";

print_trailer (); ?>
</body>
</html>