From fec244eb00508517cd3313f6cf55973c2d2e99cf Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Thu, 7 Jun 2012 17:20:16 -0700 Subject: [PATCH] merge RTx-Calendar 0.14 --- rt/lib/RTx/Calendar.pm | 61 +++++++++++------- .../Callbacks/RTx-Calendar/Elements/Header/Head | 3 + .../RTx-Calendar/Elements/Tabs/Privileged | 73 ++++++++++++++++++++++ .../RTx-Calendar/Ticket/Elements/Tabs/Default | 2 +- rt/share/html/Elements/CalendarEvent | 8 +-- rt/share/html/NoAuth/Calendar/dhandler | 6 +- rt/share/html/NoAuth/css/calendar.css | 10 +-- rt/share/html/Prefs/Calendar.html | 11 ++-- rt/share/html/Search/Calendar.html | 9 ++- 9 files changed, 136 insertions(+), 47 deletions(-) create mode 100644 rt/share/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged diff --git a/rt/lib/RTx/Calendar.pm b/rt/lib/RTx/Calendar.pm index 20568e853..e297566f0 100644 --- a/rt/lib/RTx/Calendar.pm +++ b/rt/lib/RTx/Calendar.pm @@ -5,7 +5,10 @@ use base qw( Exporter ); use DateTime; use DateTime::Set; -our $VERSION = "0.07"; +our $VERSION = "0.14"; + +RT->AddStyleSheets('calendar.css') + if RT->can('AddStyleSheets'); our @EXPORT_OK = qw( FirstDay LastDay ); @@ -48,7 +51,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 +85,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 +107,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 +138,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,9 +150,6 @@ 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. @@ -206,26 +224,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 diff --git a/rt/share/html/Callbacks/RTx-Calendar/Elements/Header/Head b/rt/share/html/Callbacks/RTx-Calendar/Elements/Header/Head index c1f24c2b4..dcaaa1279 100644 --- a/rt/share/html/Callbacks/RTx-Calendar/Elements/Header/Head +++ b/rt/share/html/Callbacks/RTx-Calendar/Elements/Header/Head @@ -1,2 +1,5 @@ +<%init> +return if RT->can('AddStyleSheets'); + diff --git a/rt/share/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged b/rt/share/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged new file mode 100644 index 000000000..31ed90aea --- /dev/null +++ b/rt/share/html/Callbacks/RTx-Calendar/Elements/Tabs/Privileged @@ -0,0 +1,73 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC +%# +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%INIT> +my $request_path = $HTML::Mason::Commands::r->path_info; + +my $query_string = sub { + my %args = @_; + my $u = URI->new(); + $u->query_form(%args); + return $u->query; +}; + +if ( $request_path =~ qr{^/Search/} && $m->request_args->{Query} ) { + my $tabs = PageMenu; + my $chart = $tabs->child('chart'); + $chart->add_after( 'calendar' => title => loc('Calendar'), + path => '/Search/Calendar.html?' . $query_string->( %{$m->request_args} ) ); +} + +my $about_me = Menu->child( 'preferences' ); +my $settings = $about_me ? $about_me->child('settings') : undef; + +if ( $settings ) { + $settings->child( 'calendar' => title => loc('Calendar'), + path => '/Prefs/Calendar.html' ); +} + + diff --git a/rt/share/html/Callbacks/RTx-Calendar/Ticket/Elements/Tabs/Default b/rt/share/html/Callbacks/RTx-Calendar/Ticket/Elements/Tabs/Default index cb46fdaf6..b6d390598 100644 --- a/rt/share/html/Callbacks/RTx-Calendar/Ticket/Elements/Tabs/Default +++ b/rt/share/html/Callbacks/RTx-Calendar/Ticket/Elements/Tabs/Default @@ -1,4 +1,4 @@ -<%init> +<%init> my $args; $args= "?" . $m->comp( '/Elements/QueryString', diff --git a/rt/share/html/Elements/CalendarEvent b/rt/share/html/Elements/CalendarEvent index 3a6b00bb8..65dd58c9f 100644 --- a/rt/share/html/Elements/CalendarEvent +++ b/rt/share/html/Elements/CalendarEvent @@ -13,11 +13,11 @@ $DateTypes => undef % and RTx::Calendar::LocalDate($Object->ResolvedObj->Unix) eq $today) { -% } elsif ($DateTypes->{Starts} and $DateTypes->{Due} +% } elsif ($DateTypes->{Starts} and $DateTypes->{Due} % and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today ) { -% } elsif ($DateTypes->{Due} and $DateTypes->{Created} +% } elsif ($DateTypes->{Due} and $DateTypes->{Created} % and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today and RTx::Calendar::LocalDate($Object->CreatedObj->Unix) eq $today ) { @@ -25,7 +25,7 @@ $DateTypes => undef % and RTx::Calendar::LocalDate($Object->StartsObj->Unix) eq $today) { -% } elsif ($DateTypes->{Due} +% } elsif ($DateTypes->{Due} % and RTx::Calendar::LocalDate($Object->DueObj->Unix) eq $today) { @@ -64,7 +64,7 @@ $DateTypes => undef % my $method = '$Object->'.$attr.'()'; % $method =~ s/->ISO\(\)$/->ISO( Timezone => 'user' )/; % $value = eval $method; -% if ($@) {die "Check your CalendarPopupFields config in etc/RT_SiteConfig.pm.

