[Rt-commit] r3167 - in RT-Extension-MergeUsers: . html html/Admin
html/Admin/Users inc inc/.author inc/Module
inc/Module/Install lib lib/RT lib/RT/Extension t
kevinr at bestpractical.com
kevinr at bestpractical.com
Wed Jun 15 15:22:53 EDT 2005
Author: kevinr
Date: Wed Jun 15 15:22:51 2005
New Revision: 3167
Added:
RT-Extension-MergeUsers/MANIFEST
RT-Extension-MergeUsers/META.yml
RT-Extension-MergeUsers/Makefile.PL
RT-Extension-MergeUsers/README
RT-Extension-MergeUsers/html/
RT-Extension-MergeUsers/html/Admin/
RT-Extension-MergeUsers/html/Admin/Users/
RT-Extension-MergeUsers/html/Admin/Users/Modify.html (contents, props changed)
RT-Extension-MergeUsers/inc/
RT-Extension-MergeUsers/inc/.author/
RT-Extension-MergeUsers/inc/Module/
RT-Extension-MergeUsers/inc/Module/Install/
RT-Extension-MergeUsers/inc/Module/Install.pm
RT-Extension-MergeUsers/inc/Module/Install/Base.pm
RT-Extension-MergeUsers/inc/Module/Install/Can.pm
RT-Extension-MergeUsers/inc/Module/Install/Fetch.pm
RT-Extension-MergeUsers/inc/Module/Install/Makefile.pm
RT-Extension-MergeUsers/inc/Module/Install/Metadata.pm
RT-Extension-MergeUsers/inc/Module/Install/RTx.pm
RT-Extension-MergeUsers/inc/Module/Install/Win32.pm
RT-Extension-MergeUsers/inc/Module/Install/WriteAll.pm
RT-Extension-MergeUsers/lib/
RT-Extension-MergeUsers/lib/RT/
RT-Extension-MergeUsers/lib/RT/Extension/
RT-Extension-MergeUsers/lib/RT/Extension/MergeUsers.pm
RT-Extension-MergeUsers/lib/RT/User_Vendor.pm
RT-Extension-MergeUsers/t/
RT-Extension-MergeUsers/t/01merge_users.t (contents, props changed)
Modified:
RT-Extension-MergeUsers/ (props changed)
Log:
r4293 at sad-girl-in-snow: kevinr | 2005-06-15 15:22:39 -0400
* Moved RT::Extension::MergeUsers
Added: RT-Extension-MergeUsers/MANIFEST
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/MANIFEST Wed Jun 15 15:22:51 2005
@@ -0,0 +1,17 @@
+html/Admin/Users/Modify.html
+inc/Module/Install.pm
+inc/Module/Install/Base.pm
+inc/Module/Install/Can.pm
+inc/Module/Install/Fetch.pm
+inc/Module/Install/Makefile.pm
+inc/Module/Install/Metadata.pm
+inc/Module/Install/RTx.pm
+inc/Module/Install/Win32.pm
+inc/Module/Install/WriteAll.pm
+lib/RT/Extension/MergeUsers.pm
+lib/RT/User_Vendor.pm
+t/01merge_users.t
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
Added: RT-Extension-MergeUsers/META.yml
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/META.yml Wed Jun 15 15:22:51 2005
@@ -0,0 +1,11 @@
+name: RT-Extension-MergeUsers
+version: 0.02
+abstract: Merges two users into the same effective user
+author: Alex Vandiver <alexmv at bestpractical.com>
+license: GPL version 2
+distribution_type: module
+no_index:
+ directory:
+ - html
+ - inc
+generated_by: Module::Install version 0.36
Added: RT-Extension-MergeUsers/Makefile.PL
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/Makefile.PL Wed Jun 15 15:22:51 2005
@@ -0,0 +1,11 @@
+use inc::Module::Install;
+
+RTx('RT-Extension-MergeUsers');
+
+name ('RT-Extension-MergeUsers');
+abstract ('Merges two users into the same effective user');
+author ('Alex Vandiver <alexmv at bestpractical.com>');
+version_from ('lib/RT/Extension/MergeUsers.pm');
+license ('GPL version 2');
+
+&WriteAll;
Added: RT-Extension-MergeUsers/README
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/README Wed Jun 15 15:22:51 2005
@@ -0,0 +1,12 @@
+This RT extension adds a "Merge Users" box to the User Administration page,
+which allows you to merge the user you are currently viewing with another
+user on your RT instance. It also adds MergeInto() and Unmerge() functions to
+the RT::User class, which allow you to programmatically accomplish the same
+thing from your scrips. It also provides a version of CanonicalizeEmailAddress,
+which means that all e-mail sent from secondary users is displayed as coming
+from the primary user.
+
+To install:
+
+ perl Makefile.PL
+ make install
Added: RT-Extension-MergeUsers/html/Admin/Users/Modify.html
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/html/Admin/Users/Modify.html Wed Jun 15 15:22:51 2005
@@ -0,0 +1,437 @@
+%# BEGIN BPS TAGGED BLOCK {{{
+%#
+%# COPYRIGHT:
+%#
+%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+%# <jesse at bestpractical.com>
+%#
+%# (Except where explicitly superseded by other copyright notices)
+%#
+%#
+%# LICENSE:
+%#
+%# This work is made available to you under the terms of Version 2 of
+%# the GNU General Public License. A copy of that license should have
+%# been provided with this software, but in any event can be snarfed
+%# from www.gnu.org.
+%#
+%# This work is distributed in the hope that it will be useful, but
+%# WITHOUT ANY WARRANTY; without even the implied warranty of
+%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+%# General Public License for more details.
+%#
+%# You should have received a copy of the GNU General Public License
+%# along with this program; if not, write to the Free Software
+%# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+%#
+%#
+%# CONTRIBUTION SUBMISSION POLICY:
+%#
+%# (The following paragraph is not intended to limit the rights granted
+%# to you to modify and distribute this software under the terms of
+%# the GNU General Public License and is only of importance to you if
+%# you choose to contribute your changes and enhancements to the
+%# community by submitting them to Best Practical Solutions, LLC.)
+%#
+%# By intentionally submitting any modifications, corrections or
+%# derivatives to this work, or any other work intended for use with
+%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+%# you are the copyright holder for those contributions and you grant
+%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+%# royalty-free, perpetual, license to use, copy, create derivative
+%# works based on those contributions, and sublicense and distribute
+%# those contributions and any derivatives thereof.
+%#
+%# END BPS TAGGED BLOCK }}}
+<& /Admin/Elements/Header, Title => $title &>
+<& /Admin/Elements/UserTabs,
+ id => $id,
+ UserObj => $UserObj,
+ current_tab => $current_tab,
+ Title => $title &>
+
+<& /Elements/ListActions, actions => \@results &>
+
+<FORM ACTION="<%$RT::WebPath%>/Admin/Users/Modify.html" METHOD=POST ENCTYPE="multipart/form-data">
+%if ($Create) {
+<INPUT TYPE=HIDDEN NAME=id VALUE="new">
+% } else {
+<INPUT TYPE=HIDDEN NAME=id VALUE="<%$UserObj->Id%>">
+% }
+<TABLE WIDTH=100% BORDER=0>
+<TR>
+
+<TD VALIGN=TOP class="boxcontainer">
+<& /Elements/TitleBoxStart, title => loc('Identity') &>
+
+<TABLE>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Username</&>:
+</TD><TD>
+<input name="Name" value="<%$UserObj->Name%>"> <b><&|/l&>(required)</&></b>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Email</&>:
+</TD><TD>
+<input name="EmailAddress" value="<%$UserObj->EmailAddress%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Real Name</&>:
+</TD><TD>
+<input name="RealName" value="<%$UserObj->RealName%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Nickname</&>:
+</TD><TD>
+<input name="NickName" value="<%$UserObj->NickName%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Unix login</&>:
+</TD><TD>
+<input name="Gecos" value="<%$UserObj->Gecos%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Language</&>:
+</TD><TD>
+<& /Elements/SelectLang, Name => 'Lang', Default => $UserObj->Lang &>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Extra info</&>:
+</TD><TD>
+<textarea name="FreeformContactInfo" cols=20 rows=5><%$UserObj->FreeformContactInfo%></TEXTAREA>
+</TD></TR>
+</TABLE>
+<& /Elements/TitleBoxEnd &>
+<br>
+<& /Elements/TitleBoxStart, title => loc('Access control') &>
+<INPUT TYPE=HIDDEN NAME="SetEnabled" VALUE="1">
+<INPUT TYPE=CHECKBOX NAME="Enabled" VALUE="1" <%$EnabledChecked%>>
+<&|/l&>Let this user access RT</&><BR>
+
+
+<INPUT TYPE=HIDDEN NAME="SetPrivileged" VALUE="1">
+<INPUT TYPE=CHECKBOX NAME="Privileged" VALUE="1" <%$PrivilegedChecked%>> <&|/l&>Let this user be granted rights</&><BR>
+
+% unless ($RT::WebExternalAuth and !$RT::WebFallbackToInternalAuth) {
+<TABLE>
+<TR>
+<TD ALIGN=RIGHT>
+<&|/l&>New Password</&>:
+</TD>
+<TD ALIGN=LEFT>
+<input type=password name="Pass1">
+</TD>
+</TR>
+<TR><TD ALIGN=RIGHT>
+<&|/l&>Retype Password</&>:
+</TD>
+<TD>
+<input type=password name="Pass2">
+</TD>
+</TR>
+</TABLE>
+% }
+<& /Elements/TitleBoxEnd &>
+</TD>
+
+<TD VALIGN=TOP class="boxcontainer">
+<& /Elements/TitleBoxStart, title => loc('Location') &>
+<TABLE>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Organization</&>:
+</TD><TD>
+<input name="Organization" value="<%$UserObj->Organization%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Address1</&>:
+</TD><TD>
+<input name="Address1" value="<%$UserObj->Address1%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Address2</&>:
+</TD><TD>
+<input name="Address2" value="<%$UserObj->Address2%>">
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>City</&>:
+</TD><TD>
+<input name="City" value="<%$UserObj->City%>" size=14>
+
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>State</&>:
+</TD><TD>
+<input name="State" value="<%$UserObj->State%>" size=3>
+
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Zip</&>:
+</TD><TD>
+<input name="Zip" value="<%$UserObj->Zip%>" size=9>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Country</&>:
+</TD><TD>
+<input name="Country" value="<%$UserObj->Country%>">
+</TD></TR>
+</TABLE>
+<& /Elements/TitleBoxEnd &>
+<br>
+<& /Elements/TitleBoxStart, title => loc('Phone numbers') &>
+<TABLE>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Residence</&>:
+</TD><TD>
+<input name="HomePhone" value="<%$UserObj->HomePhone%>" size=13><br>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Work</&>:
+</TD><TD>
+<input name="WorkPhone" value="<%$UserObj->WorkPhone%>" size=13><br>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Mobile</&>:
+</TD><TD>
+<input name="MobilePhone" value="<%$UserObj->MobilePhone%>" size=13><br>
+</TD></TR>
+<TR><TD ALIGN="RIGHT">
+<&|/l&>Pager</&>:
+</TD><TD>
+<input name="PagerPhone" value="<%$UserObj->PagerPhone%>" size=13><br>
+<& /Elements/TitleBoxEnd &>
+</TD>
+
+</TR>
+</TABLE>
+<BR>
+<& /Elements/TitleBoxStart, title => loc('Custom Fields') &>
+<TABLE>
+% my $CFs = $UserObj->CustomFields;
+% while (my $CF = $CFs->Next) {
+<TR VALIGN="TOP"><TD ALIGN="RIGHT">
+<% $CF->Name %>:
+</TD><TD>
+<& /Elements/EditCustomField, %ARGS, Object => $UserObj, CustomField => $CF &>
+</TD></TR>
+% }
+<TR>
+</TR>
+</TABLE>
+<& /Elements/TitleBoxEnd &>
+
+<BR>
+<& /Elements/TitleBoxStart, title => loc('Merge user') &>
+% my ($EffectiveId) = $UserObj->Attributes->Named("EffectiveId");
+% if ($EffectiveId) {
+This user has been merged with <a href="Modify.html?id=<% $EffectiveId->Content %>">
+% my $real = RT::User->new($session{'CurrentUser'});
+% $real->Load($EffectiveId->Content);
+<% $real->EmailAddress %></a>; <input type="submit" name="Unmerge" value="Unmerge" />
+% } else {
+Merge this user into: <input name="MergeUser" value="" />
+% }
+<& /Elements/TitleBoxEnd &>
+
+</TD></TR>
+
+<TR>
+<TD colspan="2">
+<& /Elements/TitleBoxStart, title => loc('Comments about this user') &>
+<TEXTAREA class="comments" name="Comments" COLS=80 ROWS=5 WRAP=VIRTUAL><%$UserObj->Comments%></TEXTAREA>
+<& /Elements/TitleBoxEnd &>
+%if ($UserObj->Privileged) {
+<BR>
+<& /Elements/TitleBoxStart, title => loc('Signature') &>
+<TEXTAREA class="signature" COLS=80 ROWS=5 name="Signature" WRAP=HARD><%$UserObj->Signature%></TEXTAREA>
+<& /Elements/TitleBoxEnd &>
+% }
+
+</TD>
+</TR>
+</TABLE>
+
+<& /Elements/Submit, Label => loc('Save Changes') &>
+</form>
+
+<%INIT>
+
+my $current_tab;
+my $UserObj = new RT::User($session{'CurrentUser'});
+my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
+
+my ($val, $msg);
+
+if ($Create) {
+ $current_tab = 'Admin/Users/Modify.html?Create=1';
+ $title = loc("Create a new user");
+}
+else {
+
+ $current_tab = 'Admin/Users/Modify.html?id='.$id;
+ if ($id eq 'new') {
+ ( $val, $msg ) = $UserObj->Create(
+ Name => $Name,
+ EmailAddress => $ARGS{'EmailAddress'},
+ Name => $ARGS{'Name'},
+ Comments => $ARGS{'Comments'},
+ Signature => $ARGS{'Signature'},
+ EmailAddress => $ARGS{'EmailAddress'},
+ FreeformContactInfo => $ARGS{'FreeformContactInfo'},
+ Organization => $ARGS{'Organization'},
+ RealName => $ARGS{'RealName'},
+ NickName => $ARGS{'NickName'},
+ Lang => $ARGS{'Lang'},
+ EmailEncoding => $ARGS{'EmailEncoding'},
+ WebEncoding => $ARGS{'WebEncoding'},
+ ExternalContactInfoId => $ARGS{'ExternalContactInfoId'},
+ ContactInfoSystem => $ARGS{'ContactInfoSystem'},
+ Gecos => $ARGS{'Gecos'},
+ ExternalAuthId => $ARGS{'ExternalAuthId'},
+ AuthSystem => $ARGS{'AuthSystem'},
+ HomePhone => $ARGS{'HomePhone'},
+ WorkPhone => $ARGS{'WorkPhone'},
+ MobilePhone => $ARGS{'MobilePhone'},
+ PagerPhone => $ARGS{'PagerPhone'},
+ Address1 => $ARGS{'Address1'},
+ Address2 => $ARGS{'Address2'},
+ City => $ARGS{'City'},
+ State => $ARGS{'State'},
+ Zip => $ARGS{'Zip'},
+ Country => $ARGS{'Country'},
+ Privileged => $ARGS{'Privileged'},
+ Disabled => ($ARGS{'Enabled'} ? 0 : 1)
+ );
+ if ($val) {
+ push @results, $msg;
+ } else {
+ push @results, loc('User could not be created: [_1]', $msg);
+ }
+
+ } else {
+ $UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
+ $val = $UserObj->Id();
+ }
+
+ if ($val) {
+ $title = loc("Modify the user [_1]", $UserObj->Name);
+ }
+
+ # If the create failed
+ else {
+ $title = loc("Create a new user");
+ $Create = 1;
+ }
+
+}
+
+
+
+
+# If we have a user to modify, lets try.
+if ($UserObj->Id && $id ne 'new') {
+
+ my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo
+ Organization RealName NickName Lang EmailEncoding WebEncoding
+ ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId
+ AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
+ Address2 City State Zip Country
+ );
+
+ my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
+ Object => $UserObj,
+ ARGSRef => \%ARGS );
+ push (@results, at fieldresults);
+ push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
+
+
+# {{{ Deal with special fields: Privileged, Enabled and Password
+if ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
+my ($code, $msg) = $UserObj->SetPrivileged($Privileged);
+ push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
+}
+
+#we're asking about enabled on the web page but really care about disabled.
+if ($Enabled == 1) {
+ $Disabled = 0;
+}
+else {
+ $Disabled = 1;
+}
+if ( ($SetEnabled) and ( $Disabled != $UserObj->Disabled) ) {
+ my ($code, $msg) = $UserObj->SetDisabled($Disabled);
+ push @results, loc('Enabled status [_1]', loc_fuzzy($msg));
+}
+
+
+#TODO: make this report errors properly
+if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
+ my ($code, $msg);
+ ($code, $msg) = $UserObj->SetPassword($Pass1);
+ push @results, loc('Password: [_1]', loc_fuzzy($msg));
+} elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
+ push @results, loc("Passwords do not match.");
+}
+
+# }}}
+}
+
+if ($ARGS{MergeUser}) {
+ $UserObj->MergeInto($ARGS{MergeUser});
+} elsif ($ARGS{Unmerge}) {
+ $UserObj->UnMerge();
+}
+
+# {{{ Do some setup for the ui
+unless ($UserObj->Disabled()) {
+ $EnabledChecked ="CHECKED";
+}
+
+if ($UserObj->Privileged()) {
+ $PrivilegedChecked = "CHECKED";
+}
+
+# }}}
+
+# set the id, so the the menu will have the right info, this needs to
+# be done here to avoid creating and then modifying a user
+$id = $UserObj->Id;
+
+</%INIT>
+
+
+<%ARGS>
+$id => undef
+$Name => undef
+$Comments => undef
+$Signature => undef
+$EmailAddress => undef
+$FreeformContactInfo => undef
+$Organization => undef
+$RealName => undef
+$NickName => undef
+$Privileged => undef
+$SetPrivileged => undef
+$Enabled => undef
+$SetEnabled => undef
+$Lang => undef
+$EmailEncoding => undef
+$WebEncoding => undef
+$ExternalContactInfoId => undef
+$ContactInfoSystem => undef
+$Gecos => undef
+$ExternalAuthId => undef
+$AuthSystem => undef
+$HomePhone => undef
+$WorkPhone => undef
+$MobilePhone => undef
+$PagerPhone => undef
+$Address1 => undef
+$Address2 => undef
+$City => undef
+$State => undef
+$Zip => undef
+$Country => undef
+$Pass1 => undef
+$Pass2=> undef
+$Create=> undef
+</%ARGS>
Added: RT-Extension-MergeUsers/inc/Module/Install.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,169 @@
+#line 1 "inc/Module/Install.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install.pm"
+package Module::Install;
+$VERSION = '0.36';
+
+die << "." unless $INC{join('/', inc => split(/::/, __PACKAGE__)).'.pm'};
+Please invoke ${\__PACKAGE__} with:
+
+ use inc::${\__PACKAGE__};
+
+not:
+
+ use ${\__PACKAGE__};
+
+.
+
+use strict 'vars';
+use Cwd ();
+use File::Find ();
+use File::Path ();
+
+ at inc::Module::Install::ISA = 'Module::Install';
+*inc::Module::Install::VERSION = *VERSION;
+
+#line 129
+
+sub import {
+ my $class = shift;
+ my $self = $class->new(@_);
+
+ if (not -f $self->{file}) {
+ require "$self->{path}/$self->{dispatch}.pm";
+ File::Path::mkpath("$self->{prefix}/$self->{author}");
+ $self->{admin} =
+ "$self->{name}::$self->{dispatch}"->new(_top => $self);
+ $self->{admin}->init;
+ @_ = ($class, _self => $self);
+ goto &{"$self->{name}::import"};
+ }
+
+ *{caller(0) . "::AUTOLOAD"} = $self->autoload;
+
+ # Unregister loader and worker packages so subdirs can use them again
+ delete $INC{"$self->{file}"};
+ delete $INC{"$self->{path}.pm"};
+}
+
+#line 156
+
+sub autoload {
+ my $self = shift;
+ my $caller = caller;
+
+ my $cwd = Cwd::cwd();
+ my $sym = "$caller\::AUTOLOAD";
+
+ $sym->{$cwd} = sub {
+ my $pwd = Cwd::cwd();
+ if (my $code = $sym->{$pwd}) {
+ goto &$code unless $cwd eq $pwd; # delegate back to parent dirs
+ }
+ $$sym =~ /([^:]+)$/ or die "Cannot autoload $caller";
+ unshift @_, ($self, $1);
+ goto &{$self->can('call')} unless uc($1) eq $1;
+ };
+}
+
+#line 181
+
+sub new {
+ my ($class, %args) = @_;
+
+ return $args{_self} if $args{_self};
+
+ $args{dispatch} ||= 'Admin';
+ $args{prefix} ||= 'inc';
+ $args{author} ||= '.author';
+ $args{bundle} ||= 'inc/BUNDLES';
+
+ $class =~ s/^\Q$args{prefix}\E:://;
+ $args{name} ||= $class;
+ $args{version} ||= $class->VERSION;
+
+ unless ($args{path}) {
+ $args{path} = $args{name};
+ $args{path} =~ s!::!/!g;
+ }
+ $args{file} ||= "$args{prefix}/$args{path}.pm";
+
+ bless(\%args, $class);
+}
+
+#line 210
+
+sub call {
+ my $self = shift;
+ my $method = shift;
+ my $obj = $self->load($method) or return;
+
+ unshift @_, $obj;
+ goto &{$obj->can($method)};
+}
+
+#line 225
+
+sub load {
+ my ($self, $method) = @_;
+
+ $self->load_extensions(
+ "$self->{prefix}/$self->{path}", $self
+ ) unless $self->{extensions};
+
+ foreach my $obj (@{$self->{extensions}}) {
+ return $obj if $obj->can($method);
+ }
+
+ my $admin = $self->{admin} or die << "END";
+The '$method' method does not exist in the '$self->{prefix}' path!
+Please remove the '$self->{prefix}' directory and run $0 again to load it.
+END
+
+ my $obj = $admin->load($method, 1);
+ push @{$self->{extensions}}, $obj;
+
+ $obj;
+}
+
+#line 255
+
+sub load_extensions {
+ my ($self, $path, $top_obj) = @_;
+
+ unshift @INC, $self->{prefix}
+ unless grep { $_ eq $self->{prefix} } @INC;
+
+ local @INC = ($path, @INC);
+ foreach my $rv ($self->find_extensions($path)) {
+ my ($file, $pkg) = @{$rv};
+ next if $self->{pathnames}{$pkg};
+
+ eval { require $file; 1 } or (warn($@), next);
+ $self->{pathnames}{$pkg} = delete $INC{$file};
+ push @{$self->{extensions}}, $pkg->new( _top => $top_obj );
+ }
+}
+
+#line 279
+
+sub find_extensions {
+ my ($self, $path) = @_;
+ my @found;
+
+ File::Find::find(sub {
+ my $file = $File::Find::name;
+ return unless $file =~ m!^\Q$path\E/(.+)\.pm\Z!is;
+ return if $1 eq $self->{dispatch};
+
+ $file = "$self->{path}/$1.pm";
+ my $pkg = "$self->{name}::$1"; $pkg =~ s!/!::!g;
+ push @found, [$file, $pkg];
+ }, $path) if -d $path;
+
+ @found;
+}
+
+1;
+
+__END__
+
+#line 617
Added: RT-Extension-MergeUsers/inc/Module/Install/Base.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Base.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,54 @@
+#line 1 "inc/Module/Install/Base.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Base.pm"
+package Module::Install::Base;
+
+#line 28
+
+sub new {
+ my ($class, %args) = @_;
+
+ foreach my $method (qw(call load)) {
+ *{"$class\::$method"} = sub {
+ +shift->_top->$method(@_);
+ } unless defined &{"$class\::$method"};
+ }
+
+ bless(\%args, $class);
+}
+
+#line 46
+
+sub AUTOLOAD {
+ my $self = shift;
+ goto &{$self->_top->autoload};
+}
+
+#line 57
+
+sub _top { $_[0]->{_top} }
+
+#line 68
+
+sub admin {
+ my $self = shift;
+ $self->_top->{admin} or Module::Install::Base::FakeAdmin->new;
+}
+
+sub is_admin {
+ my $self = shift;
+ $self->admin->VERSION;
+}
+
+sub DESTROY {}
+
+package Module::Install::Base::FakeAdmin;
+
+my $Fake;
+sub new { $Fake ||= bless(\@_, $_[0]) }
+sub AUTOLOAD {}
+sub DESTROY {}
+
+1;
+
+__END__
+
+#line 112
Added: RT-Extension-MergeUsers/inc/Module/Install/Can.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Can.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,38 @@
+#line 1 "inc/Module/Install/Can.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Can.pm"
+package Module::Install::Can;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+$VERSION = '0.01';
+
+use strict;
+use Config ();
+use File::Spec ();
+use ExtUtils::MakeMaker ();
+
+# check if we can run some command
+sub can_run {
+ my ($self, $cmd) = @_;
+
+ my $_cmd = $cmd;
+ return $_cmd if (-x $_cmd or $_cmd = MM->maybe_command($_cmd));
+
+ for my $dir ((split /$Config::Config{path_sep}/, $ENV{PATH}), '.') {
+ my $abs = File::Spec->catfile($dir, $_[1]);
+ return $abs if (-x $abs or $abs = MM->maybe_command($abs));
+ }
+
+ return;
+}
+
+sub can_cc {
+ my $self = shift;
+ my @chunks = split(/ /, $Config::Config{cc}) or return;
+
+ # $Config{cc} may contain args; try to find out the program part
+ while (@chunks) {
+ return $self->can_run("@chunks") || (pop(@chunks), next);
+ }
+
+ return;
+}
+
+1;
Added: RT-Extension-MergeUsers/inc/Module/Install/Fetch.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Fetch.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,86 @@
+#line 1 "inc/Module/Install/Fetch.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Fetch.pm"
+package Module::Install::Fetch;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+sub get_file {
+ my ($self, %args) = @_;
+ my ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+
+ if ($scheme eq 'http' and !eval { require LWP::Simple; 1 }) {
+ $args{url} = $args{ftp_url}
+ or (warn("LWP support unavailable!\n"), return);
+ ($scheme, $host, $path, $file) =
+ $args{url} =~ m|^(\w+)://([^/]+)(.+)/(.+)| or return;
+ }
+
+ $|++;
+ print "Fetching '$file' from $host... ";
+
+ unless (eval { require Socket; Socket::inet_aton($host) }) {
+ warn "'$host' resolve failed!\n";
+ return;
+ }
+
+ return unless $scheme eq 'ftp' or $scheme eq 'http';
+
+ require Cwd;
+ my $dir = Cwd::getcwd();
+ chdir $args{local_dir} or return if exists $args{local_dir};
+
+ if (eval { require LWP::Simple; 1 }) {
+ LWP::Simple::mirror($args{url}, $file);
+ }
+ elsif (eval { require Net::FTP; 1 }) { eval {
+ # use Net::FTP to get past firewall
+ my $ftp = Net::FTP->new($host, Passive => 1, Timeout => 600);
+ $ftp->login("anonymous", 'anonymous at example.com');
+ $ftp->cwd($path);
+ $ftp->binary;
+ $ftp->get($file) or (warn("$!\n"), return);
+ $ftp->quit;
+ } }
+ elsif (my $ftp = $self->can_run('ftp')) { eval {
+ # no Net::FTP, fallback to ftp.exe
+ require FileHandle;
+ my $fh = FileHandle->new;
+
+ local $SIG{CHLD} = 'IGNORE';
+ unless ($fh->open("|$ftp -n")) {
+ warn "Couldn't open ftp: $!\n";
+ chdir $dir; return;
+ }
+
+ my @dialog = split(/\n/, << ".");
+open $host
+user anonymous anonymous\@example.com
+cd $path
+binary
+get $file $file
+quit
+.
+ foreach (@dialog) { $fh->print("$_\n") }
+ $fh->close;
+ } }
+ else {
+ warn "No working 'ftp' program available!\n";
+ chdir $dir; return;
+ }
+
+ unless (-f $file) {
+ warn "Fetching failed: $@\n";
+ chdir $dir; return;
+ }
+
+ return if exists $args{size} and -s $file != $args{size};
+ system($args{run}) if exists $args{run};
+ unlink($file) if $args{remove};
+
+ print(((!exists $args{check_for} or -e $args{check_for})
+ ? "done!" : "failed! ($!)"), "\n");
+ chdir $dir; return !$?;
+}
+
+1;
Added: RT-Extension-MergeUsers/inc/Module/Install/Makefile.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Makefile.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,143 @@
+#line 1 "inc/Module/Install/Makefile.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Makefile.pm"
+package Module::Install::Makefile;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.01';
+
+use strict 'vars';
+use vars '$VERSION';
+
+use ExtUtils::MakeMaker ();
+
+sub Makefile { $_[0] }
+
+sub prompt {
+ shift;
+ goto &ExtUtils::MakeMaker::prompt;
+}
+
+sub makemaker_args {
+ my $self = shift;
+ my $args = ($self->{makemaker_args} ||= {});
+ %$args = ( %$args, @_ ) if @_;
+ $args;
+}
+
+sub clean_files {
+ my $self = shift;
+ my $clean = $self->makemaker_args->{clean} ||= {};
+ %$clean = (
+ %$clean,
+ FILES => join(" ", grep length, $clean->{FILES}, @_),
+ );
+}
+
+sub libs {
+ my $self = shift;
+ my $libs = ref $_[0] ? shift : [shift];
+ $self->makemaker_args( LIBS => $libs );
+}
+
+sub inc {
+ my $self = shift;
+ $self->makemaker_args( INC => shift );
+}
+
+sub write {
+ my $self = shift;
+ die "&Makefile->write() takes no arguments\n" if @_;
+
+ my $args = $self->makemaker_args;
+
+ $args->{DISTNAME} = $self->name;
+ $args->{NAME} = $self->module_name || $self->name || $self->determine_NAME($args);
+ $args->{VERSION} = $self->version || $self->determine_VERSION($args);
+ $args->{NAME} =~ s/-/::/g;
+
+ if ($] >= 5.005) {
+ $args->{ABSTRACT} = $self->abstract;
+ $args->{AUTHOR} = $self->author;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) >= 6.10 ) {
+ $args->{NO_META} = 1;
+ }
+ if ( eval($ExtUtils::MakeMaker::VERSION) > 6.17 ) {
+ $args->{SIGN} = 1 if $self->sign;
+ }
+ delete $args->{SIGN} unless $self->is_admin;
+
+ # merge both kinds of requires into prereq_pm
+ my $prereq = ($args->{PREREQ_PM} ||= {});
+ %$prereq = ( %$prereq, map { @$_ } map { @$_ } grep $_,
+ ($self->build_requires, $self->requires) );
+
+ # merge both kinds of requires into prereq_pm
+ my $dir = ($args->{DIR} ||= []);
+ if ($self->bundles) {
+ push @$dir, map "$_->[1]", @{$self->bundles};
+ delete $prereq->{$_->[0]} for @{$self->bundles};
+ }
+
+ if (my $perl_version = $self->perl_version) {
+ eval "use $perl_version; 1"
+ or die "ERROR: perl: Version $] is installed, ".
+ "but we need version >= $perl_version";
+ }
+
+ my %args = map {($_ => $args->{$_})} grep {defined($args->{$_})} keys %$args;
+
+ if ($self->admin->preop) {
+ $args{dist} = $self->admin->preop;
+ }
+
+ ExtUtils::MakeMaker::WriteMakefile(%args);
+
+ $self->fix_up_makefile();
+}
+
+sub fix_up_makefile {
+ my $self = shift;
+ my $top_class = ref($self->_top) || '';
+ my $top_version = $self->_top->VERSION || '';
+
+ my $preamble = $self->preamble
+ ? "# Preamble by $top_class $top_version\n" . $self->preamble
+ : '';
+ my $postamble = "# Postamble by $top_class $top_version\n" .
+ ($self->postamble || '');
+
+ open MAKEFILE, '< Makefile' or die $!;
+ my $makefile = do { local $/; <MAKEFILE> };
+ close MAKEFILE;
+
+ $makefile =~ s/\b(test_harness\(\$\(TEST_VERBOSE\), )/$1'inc', /;
+ $makefile =~ s/( -I\$\(INST_ARCHLIB\))/ -Iinc$1/g;
+ $makefile =~ s/( "-I\$\(INST_LIB\)")/ "-Iinc"$1/g;
+
+ $makefile =~ s/^(FULLPERL = .*)/$1 -Iinc/m;
+ $makefile =~ s/^(PERL = .*)/$1 -Iinc/m;
+
+ open MAKEFILE, '> Makefile' or die $!;
+ print MAKEFILE "$preamble$makefile$postamble";
+ close MAKEFILE;
+}
+
+sub preamble {
+ my ($self, $text) = @_;
+ $self->{preamble} = $text . $self->{preamble} if defined $text;
+ $self->{preamble};
+}
+
+sub postamble {
+ my ($self, $text) = @_;
+
+ $self->{postamble} ||= $self->admin->postamble;
+ $self->{postamble} .= $text if defined $text;
+ $self->{postamble}
+}
+
+1;
+
+__END__
+
+#line 273
Added: RT-Extension-MergeUsers/inc/Module/Install/Metadata.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Metadata.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,187 @@
+#line 1 "inc/Module/Install/Metadata.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Metadata.pm"
+package Module::Install::Metadata;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.04';
+
+use strict 'vars';
+use vars qw($VERSION);
+
+sub Meta { shift }
+
+my @scalar_keys = qw(
+ name module_name version abstract author license
+ distribution_type sign perl_version
+);
+my @tuple_keys = qw(build_requires requires recommends bundles);
+
+foreach my $key (@scalar_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{'values'}{$key} unless @_;
+ $self->{'values'}{$key} = shift;
+ return $self;
+ };
+}
+
+foreach my $key (@tuple_keys) {
+ *$key = sub {
+ my $self = shift;
+ return $self->{'values'}{$key} unless @_;
+ my @rv;
+ while (@_) {
+ my $module = shift or last;
+ my $version = shift || 0;
+ if ($module eq 'perl') {
+ $version =~ s{^(\d+)\.(\d+)\.(\d+)}
+ {$1 + $2/1_000 + $3/1_000_000}e;
+ $self->perl_version($version);
+ next;
+ }
+ my $rv = [$module, $version];
+ push @{$self->{'values'}{$key}}, $rv;
+ push @rv, $rv;
+ }
+ return @rv;
+ };
+}
+
+sub features {
+ my $self = shift;
+ while (my ($name, $mods) = splice(@_, 0, 2)) {
+ my $count = 0;
+ push @{$self->{'values'}{'features'}}, ($name => [
+ map { (++$count % 2 and ref($_) and ($count += $#$_)) ? @$_ : $_ } @$mods
+ ] );
+ }
+ return @{$self->{'values'}{'features'}};
+}
+
+sub no_index {
+ my $self = shift;
+ my $type = shift;
+ push @{$self->{'values'}{'no_index'}{$type}}, @_ if $type;
+ return $self->{'values'}{'no_index'};
+}
+
+sub _dump {
+ my $self = shift;
+ my $package = ref($self->_top);
+ my $version = $self->_top->VERSION;
+ my %values = %{$self->{'values'}};
+
+ delete $values{sign};
+ if (my $perl_version = delete $values{perl_version}) {
+ # Always canonical to three-dot version
+ $perl_version =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2), int($3))}e
+ if $perl_version >= 5.006;
+ $values{requires} = [
+ [perl => $perl_version],
+ @{$values{requires}||[]},
+ ];
+ }
+
+ warn "No license specified, setting license = 'unknown'\n"
+ unless $values{license};
+
+ $values{license} ||= 'unknown';
+ $values{distribution_type} ||= 'module';
+ $values{name} ||= do {
+ my $name = $values{module_name};
+ $name =~ s/::/-/g;
+ $name;
+ } if $values{module_name};
+
+ if ($values{name} =~ /::/) {
+ my $name = $values{name};
+ $name =~ s/::/-/g;
+ die "Error in name(): '$values{name}' should be '$name'!\n";
+ }
+
+ my $dump = '';
+ foreach my $key (@scalar_keys) {
+ $dump .= "$key: $values{$key}\n" if exists $values{$key};
+ }
+ foreach my $key (@tuple_keys) {
+ next unless exists $values{$key};
+ $dump .= "$key:\n";
+ foreach (@{$values{$key}}) {
+ $dump .= " $_->[0]: $_->[1]\n";
+ }
+ }
+
+ if (my $no_index = $values{no_index}) {
+ push @{$no_index->{'directory'}}, 'inc';
+ require YAML;
+ local $YAML::UseHeader = 0;
+ $dump .= YAML::Dump({ no_index => $no_index});
+ }
+ else {
+ $dump .= << "META";
+no_index:
+ directory:
+ - inc
+META
+ }
+
+ $dump .= "generated_by: $package version $version\n";
+ return $dump;
+}
+
+sub read {
+ my $self = shift;
+ $self->include_deps( 'YAML', 0 );
+ require YAML;
+ my $data = YAML::LoadFile( 'META.yml' );
+ # Call methods explicitly in case user has already set some values.
+ while ( my ($key, $value) = each %$data ) {
+ next unless $self->can( $key );
+ if (ref $value eq 'HASH') {
+ while (my ($module, $version) = each %$value) {
+ $self->$key( $module => $version );
+ }
+ }
+ else {
+ $self->$key( $value );
+ }
+ }
+ return $self;
+}
+
+sub write {
+ my $self = shift;
+ return $self unless $self->is_admin;
+
+ META_NOT_OURS: {
+ local *FH;
+ if (open FH, "META.yml") {
+ while (<FH>) {
+ last META_NOT_OURS if /^generated_by: Module::Install\b/;
+ }
+ return $self if -s FH;
+ }
+ }
+
+ warn "Writing META.yml\n";
+ open META, "> META.yml" or warn "Cannot write to META.yml: $!";
+ print META $self->_dump;
+ close META;
+ return $self;
+}
+
+sub version_from {
+ my ($self, $version_from) = @_;
+ require ExtUtils::MM_Unix;
+ $self->version(ExtUtils::MM_Unix->parse_version($version_from));
+}
+
+sub abstract_from {
+ my ($self, $abstract_from) = @_;
+ require ExtUtils::MM_Unix;
+ $self->abstract(
+ bless( { DISTNAME => $self->name }, 'ExtUtils::MM_Unix')
+ ->parse_abstract($abstract_from)
+ );
+}
+
+1;
Added: RT-Extension-MergeUsers/inc/Module/Install/RTx.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/RTx.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,158 @@
+#line 1 "inc/Module/Install/RTx.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/RTx.pm"
+package Module::Install::RTx;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$Module::Install::RTx::VERSION = '0.11';
+
+use strict;
+use FindBin;
+use File::Glob ();
+use File::Basename ();
+
+sub RTx {
+ my ($self, $name) = @_;
+ my $RTx = 'RTx';
+ $RTx = $1 if $name =~ s/^(\w+)-//;
+ my $fname = $name;
+ $fname =~ s!-!/!g;
+
+ $self->name("$RTx-$name")
+ unless $self->name;
+ $self->abstract("RT $name Extension")
+ unless $self->abstract;
+ $self->version_from (-e "$name.pm" ? "$name.pm" : "lib/$RTx/$fname.pm")
+ unless $self->version;
+
+ my @prefixes = (qw(/opt /usr/local /home /usr /sw ));
+ my $prefix = $ENV{PREFIX};
+ @ARGV = grep { /PREFIX=(.*)/ ? (($prefix = $1), 0) : 1 } @ARGV;
+
+ if ($prefix) {
+ $RT::LocalPath = $prefix;
+ $INC{'RT.pm'} = "$RT::LocalPath/lib/RT.pm";
+ }
+ else {
+ local @INC = (
+ @INC,
+ $ENV{RTHOME} ? ($ENV{RTHOME}, "$ENV{RTHOME}/lib") : (),
+ map {( "$_/rt3/lib", "$_/lib/rt3", "$_/lib" )} grep $_, @prefixes
+ );
+ until ( eval { require RT; $RT::LocalPath } ) {
+ warn "Cannot find the location of RT.pm that defines \$RT::LocalPath in: @INC\n";
+ $_ = $self->prompt("Path to your RT.pm:") or exit;
+ push @INC, $_, "$_/rt3/lib", "$_/lib/rt3";
+ }
+ }
+
+ my $lib_path = File::Basename::dirname($INC{'RT.pm'});
+ print "Using RT configurations from $INC{'RT.pm'}:\n";
+
+ $RT::LocalVarPath ||= $RT::VarPath;
+ $RT::LocalPoPath ||= $RT::LocalLexiconPath;
+ $RT::LocalHtmlPath ||= $RT::MasonComponentRoot;
+
+ my %path;
+ my $with_subdirs = $ENV{WITH_SUBDIRS};
+ @ARGV = grep { /WITH_SUBDIRS=(.*)/ ? (($with_subdirs = $1), 0) : 1 } @ARGV;
+ my %subdirs = map { $_ => 1 } split(/\s*,\s*/, $with_subdirs);
+
+ foreach (qw(bin etc html po sbin var)) {
+ next unless -d "$FindBin::Bin/$_";
+ next if %subdirs and !$subdirs{$_};
+ $self->no_index( directory => $_ );
+
+ no strict 'refs';
+ my $varname = "RT::Local" . ucfirst($_) . "Path";
+ $path{$_} = ${$varname} || "$RT::LocalPath/$_";
+ }
+
+ $path{$_} .= "/$name" for grep $path{$_}, qw(etc po var);
+ my $args = join(', ', map "q($_)", %path);
+ $path{lib} = "$RT::LocalPath/lib" unless %subdirs and !$subdirs{'lib'};
+ print "./$_\t=> $path{$_}\n" for sort keys %path;
+
+ if (my @dirs = map { (-D => $_) } grep $path{$_}, qw(bin html sbin)) {
+ my @po = map { (-o => $_) } grep -f, File::Glob::bsd_glob("po/*.po");
+ $self->postamble(<< ".") if @po;
+lexicons ::
+\t\$(NOECHO) \$(PERL) -MLocale::Maketext::Extract::Run=xgettext -e \"xgettext(qw(@dirs @po))\"
+.
+ }
+
+ my $postamble = << ".";
+install ::
+\t\$(NOECHO) \$(PERL) -MExtUtils::Install -e \"install({$args})\"
+.
+
+ if ($path{var} and -d $RT::MasonDataDir) {
+ my ($uid, $gid) = (stat($RT::MasonDataDir))[4, 5];
+ $postamble .= << ".";
+\t\$(NOECHO) chown -R $uid:$gid $path{var}
+.
+ }
+
+ my %has_etc;
+ if (File::Glob::bsd_glob("$FindBin::Bin/etc/schema.*")) {
+ # got schema, load factory module
+ $has_etc{schema}++;
+ $self->load('RTxFactory');
+ $self->postamble(<< ".");
+factory ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name))"
+
+dropdb ::
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxFactory(qw($RTx $name drop))"
+
+.
+ }
+ if (File::Glob::bsd_glob("$FindBin::Bin/etc/acl.*")) {
+ $has_etc{acl}++;
+ }
+ if (-e 'etc/initialdata') {
+ $has_etc{initialdata}++;
+ }
+
+ $self->postamble("$postamble\n");
+ if (%subdirs and !$subdirs{'lib'}) {
+ $self->makemaker_args(
+ PM => { "" => "" },
+ )
+ }
+ else {
+ $self->makemaker_args( INSTALLSITELIB => "$RT::LocalPath/lib" );
+ }
+
+ if (%has_etc) {
+ $self->load('RTxInitDB');
+ print "For first-time installation, type 'make initdb'.\n";
+ my $initdb = '';
+ $initdb .= <<"." if $has_etc{schema};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(schema))"
+.
+ $initdb .= <<"." if $has_etc{acl};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(acl))"
+.
+ $initdb .= <<"." if $has_etc{initialdata};
+\t\$(NOECHO) \$(PERL) -Ilib -I"$lib_path" -Minc::Module::Install -e"RTxInitDB(qw(insert))"
+.
+ $self->postamble("initdb ::\n$initdb\n");
+ $self->postamble("initialize-database ::\n$initdb\n");
+ }
+}
+
+sub RTxInit {
+ unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
+ require RT;
+ RT::LoadConfig();
+ RT::ConnectToDatabase();
+
+ die "Cannot load RT" unless $RT::Handle and $RT::DatabaseType;
+}
+
+1;
+
+__END__
+
+#line 221
+
+#line 242
Added: RT-Extension-MergeUsers/inc/Module/Install/Win32.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/Win32.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,63 @@
+#line 1 "inc/Module/Install/Win32.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/Win32.pm"
+package Module::Install::Win32;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+$VERSION = '0.02';
+
+use strict;
+
+# determine if the user needs nmake, and download it if needed
+sub check_nmake {
+ my $self = shift;
+ $self->load('can_run');
+ $self->load('get_file');
+
+ require Config;
+ return unless (
+ $Config::Config{make} and
+ $Config::Config{make} =~ /^nmake\b/i and
+ $^O eq 'MSWin32' and
+ !$self->can_run('nmake')
+ );
+
+ print "The required 'nmake' executable not found, fetching it...\n";
+
+ require File::Basename;
+ my $rv = $self->get_file(
+ url => 'http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe',
+ ftp_url => 'ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe',
+ local_dir => File::Basename::dirname($^X),
+ size => 51928,
+ run => 'Nmake15.exe /o > nul',
+ check_for => 'Nmake.exe',
+ remove => 1,
+ );
+
+ if (!$rv) {
+ die << '.';
+
+-------------------------------------------------------------------------------
+
+Since you are using Microsoft Windows, you will need the 'nmake' utility
+before installation. It's available at:
+
+ http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe
+ or
+ ftp://ftp.microsoft.com/Softlib/MSLFILES/Nmake15.exe
+
+Please download the file manually, save it to a directory in %PATH% (e.g.
+C:\WINDOWS\COMMAND\), then launch the MS-DOS command line shell, "cd" to
+that directory, and run "Nmake15.exe" from there; that will create the
+'nmake.exe' file needed by this module.
+
+You may then resume the installation process described in README.
+
+-------------------------------------------------------------------------------
+.
+ }
+}
+
+1;
+
+__END__
+
Added: RT-Extension-MergeUsers/inc/Module/Install/WriteAll.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/inc/Module/Install/WriteAll.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,36 @@
+#line 1 "inc/Module/Install/WriteAll.pm - /sw/lib/perl5/site_perl/5.8.6/Module/Install/WriteAll.pm"
+package Module::Install::WriteAll;
+use Module::Install::Base; @ISA = qw(Module::Install::Base);
+
+sub WriteAll {
+ my $self = shift;
+ my %args = (
+ meta => 1,
+ sign => 0,
+ inline => 0,
+ check_nmake => 1,
+ @_
+ );
+
+ $self->sign(1) if $args{sign};
+ $self->Meta->write if $args{meta};
+ $self->admin->WriteAll(%args) if $self->is_admin;
+
+ if ($0 =~ /Build.PL$/i) {
+ $self->Build->write;
+ }
+ else {
+ $self->check_nmake if $args{check_nmake};
+ $self->makemaker_args( PL_FILES => {} )
+ unless $self->makemaker_args->{'PL_FILES'};
+
+ if ($args{inline}) {
+ $self->Inline->write;
+ }
+ else {
+ $self->Makefile->write;
+ }
+ }
+}
+
+1;
Added: RT-Extension-MergeUsers/lib/RT/Extension/MergeUsers.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/lib/RT/Extension/MergeUsers.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,5 @@
+package RT::Extension::MergeUsers;
+
+our $VERSION = '0.02';
+
+1;
Added: RT-Extension-MergeUsers/lib/RT/User_Vendor.pm
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/lib/RT/User_Vendor.pm Wed Jun 15 15:22:51 2005
@@ -0,0 +1,162 @@
+# BEGIN BPS TAGGED BLOCK {{{
+#
+# COPYRIGHT:
+#
+# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC
+# <jesse at bestpractical.com>
+#
+# (Except where explicitly superseded by other copyright notices)
+#
+#
+# LICENSE:
+#
+# This work is made available to you under the terms of Version 2 of
+# the GNU General Public License. A copy of that license should have
+# been provided with this software, but in any event can be snarfed
+# from www.gnu.org.
+#
+# This work is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+#
+# CONTRIBUTION SUBMISSION POLICY:
+#
+# (The following paragraph is not intended to limit the rights granted
+# to you to modify and distribute this software under the terms of
+# the GNU General Public License and is only of importance to you if
+# you choose to contribute your changes and enhancements to the
+# community by submitting them to Best Practical Solutions, LLC.)
+#
+# By intentionally submitting any modifications, corrections or
+# derivatives to this work, or any other work intended for use with
+# Request Tracker, to Best Practical Solutions, LLC, you confirm that
+# you are the copyright holder for those contributions and you grant
+# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
+# royalty-free, perpetual, license to use, copy, create derivative
+# works based on those contributions, and sublicense and distribute
+# those contributions and any derivatives thereof.
+#
+# END BPS TAGGED BLOCK }}}
+
+no warnings qw(redefine);
+
+package RT::User;
+
+sub CanonicalizeEmailAddress {
+ my $self = shift;
+ my $address = shift;
+
+ if ($RT::CanonicalizeEmailAddressMatch && $RT::CanonicalizeEmailAddressReplace ) {
+ $address =~ s/$RT::CanonicalizeEmailAddressMatch/$RT::CanonicalizeEmailAddressReplace/gi;
+ }
+
+ # get the user whose email address this is
+ my $canonical_user = RT::User->new($RT::SystemUser);
+ $canonical_user->LoadByCol( "EmailAddress", $address );
+
+ # if we got a user, check for a parent
+ if ($canonical_user->Id) {
+ my ($effective_id) = $canonical_user->Attributes->Named("EffectiveId");
+ if (defined $effective_id) {
+ $canonical_user->LoadById($effective_id->Content);
+ # is there another parent user above this one?
+ return $canonical_user->CanonicalizeEmailAddress($canonical_user->EmailAddress)
+ if ($canonical_user->Id);
+ }
+ }
+ # we've hit the primary user
+ return $address;
+}
+
+sub MergeInto {
+ my $self = shift;
+ my $user = shift;
+
+ # Load the user objects we were called with
+ my $merge;
+ if (ref $user) {
+ $merge = RT::User->new($RT::SystemUser);
+ $merge->Load($user->Id);
+ } else {
+ $merge = RT::User->new($RT::SystemUser);
+ $merge->Load($user);
+ }
+
+ return (0, "Could not load @{[$merge->Name]}") unless $merge->Id;
+
+ # Get copies of the canonicalized users
+ my $email;
+ if (defined $merge->Attributes->Named('EffectiveId')) {
+ $email = $merge->CanonicalizeEmailAddress($merge->EmailAddress);
+ $merge->LoadByEmail($email);
+ }
+ return (0, "Could not load user to be merged") unless $merge->Id;
+
+ my $canonical_self = RT::User->new($RT::SystemUser);
+ $canonical_self->Load($self->Id);
+ if (defined $canonical_self->Attributes->Named('EffectiveId')) {
+ $email = $canonical_self->CanonicalizeEmailAddress($canonical_self->EmailAddress);
+ $canonical_self->LoadByEmail($email);
+ }
+ return (0, "Could not load user to merge into") unless $canonical_self->Id;
+
+ # No merging into yourself!
+ return (0, "Could not merge @{[$merge->Name]} into itself")
+ if $merge->Id == $canonical_self->Id;
+
+ # No merging if the user you're merging into was merged into you
+ # (ie. you're the primary address for this user)
+ my ($new) = $merge->Attributes->Named("EffectiveId");
+ return (0, "User @{[$canonical_self->Name]} has already been merged")
+ if defined $new and $new->Content == $canonical_self->Id;
+
+ # do the merge
+ $canonical_self->SetAttribute(Name => "EffectiveId",
+ Description => "Primary ID of this email address",
+ Content => $merge->Id,
+ );
+
+ $canonical_self->SetComments(join "\n", grep {/\S/} (
+ $canonical_self->Comments,
+ "Merged into ".$merge->EmailAddress." (".$merge->id.")",
+ )
+ );
+ $merge->SetComments(join "\n", grep {/\S/} (
+ $merge->Comments,
+ $canonical_self->EmailAddress." (".$canonical_self->Id.") merged into this user",
+ )
+ );
+}
+
+sub UnMerge {
+ my $self = shift;
+
+ my ($current) = $self->Attributes->Named("EffectiveId");
+ return (0, "No parent user") unless $current;
+
+ my $merge = RT::User->new($RT::SystemUser);
+ $merge->Load($current->Content);
+
+ $current->Delete;
+ $self->SetComments(join "\n", grep {/\S/} (
+ $self->Comments,
+ "Unmerged from ".$merge->EmailAddress." (".$merge->Id.")",
+ )
+ );
+
+ $merge->SetComments(join "\n", grep {/\S/} (
+ $merge->Comments,
+ $self->EmailAddress." (".$self->Id.") unmerged from this user",
+ )
+ );
+
+ return ($merge->Id, "Unmerged from @{[$merge->EmailAddress]}");
+}
+
+1;
Added: RT-Extension-MergeUsers/t/01merge_users.t
==============================================================================
--- (empty file)
+++ RT-Extension-MergeUsers/t/01merge_users.t Wed Jun 15 15:22:51 2005
@@ -0,0 +1,93 @@
+#!/sw/bin/perl5.8.6
+
+use strict;
+#use Test::More qw/no_plan/;
+use Test::More tests => 16;
+
+use RT;
+RT::LoadConfig();
+RT::Init;
+
+use RT::Extension::MergeUsers;
+
+my ($id, $message);
+
+# make sure the extension is installed
+use_ok('RT::Extension::MergeUsers');
+
+# create N unique users ($$ == our pid)
+my $primary_user = RT::User->new($RT::SystemUser);
+($id, $message) = $primary_user->Create( EmailAddress => "primary-$$\@example.com" );
+ok($id, "Created 'primary' user? $message");
+
+my $secondary_user = RT::User->new($RT::SystemUser);
+($id, $message) = $secondary_user->Create( EmailAddress => "secondary-$$\@example.com" );
+ok($id, "Created 'secondary' user? $message");
+
+my $tertiary_user = RT::User->new($RT::SystemUser);
+($id, $message) = $tertiary_user->Create( EmailAddress => "tertiary-$$\@example.com" );
+ok($id, "Created 'tertiary' user? $message");
+
+my $quaternary_user = RT::User->new($RT::SystemUser);
+($id, $message) = $quaternary_user->Create( EmailAddress => "quaternary-$$\@example.com" );
+ok($id, "Created 'quaternary' user? $message");
+
+# load a nonexistent user
+my $nonexistent_user = RT::User->new($RT::SystemUser);
+#or, rather, don't load anything at all
+
+# module should error if there isn't a valid user
+($id, $message) = $primary_user->MergeInto($nonexistent_user);
+ok(!$id, "Doesn't merge into non-existent users? $message");
+
+# a user should not be able to be merged into itself
+($id, $message) = $primary_user->MergeInto($primary_user);
+ok(!$id, "Doesn't merge a user into itself? $message");
+
+# successfully merges users
+($id, $message) = $secondary_user->MergeInto($primary_user);
+ok($id, "Successfully merges users? $message");
+
+# recognizes already-merged users
+($id, $message) = $secondary_user->MergeInto($primary_user);
+ok(!$id, "Recognizes secondary as child? $message");
+($id, $message) = $primary_user->MergeInto($secondary_user);
+ok(!$id, "Recognizes primary as parent? $message");
+
+# DTRT with multiple inheritance
+$quaternary_user->MergeInto($tertiary_user);
+($id, $message) = $tertiary_user->MergeInto($primary_user);
+ok($id, "Merges users with children? $message");
+
+# recognizes siblings
+($id, $message) = $tertiary_user->MergeInto($secondary_user);
+ok(!$id, "Recognizes siblings? $message");
+
+# recognizes children of children as children of the primary
+($id, $message) = $quaternary_user->MergeInto($primary_user);
+ok(!$id, "Recognizes children of children? $message");
+
+# Associates tickets from a secondary address with the primary address
+my $ticket = RT::Ticket->new($RT::SystemUser);
+my $transaction_obj;
+($id, $transaction_obj, $message)
+ = $ticket->Create( Requestor => ["secondary-$$\@example.com"],
+ Queue => 'general',
+ Subject => 'MergeUsers test',
+ );
+ok($ticket->RequestorAddresses =~ /primary-$$\@example.com/, "Canonicalizes tickets properly: @{[$ticket->RequestorAddresses]}");
+
+# allows unmerging
+($id, $message) = $secondary_user->UnMerge;
+ok($id, "Unmerges users? $message");
+
+# Associates tickets from unmerged address with the secondary address
+my $ticket2 = RT::Ticket->new($RT::SystemUser);
+($id, $transaction_obj, $message)
+ = $ticket2->Create( Requestor => ["secondary-$$\@example.com"],
+ Queue => 'general',
+ Subject => 'UnMergeUsers test',
+ );
+ok($ticket2->RequestorAddresses =~ /secondary-$$\@example.com/, "Unmerges tickets properly: @{[$ticket2->RequestorAddresses]}");
+
+1;
More information about the Rt-commit
mailing list