[Rt-commit] r16222 - rt/3.8/trunk/sbin

ruz at bestpractical.com ruz at bestpractical.com
Mon Oct 6 11:15:17 EDT 2008


Author: ruz
Date: Mon Oct  6 11:15:16 2008
New Revision: 16222

Modified:
   rt/3.8/trunk/sbin/rt-validator.in

Log:
* move redo into delete/create functions, so we don't need to flag
  the same things around when we delete records in the same tables

Modified: rt/3.8/trunk/sbin/rt-validator.in
==============================================================================
--- rt/3.8/trunk/sbin/rt-validator.in	(original)
+++ rt/3.8/trunk/sbin/rt-validator.in	Mon Oct  6 11:15:16 2008
@@ -161,6 +161,43 @@
     User
 );
 
+my %redo_on;
+$redo_on{'Delete'} = {
+    ACL => [],
+
+    Attributes => [],
+
+    Links => [],
+
+    CustomFields => [],
+    CustomFieldValues => [],
+    ObjectCustomFields => [],
+    ObjectCustomFieldValues => [],
+
+    Queues => [],
+
+    Scrips => [],
+    ScripActions => [],
+    ScripConditions => [],
+    Templates => [],
+
+    Tickets => [ 'Tickets -> other' ],
+    Transactions => [ 'Attachments -> other' ],
+
+    Principals => ['User <-> ACL equivalence group', 'GMs -> Groups, Members' ],
+    Users => ['User <-> ACL equivalence group', 'GMs -> Groups, Members' ],
+    Groups => ['User <-> ACL equivalence group', 'GMs -> Groups, Members', 'CGM vs. GM' ],
+
+    GroupMembers => [ 'CGM vs. GM' ],
+    CachedGroupMembers => [ 'CGM vs. GM' ],
+};
+$redo_on{'Create'} = {
+    Principals => ['User <-> ACL equivalence group', 'GMs -> Groups, Members' ],
+    Groups => ['User <-> ACL equivalence group', 'GMs -> Groups, Members', 'CGM vs. GM' ],
+    GroupMembers => [ 'CGM vs. GM' ],
+    CachedGroupMembers => [ 'CGM vs. GM' ],
+};
+
 { my %cache = ();
 sub m2t($) {
     my $model = shift;
@@ -268,7 +305,6 @@
             return unless prompt( 'Delete', 'GroupMembers', $msg );
 
             delete_record( 'GroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
     check_integrity(
@@ -278,7 +314,6 @@
             return unless prompt( 'Delete', 'GroupMembers', $msg );
 
             delete_record( 'GroupMembers', $id );
-            $redo_check{'CGM vs, GM'} = 1;
         },
     );
 };
@@ -323,7 +358,6 @@
             );
 
             delete_record( 'CachedGroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
     # each group should have a CGM record where MemberId == GroupId
@@ -367,7 +401,6 @@
             );
 
             delete_record( 'CachedGroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
     # Via
@@ -382,7 +415,6 @@
             );
 
             delete_record( 'CachedGroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
 
@@ -400,7 +432,6 @@
             );
 
             delete_record( 'CachedGroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
 
@@ -418,7 +449,6 @@
             );
 
             delete_record( 'CachedGroupMembers', $id );
-            $redo_check{'CGM vs. GM'} = 1;
         },
     );
 
@@ -799,9 +829,16 @@
     my ($table, $id) = (@_);
     print "Deleting record #$id in $table\n" if $opt{'verbose'};
     my $query = "DELETE FROM $table WHERE id = ?";
+    $redo_check{ $_ } = 1 foreach @{ $redo_on{'Delete'}{ $table } || [] };
     return execute_query( $query, $id );
 }
 
+sub create_record {
+    print "Creating a record in $_[0]\n" if $opt{'verbose'};
+    $redo_check{ $_ } = 1 foreach @{ $redo_on{'Create'}{ $_[0] } || [] };
+    return $RT::Handle->Insert( @_ );
+}
+
 sub execute_query {
     my ($query, @binds) = @_;
 
@@ -812,11 +849,6 @@
     return $sth;
 }
 
-sub create_record {
-    print "Creating a record in $_[0]\n" if $opt{'verbose'};
-    return $RT::Handle->Insert( @_ );
-}
-
 { my %cached_answer;
 sub prompt {
     my $action = shift;


More information about the Rt-commit mailing list