Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / share / html / NoAuth / iCal / dhandler
index 338db8b..988488f 100644 (file)
@@ -90,30 +90,60 @@ while (my $t = $tickets->Next) {
 
     my $starttime = $t->StartsObj->Unix > 0 ? $t->StartsObj : $t->CreatedObj;
 
+    my $url;
+    if ( RT->Config->Get('CanonicalizeURLsInFeeds') ) {
+        $url = RT->Config->Get('WebURL');
+    }
+    else {
+        $url = RT::Interface::Web::GetWebURLFromRequest();
+    }
+    $url .= "Ticket/Display.html?id=".$t->id,
+
     my $now = RT::Date->new( $cu ); $now->SetToNow;
     my $start = Data::ICal::Entry::Event->new;
     my $end   = Data::ICal::Entry::Event->new;
+
+
     $_->add_properties(
-        url       => RT->Config->Get('WebURL') . "Ticket/Display.html?id=".$t->id,
-        organizer => $t->OwnerObj->Name,
-        dtstamp   => $now->iCal,
-        created   => $t->CreatedObj->iCal,
+        url            => $url,
+        description    => $url,
+        organizer      => $t->OwnerObj->Name,
+        dtstamp        => $now->iCal,
+        created        => $t->CreatedObj->iCal,
        'last-modified' => $t->LastUpdatedObj->iCal,
     ) for $start, $end;
 
-    $start->add_properties(
-        summary   => "Start: ".$t->Subject,
-        dtstart   => [$starttime->iCal( Time => 0 ) => { value => 'DATE' }],
-        dtend     => [$starttime->iCal( Time => 0 ) => { value => 'DATE'}],
-    );
-    $end->add_properties(
-        summary   => "Due: ".$t->Subject,
-        dtstart   => [$t->DueObj->iCal( Time => 0 ) => { value => 'DATE' }],
-        dtend     => [$t->DueObj->iCal( Time => 0 ) => { value => 'DATE' }],
-    );
-
-    $feed->add_entry($start);
-    $feed->add_entry($end);
+    my %time = ( Time => 0 );
+    my %ical_value = ( value => 'DATE' );
+
+    if ( defined $ARGS{Time} ?
+         $ARGS{Time} : RT->Config->Get('TimeInICal', $user) ) {
+        $time{Time} = 1;
+        $ical_value{value} = 'DATE-TIME';
+    }
+
+    if( $ARGS{SingleEvent} ){
+        $start->add_properties(
+                               summary   => $t->Subject,
+                               dtstart   => [$starttime->iCal( %time ) => \%ical_value ],
+                               dtend     => [$t->DueObj->iCal( %time ) => \%ical_value ],
+                              );
+        $feed->add_entry($start);
+    }
+    else{
+        $start->add_properties(
+                               summary   => "Start: ".$t->Subject,
+                               dtstart   => [$starttime->iCal( %time ) => \%ical_value ],
+                               dtend     => [$starttime->iCal( %time ) => \%ical_value ],
+                              );
+        $end->add_properties(
+                             summary   => "Due: ".$t->Subject,
+                             dtstart   => [$t->DueObj->iCal( %time ) => \%ical_value ],
+                             dtend     => [$t->DueObj->iCal( %time ) => \%ical_value ],
+                            );
+        $feed->add_entry($start);
+        $feed->add_entry($end);
+    }
 }
 
 $m->clear_buffer;