[Rt-commit] rt branch, master, updated. rt-3.9.7-1222-gfcec606
Emannuel Lacour
elacour at bestpractical.com
Wed Jan 19 11:47:17 EST 2011
The branch, master has been updated
via fcec6062c9b3ae6766200e8b5e28fd45712fcaef (commit)
from 86f46f7e09d6184d86fc2b3620b57e15db7a97a2 (commit)
Summary of changes:
lib/RT/Handle.pm | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
- Log -----------------------------------------------------------------
commit fcec6062c9b3ae6766200e8b5e28fd45712fcaef
Author: Emmanuel Lacour <elacour at easter-eggs.com>
Date: Wed Jan 19 17:46:24 2011 +0100
Allow adding users to groups when creating RT users with rt-setup-database
diff --git a/lib/RT/Handle.pm b/lib/RT/Handle.pm
index 5392243..0ab7381 100644
--- a/lib/RT/Handle.pm
+++ b/lib/RT/Handle.pm
@@ -804,6 +804,7 @@ sub InsertData {
if ( @Users ) {
$RT::Logger->debug("Creating users...");
foreach my $item (@Users) {
+ my $member_of = delete $item->{'MemberOf'};
if ( $item->{'Name'} eq 'root' && $root_password ) {
$item->{'Password'} = $root_password;
}
@@ -814,6 +815,37 @@ sub InsertData {
} else {
$RT::Logger->debug( $return ."." );
}
+ if ( $member_of ) {
+ $member_of = [ $member_of ] unless ref $member_of eq 'ARRAY';
+ foreach( @$member_of ) {
+ my $parent = RT::Group->new($RT::SystemUser);
+ if ( ref $_ eq 'HASH' ) {
+ $parent->LoadByCols( %$_ );
+ }
+ elsif ( !ref $_ ) {
+ $parent->LoadUserDefinedGroup( $_ );
+ }
+ else {
+ $RT::Logger->error(
+ "(Error: wrong format of MemberOf field."
+ ." Should be name of user defined group or"
+ ." hash reference with 'column => value' pairs."
+ ." Use array reference to add to multiple groups)"
+ );
+ next;
+ }
+ unless ( $parent->Id ) {
+ $RT::Logger->error("(Error: couldn't load group to add member)");
+ next;
+ }
+ my ( $return, $msg ) = $parent->AddMember( $new_entry->Id );
+ unless ( $return ) {
+ $RT::Logger->error( $msg );
+ } else {
+ $RT::Logger->debug( $return ."." );
+ }
+ }
+ }
}
$RT::Logger->debug("done.");
}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list