1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
use strict;
use warnings;
our @Initial = (
sub {
use RT::CustomFields;
my $cfs = RT::CustomFields->new(RT->SystemUser);
$cfs->{'find_disabled_rows'} = 1;
$cfs->Limit( FIELD => 'LookupType', VALUE => 'RT::FM::Class-RT::FM::Article' );
while ( my $cf = $cfs->Next ) {
my ($ret, $msg) = $cf->__Set( Field => 'LookupType', Value => 'RT::Class-RT::Article' );
RT->Logger->warning("Update Custom Field LookupType for CF.".$cf->Id." $msg");
}
return 1;
},
sub {
use RT::ObjectCustomFieldValues;
my $ocfvs = RT::ObjectCustomFieldValues->new(RT->System);
$ocfvs->{'find_expired_rows'} = 1;
$ocfvs->Limit( FIELD => 'ObjectType', VALUE => 'RT::FM::Article' );
while ( my $ocfv = $ocfvs->Next ) {
my ($ret, $msg) = $ocfv->__Set( Field => 'ObjectType', Value => 'RT::Article' );
RT->Logger->warning("Updated CF ".$ocfv->__Value('CustomField')." Value for Article ".$ocfv->__Value('ObjectId'));
}
return 1;
},
sub {
require RT::Scrips;
my $scrips = RT::Scrips->new( RT->SystemUser );
$scrips->{'find_disabled_rows'} = 1;
$scrips->Limit( FIELD => 'Disabled', VALUE => 1 );;
while ( my $scrip = $scrips->Next ) {
my $id = $scrip->Template;
if ( $id =~ /\D/ ) {
$RT::Logger->info('Template column for scrip #'. $scrip->id .' already contains characters');
next;
}
my $name;
my $template = RT::Template->new( RT->SystemUser );
$template->Load( $id );
unless ( $template->id ) {
$RT::Logger->error("Scrip #". $scrip->id ." has template set to #$id, but it's not in DB, setting it 'Blank'");
$name = 'Blank';
} else {
$name = $template->Name;
}
my ($status, $msg) = $scrip->_Set( Field => 'Template', Value => $name );
unless ( $status ) {
$RT::Logger->error("Couldn't set template: $msg");
}
}
},
);
|