@@ -85,7 +85,7 @@ function availableCalendars($username, $password, $cal_filename, $admin = false)
85
85
// The file process block below expects actual filenames. So
86
86
// we have to append '.ics' to the passed in calendar names.
87
87
foreach ($ cal_filename_local as $ filename ) {
88
- array_push ($ files , "$ search_path/ $ filename" . " .ics " );
88
+ array_push ($ files , "$ search_path/ $ filename.ics " );
89
89
}
90
90
}
91
91
@@ -175,7 +175,13 @@ function getCalendarName($cal_path) {
175
175
}
176
176
177
177
// At this point, just pull the name off the file.
178
- return str_replace (".ics " , '' , basename ($ cal_path ));
178
+ $ name = str_replace (".ics " , '' , basename ($ cal_path ));
179
+ if ((substr ($ cal_path , 0 , 7 ) == 'http:// ' ) ||
180
+ (substr ($ cal_path , 0 , 8 ) == 'https:// ' ) ||
181
+ (substr ($ cal_path , 0 , 9 ) == 'webcal:// ' )) {
182
+ $ name = urldecode ($ name );
183
+ }
184
+ return $ name ;
179
185
}
180
186
181
187
// This function prints out the calendars available to the user, for
@@ -184,7 +190,7 @@ function getCalendarName($cal_path) {
184
190
//
185
191
// $cals = The calendars (entire path, e.g. from availableCalendars).
186
192
function display_ical_list ($ cals , $ pick =FALSE ) {
187
- global $ cal , $ current_view , $ getdate , $ lang , $ calendar_lang , $ all_cal_comb_lang , $ cal_filelist , $ cal_displaynames , $ list_webcals , $ phpiCal_config ;
193
+ global $ cal , $ current_view , $ getdate , $ lang , $ calendar_lang , $ all_cal_comb_lang , $ cal_filelist , $ cal_displaynames , $ list_webcals , $ phpiCal_config, $ master_array ;
188
194
// Print each calendar option.
189
195
$ return = '' ;
190
196
@@ -194,18 +200,28 @@ function display_ical_list($cals, $pick=FALSE) {
194
200
foreach ($ cals as $ cal_tmp ) {
195
201
// Format the calendar path for display.
196
202
//
197
- // Only display the calendar name, replace all instances of "32" with " ",
198
- // and remove the .ics suffix.
199
- $ cal_displayname_tmp = getCalendarName ($ cal_tmp );
200
- #$cal_displayname_tmp = str_replace("32", " ", $cal_displayname_tmp);
201
- #overwrite the display name if we already have a real name
202
- if (is_numeric (array_search ($ cal_tmp , $ cal_filelist ))){
203
- $ cal_displayname_tmp = $ cal_displaynames [array_search ($ cal_tmp ,$ cal_filelist )];
204
- }else {
203
+ $ cal_displayname_tmp = '' ;
204
+ $ search_idx = array_search ($ cal_tmp , $ cal_filelist );
205
+ if (is_numeric ($ search_idx )) {
206
+ $ cal_displayname_tmp = $ cal_displaynames [$ search_idx ];
207
+ }
208
+ else if ((substr ($ cal_tmp , 0 , 7 ) == 'http:// ' ) ||
209
+ (substr ($ cal_tmp , 0 , 8 ) == 'https:// ' ) ||
210
+ (substr ($ cal_tmp , 0 , 9 ) == 'webcal:// ' )) {
211
+ $ cal_tmp2 = str_replace ('webcal:// ' , 'http:// ' , $ cal_tmp );
212
+ $ cal_tmp2 = str_replace ('https:// ' , 'http:// ' , $ cal_tmp2 );
213
+ $ num = 1 ;
214
+ foreach ($ master_array [-4 ] as $ master_cal ) {
215
+ if ($ master_cal ['filename ' ] == $ cal_tmp2 ) {
216
+ $ cal_displayname_tmp = $ master_array [-3 ][$ num ];
217
+ break ;
218
+ }
219
+ $ num ++;
220
+ }
221
+ }
222
+ else {
205
223
# pull the name from the $cal_tmp file
206
- $ cal_tmp2 = str_replace ('webcal:// ' ,'http:// ' ,$ cal_tmp );
207
-
208
- $ ifile = @fopen ($ cal_tmp2 , "r " );
224
+ $ ifile = @fopen ($ cal_tmp , 'r ' );
209
225
if ($ ifile == FALSE ) exit (error ($ lang ['l_error_cantopen ' ], $ cal_tmp ));
210
226
while (!feof ($ ifile )) {
211
227
$ line = fgets ($ ifile , 1024 );
@@ -225,7 +241,13 @@ function display_ical_list($cals, $pick=FALSE) {
225
241
#stop reading if we find an event or timezone before there's a name
226
242
if ($ line == "BEGIN:VTIMEZONE " ||$ line == "BEGIN:VEVENT " ) break ;
227
243
}
228
-
244
+ @fclose ($ ifile );
245
+ }
246
+ if (empty ($ cal_displayname_tmp )) {
247
+ // Only display the calendar name, replace all instances of "32" with " ",
248
+ // and remove the .ics suffix.
249
+ $ cal_displayname_tmp = getCalendarName ($ cal_tmp );
250
+ #$cal_displayname_tmp = str_replace('32', ' ', $cal_displayname_tmp);
229
251
}
230
252
231
253
// If this is a webcal, add 'Webcal' to the display name.
0 commit comments