Failed to find \"$attr\" - ". $@}; +% if ($@) {die "Check your CalendarPopupFields config in etc/RT_SiteConfig.pm.

Failed to find \"$attr\" - ". $@}; % } <&|/l&><% $label_of{$attr} %>: <% $value %>
% } diff --git a/rt/share/html/NoAuth/Calendar/dhandler b/rt/share/html/NoAuth/Calendar/dhandler index 4b4aa631e..ea08c9a76 100644 --- a/rt/share/html/NoAuth/Calendar/dhandler +++ b/rt/share/html/NoAuth/Calendar/dhandler @@ -101,14 +101,14 @@ my $cal = $calendar->as_string; $r->content_type('text/calendar;charset=utf-8'); $m->clear_buffer(); $m->out($cal); -$m->abort; +$m->abort; sub add_event { my ($Reminder, $uid) = @_; return unless defined $Reminder->RefersTo->First; my $Ticket = $Reminder->RefersTo->First->TargetObj; - + my %event = ( summary => $Reminder->Subject ? $Reminder->Subject : '', url => "${RT::WebURL}/Ticket/Display.html?id=" . $Ticket->id, @@ -142,7 +142,7 @@ sub add_todo { $vtodo{attendee} = "MAILTO:" . $Ticket->OwnerObj->EmailAddress; } elsif ($Ticket->QueueObj->CommentAddress) { $vtodo{organizer} = "MAILTO:" . $Ticket->QueueObj->CommentAddress; - $vtodo{attendee} = "MAILTO:" . $Ticket->QueueObj->CommentAddress; + $vtodo{attendee} = "MAILTO:" . $Ticket->QueueObj->CommentAddress; } $vtodo{priority} = $Ticket->Priority diff --git a/rt/share/html/NoAuth/css/calendar.css b/rt/share/html/NoAuth/css/calendar.css index c6b584e96..93edccf4c 100644 --- a/rt/share/html/NoAuth/css/calendar.css +++ b/rt/share/html/NoAuth/css/calendar.css @@ -1,8 +1,8 @@ -.tooltip{position:relative;z-index:1;} -.tooltip:hover{z-index:5;color:#000;} -.tooltip span.tip{display: none; text-align:left;} +.rtxcalendar .tooltip{position:relative;z-index:1;} +.rtxcalendar .tooltip:hover{z-index:5;color:#000;} +.rtxcalendar .tooltip span.tip{display: none; text-align:left;} -div.tooltip:hover span.tip{ +.rtxcalendar div.tooltip:hover span.tip{ display:block; position:absolute; top:12px; left:24px; width:350px; @@ -13,7 +13,7 @@ font-size: 0.8em; color:#505050; } -.calendardate { +.rtxcalendar .date { text-align: right; background-color: #f8f8ff; width:100%; diff --git a/rt/share/html/Prefs/Calendar.html b/rt/share/html/Prefs/Calendar.html index 5fbdd2717..b508d103b 100644 --- a/rt/share/html/Prefs/Calendar.html +++ b/rt/share/html/Prefs/Calendar.html @@ -6,10 +6,7 @@ $HiddenField => undef <& /Elements/Header, Title => $title &> -<& /User/Elements/Tabs, - current_tab => 'Prefs/Calendar.html', - Title => $title -&> +<& /Elements/Tabs &> <&| /Widgets/TitleBox, title => loc('ICal Feeds (ics)') &> @@ -50,7 +47,7 @@ Builder")%>.

<& /Prefs/Elements/CalendarFeed &> -% # only allow this part if +% # only allow this part if % if ($AllowSearch) { % my $search_count; @@ -107,9 +104,9 @@ $AllowSearch = 1 my $object; -if ($HiddenField eq 'Private') { +if ($HiddenField && $HiddenField eq 'Private') { $object = $session{CurrentUser}->UserObj; -} elsif ($AllowSearch and my ($SearchId) = $HiddenField =~ m/SavedSearch\-(\d+)/) { +} elsif ($AllowSearch and $HiddenField my ($SearchId) = $HiddenField =~ m/SavedSearch\-(\d+)/) { $object = $session{CurrentUser}->Attributes->WithId($SearchId); } diff --git a/rt/share/html/Search/Calendar.html b/rt/share/html/Search/Calendar.html index 9d2b6f546..8a1b79609 100644 --- a/rt/share/html/Search/Calendar.html +++ b/rt/share/html/Search/Calendar.html @@ -10,9 +10,8 @@ $NewQuery => 0 <& /Elements/Header, Title => $title &> -<& /Ticket/Elements/Tabs, - current_tab => "Search/Calendar.html?$QueryString", - Title => $title &> +<& /Elements/Tabs &> + <&| /Widgets/TitleBox, title => loc('Calendar for ') . $rtdate->GetMonth($Month) . " $Year" , title_class=> 'inverse', @@ -195,7 +194,7 @@ my $set = DateTime::Set->from_recurrence( next => sub { $_[0]->truncate( to => 'day' )->add( days => 1 ) } ); -my $QueryString = +my $QueryString = $m->comp( '/Elements/QueryString', Query => $Query, @@ -212,7 +211,7 @@ $QueryString ||= 'NewQuery=1'; my $TempFormat = "__Starts__ __Due__"; my $TempQuery = "( Status = 'new' OR Status = 'open' OR Status = 'stalled') AND ( Owner = '" . $session{CurrentUser}->Id ."' OR Owner = 'Nobody' ) - AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; + AND ( Type = 'reminder' OR 'Type' = 'ticket' )"; if ( my $Search = RTx::Calendar::SearchDefaultCalendar($session{CurrentUser}) ) { $TempFormat = $Search->SubValue('Format'); -- 2.11.0