#!/usr/bin/perl # before anything else, the script needs to find out its own name # # some servers (notably IIS on windows) don't set the cwd to the script's # directory before executing it. So we get that information # from $0 (the full name & path of the script). BEGIN{($_=$0)=~s![\\/][^\\/]+$!!;push@INC,$_} $name = $0; $name =~ s/.+\/?.+\///; # for unix $name =~ s/.+\\.+\\//; # for windows $path = $0; $path =~ s/(.+\/).+/$1/g; # for unix $path =~ s/(.+\\).+/$1/g; # for windows # The "use Cwd" method would be nice, but it doesn't work with # some versions of IIS/ActivePerl #use Cwd; #$path = cwd; if ($path ne "") { chdir $path; push @INC,$path; } # finished discovering name use Data::Dumper; # some global variables (more further down) local $plans_version = "7.2"; # version local $debug_info; local %options; local $perl_version = (sprintf ("%vd",$^V)); #local $options{data_storage_mode}; local $fatal_error = 0; # fatal errors cause plans to abort and print an error message to the browser local $error_info = ""; local $html_output; local $script_url = ""; local $messages = ""; # formatted in plain text with newlines. Converted to html at display time. local $template_html; local $event_details_template; local $list_item_template; local $calendar_item_template; local $upcoming_item_template; local %calendars; local %current_calendar; local %latest_calendar; local %new_calendars; # used when adding new entries local $max_cal_id = 0; local $max_event_id = 0; local $max_series_id = 0; local $max_user_id = 0; local $max_action_id = 0; # used to protect against refreshes local $latest_cal_id = 0; local $latest_event_id = 0; local $latest_new_cal_id = 0; local $latest_new_event_id = 0; local $session; local %users; my $profile; local $logged_in = 0; local $logged_in_as_root = 0; local $logged_in_as_current_cal_user = 0; local $logged_in_as_current_cal_admin = 0; local $lg_name = ""; local $lg_password = ""; local %events; local %new_events; local @pending_events_to_display; local %current_event; local %text; local %cookie_parms; local $cookie_text = ""; local $cookie_header_text = ""; local $max_remote_event_id = 0; local %discoveries; local $options{default_template_path} = ""; local $theme_url = ""; local $options{choose_themes} = ""; local $graphics_url = ""; local $icons_url = ""; local $input_cal_id_valid = 0; local $options{right_click_menus_enabled} = 0; local %cal_options; local $rightnow; local @months; local @months_abv; local @day_names; local $loaded_all_events; # flag used to avoid calling load_events("all") twice # not needed for calendars (we always load all calendars) local @disabled_tabs; # check for required modules. my $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/plans_config.pl") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "Unable to locate plans_config.pl! It should be in the same directory as plans.cgi!\n"; } else {require "plans_config.pl";} $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/CGI") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "unable to locate required module CGI!\n"; } else {use CGI;} $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/CGI/Session") {$module_found=1;} } if ($options{sessions} eq "1") { if ($module_found == 0) { $fatal_error = 1; $error_info .= "unable to locate required module CGI::Session!\n"; } else {require CGI::Session;} } $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/CGI/Carp.pm") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "unable to locate required module CGI::Carp!\n"; } else {use CGI::Carp qw/fatalsToBrowser/;} $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/Time") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "unable to locate required module Time.pm!\n"; } else {use Time::Local;} $module_found=0; foreach $temp_path (@INC) { if (-e "$temp_path/IO.pm") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "unable to locate required module IO.pm!\n"; } else {use IO::Socket;} if ($fatal_error == 1) # print error and bail out { &fatal_error(); } $module_found=0; foreach $temp_path (@INC) { if (-r "$temp_path/plans_lib.pl") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "Unable to locate plans_lib.pl! It should be in the same directory as plans.cgi!\n"; } else {require "plans_lib.pl";} # multi-language stuff if (defined $options{language_files}) { my @language_files = split(',', $options{language_files}); # pull in language files foreach $language_file (@language_files) { $module_found=0; foreach $temp_path (@INC) { if (-r "$temp_path/$language_file") {$module_found=1;} } if ($module_found == 0) { $fatal_error=1; $error_info .= "Unable to locate language file $language_file! It should be in the same directory as plans.cgi!\n"; } else {require $language_file;} } # create a javascript file with language strings open (FH, "$options{default_theme_path}/$options{js_language_file}") || {$debug_info.= "unable to open file $options{default_theme_path}/$options{js_language_file}\n"}; flock FH,2; my $first_lang_line=; close FH; if ($options{generate_js_lang} eq "1" || $first_lang_line !~ /$plans_version/) { my $lang_string = ""; $lang_string .= "//$plans_version\n"; $lang_string .= "var plans_lang = new Array();\n"; # generate %lang keys foreach $lang_key (keys %lang) { if (ref $lang{$lang_key} eq "ARRAY") { $lang_string .= "plans_lang['$lang_key']=new Array("; my $first = 1; foreach $key (@{$lang{$lang_key}}) { if (!$first) {$lang_string .= ',';} if ($first) {$first = 0;} my $lang_val = &js_string($key); $lang_string .= "'$lang_val'"; } $lang_string .= ");\n"; } else { my $lang_val = &js_string($lang{$lang_key}); $lang_string .= "plans_lang['$lang_key']='$lang_val';\n" } } open (FH, ">$options{default_theme_path}/$options{js_language_file}") || {$debug_info .= "unable to open file $options{default_theme_path}/$options{js_language_file} for writing!\n"}; flock FH,2; print FH $lang_string; close FH; } } else { $fatal_error=1; $error_info .= "No language files defined in plans.config!\n"; } # check for perl version my $temp = substr($perl_version,0,3); if ($temp < 5.6) { $fatal_error=1; $error_info .= "Your version of perl ($perl_version) is too old! Plans requires perl version 5.6 or better.\n"; } if ($fatal_error == 1) # print error and bail out { &fatal_error(); } # load discoveries &load_discoveries(); # init cgi stuff $q = new CGI; $script_url = $q->url(-path_info>=1); $script_url =~ /(.*)\//; # remove trailing / and all text after $script_url = $1; # remove trailing / and all text after &force_discovery($script_url, "script_url"); %cookie_parms = %{&extract_cookie_parms()}; # check if data files or tables are present &check_data(); # fatal error? Print error and bail out if ($fatal_error == 1) {&fatal_error();} if ($theme_url eq "") # not defined in config file { $theme_url = $discoveries{theme_url}; # have we discovered it yet? if ($theme_url eq "") # if we haven't discovered it yet { $theme_url = "$script_url/theme"; } } else # defined in config file { if ($theme_url ne $discoveries{theme_url}) # changed or new { &force_discovery($theme_url, "theme_url"); } } if ($options{choose_themes}) { $chosen_url = $q->param('theme_url'); $chosen_url = $cookie_parms{'theme_url'} if ($chosen_url eq ""); $theme_url = $chosen_url if ($chosen_url ne ""); } $graphics_url ="$theme_url/graphics"; # where misc. graphics are $icons_url = "$theme_url/icons"; # where icons are $css_path = "$theme_url/plans.css"; # css file # globals for http parameters my $active_tab = $q->param('active_tab') + 0; # +0 ensures numericity $active_tab = 0 if ($active_tab > scalar @{$lang{tab_text}} - 1); my $add_edit_cal_action = $q->param('add_edit_cal_action'); $add_edit_cal_action = "" if (!&contains(["add", "edit", "view_pending"],$add_edit_cal_action)); # validate my $add_edit_event = $q->param('add_edit_event'); $add_edit_event = "" if (!&contains(["add", "edit"],$add_edit_event)); # validate local $current_event_id = $q->param('evt_id'); $current_event_id = "" if ($current_event_id !~ /^R?\d+$/); # validate local $pending_event_id = $q->param('pending_event_id'); $pending_event_id = "" if ($pending_event_id !~ /^R?\d+$/); # validate local $cal_start_month = $q->param('cal_start_month') + 0; # +0 ensures numericity local $cal_start_year = $q->param('cal_start_year') + 0; # +0 ensures numericity local $cal_num_months = $q->param('cal_num_months') + 0; # +0 ensures numericity # if view parameters not supplied in http request, check cookie $cal_start_month = $cookie_parms{'cal_start_month'} if ($q->param('cal_start_month') eq ""); $cal_start_year = $cookie_parms{'cal_start_year'} if ($cal_start_year == 0); $cal_num_months = $cookie_parms{'cal_num_months'} if ($cal_num_months == 0); my $special_action = $q->param('special_action'); # needs no validation - never used in output local $display_type = $q->param('display_type') + 0; # +0 ensures numericity $display_type = $cookie_parms{'display_type'} if ($cal_start_month == 0); $messages = $q->param('messages') if ($q->param('messages') ne ""); # other globals my $event_start_date; my $event_start_timestamp; my $event_days; my $start_mday; my $start_mon; my $start_year; my @timestamp_array; my $prev_month_link = ""; my $next_month_link = ""; # load calendar data &load_calendars(); &load_users(); &load_actions(); local $current_cal_id = 0; if ($q->param('cal_id') eq "") { $current_cal_id = $cookie_parms{'cal_id'} if ($current_cal_id == 0); } else { $current_cal_id = $q->param('cal_id'); } $current_cal_id += 0; # +0 ensures numericity # if calendar id not supplied, but evt_id is supplied (like when viewing an event) use that event's calendar as the current calendar #if ($current_event_id ne "") #{ # &load_event($current_event_id); # # my %temp_current_event = %{$events{$current_event_id}}; # if ($current_cal_id eq "") # { # $current_cal_id = $temp_current_event{cal_ids}[0]; # } #} foreach $cal_id (keys %calendars) { if ($cal_id eq $current_cal_id) {$input_cal_id_valid = 1;} } if ($current_cal_id eq "") {$input_cal_id_valid = 0;} if ($current_cal_id =~ /\D/) {$input_cal_id_valid = 0;} $current_cal_id = 0 if ($current_event_id eq "" && !$input_cal_id_valid); # make all calendars selectable by default foreach $cal_id (keys %calendars) {$default_cal{selectable_calendars}{$cal_id} = 1;} %current_calendar = %{$calendars{$current_cal_id}}; # time-related globals $rightnow = time() + 3600 * $current_calendar{gmtime_diff}; @rightnow_array = gmtime $rightnow; $rightnow_year = $rightnow_array[5]+1900; $rightnow_month = $rightnow_array[4]; $rightnow_mday = $rightnow_array[3]; $next_year = $rightnow_year+1; $rightnow_description = formatted_time($rightnow, "hh:mm:ss mn md yy"); @weekday_sequence = @day_names; # session stuff if ($options{sessions} eq "1") { #$lg_name = $q->param('lg_name'); $lg_name = $current_cal_id; $lg_password = $q->param('cal_password'); &delete_old_sessions(1); # in days #$debug_info .= "plans_sid (cookie): ".$q->cookie("plans_sid")."\n"; my $current_session_id = $q->cookie("plans_sid") || undef; $session = new CGI::Session(undef, $current_session_id, {Directory=>$options{sessions_directory}}); $session->expire("+1d"); #$debug_info .= "current_session_id: $current_session_id\n"; # log out? if ($q->param('logout') eq "1") { $session->delete(); $cookie_text .= " plans_sid=deleted;"; } # try to match session with user id. (If this fails, it's not really a session.) my $results = &init_session($q, $session); $profile = $session->param("~profile"); if (defined $profile->{calendar_permissions}) { $logged_in = 1; $cookie_text .= " plans_sid=".$session->id.";"; } } if ($options{sessions} eq "1") { $logged_in_as_root = ($profile->{calendar_permissions}->{0}->{admin} eq "1") ? 1:0; $logged_in_as_current_cal_user = ($profile->{calendar_permissions}->{$current_cal_id}->{user} ne "") ? 1:0; $logged_in_as_current_cal_admin = ($profile->{calendar_permissions}->{$current_cal_id}->{admin} ne "") ? 1:0; } else { $logged_in_as_root = ($calendars{0}{password} eq crypt($q->param('cal_password'), $options{salt})) ? 1:0; $logged_in_as_current_cal_admin = ($current_calendar{password} eq crypt($q->param('cal_password'), $options{salt})) ? 1:0; foreach $user_id (keys %users) { my %user = %{$users{$user_id}}; my %user_calendars = %{$user{calendars}}; foreach $user_cal_id (keys %user_calendars) { if ($user_cal_id eq $current_cal_id && $user{calendars}{$user_cal_id}{edit_events} eq "1" && $user{password} eq crypt($q->param('cal_password'), $options{salt})) {$logged_in_as_current_cal_user = 1;} } } } $logged_in_as_current_cal_user = 0 if (!$options{users}) ; #$debug_info .= "init_session results: $results\n"; #$debug_info .= "logged-in: ".$session->param("~logged-in")."\n"; #$debug_info .= "session id: ".$session->id."\n"; #$debug_info .= "profile user_id: ".$profile->{calendar_permissions}->{$current_cal_id}."\n"; #$debug_info .= "options{sessions}: $options{sessions}\n"; #$debug_info .= "logged_in_as_root: $logged_in_as_root\n"; #$debug_info .= "logged_in_as_current_cal_user: $logged_in_as_current_cal_user\n"; #$debug_info .= "logged_in_as_current_cal_admin: $logged_in_as_current_cal_admin\n"; # custom stylesheet? if ($current_calendar{custom_stylesheet} ne "") { $css_path = "http://$current_calendar{custom_stylesheet}"; } # if this is a custom calendar request, shoehorn the request parameters in if ($q->param('custom_calendar') eq "1") { $current_cal_id = $q->param('custom_calendar_calendar') + 0; @custom_calendar_backgound_calendars = $q->param('custom_calendar_background_calendars'); foreach $local_background_calendar (keys %{$calendars{$current_cal_id}{local_background_calendars}}) {delete $calendars{$current_cal_id}{local_background_calendars}{$local_background_calendar};} foreach $local_background_calendar (@custom_calendar_backgound_calendars) {$calendars{$current_cal_id}{local_background_calendars}{$local_background_calendar} = 1;} %current_calendar = %{$calendars{$current_cal_id}}; } # make sure we can select the current calendar #$current_calendar{selectable_calendars}{$current_cal_id} = 1; # set info window height & width $current_calendar{info_window_size} ="400x400" if ($current_calendar{info_window_size} eq ""); # default my ($info_window_width, $info_window_height) = split("x", $current_calendar{info_window_size}); # rotate weekday_sequence by the offset defined in the week start day. for ($l1=0;$l1 < $current_calendar{week_start_day};$l1++) {push @weekday_sequence, (shift @weekday_sequence);} # load background_colors my @temp_lines = split ("\n", $event_background_colors); foreach $temp_line (@temp_lines) { if ($temp_line !~ /\w/) # skip any blank lines {next;} $temp_line =~ s/^\s+//; my ($hex_color, $hex_color_title) = split (/,*\s+/, $temp_line, 2); if ($hex_color_title eq "") {$hex_color_title = " ";} push @event_bgcolors, {color => $hex_color, title => $hex_color_title}; } #evaluate browser type and version $_ = $ENV{HTTP_USER_AGENT}; if (/Mozilla/) { if (/Opera.([0-9\.]+)/) { $browser_type = 'Opera'; $browser_version=$1;} elsif (/MSIE.([0-9.]+)/) { $browser_type = 'IE'; $browser_version = $1;} elsif (/Mozilla\/([0-9\.]+)/) {$browser_type = 'Mozilla'; $browser_version=$1; if (($browser_version<5) || (/Netscape/)) {$browser_type = "Netscape";} } if (/\)[^0-9.]+[0-9]*[\/\ ]([0-9.]+)/) {$browser_version=$1;} } elsif (/(\w+)\/([0-9\.]+)/) {$browser_type = $1; $browser_version = $2} #evaluate, transform, tweak, adjust, modify input values #$debug_info .= "browser type: $browser_type
"; #if no month is selected, use the current month if ($cal_start_month eq "" && $q->param('cal_start_month') eq "") { $cal_start_month = $rightnow_month; #$cal_start_month = 2; } #if the input year is out of range use the current year if (($cal_start_year+0) < 1902 || ($cal_start_year+0)> 2037) { $cal_start_year = $rightnow_year; } $cal_num_months = $current_calendar{default_number_of_months} if ($cal_num_months < 1); $cal_num_months = $current_calendar{default_number_of_months} if ($cal_num_months > $current_calendar{max_number_of_months}); $cal_num_months = 1 if ($cal_num_months > $current_calendar{max_number_of_months}); $cal_num_months = 1 if ($cal_num_months == 0); #calculate calendar end month and year $cal_end_month = $cal_start_month; $cal_end_year = $cal_start_year; for ($l1=1;$l1<$cal_num_months;$l1++) { $cal_end_month++; if ($cal_end_month == 12) { $cal_end_month=0; $cal_end_year++; } } #check to make sure num_months+cal_start_date doesn't go out of bounds if ($cal_end_year < 1902 || $cal_end_year> 2037) { $cal_end_year = $cal_start_year; $cal_end_month = $cal_start_month; $cal_num_months = 1; } # time window for loading events my $cal_start_timestamp = timegm(0,0,0,1,$cal_start_month,$cal_start_year) - 2592000; my $cal_end_timestamp = timegm(0,0,0,1,$cal_end_month,$cal_end_year) + 5184000; if ($q->param('cal_start_timestamp') ne "" && $q->param('cal_start_timestamp') !~ /\D/) {$cal_start_timestamp = $q->param('cal_start_timestamp');} if ($q->param('cal_end_timestamp') ne "" && $q->param('cal_end_timestamp') !~ /\D/) {$cal_end_timestamp = $q->param('cal_end_timestamp');} #$debug_info .="start: $cal_start_timestamp\nend: $cal_end_timestamp\nrightnow: $rightnow\n"; # load event data, for main calendar and its background calendars my @temp_calendars = ($current_cal_id); foreach $local_background_calendar (keys %{$current_calendar{local_background_calendars}}) {push @temp_calendars, $local_background_calendar;} &load_events($cal_start_timestamp, $cal_end_timestamp, \@temp_calendars); if ($current_event_id ne "") { &load_event($current_event_id); %current_event = %{$events{$current_event_id}}; } # load events from remote background calendars if (scalar keys %{$current_calendar{remote_background_calendars}} > 0) { $remote_calendars_status=""; my $temp = scalar keys %{$current_calendar{remote_background_calendars}}; foreach $remote_calendar_id (keys %{$current_calendar{remote_background_calendars}}) { # pull in remote calendar name my $remote_calendar_url = $current_calendar{remote_background_calendars}{$remote_calendar_id}{url}; $remote_calendar_complete_url = $remote_calendar_url; #$debug_info .= "remote calendar: $remote_calendar_complete_url\n"; $remote_calendar_complete_url .= "?remote_calendar_request=1&cal_id=$current_calendar{remote_background_calendars}{$remote_calendar_id}{remote_id}&cal_start_year=$cal_start_year&cal_start_month=$cal_start_month&num_months=$cal_num_months"; #$debug_info .= "remote calendar url: $remote_calendar_complete_url\n"; my $xml_results = &get_remote_file($remote_calendar_complete_url); if ($xml_results =~ //) { $xml_results =~ s//>/g; $debug_info .= "Error fetching remote calendar: $xml_results\n"; } else { my %remote_calendars = %{&xml2hash($xml_results)}; my $remote_cal_title=$remote_calendars{'xml'}{calendar}{title}; my $temp=$xml_results; $temp=~ s/>/>/g; $temp=~ s/ 1) { $prev_string = $lang{previous_months}; $prev_string =~ s/###num###/$cal_num_months/; } else { $prev_string = $lang{previous_month}; } # calculate next X months range. my $next_cal_start_month = $cal_start_month + $cal_num_months; my $next_cal_start_year = $cal_start_year; if ($next_cal_start_month > 11) { $next_cal_start_year = $cal_start_year + int(abs($cal_num_months + $cal_start_month) / 12); $next_cal_start_month = abs($cal_start_month + $cal_num_months) % 12; } # singular or plural? if ($cal_num_months > 1) { $next_string = $lang{next_months}; $next_string =~ s/###num###/$cal_num_months/; } else { $next_string = $lang{next_month}; } if ($q->param('diagnostic_mode') eq "1") { my $diagnostic_results = &diagnostic_info; $html_output = < Diagnostic mode

