import rt 3.8.7
[freeside.git] / rt / etc / upgrade / 3.7.19 / content
1
2 { use strict;
3 add_description_to_all_scrips();
4
5 sub add_description_to_all_scrips {
6     require RT::Scrips;
7     my $scrips = RT::Scrips->new( $RT::SystemUser );
8     $scrips->Limit( FIELD => 'Description', OPERATOR => 'IS', VALUE => 'NULL' );
9     $scrips->Limit( FIELD => 'Description', VALUE => '' );
10     while ( my $scrip = $scrips->Next ) {
11         my $desc = $scrip->Description;
12         next if defined $desc && length $desc;
13
14         $desc = gen_scrip_description( $scrip );
15
16         my ($status, $msg) = $scrip->SetDescription( $desc );
17         unless ( $status ) {
18             print STDERR "Couldn't set description of a scrip: $msg";
19         } else {
20             print "Added description to scrip #". $scrip->id ."\n";
21         }
22     }
23 }
24
25 sub gen_scrip_description {
26     my $scrip = shift;
27     my $condition = $scrip->ConditionObj->Name
28         || $scrip->ConditionObj->Description
29         || ('On Condition #'. $scrip->Condition);
30     my $action = $scrip->ActionObj->Name
31         || $scrip->ActionObj->Description
32         || ('Run Action #'. $scrip->Action);
33     return join ' ', $condition, $action;
34 }
35 }
36
37 1;