[Rt-commit] rt branch, find_disabled_rows, updated. rt-3.8.7-166-g5a15272

Ruslan Zakirov ruz at bestpractical.com
Wed Feb 17 18:40:42 EST 2010


The branch, find_disabled_rows has been updated
       via  5a15272d5f1923b85a01e84ab5c6c340f3af6c2a (commit)
       via  15d142ca6a3470875e0b3e412b8d80defdccef28 (commit)
       via  1d792f78cc96d33edd3b698fc7a500db3a4291f8 (commit)
       via  63aec6a6cc614dcd20b6f4f29593da15f511b1b5 (commit)
       via  364103ccdbb99e74b89549fbb9cf3fcb96679706 (commit)
       via  9def8e5d0c9cf511f752822ee5f7abc533bd2b0e (commit)
      from  4658be309b346f9f9af2123cf70a92fc3865d71d (commit)

Summary of changes:
 lib/RT/CustomField_Overlay.pm            |    2 +-
 lib/RT/CustomFields_Overlay.pm           |   32 ++++-----------
 lib/RT/Groups_Overlay.pm                 |   27 +++++++------
 lib/RT/Queues_Overlay.pm                 |   25 +-----------
 lib/RT/SearchBuilder.pm                  |   62 ++++++++++++++++++++----------
 lib/RT/Shredder/Plugin/Users.pm          |   10 +----
 lib/RT/Users_Overlay.pm                  |   52 +++++++++++--------------
 share/html/Admin/CustomFields/index.html |    2 +-
 share/html/Admin/Queues/index.html       |    2 +-
 share/html/Admin/Users/index.html        |    2 +-
 10 files changed, 95 insertions(+), 121 deletions(-)

- Log -----------------------------------------------------------------
commit 9def8e5d0c9cf511f752822ee5f7abc533bd2b0e
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Feb 17 23:40:23 2010 +0300

    move method closer to related

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index f6b3571..9d75dfe 100755
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -115,6 +115,16 @@ sub LimitToDeleted {
 		);
 }
 
+=head2 FindAllRows
+
+Find all matching rows, regardless of whether they are disabled or not
+
+=cut
+
+sub FindAllRows {
+    shift->{'find_disabled_rows'} = 1;
+}
+
 =head2 LimitAttribute PARAMHASH
 
 Takes NAME, OPERATOR and VALUE to find records that has the
@@ -262,16 +272,6 @@ sub LimitCustomField {
     );
 }
 
-=head2 FindAllRows
-
-Find all matching rows, regardless of whether they are disabled or not
-
-=cut
-
-sub FindAllRows {
-    shift->{'find_disabled_rows'} = 1;
-}
-
 =head2 Limit PARAMHASH
 
 This Limit sub calls SUPER::Limit, but defaults "CASESENSITIVE" to 1, thus

commit 364103ccdbb99e74b89549fbb9cf3fcb96679706
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Feb 18 00:17:54 2010 +0300

    move code to handle Disabled column into RT::SB

diff --git a/lib/RT/SearchBuilder.pm b/lib/RT/SearchBuilder.pm
index 9d75dfe..3bae0ee 100755
--- a/lib/RT/SearchBuilder.pm
+++ b/lib/RT/SearchBuilder.pm
@@ -93,10 +93,9 @@ Only find items that haven't been disabled
 
 sub LimitToEnabled {
     my $self = shift;
-    
-    $self->Limit( FIELD => 'Disabled',
-		  VALUE => '0',
-		  OPERATOR => '=' );
+
+    $self->{'handled_disabled_column'} = 1;
+    $self->Limit( FIELD => 'Disabled', VALUE => '0' );
 }
 
 =head2 LimitToDeleted
@@ -107,12 +106,9 @@ Only find items that have been deleted.
 
 sub LimitToDeleted {
     my $self = shift;
-    
-    $self->{'find_disabled_rows'} = 1;
-    $self->Limit( FIELD => 'Disabled',
-		  OPERATOR => '=',
-		  VALUE => '1'
-		);
+
+    $self->{'handled_disabled_column'} = $self->{'find_disabled_rows'} = 1;
+    $self->Limit( FIELD => 'Disabled', VALUE => '1' );
 }
 
 =head2 FindAllRows
