X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=rt%2Fetc%2Fupgrade%2Fsplit-out-cf-categories;h=a5c354d3d483ab6520f306965594c4ea2930ec3f;hb=43a06151e47d2c59b833cbd8c26d97865ee850b6;hp=d4077ce54d54660f79d9383303635b4eed018900;hpb=63a268637b2d51a8766412617724b9436439deb6;p=freeside.git diff --git a/rt/etc/upgrade/split-out-cf-categories b/rt/etc/upgrade/split-out-cf-categories index d4077ce54..a5c354d3d 100755 --- a/rt/etc/upgrade/split-out-cf-categories +++ b/rt/etc/upgrade/split-out-cf-categories @@ -1,41 +1,41 @@ #!/usr/bin/perl # BEGIN BPS TAGGED BLOCK {{{ -# +# # COPYRIGHT: -# -# This software is Copyright (c) 1996-2008 Best Practical Solutions, LLC -# -# +# +# This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC +# +# # (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., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301 or visit their web page on the internet at # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. -# -# +# +# # 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 @@ -44,13 +44,13 @@ # 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 }}} use strict; use warnings; -use lib "local/lib"; -use lib "lib"; +use lib "/opt/rt3/local/lib"; +use lib "/opt/rt3/lib"; use RT; RT::LoadConfig(); @@ -62,7 +62,7 @@ $| = 1; $RT::Handle->BeginTransaction(); use RT::CustomFields; -my $CFs = RT::CustomFields->new( $RT::SystemUser ); +my $CFs = RT::CustomFields->new( RT->SystemUser ); $CFs->UnLimit; $CFs->Limit( FIELD => 'Type', VALUE => 'Select' ); @@ -96,7 +96,7 @@ while (my $cf = $CFs->Next ) { $cf->SetSortOrder( ($cf->SortOrder || 0) + 1 ); # ..and add a new CF before it - my $new = RT::CustomField->new( $RT::SystemUser ); + my $new = RT::CustomField->new( RT->SystemUser ); my ($id, $msg) = $new->Create( Name => $newname, Type => 'Select', @@ -111,10 +111,10 @@ while (my $cf = $CFs->Next ) { # Apply it to all of the same things { - my $ocfs = RT::ObjectCustomFields->new( $RT::SystemUser ); + my $ocfs = RT::ObjectCustomFields->new( RT->SystemUser ); $ocfs->LimitToCustomField( $cf->Id ); while (my $ocf = $ocfs->Next) { - my $newocf = RT::ObjectCustomField->new( $RT::SystemUser ); + my $newocf = RT::ObjectCustomField->new( RT->SystemUser ); ($id, $msg) = $newocf->Create( SortOrder => $ocf->SortOrder, CustomField => $new->Id, @@ -126,10 +126,10 @@ while (my $cf = $CFs->Next ) { # Copy over all of the rights { - my $acl = RT::ACL->new( $RT::SystemUser ); + my $acl = RT::ACL->new( RT->SystemUser ); $acl->LimitToObject( $cf ); while (my $ace = $acl->Next) { - my $newace = RT::ACE->new( $RT::SystemUser ); + my $newace = RT::ACE->new( RT->SystemUser ); ($id, $msg) = $newace->Create( PrincipalId => $ace->PrincipalId, PrincipalType => $ace->PrincipalType, @@ -152,11 +152,11 @@ while (my $cf = $CFs->Next ) { # Grovel through all ObjectCustomFieldValues, and add the # appropriate category { - my $ocfvs = RT::ObjectCustomFieldValues->new( $RT::SystemUser ); + my $ocfvs = RT::ObjectCustomFieldValues->new( RT->SystemUser ); $ocfvs->LimitToCustomField( $cf->Id ); while (my $ocfv = $ocfvs->Next) { next unless exists $mapping{$ocfv->Content}; - my $newocfv = RT::ObjectCustomFieldValue->new( $RT::SystemUser ); + my $newocfv = RT::ObjectCustomFieldValue->new( RT->SystemUser ); ($id, $msg) = $newocfv->Create( CustomField => $new->Id, ObjectType => $ocfv->ObjectType,