%#
%# COPYRIGHT:
%#
-%# This software is Copyright (c) 1996-2011 Best Practical Solutions, LLC
+%# This software is Copyright (c) 1996-2019 Best Practical Solutions, LLC
%# <sales@bestpractical.com>
%#
%# (Except where explicitly superseded by other copyright notices)
%#
%# 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 id="toggle-<% $id %>" class="toggle-<% $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="toggleTicketBookmark('<% $id|n %>', '<% $url %>'); 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>