[Rt-commit] r5196 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Wed May 10 17:41:00 EDT 2006


Author: ruz
Date: Wed May 10 17:40:59 2006
New Revision: 5196

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/sbin/rt-setup-database.in

Log:
 r2842 at cubic-pc:  cubic | 2006-05-10 14:56:19 +0400
 * implement ability to create groups and add them as members to other groups
   from initial files


Modified: rt/branches/3.7-EXPERIMENTAL/sbin/rt-setup-database.in
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/sbin/rt-setup-database.in	(original)
+++ rt/branches/3.7-EXPERIMENTAL/sbin/rt-setup-database.in	Wed May 10 17:40:59 2006
@@ -387,6 +387,7 @@
     $RT::Handle->Connect();
 
     #Put together a current user object so we can create a User object
+    require RT::CurrentUser;
     my $CurrentUser = new RT::CurrentUser();
 
     print "Checking for existing system user...";
@@ -464,9 +465,23 @@
         print "Creating groups...";
         foreach $item (@Groups) {
             my $new_entry = RT::Group->new($CurrentUser);
+            my $member_of = delete $item->{'MemberOf'};
             my ( $return, $msg ) = $new_entry->_Create(%$item);
             print "(Error: $msg)" unless ($return);
             print $return. ".";
+            if ( $member_of ) {
+                foreach( @$member_of ) {
+                    my $parent = RT::Group->new($CurrentUser);
+                    $parent->LoadByCols( %$_ );
+                    unless ( $parent->Id ) {
+                        print "(Error: couldn't load group to add member)";
+                        next;
+                    }
+                    my ( $return, $msg ) = $parent->AddMember( $new_entry->Id );
+                    print "(Error: $msg)" unless ($return);
+                    print $return. ".";
+                }
+            }
         }
         print "done.\n";
     }


More information about the Rt-commit mailing list