From 0af7a80d9b273051bad96024369d72a74b20eadb Mon Sep 17 00:00:00 2001 From: Jason Oster Date: Fri, 5 Jun 2009 14:20:40 +0000 Subject: Fix default selections in display_ical_list() --- functions/calendar_functions.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/functions/calendar_functions.php b/functions/calendar_functions.php index 25ec8ed..2c5cd69 100644 --- a/functions/calendar_functions.php +++ b/functions/calendar_functions.php @@ -187,6 +187,7 @@ function display_ical_list($cals, $pick=FALSE) { global $cal, $current_view, $getdate, $lang, $calendar_lang, $all_cal_comb_lang, $cal_filelist, $cal_displaynames, $list_webcals, $phpiCal_config; // Print each calendar option. $return = ''; + $all_cals = true; foreach ($cals as $cal_tmp) { // Format the calendar path for display. // @@ -244,6 +245,10 @@ function display_ical_list($cals, $pick=FALSE) { if(in_array($cal_tmp, $list_webcals)){ $cal_encoded_tmp = md5($phpiCal_config->salt.$cal_tmp);; } + + // Try to detect unselected calendars + if (!in_array($cal_encoded_tmp, explode(",", $cal))) $all_cals = false; + // Display the option. // // The submitted calendar will be encoded, and always use http:// @@ -256,22 +261,23 @@ function display_ical_list($cals, $pick=FALSE) { $return .= "\n"; } } else { - $cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp); - if ($cal_encoded_tmp == urldecode($cal)) { - $return .= ""; - } else { - $return .= ""; + $cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp); + if ($cal_encoded_tmp == $cal || $cal_encoded_tmp == urldecode($cal)) { + $return .= ""; + } else { + $return .= ""; + } } - } } // option to open all (non-web) calenders together if (!$pick) { - if ($cal == $phpiCal_config->ALL_CALENDARS_COMBINED) { + if ($all_cals || $cal == $phpiCal_config->ALL_CALENDARS_COMBINED) { $return .= ""; } else { $return .= ""; } } + return $return; } \ No newline at end of file -- cgit v1.2.3