Plans Diagnostic information

$diagnostic_results

Debug info:

$debug_info
p1 print $html_output; exit(0); } if ($q->param('detect_remote_calendars') eq "1") { &detect_remote_calendars(); exit(0); } if ($q->param('remote_calendar_request') eq "1") { &remote_calendar_request(); exit(0); } if ($q->param('add_edit_user') eq "1") { &add_edit_user(); exit(0); } if ($q->param('add_new_ical') eq "1") { &add_new_ical(); exit(0); } if ($q->param('js_login') eq "1") { &js_login(); exit(0); } if ($q->param('manage_pending_events') eq "1") { &manage_pending_events(); exit(0); } if ($q->param('export_calendar') eq "1") { &normalize_timezone(); if ($q->param('export_type') eq "ascii_text") { &ascii_text_cal($cal_start_month, $cal_start_year, $cal_end_month, $cal_end_year); exit(0); } elsif ($q->param('export_type') eq "csv_file") { &csv_file($cal_start_month, $cal_start_year, $cal_end_month, $cal_end_year); exit(0); } elsif ($q->param('export_type') eq "csv_file_palm") { &csv_file_palm($cal_start_month, $cal_start_year, $cal_end_month, $cal_end_year); exit(0); } elsif ($q->param('export_type') eq "vcalendar") { &vcalendar_export_cal($cal_start_month, $cal_start_year, $cal_end_month, $cal_end_year); exit(0); } } if ($q->param('export_event') eq "1") { if ($q->param('export_type') eq "ascii_text") { &ascii_text_event(); exit(0); } elsif ($q->param('export_type') eq "icalendar") { &icalendar_export_event(); exit(0); } elsif ($q->param('export_type') eq "vcalendar") { &vcalendar_export_event(); exit(0); } } elsif ($q->param('view_event') eq "1") { &load_templates(); &view_event(); exit(0); } elsif ($q->param('view_pending_event') eq "1") { &load_templates(); my %pending_event = %{$new_events{$pending_event_id}}; &view_pending_event(\%pending_event); exit(0); } elsif ($q->param('email_reminder') eq "1") { &load_templates(); &email_reminder_prompt(); exit(0); } elsif ($q->param('email_reminder_confirm') eq "1") { &load_templates(); &email_reminder_confirm(); exit(0); } elsif ($special_action eq "preview_event") { &load_templates(); &preview_event(); exit(0); } elsif ($special_action eq "preview_date") { &load_templates(); &preview_date(); exit(0); } elsif ($q->param('validate_event') eq "1") { &validate_event(); exit(0); } #load templates &load_templates(); # ssi-style includes in the template if ($local_template_file) { my $new_html = $template_html; $template_html =~ s/###include\s+(.+)###/&load_file($1)/ge; #while ($new_html =~ s/###include\s+(.+)###//g) if(0) { my $include_file=$1; if (-e $include_file) { open (FH, "$include_file") || ($debug_info .="
unable to open include file $include_file for reading
"); flock FH,2; my @include_lines=; close FH; $include_html = join "", @include_lines; } $template_html =~ s/###include\s+(.+)###/$include_html/; } } if($options{choose_themes}) { my $theme_file="choose_theme.html"; my $theme_html=""; if (-e $theme_file) { open (FH, "$theme_file") || ($debug_info .="
unable to open theme file $theme_file for reading
"); flock FH,2; my @theme_lines=; close FH; $theme_html = join "", @theme_lines; } $template_html =~ s/###choose theme###/$theme_html/; } else { $template_html =~ s/###choose theme###//; } my $view_cookie = &xml_store($cal_start_month, "cal_start_month"); $view_cookie .= &xml_store($cal_start_year, "cal_start_year"); $view_cookie .= &xml_store($cal_num_months, "cal_num_months"); $view_cookie .= &xml_store($current_cal_id, "cal_id"); $view_cookie .= &xml_store($display_type, "display_type"); $cookie_text .= " plans_view=$view_cookie;"; $cookie_header_text = "Set-Cookie:$cookie_text path=/;\n"; #$debug_info .= "cookie: $cookie_header_text\n"; $html_output .=< p1 chomp $insert_text; $html_output =~ s/###javascript stuff###/$insert_text/; # sneak in the color select javascript before all other javascript. my $temp =< p1 $html_output =~ s/( "inactive", html => "$lang{tab_text}[0]"}; $menu_tabs[1] = {status => "inactive", html => "$lang{tab_text}[1]"}; $menu_tabs[2] = {status => "inactive", html => "$lang{tab_text}[2]"}; $menu_tabs[$active_tab]{status} ="active"; $menu_tabs[2]{html} = "$lang{tab_text}[2]"; $insert_text =<
p1 # this kludge sucks! if ($browser_type eq "IE") {$tab_vert_offset=4;} else {$tab_vert_offset=0;} #lay out the actual menu tabs for ($l1=0;$l1       $$menu_tab{html}       p1 $noinsert_text .=<$$menu_tab{html}       p1 } $insert_text .=< p1 chomp $insert_text; if ($q->param('custom_calendar') == 1) { $html_output =~ s/###tab menu stuff###//g; } else { $html_output =~ s/###tab menu stuff###/$insert_text/g; } $insert_text =""; #invisible html for context menu $insert_text .=<
p1 #main box stuff $insert_text .=<$prev_string p1 $next_month_link .=<$next_string p1 my $cal_controls_text =<
$lang{controls_start_month}:
$lang{controls_num_months}
p1 $cal_controls_text .=< $lang{controls_calendar_label}
p1 my $num_selectable_calendars = scalar keys %{$current_calendar{selectable_calendars}}; my @selectable_calendars; if ($options{all_calendars_selectable}) { @selectable_calendars = keys %calendars; } else { @selectable_calendars = keys %{$current_calendar{selectable_calendars}}; } if (scalar @selectable_calendars > 1) { $cal_controls_text .=< p1 #list each calendar for the user to select my %explicit_calendar_order; if ($options{calendar_select_order} ne "alpha" && $options{calendar_select_order} ne "") { my @cal_order_ids = split(',',$options{calendar_select_order}); my $cal_order_index = 0; foreach $cal_order_id (@cal_order_ids) { $explicit_calendar_order{$cal_order_id} = $cal_order_index; $cal_order_index++; } } foreach $selectable_calendar_id (sort { if ($options{calendar_select_order} eq "alpha") { return lc $calendars{$a}{title} cmp lc $calendars{$b}{title}; } elsif ($options{calendar_select_order} ne "") {return $explicit_calendar_order{$a} <=> $explicit_calendar_order{$b};} else {return $a <=> $b;} } @selectable_calendars) { my $selected =""; $selected =" selected" if ($selectable_calendar_id eq $current_calendar{id}); $selectable_calendar_id=~ s/\D//g; $cal_controls_text .=<$calendars{$selectable_calendar_id}{title} p1 } $cal_controls_text .=< p1 } else { $cal_controls_text .=<$current_calendar{title} p1 } $cal_controls_text .=< p1 $cal_controls_text .=< $lang{controls_display_label}
p1 $insert_text .= &add_edit_events(); $insert_text .=< p1 #generate javascript for add/edit events page $page_javascript .= &add_edit_events_javascript(); } elsif ($active_tab eq "2") #the third tab is for calendar information { $html_output =~ s/###calendar controls###//; if ($add_edit_cal_action eq "") # calendar management view { $num_new_calendars = scalar keys %new_calendars; if ($num_new_calendars == 0) {$new_calendars_info = $lang{tab2_no_new_calendars};} else { $new_calendars_info = $lang{tab2_some_new_calendars}; $new_calendars_info =~ s/###num###/$num_new_calendars/; } $insert_text .=<
$lang{tab2_select_a_calendar}

$add_edit_string

$lang{fields_text1} $lang{fields_text2} $lang{fields_text3}
$lang{add_edit_calendars_tab0} $lang{add_edit_calendars_tab1} $lang{add_edit_calendars_tab2} $lang{add_edit_calendars_tab3} p1 if ($options{users} eq "1") { $return_text .=<$lang{add_edit_calendars_tab4} p1 } $return_text .=<

$lang{help_on_this}  

 
p1 if ($options{all_calendars_selectable} eq "1") { $return_text.=<$lang{selectable_calendars1}
($lang{selectable_calendars3})
  p1 } else { if (scalar (keys %calendars) > 1 || $add_edit_cal_action ne "edit") { $return_text .=<$lang{selectable_calendars1}
$lang{selectable_calendars2} $lang{help_on_this} $lang{help_on_this}
p1 } } $return_text .=<

$lang{help_on_this}

 

$lang{help_on_this}
$lang{popup_window_size2} $lang{help_on_this}

p1 if ($options{users} eq "1") { $return_text .=<