RT mobile UI, #11630
[freeside.git] / rt / share / html / m / _elements / menu
1 <&| /Widgets/TitleBox, class => 'menu'&>
2 <ul class="menu">
3 % for my $item (@menu) {
4 % if (exists $item->{html}) {
5 <li><%$item->{html} |n%></li>
6 % } else {
7 <li><a href="<%RT->Config->Get('WebPath')%><%$item->{url}%>"><%$item->{label}%></a></li>
8 % }
9 % }
10 </ul>
11 </&>
12 <%init>
13 use RT::SavedSearches;
14 my @menu = (
15     {         html => '<form method="GET" id="search" action="'
16             . RT->Config->Get('WebPath')
17             . '/m/tickets/search">'
18             . loc("Search")
19             . ': <input type="text" name="q" id="q" value=""/>'
20             . '<input type="submit" value="'
21             . loc("Go")
22             . '"/></form>'
23     },
24     {   label => loc("New ticket"),
25         url   => '/m/ticket/select_create_queue',
26     },
27     {   label => loc("Bookmarked tickets"),
28         url   => '/m/tickets/search?name=Bookmarked%20Tickets',
29     },
30     {   label => loc("Tickets I own"),
31         url   => '/m/tickets/search?name=My%20Tickets',
32     },
33     {   label => loc("Unowned tickets"),
34         url   => '/m/tickets/search?name=Unowned%20Tickets',
35     },
36     {   label => loc("All tickets"),
37         url   => '/m/tickets/search?query=id!%3d0&order_by=id&order=DESC'
38     },
39 );
40
41
42 if ( $session{'CurrentUser'}->HasRight( Right  => 'LoadSavedSearch', Object => $RT::System))
43     {
44
45         my @Objects = RT::SavedSearches->new( $session{CurrentUser} )->_PrivacyObjects;
46         push @Objects, RT::System->new( $session{'CurrentUser'} )
47             if $session{'CurrentUser'}->HasRight(
48             Object => $RT::System,
49             Right  => 'SuperUser'
50             );
51
52         foreach my $object (@Objects) {
53             my @searches = $object->Attributes->Named('SavedSearch');
54             foreach my $search (@searches) {
55                 next unless $search->SubValue("SearchType") eq 'Ticket';
56                 push @menu, { label => $search->Description, url => '/m/tickets/search?query=' . $search->SubValue("Query").'&order='.$search->SubValue("Order").'&order_by='.$search->SubValue("OrderBy") };
57
58             }
59         }
60 }
61 push @menu,  {   label => loc("Logout"), url   => '/m/logout', } 
62   if !RT->Config->Get('WebExternalAuth');
63 </%init>