57eb007f6fe7bf5f1450fbe62b5d812fb2dfe881
[freeside.git] / rt / share / html / Prefs / Calendar.html
1 <%args>
2 $ChangeURL   => undef
3 $ResetURL    => undef
4 $SearchType  => 'Ticket'
5 $HiddenField => undef
6 </%args>
7
8 <& /Elements/Header, Title => $title &>
9 <& /Elements/Tabs &>
10
11 <&| /Widgets/TitleBox, title => loc('ICal Feeds (ics)') &>
12
13 <&| /Widgets/TitleBox, title => 'Help' &>
14
15 <h3>displaying reminders :</h3>
16 <p>If you want to have reminders in a search you need to go in the <a
17 href="<%$RT::WebPath%>/Search/Edit.html"><%loc("Edit Query")%></a> tab
18 of the <%loc("query builder")%> and add something like that :
19
20  <pre>
21    AND ( Type = 'ticket' OR Type = 'reminder' )
22 </pre>
23 </p>
24
25 <h3>displaying other kind of dates :</h3>
26 <p>By default RTx::Calendar display Due and Starts dates. You can
27 select other kind of events you want with the <%loc("Display
28 Columns")%> section in the <a
29 href="<%$RT::WebPath%>/Search/Build.html"><%loc("Query
30 Builder")%></a>. The following one will display the two latter and
31 LastUpdated dates :
32
33 <pre>
34   '&lt;small&gt;__Due__&lt;/small&gt;',
35   '&lt;small&gt;__Starts__&lt;/small&gt;',
36   '&lt;small&gt;__LastUpdated__&lt;/small&gt;'
37 </pre>
38 </p>
39
40 <h3>changing the default query :</h3>
41 <p>You can change the default Query of Calendar.html and MyCalendar
42 portlet by saving a query with the name <code>calendar</code> in the
43 <a href="<%$RT::WebPath%>/Search/Build.html"><%loc("Query
44 Builder")%></a>.</p>
45
46 </&>
47
48 <& /Prefs/Elements/CalendarFeed &>
49
50 % # only allow this part if
51 % if ($AllowSearch) {
52
53 % my $search_count;
54
55 %   # I'm quite sure the loop isn't usefull but...
56 %   my @Objects = $session{CurrentUser}->UserObj;
57 %   for my $object (@Objects) {
58 %     next unless ref($object) eq 'RT::User' && $object->id == $session{'CurrentUser'}->Id;
59 %     my @searches = $object->Attributes->Named('SavedSearch');
60 %     for my $search (@searches) {
61 %       next if ($search->SubValue('SearchType')
62 %              && $search->SubValue('SearchType') ne $SearchType);
63 %       $search_count++;
64 <& /Prefs/Elements/CalendarFeed, Object => $object, Search => $search &>
65
66 %     }
67 %   }
68 %   unless ($search_count) {
69
70 <&| /Widgets/TitleBox, title => loc('Private Search ICal feeds')
71                      , title_class=> 'inverse'
72                      , color => "#993333" &>
73
74 You can add private ICal feeds by saving new queries in <a
75 href="<%$RT::WebPath . '/Search/Build.html'%>">the Query Builder</a>
76
77 </&>
78
79 %   }
80 % } else {
81 %#<&| /Widgets/TitleBox, title => loc('Private Search ICal feeds')
82 %#                     , title_class=> 'inverse'
83 %#                     , color => "#993333" &>
84 %#
85 %#<%loc('Private search ICal feeds disabled. To enable them, ask your admin for "[_1]" and "[_2]" rights',
86 %#       loc('CreateSavedSearch'),
87 %#       loc('LoadSavedSearch') )%>
88 %#
89 %#</&>
90 % }
91
92 </&>
93
94 <%INIT>
95 use Digest::SHA 'sha1_base64';
96 use RT::SavedSearches;
97
98 my $title = loc("Calendar Prefs");
99 my $AllowSearch;
100
101 $AllowSearch = 1
102  if $session{'CurrentUser'}->HasRight( Right => 'LoadSavedSearch',
103                                        Object=> $RT::System );
104
105 my $object;
106
107 if ($HiddenField && $HiddenField eq 'Private') {
108    $object = $session{CurrentUser}->UserObj;
109 } elsif ($AllowSearch and $HiddenField and my ($SearchId) = $HiddenField =~ m/SavedSearch\-(\d+)/) {
110     $object = $session{CurrentUser}->Attributes->WithId($SearchId);
111 }
112
113 if (defined $ChangeURL) {
114   my @args = $object->SetAttribute(Name => 'ICalURL', Content => sha1_base64(time));
115 } elsif (defined $ResetURL) {
116   my @args = $object->DeleteAttribute('ICalURL');
117 }
118
119
120 </%INIT>