[Bps-public-commit] r19091 - in RT-Extension-MergeUsers/trunk: bin

falcone at bestpractical.com falcone at bestpractical.com
Tue Apr 7 17:29:51 EDT 2009


Author: falcone
Date: Tue Apr  7 17:29:42 2009
New Revision: 19091

Added:
   RT-Extension-MergeUsers/trunk/bin/rt-update-merged-users   (contents, props changed)
Modified:
   RT-Extension-MergeUsers/trunk/   (props changed)

Log:
 r46247 at ketch:  falcone | 2009-04-07 17:06:30 -0400
 * if you used an older version of MergeUsers, run this to add the new Attribute


Added: RT-Extension-MergeUsers/trunk/bin/rt-update-merged-users
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/trunk/bin/rt-update-merged-users	Tue Apr  7 17:29:42 2009
@@ -0,0 +1,30 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+
+### after: use lib qw(@RT_LIB_PATH@);
+use lib qw(/opt/rt3/local/lib /opt/rt3/lib);
+use RT;
+RT::LoadConfig();
+RT::Init();
+
+my $Attributes = RT::Attributes->new($RT::SystemUser);
+$Attributes->Limit( FIELD => 'Name', VALUE => 'EffectiveId' );
+$Attributes->Limit( FIELD => 'ObjectType', VALUE => 'RT::User' );
+
+my $primary_user = RT::User->new($RT::SystemUser);
+
+while ( my $Attr = $Attributes->Next ) {
+    $primary_user->LoadById($Attr->Content);
+    my $merged_users = $primary_user->GetMergedUsers;
+    if ( grep { $_ == $Attr->ObjectId } @{$merged_users->Content} ) {
+        print $Attr->Content." already has ".$Attr->ObjectId." in the merge list\n";
+    } else {
+        print "Adding ".$Attr->ObjectId." to the merged user list for ".$Attr->Content."\n";
+        $merged_users->SetContent([ $Attr->ObjectId, @{$merged_users->Content} ]);
+    }
+}
+
+print "DONE.\n";
+exit 0;



More information about the Bps-public-commit mailing list