default to a session cookie instead of setting an explicit timeout, weird timezone...
[freeside.git] / rt / etc / upgrade / 3.7.19 / content
1 use strict;
2 use warnings;
3
4 our @Final = (
5     sub {
6         require RT::Scrips;
7         my $scrips = RT::Scrips->new( RT->SystemUser );
8         $scrips->{'with_disabled_column'} = 0;
9         $scrips->Limit( FIELD => 'Description', OPERATOR => 'IS', VALUE => 'NULL' );
10         $scrips->Limit( FIELD => 'Description', VALUE => '' );
11         while ( my $scrip = $scrips->Next ) {
12             my $desc = $scrip->Description;
13             next if defined $desc && length $desc;
14
15             $desc = gen_scrip_description( $scrip );
16
17             my ($status, $msg) = $scrip->SetDescription( $desc );
18             unless ( $status ) {
19                 print STDERR "Couldn't set description of a scrip: $msg";
20             } else {
21                 print "Added description to scrip #". $scrip->id ."\n";
22             }
23         }
24     },
25 );
26
27 sub gen_scrip_description {
28     my $scrip = shift;
29
30     my $condition;
31     eval{
32       $condition = $scrip->ConditionObj->Name
33         || $scrip->ConditionObj->Description
34         || ('On Condition #'. $scrip->Condition);
35     };
36
37     if ($@){
38       print STDERR $@;
39       print STDERR "Reference to missing scrip condition found. If you have ScripCondition = 0 in the Scrips table, update with a real condition number.\n";
40       $condition = 'On undefined Condition # 0';
41     }
42
43     my $action = $scrip->ActionObj->Name
44         || $scrip->ActionObj->Description
45         || ('Run Action #'. $scrip->Action);
46     return join ' ', $condition, $action;
47 }
48
49 1;