|
Server : Apache/2.4.62 System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64 User : www ( 80) PHP Version : 8.3.8 Disable Function : NONE Directory : /domains/compasssysweb/calendar/CalciumDir39/Operation/ |
Upload File : |
# Copyright 1999-2003, Fred Steinberg, Brown Bear Software
# This ends up displaying a Calendar; Month, Week, or Year view. Block or List.
package ShowIt;
use strict;
use CGI;
use Calendar::Body;
use Calendar::BottomBars;
use Calendar::Date;
use Calendar::Footer;
use Calendar::Header;
use Calendar::Name;
use Calendar::NavigationBar;
use Calendar::QuickFilterBar;
use Calendar::Title;
use vars ('@ISA');
@ISA = ('Operation');
sub perform {
my $self = shift;
unless ($self->calendarName) {
print $self->redir ($self->makeURL ({Op => 'Splash'}));
return;
}
my ($date) = $self->getParams ('Date');
$date = Date->new ($date);
if (!$date->valid) {
GetHTML->errorPage ($self->I18N,
message => $self->I18N->get ('Invalid Date') .
": $date")
}
my $preferences = $self->prefs;
my ($amount, $navType, $type) = $self->ParseDisplaySpecs ($preferences);
# save stuff in case we're auditing
$self->{audit_date} = $date;
$self->{audit_mode} = "$amount $type";
if ($type =~ /planner/i) {
if ($preferences->getIncludedCalendarNames) {
$amount = 'week' unless $amount =~ /week|day/i;
} else { # no planner view if no included calendars
$type = $preferences->BlockOrList || 'Block';
}
} elsif ($type =~ /timeplan/i) {
if ($amount !~ /month|week|day/i) {
$self->{params}->{Amount} = 'Week'; # hack
$amount = 'week';
}
}
my ($fiscalType, $fiscalEpoch);
if ($amount =~ /fperiod|fyear|fquarter/i) {
$fiscalType = $preferences->FiscalType || '';
if ($fiscalType eq 'floating') {
$fiscalType = 'Date::Fiscal::Floating';
} else {
$fiscalType = 'Date::Fiscal::Fixed';
}
eval "require Calendar::$fiscalType";
die "Couldn't find Calendar::$fiscalType" if $@;
$fiscalEpoch = $preferences->FiscalEpoch || '2002/01/01';
}
my ($startDate, $endDate) = $self->getParams (qw /StartDate EndDate/);
if ($startDate and $endDate) {
$startDate = Date->new ($startDate);
$endDate = Date->new ($endDate);
}
elsif ($amount =~ /month/i) {
# If not in relative mode, always put first of month at top.
# (Also do this if 'Today' was selected.)
my $today = Date->new();
$startDate = Date->new($date);
if ($navType =~ /absolute|neither/i) { # or "$date" eq "$today") {
$startDate = $startDate->firstOfMonth;
}
$endDate = Date->new ($startDate);
($endDate->addMonths(1))->addDays(-1);
# If today is displayed, set it for bottombar links
if ($today->inRange ($startDate, $endDate)) {
$date = $today;
}
}
elsif ($amount =~ /fperiod/i) {
$startDate = $fiscalType->new ($date)->startOfPeriod;
$endDate = $fiscalType->new ($date)->endOfPeriod;
$startDate->epoch ($fiscalEpoch);
$endDate->epoch ($fiscalEpoch);
}
elsif ($amount =~ /week/i) {
my $startWeekOn = $preferences->StartWeekOn || 7; # 7,1-6
$startDate = $date->firstOfWeek ($startWeekOn);
$endDate = Date->new ($startDate) + 6;
}
elsif ($amount =~ /day/i) {
$startDate = Date->new ($date);
$endDate = Date->new ($date);
}
elsif ($amount =~ /fyear|fquarter/i) {
$startDate = $fiscalType->new ($date);
$startDate->epoch ($fiscalEpoch);
if ($amount =~ /fyear/i) {
$startDate = $startDate->startOfYear;
$endDate = $startDate->endOfYear;
} else {
$startDate = $startDate->startOfQuarter;
$endDate = $startDate->endOfQuarter;
}
}
elsif ($amount =~ /quarter/i) {
$startDate = $date->startOfQuarter;
$endDate = $date->endOfQuarter;
}
elsif ($amount =~ /year/i) {
$startDate = Date->new ($date->year, 1, 1);
$endDate = Date->new ($date->year, 12, 31);
} else {
die ("Oops! Bad 'Amount' param to showIt.pl\n");
}
my $printObj;
if ($self->getParams ('PrintView')) {
my ($colors, $title, $header, $footer, $dateHeader, $background) =
$self->getParams (qw /PrintColors PrintTitle PrintHeader
PrintFooter PrintDateHeader
PrintBackground/);
require Calendar::PrintOptions;
my %printParams = (colors => ($colors || 'none'),
title => $title,
header => $header,
footer => $footer,
dateHeader => $dateHeader,
background => $background);
$printObj = PrintOptions->new (%printParams);
$preferences->PrintPrefs ($printObj);
}
# Don't bother parsing both Block and List View.pm files
my ($theView, $savedNavType);
if ($type =~ /block/i) {
require Calendar::BlockView;
$theView = BlockView->new ($self, $startDate->new ($startDate),
$endDate->new ($endDate));
} elsif ($type =~ /planner/i) {
if ($amount =~ /day/i) {
require Calendar::DayPlanner;
$theView = DayPlanner->new ($self, Date->new ($startDate),
Date->new ($endDate));
} else {
require Calendar::MultiView;
$theView = MultiView->new ($self, Date->new ($startDate),
Date->new ($endDate));
$savedNavType = $self->getParams ('NavType');
if ($savedNavType =~ /absolute/i) {
$self->{params}->{NavType} = 'both'; # hack
}
}
} elsif ($type =~ /timeplan/i) {
require Calendar::TimePlanView;
$theView = TimePlanView->new ($self, Date->new ($startDate),
Date->new ($endDate));
} else {
require Calendar::ListView;
$theView = ListView->new ($self, $startDate, $endDate);
}
my $winTitle = $preferences->Description;
my $css; # if printing, don't underline links
if ($preferences->PrintPrefs) {
$css = qq {
A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: none}
};
$winTitle = $self->I18N->get ('Printable View') .
': ' . $self->calendarName;
}
# Build the page
my @page;
push @page, Header->new ($winTitle, $css);
push @page, Body->new ($preferences,
QuickFilterBar->new ($self),
Name->new ($preferences, $printObj),
$printObj ? undef
: NavigationBar->new ($self, $startDate,
'top'),
!$printObj || $printObj->dateHeader ?
Title->new ($self, $amount, $type,
$startDate, $endDate) : undef,
$theView,
!$printObj || $printObj->footer ?
Footer->new ($preferences) : undef,
$printObj ? undef :
NavigationBar->new ($self, $startDate,
'bottom'),
$printObj ? undef :
BottomBars->new ($self, $date));
$self->{params}->{NavType} = $savedNavType if $savedNavType; # hack
# And print it all out!
my $cgi = new CGI;
# If we did before, re-set cookie for display params
# (only needed if separate popup window needs it.)
if ($cgi->cookie ('CalciumDisplayParams')) {
print $cgi->header (-cookie => $self->displayParamCookie);
} else {
print $cgi->header;
}
foreach (@page) {
print $_->getHTML(), "\n";
}
print $cgi->end_html
unless (($ENV{SERVER_PROTOCOL} || '') eq 'INCLUDED');
}
# Pass listref of events, return those that are not Tentative, or that we
# have Edit permission for
sub removeTentatives {
my ($self, $events) = @_;
my @keepers;
my $calName = $self->calendarName;
$self->{_canEdit} ||= {};
foreach (@$events) {
if ($_->isTentative) {
my $cal = $_->includedFrom || $calName;
if (!exists $self->{_canEdit}->{$cal}) {
my $perm = Permissions->new ($cal);
$self->{_canEdit}->{$cal} =
$perm->permitted ($self->getUsername, 'Edit');
}
next unless ($self->{_canEdit}->{$cal});
}
push @keepers, $_;
}
return @keepers;
}
sub auditString {
my ($self, $short) = @_;
my $line = $self->SUPER::auditString ($short);
$line .= ' ' . $self->{audit_date} . ' ' . $self->{audit_mode};
}
1;