@@ -323,6 +319,32 @@ sub ItemsArrayRef {
     return $self->ItemsOrderBy($self->SUPER::ItemsArrayRef());
 }
 
+# make sure that Disabled rows never get seen unless
+# we're explicitly trying to see them.
+
+sub _DoSearch {
+    my $self = shift;
+
+    if ( $self->{'with_disabled_column'}
+        && !$self->{'handled_disabled_column'}
+        && !$self->{'find_disabled_rows'}
+    ) {
+        $self->LimitToEnabled;
+    }
+    return $self->SUPER::_DoSearch(@_);
+}
+sub _DoCount {
+    my $self = shift;
+
+    if ( $self->{'with_disabled_column'}
+        && !$self->{'handled_disabled_column'}
+        && !$self->{'find_disabled_rows'}
+    ) {
+        $self->LimitToEnabled;
+    }
+    return $self->SUPER::_DoCount(@_);
+}
+
 eval "require RT::SearchBuilder_Vendor";
 die $@ if ($@ && $@ !~ qr{^Can't locate RT/SearchBuilder_Vendor.pm});
 eval "require RT::SearchBuilder_Local";

commit 63aec6a6cc614dcd20b6f4f29593da15f511b1b5
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Feb 18 00:19:04 2010 +0300

    Queue has Disabled column, use new API

diff --git a/lib/RT/Queues_Overlay.pm b/lib/RT/Queues_Overlay.pm
index 9338b21..78307c4 100755
--- a/lib/RT/Queues_Overlay.pm
+++ b/lib/RT/Queues_Overlay.pm
@@ -74,6 +74,7 @@ sub _Init {
   my $self = shift;
   $self->{'table'} = "Queues";
   $self->{'primary_key'} = "id";
+  $self->{'with_disabled_column'} = 1;
 
   # By default, order by name
   $self->OrderBy( ALIAS => 'main',
@@ -84,30 +85,6 @@ sub _Init {
 }
 # }}}
 
-# {{{ sub _DoSearch 
-
-=head2 _DoSearch
-
-  A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
-we're explicitly trying to see them.
-
-=cut
-
-sub _DoSearch {
-    my $self = shift;
-    
-    #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
-    unless($self->{'find_disabled_rows'}) {
-	$self->LimitToEnabled();
-    }
-    
-    return($self->SUPER::_DoSearch(@_));
-    
-}
-
-# }}}
-  
-
 # {{{ sub Limit 
 sub Limit  {
   my $self = shift;

commit 1d792f78cc96d33edd3b698fc7a500db3a4291f8
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Feb 18 00:19:38 2010 +0300

    switch users and groups to new API around Disabled column

diff --git a/lib/RT/Groups_Overlay.pm b/lib/RT/Groups_Overlay.pm
index f20c6ae..793a85d 100755
--- a/lib/RT/Groups_Overlay.pm
+++ b/lib/RT/Groups_Overlay.pm
@@ -88,6 +88,7 @@ sub _Init {
   my $self = shift;
   $self->{'table'} = "Groups";
   $self->{'primary_key'} = "id";
+  $self->{'with_disabled_column'} = 1;
 
   my @result = $self->SUPER::_Init(@_);
 
@@ -376,12 +377,13 @@ Only find items that haven\'t been disabled
 
 sub LimitToEnabled {
     my $self = shift;
-    
-    $self->Limit( ALIAS => $self->PrincipalsAlias,
-		          FIELD => 'Disabled',
-		          VALUE => '0',
-		          OPERATOR => '=',
-                );
+
+    $self->{'handled_disabled_column'} = 1;
+    $self->Limit(
+        ALIAS => $self->PrincipalsAlias,
+        FIELD => 'Disabled',
+        VALUE => '0',
+    );
 }
 # }}}
 
@@ -396,13 +398,14 @@ Only find items that have been deleted.
 sub LimitToDeleted {
     my $self = shift;
     
-    $self->{'find_disabled_rows'} = 1;
-    $self->Limit( ALIAS => $self->PrincipalsAlias,
-                  FIELD => 'Disabled',
-                  OPERATOR => '=',
-                  VALUE => 1,
-                );
+    $self->{'handled_disabled_column'} = $self->{'find_disabled_rows'} = 1;
+    $self->Limit(
+        ALIAS => $self->PrincipalsAlias,
+        FIELD => 'Disabled',
+        VALUE => 1,
+    );
 }
+
 # }}}
 
 # {{{ sub Next
diff --git a/lib/RT/Users_Overlay.pm b/lib/RT/Users_Overlay.pm
index a2d235c..9e4a94f 100755
--- a/lib/RT/Users_Overlay.pm
+++ b/lib/RT/Users_Overlay.pm
@@ -73,11 +73,10 @@ no warnings qw(redefine);
 sub _Init {
     my $self = shift;
     $self->{'table'} = 'Users';
-        $self->{'primary_key'} = 'id';
+    $self->{'primary_key'} = 'id';
+    $self->{'with_disabled_column'} = 1;
 
-
-
-    my @result =          $self->SUPER::_Init(@_);
+    my @result = $self->SUPER::_Init(@_);
     # By default, order by name
     $self->OrderBy( ALIAS => 'main',
                     FIELD => 'Name',
@@ -114,46 +113,41 @@ sub PrincipalsAlias {
 }
 
 
-# {{{ sub _DoSearch 
-
-=head2 _DoSearch
+=head2 LimitToEnabled
 
-  A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that _Disabled rows never get seen unless
-we're explicitly trying to see them.
+Only find items that haven\'t been disabled
 
 =cut
 
-sub _DoSearch {
+# XXX: should be generalized
+sub LimitToEnabled {
     my $self = shift;
 
-    #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
-    unless ( $self->{'find_disabled_rows'} ) {
-        $self->LimitToEnabled();
-    }
-    return ( $self->SUPER::_DoSearch(@_) );
-
+    $self->{'handled_disabled_column'} = 1;
+    $self->Limit(
+        ALIAS    => $self->PrincipalsAlias,
+        FIELD    => 'Disabled',
+        VALUE    => '0',
+    );
 }
 
-# }}}
-# {{{ sub LimitToEnabled
-
-=head2 LimitToEnabled
+=head2 LimitToDeleted
 
-Only find items that haven\'t been disabled
+Only find items that have been deleted.
 
 =cut
 
-# XXX: should be generalized
-sub LimitToEnabled {
+sub LimitToDeleted {
     my $self = shift;
-
-    $self->Limit( ALIAS    => $self->PrincipalsAlias,
-                  FIELD    => 'Disabled',
-                  VALUE    => '0',
-                  OPERATOR => '=' );
+    
+    $self->{'handled_disabled_column'} = $self->{'find_disabled_rows'} = 1;
+    $self->Limit(
+        ALIAS => $self->PrincipalsAlias,
+        FIELD => 'Disabled',
+        VALUE => 1,
+    );
 }
 
-# }}}
 
 # {{{ LimitToEmail
 

commit 15d142ca6a3470875e0b3e412b8d80defdccef28
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Feb 18 02:31:04 2010 +0300

    custom fields also can be disabled

diff --git a/lib/RT/CustomFields_Overlay.pm b/lib/RT/CustomFields_Overlay.pm
index 0f117c6..4f3b280 100755
--- a/lib/RT/CustomFields_Overlay.pm
+++ b/lib/RT/CustomFields_Overlay.pm
@@ -69,6 +69,14 @@ use strict;
 no warnings qw(redefine);
 use DBIx::SearchBuilder::Unique;
 
+sub _Init {
+    my $self = shift;
+    $self->{'table'} = 'CustomFields';
+    $self->{'primary_key'} = 'id';
+    $self->{'with_disabled_column'} = 1;
+
+    return $self->SUPER::_Init(@_);
+}
 
 sub _OCFAlias {
     my $self = shift;
@@ -147,30 +155,6 @@ sub LimitToGlobal  {
 # }}}
 
 
-# {{{ sub _DoSearch 
-
-=head2 _DoSearch
-
-A subclass of DBIx::SearchBuilder::_DoSearch that makes sure that 
- _Disabled rows never get seen unless we're explicitly trying to see 
-them.
-
-=cut
-
-sub _DoSearch {
-    my $self = shift;
-    
-    #unless we really want to find disabled rows, make sure we\'re only finding enabled ones.
-    unless($self->{'find_disabled_rows'}) {
-        $self->LimitToEnabled();
-    }
-    
-    return($self->SUPER::_DoSearch(@_));
-    
-}
-
-# }}}
-
 # {{{ sub Next 
 
 =head2 Next

commit 5a15272d5f1923b85a01e84ab5c6c340f3af6c2a
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Feb 18 02:37:42 2010 +0300

    use methods instead of find_disabled_rows
    
    Old style find_disabled_rows = 1 still works, but methods
    a little bit better.

diff --git a/lib/RT/CustomField_Overlay.pm b/lib/RT/CustomField_Overlay.pm
index 9286d7a..f8778c4 100755
--- a/lib/RT/CustomField_Overlay.pm
+++ b/lib/RT/CustomField_Overlay.pm
@@ -342,7 +342,7 @@ sub LoadByName {
 
     # When loading by name, we _can_ load disabled fields, but prefer
     # non-disabled fields.
-    $CFs->{'find_disabled_rows'}=1;
+    $CFs->FindAllRows;
     $CFs->OrderByCols(
         { FIELD => "Disabled", ORDER => 'ASC' },
     );
diff --git a/lib/RT/Shredder/Plugin/Users.pm b/lib/RT/Shredder/Plugin/Users.pm
index 2565fc5..99071a2 100644
--- a/lib/RT/Shredder/Plugin/Users.pm
+++ b/lib/RT/Shredder/Plugin/Users.pm
@@ -166,15 +166,9 @@ sub Run
     #                   Creator Created LastUpdated LastUpdatedBy));
     if( my $s = $self->{'opt'}{'status'} ) {
         if( $s eq 'any' ) {
-            $objs->{'find_disabled_rows'} = 1;
+            $objs->FindAllRows;
         } elsif( $s eq 'disabled' ) {
-            $objs->{'find_disabled_rows'} = 1;
-            $objs->Limit(
-                ALIAS => $objs->PrincipalsAlias,
-                FIELD    => 'Disabled',
-                OPERATOR => '!=',
-                VALUE    => '0',
-            );
+            $objs->LimitToDeleted;
         } else {
             $objs->LimitToEnabled;
         }
diff --git a/share/html/Admin/CustomFields/index.html b/share/html/Admin/CustomFields/index.html
index 139b8eb..1164a6b 100644
--- a/share/html/Admin/CustomFields/index.html
+++ b/share/html/Admin/CustomFields/index.html
@@ -102,7 +102,7 @@ if ( !$Type && $ARGS{'type'} ) {
 
 my $CustomFields = RT::CustomFields->new($session{'CurrentUser'});
 $CustomFields->UnLimit;
-$CustomFields->{'find_disabled_rows'} = 1 if $ShowDisabled;
+$CustomFields->FindAllRows if $ShowDisabled;
 $CustomFields->LimitToLookupType( $Type ) if $Type;
 $CustomFields->OrderByCols( { FIELD => 'LookupType' }, { FIELD => 'Name' } );
 </%INIT>
diff --git a/share/html/Admin/Queues/index.html b/share/html/Admin/Queues/index.html
index 52e7b3b..6b5652b 100755
--- a/share/html/Admin/Queues/index.html
+++ b/share/html/Admin/Queues/index.html
@@ -92,7 +92,7 @@
 
 <%INIT>
 my $queues = new RT::Queues($session{'CurrentUser'});
-$queues->{'find_disabled_rows'} = 1 if $FindDisabledQueues;
+$queues->FindAllRows if $FindDisabledQueues;
 
 my ($caption);
 if ( defined $QueueString && length $QueueString ) {
diff --git a/share/html/Admin/Users/index.html b/share/html/Admin/Users/index.html
index e9a5818..88667b8 100755
--- a/share/html/Admin/Users/index.html
+++ b/share/html/Admin/Users/index.html
@@ -93,7 +93,7 @@
 <%INIT>
 my $caption;
 my $users = RT::Users->new( $session{'CurrentUser'} );
-$users->{'find_disabled_rows'} = 1 if $FindDisabledUsers;
+$users->FindAllRows if $FindDisabledUsers;
 
 if ( defined($UserString) && length $UserString ) {
     $caption = loc("Users matching search criteria");

-----------------------------------------------------------------------


More information about the Rt-commit mailing list