From e70abd21bab68b23488f7ef1ee2e693a3b365691 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 18 May 2010 18:49:59 +0000 Subject: import rt 3.8.8 --- rt/etc/upgrade/3.8.8/content | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 rt/etc/upgrade/3.8.8/content (limited to 'rt/etc/upgrade') diff --git a/rt/etc/upgrade/3.8.8/content b/rt/etc/upgrade/3.8.8/content new file mode 100644 index 0000000..ee19433 --- /dev/null +++ b/rt/etc/upgrade/3.8.8/content @@ -0,0 +1,38 @@ +@Initial = ( + sub { + # make sure global CFs are not applied to local objects + my $ocfs = RT::ObjectCustomFields->new( $RT::SystemUser ); + $ocfs->Limit( FIELD => 'ObjectId', OPERATOR => '!=', VALUE => 0 ); + my $alias = $ocfs->Join( + FIELD1 => 'CustomField', + TABLE2 => 'ObjectCustomFields', + FIELD2 => 'CustomField', + ); + $ocfs->Limit( ALIAS => $alias, FIELD => 'ObjectId', VALUE => 0 ); + while ( my $ocf = $ocfs->Next ) { + $ocf->Delete; + } + }, + sub { + # sort SortOrder + my $sth = $RT::Handle->dbh->prepare( + "SELECT cfs.LookupType, ocfs.id" + ." FROM ObjectCustomFields ocfs, CustomFields cfs" + ." WHERE cfs.id = ocfs.CustomField" + ." ORDER BY cfs.LookupType, ocfs.SortOrder, cfs.Name" + ); + $sth->execute; + + my ($i, $prev_type) = (0, ''); + while ( my ($lt, $id) = $sth->fetchrow_array ) { + $i = 0 if $prev_type ne $lt; + my $ocf = RT::ObjectCustomField->new( $RT::SystemUser ); + $ocf->Load( $id ); + my ($status, $msg) = $ocf->SetSortOrder( $i++ ); + $RT::Logger->warning("Couldn't set SortOrder: $msg") + unless $status; + $prev_type = $lt; + } + }, +); + -- cgit v1.1