diff options
Diffstat (limited to 'rt/lib/RTx')
-rw-r--r-- | rt/lib/RTx/Calendar.pm | 233 | ||||
-rwxr-xr-x | rt/lib/RTx/Statistics.pm | 239 | ||||
-rw-r--r-- | rt/lib/RTx/WebCronTool.pm | 41 |
3 files changed, 0 insertions, 513 deletions
diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm deleted file mode 100644 index 20568e853..000000000 --- a/rt/lib/RTx/Calendar.pm +++ /dev/null @@ -1,233 +0,0 @@ -package RTx::Calendar; - -use strict; -use base qw( Exporter ); -use DateTime; -use DateTime::Set; - -our $VERSION = "0.07"; - -our @EXPORT_OK = qw( FirstDay LastDay ); - -sub FirstDay { - my ($year, $month, $matchday) = @_; - my $set = DateTime::Set->from_recurrence( - next => sub { $_[0]->truncate( to => 'day' )->subtract( days => 1 ) } - ); - - my $day = DateTime->new( year => $year, month => $month ); - - $day = $set->next($day) while $day->day_of_week != $matchday; - $day; - -} - -sub LastDay { - my ($year, $month, $matchday) = @_; - my $set = DateTime::Set->from_recurrence( - next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } - ); - - my $day = DateTime->last_day_of_month( year => $year, month => $month ); - - $day = $set->next($day) while $day->day_of_week != $matchday; - $day; -} - -# we can't use RT::Date::Date because it uses gmtime -# and we need localtime -sub LocalDate { - my $ts = shift; - my ($d,$m,$y) = (localtime($ts))[3..5]; - sprintf "%4d-%02d-%02d", ($y + 1900), ++$m, $d; -} - -sub DatesClauses { - my ($Dates, $begin, $end) = @_; - - my $clauses = ""; - - my @DateClauses = map { - "($_ >= '" . $begin . "' AND $_ <= '" . $end . "')" - } @$Dates; - $clauses .= " AND " . " ( " . join(" OR ", @DateClauses) . " ) " - if @DateClauses; - - return $clauses -} - -sub FindTickets { - my ($CurrentUser, $Query, $Dates, $begin, $end) = @_; - - $Query .= DatesClauses($Dates, $begin, $end) - if $begin and $end; - - my $Tickets = RT::Tickets->new($CurrentUser); - $Tickets->FromSQL($Query); - - my %Tickets; - my %AlreadySeen; - - while ( my $Ticket = $Tickets->Next()) { - - # How to find the LastContacted date ? - for my $Date (@$Dates) { - my $DateObj = $Date . "Obj"; - push @{ $Tickets{ LocalDate($Ticket->$DateObj->Unix) } }, $Ticket - # if reminder, check it's refering to a ticket - unless ($Ticket->Type eq 'reminder' and not $Ticket->RefersTo->First) - or $AlreadySeen{ LocalDate($Ticket->$DateObj->Unix) }{ $Ticket }++; - } - } - return %Tickets; -} - -# -# Take a user object and return the search with Description "calendar" if it exists -# -sub SearchDefaultCalendar { - my $CurrentUser = shift; - my $Description = "calendar"; - - # I'm quite sure the loop isn't usefull but... - my @Objects = $CurrentUser->UserObj; - for my $object (@Objects) { - next unless ref($object) eq 'RT::User' && $object->id == $CurrentUser->Id; - my @searches = $object->Attributes->Named('SavedSearch'); - for my $search (@searches) { - next if ($search->SubValue('SearchType') - && $search->SubValue('SearchType') ne 'Ticket'); - - return $search - if "calendar" eq $search->Description; - } - } -} - - -1; - -__END__ - -=head1 NAME - -RTx::Calendar - Calendar for RT due tasks - -=head1 VERSION - -This document describes version 0.07 of RTx::Calendar - -=head1 DESCRIPTION - -This RT extension provides a calendar view for your tickets and your -reminders so you see when is your next due ticket. You can find it in -the menu Search->Calendar. - -There's a portlet to put on your home page (see Prefs/MyRT.html) - -You can also enable ics (ICal) feeds for your default calendar and all -your private searches in Prefs/Calendar.html. Authentication is magic -number based so that you can give those feeds to other people. - -You can find screenshots on -http://gaspard.mine.nu/dotclear/index.php?tag/rtx-calendar - -=head1 INSTALLATION - -If you upgrade from 0.02, see next part before. - -You need to install those three modules : - - * Date::ICal - * Data::ICal - * DateTime::Set - -Install it like a standard perl module - - perl Makefile.PL - make - make install - -If your RT is not in the default path (/opt/rt3) you must set RTHOME -before doing the Makefile.PL - -=head1 CONFIGURATION - -=head2 Base configuration - -In RT 3.8 and later, to enable calendar plugin, you must add something -like that in your etc/RT_SiteConfig.pm : - - Set(@Plugins,(qw(RTx::Calendar))); - -To use MyCalendar portlet you must add MyCalendar to -$HomepageComponents in etc/RT_SiteConfig.pm like that : - - Set($HomepageComponents, [qw(QuickCreate Quicksearch MyCalendar - MyAdminQueues MySupportQueues MyReminders RefreshHomepage)]); - -To enable private searches ICal feeds, you need to give -CreateSavedSearch and LoadSavedSearch rights to your users. - -=head2 Display configuration - -You can show the owner in each day box by adding this line to your -etc/RT_SiteConfig.pm : - - Set($CalendarDisplayOwner, 1); - -You can change which fields show up in the popup display when you -mouse over a date in etc/RT_SiteConfig.pm : - - @CalendarPopupFields = ('Status', 'OwnerObj->Name', 'DueObj->ISO'); - -=head2 ICAL feed configuration - -By default, tickets are todo and reminders event. You can change this -by setting $RT::ICalTicketType and $RT::ICalReminderType in etc/RT_SiteConfig.pm : - - Set($ICalTicketType, "Data::ICal::Entry::Event"); - Set($ICalReminderType ,"Data::ICal::Entry::Todo"); - -=head1 USAGE - -A small help section is available in /Prefs/Calendar.html - -=head1 UPGRADE FROM 0.02 - -As I've change directory structure, if you upgrade from 0.02 you need -to delete old files manually. Go in RTHOME/share/html (by default -/opt/rt3/share/html) and delete those files : - - rm -rf Callbacks/RTx-Calendar - rm Tools/Calendar.html - -RTx-Calendar may work without this but it's not very clean. - -=head1 BUGS - -=over - -=item * -compatible only with RT 3.6 for the moment. If someone need -compatibility with 3.4 I can work on this. And I will work on 3.7 -compatibility later. - -=back - -=head1 AUTHORS - -Nicolas Chuche E<lt>nchuche@barna.beE<gt> - -Idea borrowed from redmine's calendar (Thanks Jean-Philippe). - -=head1 COPYRIGHT - -Copyright 2007 by Nicolas Chuche E<lt>nchuche@barna.beE<gt> - -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -See L<http://www.perl.com/perl/misc/Artistic.html> - -=cut diff --git a/rt/lib/RTx/Statistics.pm b/rt/lib/RTx/Statistics.pm deleted file mode 100755 index 8b9d6e4f0..000000000 --- a/rt/lib/RTx/Statistics.pm +++ /dev/null @@ -1,239 +0,0 @@ -package Statistics; - -use vars qw( -$MultiQueueStatus $MultiQueueDateFormat @MultiQueueQueueList $MultiQueueMaxRows $MultiQueueWeekends $MultiQueueLabelDateFormat -$PerDayStatus $PerDayDateFormat $PerDayQueue $PerDayMaxRows $PerDayWeekends $PerDayLabelDateFormat $PerDayPeriod -$DayOfWeekQueue -@OpenStalledQueueList $OpenStalledWeekends -$TimeToResolveDateFormat $TimeToResolveQueue $TimeToResolveMaxRows $TimeToResolveWeekends $TimeToResolveLabelDateFormat -$TimeToResolveGraphQueue -@years @months %monthsMaxDay -$secsPerDay -$RestrictAccess -$GraphWidth $GraphHeight -); - -use Time::Local; - -# I couldn't figure out a way to override these in RT_SiteConfig, which would be -# preferable. - -# Width and Height of all graphics -$GraphWidth=500; -$GraphHeight=400; - -# Initial settings for the CallsMultiQueue stat page -$MultiQueueStatus = "resolved"; -$MultiQueueDateFormat = "%a %b %d %Y"; # format for dates on Multi Queue report, see "man strftime" for options -@MultiQueueQueueList = ("General"); # list of queues to start Multi Queue per day reports -$MultiQueueMaxRows = 10; -$MultiQueueWeekends = 1; -$MultiQueueLabelDateFormat = "%a"; - -# Initial settings for the CallsQueueDay stat page -$PerDayStatus = "resolved"; -$PerDayDateFormat = "%a %b %d %Y"; -$PerDayQueue = "General"; -$PerDayMaxRows = 10; -$PerDayWeekends = 1; -$PerDayLabelDateFormat = "%a"; -$PerDayPeriod = 10; - -# Initial settings for the DayOfWeek stat page -$DayOfWeekQueue = "General"; - -# Initial settings for the OpenStalled stat page -@OpenStalledQueueList = ("General"); -$OpenStalledWeekends = 1; - -# Initial settings for the TimeToResolve stat page -$TimeToResolveDateFormat = "%a %b %d"; -$TimeToResolveQueue = "General"; -$TimeToResolveMaxRows = 10; -$TimeToResolveWeekends = 1; -$TimeToResolveLabelDateFormat = "%a"; - -# Initial settings for the TimeToResolve Graph page -$TimeToResolveGraphQueue = "General"; - -$secsPerDay = 86400; - -# List of years and months to populate drop down lists -@years =('2010', '2009', '2008', '2007', '2006', '2005', '2004', '2003' ,'2003' ,'2002'); -@months=qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; -%monthsMaxDay = ( - 0 => 31, # January - 1 => 29, # February, allow for leap year - 2 => 31, # March - 3 => 30, # April - 4 => 31, # May - 5 => 30, # June - 6 => 31, # July - 7 => 31, # August - 8 => 30, # September - 9 => 31, # October - 10=> 30, # November - 11=> 31 # December - ); - -# Set to one to prevent users without the ShowConfigTab right from seeing Statistics -$RestrictAccess = 0; - -# Variables to control debugging -my $debugging=0; # set to 1 to enable debugging -my $debugtext=""; - -=head2 FormatDate - -Returns a string representing the specified date formatted by the specified string - -=cut -sub FormatDate { - my $fmt = shift; - my $self = shift; - return POSIX::strftime($fmt, localtime($self->Unix)); -} - - -=head2 RTDateSetToLocalMidnight - -Sets the date to midnight (at the beginning of the day) local time -Returns the unixtime at midnight. - -=cut -sub RTDateSetToLocalMidnight { - my $self = shift; - - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime($self->Unix); - $self->Unix(timelocal (0,0,0,$mday,$mon,$year,$wday,$yday)); - - return ($self->Unix); -} - -=head2 RTDateIsWeekend - -Returns 1 if the date is on saturday or sunday - -=cut -sub RTDateIsWeekend { - my $self = shift; - - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime($self->Unix); - return 1 if (($wday==6) || ($wday==0)); - 0; -} - -=head2 RTDateGetDateWeekday - -Returns the localized name of the day specified by date - -=cut -sub RTDateGetDateWeekday { - my $self = shift; - - my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday) = localtime($self->Unix); - return $self->GetWeekday($wday); -} - -=head2 RTDateSubDay - -Subtracts 24 hours from the current time - -=cut - -sub RTDateSubDay { - my $self = shift; - $self->AddSeconds(0 - $DAY); -} - -=head2 RTDateSubDays $DAYS - -Subtracts 24 hours * $DAYS from the current time - -=cut - -sub RTDateSubDays { - my $self = shift; - my $days = shift; - $self->AddSeconds(0 - ($days * $DAY)); -} - -=head2 DebugInit - -Creates a text area on the page if debugging is on. - -=cut - -sub DebugInit { - if($debugging) { - my $m = shift; - $m->print("<TEXTAREA NAME=debugarea COLS=120 ROWS=50>$debugtext</TEXTAREA>\n"); - } -} - -=head2 DebugLog $logmsg - -Adds a message to the debug area - -=cut - -sub DebugLog { - if($debugging) { - my $line = shift; - $debugtext .= $line; - $RT::Logger->debug($line); - } -} - -=head2 DebugClear - -Clears the current debug string, otherwise it builds from page to page - -=cut - -sub DebugClear { - if($debugging) { - $debugtext = undef; - } -} - -=head2 DurationAsString - -Returns a string representing the specified duration - -=cut - -sub DurationAsString { - my $Duration = shift; - my $MINUTE = 60; - my $HOUR = $MINUTE*60; - my $DAY = $HOUR * 24; - my $WEEK = $DAY * 7; - my $days = int($Duration / $DAY); - $Duration = $Duration % $DAY; - my $hours = int($Duration / $HOUR); - $hours = sprintf("%02d", $hours); - $Duration = $Duration % $HOUR; - my $minutes = int($Duration/$MINUTE); - $minutes = sprintf("%02d", $minutes); - $Duration = $Duration % $MINUTE; - my $secs = sprintf("%02d", $Duration); - - if(!$days) { - $days = "00"; - } - if(!$hours) { - $hours = "00"; - } - if(!$minutes) { - $minutes = "00"; - } - if(!$secs) { - $secs = "00"; - } - return "$days days $hours:$minutes:$secs"; -} - -1; - - diff --git a/rt/lib/RTx/WebCronTool.pm b/rt/lib/RTx/WebCronTool.pm deleted file mode 100644 index 5f086a279..000000000 --- a/rt/lib/RTx/WebCronTool.pm +++ /dev/null @@ -1,41 +0,0 @@ -package RTx::WebCronTool; -$RTx::WebCronTool::VERSION = "0.01"; - -1; - -__END__ - -=head1 NAME - -RTx::WebCronTool - Web interface to rt-crontool - -=head1 VERSION - -This document describes version 0.01 of RTx::WebCronTool, released -July 11, 2004. - -=head1 DESCRIPTION - -This RT extension provides a web interface for the built-in F<rt-crontool> -utility, allowing scheduled processes to be launched remotely. - -After installation, log in as superuser, and click on the "Web CronTool" menu -on the bottom of the navigation pane. - -To use it, simply submit the modules and arguments. All progress, error messages -and debug information will then be displayed online. - -=head1 AUTHORS - -Autrijus Tang E<lt>autrijus@autrijus.orgE<gt> - -=head1 COPYRIGHT - -Copyright 2004 by Autrijus Tang E<lt>autrijus@autrijus.orgE<gt>. - -This program is free software; you can redistribute it and/or -modify it under the same terms as Perl itself. - -See L<http://www.perl.com/perl/misc/Artistic.html> - -=cut |