X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Flib%2FRTx%2FCalendar.pm;h=7ddf186193a452037753fe697cae14ec56b2ab88;hb=cebcd8658ba5f45fc21d59769d591b1418a3fdd2;hp=20568e853530da2dd67a457b376b89f113c8393b;hpb=fb4ab1073f0d15d660c6cdc4e07afebf68ef3924;p=freeside.git diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm index 20568e853..7ddf18619 100644 --- a/rt/lib/RTx/Calendar.pm +++ b/rt/lib/RTx/Calendar.pm @@ -5,9 +5,13 @@ use base qw( Exporter ); use DateTime; use DateTime::Set; -our $VERSION = "0.07"; +our $VERSION = "0.17"; -our @EXPORT_OK = qw( FirstDay LastDay ); +RT->AddStyleSheets('calendar.css') + if RT->can('AddStyleSheets'); + +our @EXPORT_OK = qw( FirstDay LastDay LastDayOfWeek DatesClauses LocalDate + SearchDefaultCalendar FindTickets ); sub FirstDay { my ($year, $month, $matchday) = @_; @@ -34,6 +38,19 @@ sub LastDay { $day; } +sub LastDayOfWeek { + my ($year, $month, $day, $matchday) = @_; + my $set = DateTime::Set->from_recurrence( + next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } + ); + + my $dt = DateTime->new( year => $year, month => $month, day => $day ); + + $dt = $set->next($dt) while $dt->day_of_week != $matchday; + $dt; + +} + # we can't use RT::Date::Date because it uses gmtime # and we need localtime sub LocalDate { @@ -48,7 +65,7 @@ sub DatesClauses { my $clauses = ""; my @DateClauses = map { - "($_ >= '" . $begin . "' AND $_ <= '" . $end . "')" + "($_ >= '" . $begin . " 00:00:00' AND $_ <= '" . $end . " 23:59:59')" } @$Dates; $clauses .= " AND " . " ( " . join(" OR ", @DateClauses) . " ) " if @DateClauses; @@ -82,9 +99,9 @@ sub FindTickets { return %Tickets; } -# +# # Take a user object and return the search with Description "calendar" if it exists -# +# sub SearchDefaultCalendar { my $CurrentUser = shift; my $Description = "calendar"; @@ -104,6 +121,28 @@ sub SearchDefaultCalendar { } } +package RT::Interface::Web::Menu; + +# we should get an add_after method in 4.0.6 (hopefully), but until then +# shim this in so I don't copy the code. +unless (RT::Interface::Web::Menu->can('add_after')) { + *RT::Interface::Web::Menu::add_after = sub { + my $self = shift; + my $parent = $self->parent; + my $sort_order; + for my $contemporary ($parent->children) { + if ( $contemporary->key eq $self->key ) { + $sort_order = $contemporary->sort_order + 1; + next; + } + if ( $sort_order ) { + $contemporary->sort_order( $contemporary->sort_order + 1 ); + } + } + $parent->child( @_, sort_order => $sort_order ); + }; +} + 1; @@ -113,10 +152,6 @@ __END__ 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 @@ -129,16 +164,12 @@ 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 : +You need to install those two modules : - * Date::ICal * Data::ICal * DateTime::Set @@ -206,26 +237,25 @@ 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 - +All bugs should be reported via +L +or L. + =head1 AUTHORS +Best Practical Solutions + Nicolas Chuche Enchuche@barna.beE Idea borrowed from redmine's calendar (Thanks Jean-Philippe). =head1 COPYRIGHT -Copyright 2007 by Nicolas Chuche Enchuche@barna.beE +Copyright 2007-2009 by Nicolas Chuche Enchuche@barna.beE + +Copyright 2010-2012 by Best Practical Solutions. -This program is free software; you can redistribute it and/or +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See L