[Rt-commit] rt branch, 4.2/bookmarks-in-lib, updated. rt-4.0.0rc6-163-gf5db191
Shawn Moore
sartak at bestpractical.com
Tue Mar 8 15:10:51 EST 2011
The branch, 4.2/bookmarks-in-lib has been updated
via f5db1916c99d145fd70a16dc0d3f849a0d3972a2 (commit)
from d4e458bfd7ca89496b34eabe73543e7a36217678 (commit)
Summary of changes:
lib/RT/Tickets.pm | 7 +------
lib/RT/User.pm | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 6 deletions(-)
- Log -----------------------------------------------------------------
commit f5db1916c99d145fd70a16dc0d3f849a0d3972a2
Author: Shawn M Moore <sartak at bestpractical.com>
Date: Tue Mar 8 15:10:08 2011 -0500
Refactor ->Bookmarks into RT::User
diff --git a/lib/RT/Tickets.pm b/lib/RT/Tickets.pm
index 99b43a8..3b01bdd 100644
--- a/lib/RT/Tickets.pm
+++ b/lib/RT/Tickets.pm
@@ -296,12 +296,7 @@ sub _BookmarkLimit {
die "Invalid operator $op for __Bookmarked__ search on $field"
unless $op =~ /^(=|!=)$/;
- my @bookmarks = do {
- my $tmp = $sb->CurrentUser->UserObj->FirstAttribute('Bookmarks');
- $tmp = $tmp->Content if $tmp;
- $tmp ||= {};
- grep $_, keys %$tmp;
- };
+ my @bookmarks = $sb->CurrentUser->UserObj->Bookmarks;
return $sb->_SQLLimit(
FIELD => $field,
diff --git a/lib/RT/User.pm b/lib/RT/User.pm
index 205a920..dcedada 100644
--- a/lib/RT/User.pm
+++ b/lib/RT/User.pm
@@ -1591,6 +1591,23 @@ sub BasicColumns {
);
}
+=head2 Bookmarks
+
+Returns an unordered list of IDs representing the user's bookmarked tickets.
+
+=cut
+
+sub Bookmarks {
+ my $self = shift;
+ my $bookmarks = $self->FirstAttribute('Bookmarks');
+ return if !$bookmarks;
+
+ $bookmarks = $bookmarks->Content;
+ return if !$bookmarks;
+
+ return keys %$bookmarks;
+}
+
=head2 Create PARAMHASH
Create takes a hash of values and creates a row in the database:
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list