aboutsummaryrefslogtreecommitdiffstats
path: root/functions
diff options
context:
space:
mode:
authorChad Little <clittle@users.sourceforge.net>2005-09-14 20:44:55 +0000
committerChad Little <clittle@users.sourceforge.net>2005-09-14 20:44:55 +0000
commitdeac2b72545c65c85c8c81f09eaba7e06e8ac201 (patch)
tree697b747924e0069debf5a4bb7b6cc81ed120f0dc /functions
parent53a2c2b2694871cd549cd87f37497f794546617b (diff)
downloadphpicalendar-deac2b72545c65c85c8c81f09eaba7e06e8ac201.tar.gz
phpicalendar-deac2b72545c65c85c8c81f09eaba7e06e8ac201.tar.bz2
phpicalendar-deac2b72545c65c85c8c81f09eaba7e06e8ac201.zip
Multiple calendar selection patch. Needs formatting.
Diffstat (limited to 'functions')
-rw-r--r--functions/calendar_functions.php37
-rw-r--r--functions/init.inc.php34
2 files changed, 58 insertions, 13 deletions
diff --git a/functions/calendar_functions.php b/functions/calendar_functions.php
index e04883d..ebe1634 100644
--- a/functions/calendar_functions.php
+++ b/functions/calendar_functions.php
@@ -76,33 +76,43 @@ function availableCalendars($username, $password, $cal_filename, $admin = false)
// Otherwise just include the requested calendar.
else {
+ if(!is_array($cal_filename)) {
+ $cal_filename_local = array($cal_filename);
+ }
+ else {
+ $cal_filename_local = $cal_filename;
+ }
+
+ foreach($cal_filename_local as $c) {
+
// Make sure this is not a blacklisted calendar. We don't have
// to remove a .ics suffix because it would not have been passed
// in the argument.
- if (in_array($cal_filename, $blacklisted_cals))
- exit(error($lang['l_error_restrictedcal'], $cal_filename));
+ if (in_array($c, $blacklisted_cals))
+ exit(error($lang['l_error_restrictedcal'], $c));
// If HTTP authenticated, make sure this calendar is available
// to the user.
if (isset($http_user)) {
- if (!in_array($cal_filename, $apache_map[$http_user])) {
+ if (!in_array($c, $apache_map[$http_user])) {
// Use the invalid calendar message so that the user is
// not made aware of locked calendars.
- exit(error($lang['l_error_invalidcal'], $cal_filename));
+ exit(error($lang['l_error_invalidcal'], $c));
}
}
// Otherwise make sure this calendar is not locked.
- else if (in_array($cal_filename, $locked_cals) &&
- !in_array($cal_filename, $unlocked_cals))
+ else if (in_array($c, $locked_cals) &&
+ !in_array($c, $unlocked_cals))
{
// Use the invalid calendar message so that the user is
// not made aware of locked calendars.
- exit(error($lang['l_error_invalidcal'], $cal_filename));
+ exit(error($lang['l_error_invalidcal'], $c));
}
// Add this calendar.
- array_push($calendars, "$calendar_path/$cal_filename.ics");
+ array_push($calendars, "$calendar_path/$c.ics");
+ }
}
// Return the sorted calendar list.
@@ -139,7 +149,7 @@ function availableCalendarNames($username, $password, $cal_filename, $admin = fa
// is not printed out by this function.
//
// $cals = The calendars (entire path, e.g. from availableCalendars).
-function display_ical_list($cals) {
+function display_ical_list($cals, $pick=FALSE) {
global $cal, $ALL_CALENDARS_COMBINED, $current_view, $getdate, $calendar_lang, $all_cal_comb_lang;
// Print each calendar option.
@@ -177,6 +187,14 @@ function display_ical_list($cals) {
// The submitted calendar will be encoded, and always use http://
// if it is a webcal. So that is how we perform the comparison when
// trying to figure out if this is the selected calendar.
+ if($pick) {
+ if (in_array($cal_encoded_tmp, explode(",", $cal))) {
+ $return .= "<option value=\"$cal_encoded_tmp\" selected=\"selected\">$cal_displayname_tmp</option>\n";
+ } else {
+ $return .= "<option value=\"$cal_encoded_tmp\">$cal_displayname_tmp</option>\n";
+ }
+ }
+ else {
$cal_httpPrefix_tmp = str_replace('webcal://', 'http://', $cal_tmp);
if ($cal_httpPrefix_tmp == urldecode($cal)) {
$return .= "<option value=\"$current_view.php?cal=$cal_encoded_tmp&amp;getdate=$getdate\" selected=\"selected\">$cal_displayname_tmp</option>";
@@ -184,6 +202,7 @@ function display_ical_list($cals) {
$return .= "<option value=\"$current_view.php?cal=$cal_encoded_tmp&amp;getdate=$getdate\">$cal_displayname_tmp</option>";
}
}
+ }
// option to open all (non-web) calenders together
if ($cal == $ALL_CALENDARS_COMBINED) {
diff --git a/functions/init.inc.php b/functions/init.inc.php
index 7c01cf2..b5f0018 100644
--- a/functions/init.inc.php
+++ b/functions/init.inc.php
@@ -80,8 +80,21 @@ if ($calendar_path == '') {
}
$is_webcal = FALSE;
-if (isset($_GET['cal']) && $_GET['cal'] != '') {
+if (isset($_GET['cal'])) {
+ //if we get a comma-separated list of calendars, split into array
+ if(stristr($_GET['cal'], ",")) {
+ $_GET['cal'] = explode(",", $_GET['cal']);
+ }
+ //if we have an array of calendard, decode each (though I'm not sure this is necessary)
+ if(is_array($_GET['cal'])) {
+ $cal_filename = array();
+ foreach($_GET['cal'] as $c) {
+ $cal_filename[] = urldecode($c);
+ }
+ }
+ else {
$cal_filename = urldecode($_GET['cal']);
+ }
} else {
if (isset($default_cal_check)) {
if ($default_cal_check != $ALL_CALENDARS_COMBINED) {
@@ -100,7 +113,7 @@ if (isset($_GET['cal']) && $_GET['cal'] != '') {
}
}
-if (substr($cal_filename, 0, 7) == 'http://' || substr($cal_filename, 0, 8) == 'https://' || substr($cal_filename, 0, 9) == 'webcal://') {
+if (!is_array($cal_filename) && (substr($cal_filename, 0, 7) == 'http://' || substr($cal_filename, 0, 8) == 'https://' || substr($cal_filename, 0, 9) == 'webcal://')) {
$is_webcal = TRUE;
$cal_webcalPrefix = str_replace('http://','webcal://',$cal_filename);
$cal_httpPrefix = str_replace('webcal://','http://',$cal_filename);
@@ -122,9 +135,22 @@ if ($is_webcal == TRUE) {
exit(error($lang['l_error_remotecal'], $_GET['cal']));
}
} else {
- $cal_displayname = str_replace('32', ' ', $cal_filename);
+ $cal_displayname = str_replace('32', ' ', (is_array($cal_filename) ? implode(", ", $cal_filename) : $cal_filename));
+ if(is_array($cal_filename)) {
+ $cal = array();
+ $blacklisted = FALSE;
+ foreach($cal_filename as $c) {
+ $cal[] = urlencode($c);
+ if(in_array($c, $blacklisted_cals)) $blacklisted = TRUE;
+ }
+ $cal = implode(",", $cal);
+ }
+ else {
$cal = urlencode($cal_filename);
- if (in_array($cal_filename, $blacklisted_cals)) {
+ $blacklisted = in_array($cal_filename, $blacklisted_cals);
+ }
+
+ if ($blacklisted) {
exit(error($lang['l_error_restrictedcal'], $cal_filename));
} else {
if (!isset($filename)) {

© 2014-2024 Faster IT GmbH | imprint | privacy policy