diff options
Diffstat (limited to 'rt/share/html/Ticket/Elements/Bookmark')
-rw-r--r-- | rt/share/html/Ticket/Elements/Bookmark | 44 |
1 files changed, 12 insertions, 32 deletions
diff --git a/rt/share/html/Ticket/Elements/Bookmark b/rt/share/html/Ticket/Elements/Bookmark index bb80d3b79..fa40cc19b 100644 --- a/rt/share/html/Ticket/Elements/Bookmark +++ b/rt/share/html/Ticket/Elements/Bookmark @@ -46,48 +46,28 @@ %# %# END BPS TAGGED BLOCK }}} <%INIT> -my $bookmarks = $session{'CurrentUser'}->UserObj->FirstAttribute('Bookmarks'); -$bookmarks = $bookmarks->Content if $bookmarks; -$bookmarks ||= {}; +my $ticket = RT::Ticket->new( $session{'CurrentUser'} ); +$ticket->Load( $id ); -my $bookmarked = $bookmarks->{ $id }; # we still not sure if it's undef - -my @ids; -if ( $Toggle || !$bookmarked ) { - my $ticket = RT::Ticket->new( $session{'CurrentUser'} ); - $ticket->Load( $id ); - return unless $id = $ticket->id; - - @ids = ($id, $ticket->Merged); +my $is_bookmarked; +if ($Toggle) { + $is_bookmarked = $session{'CurrentUser'}->UserObj->ToggleBookmark($ticket); } - -if ( $Toggle ) { - if ( grep $bookmarks->{ $_ }, @ids ) { - delete $bookmarks->{ $_ } foreach @ids; - $bookmarked = 0; - } else { - $bookmarks->{ $id } = 1; - $bookmarked = 1; - } - $session{'CurrentUser'}->UserObj->SetAttribute( - Name => 'Bookmarks', - Content => $bookmarks, - ); -} elsif ( !$bookmarked ) { - $bookmarked = grep $bookmarks->{ $_ }, @ids; +else { + $is_bookmarked = $session{'CurrentUser'}->UserObj->HasBookmark($ticket); } </%INIT> <%ARGS> $id $Toggle => 0 </%ARGS> -<span class="toggle-bookmark-<% $id %>"> +<span class="toggle-bookmark toggle-bookmark-<% $id %>"> % my $url = RT->Config->Get('WebPath') ."/Helpers/Toggle/TicketBookmark?id=". $id; -<a align="right" href="<% $url %>" onclick="jQuery('.toggle-bookmark-'+<% $id |n,j%>).load(<% $url |n,j %>); return false;" > -% if ( $bookmarked ) { -<img src="<% RT->Config->Get('WebPath') %>/NoAuth/images/star.gif" alt="<% loc('Remove Bookmark') %>" style="border-style: none" /> +<a align="right" href="<% $url %>" onclick="jQuery.get(<% $url |n,j %>, function(data){ jQuery('.toggle-bookmark-'+<% $id |n,j%>).replaceWith(data) }); return false;" > +% if ( $is_bookmarked ) { +<img src="<% RT->Config->Get('WebPath') %>/static/images/star.gif" alt="<% loc('Remove Bookmark') %>" style="border-style: none" /> % } else { -<img src="<% RT->Config->Get('WebPath') %>/NoAuth/images/empty_star.gif" alt="<% loc('Add Bookmark') %>" style="border-style: none" /> +<img src="<% RT->Config->Get('WebPath') %>/static/images/empty_star.gif" alt="<% loc('Add Bookmark') %>" style="border-style: none" /> % } </a> </span> |