]> git.uio.no Git - usit-rt.git/blame - etc/upgrade/3.8.3/content
Putting 4.2.0 on top of 4.0.17
[usit-rt.git] / etc / upgrade / 3.8.3 / content
CommitLineData
af59614d
MKG
1use strict;
2use warnings;
3
4our @ScripConditions = (
01e3b242
MKG
5 { Name => 'On Reject', # loc
6 Description => 'Whenever a ticket is rejected', # loc
7 ApplicableTransTypes => 'Status',
8 ExecModule => 'StatusChange',
9 Argument => 'rejected'
10
11 },
12);
13
af59614d 14our @Final = (
01e3b242 15 sub {
af59614d 16 RT->Logger->debug("Going to correct descriptions of notify actions in the DB");
01e3b242
MKG
17
18 my $actions = RT::ScripActions->new( RT->SystemUser );
19 $actions->Limit(
20 FIELD => 'ExecModule',
21 VALUE => 'Notify',
22 );
23 $actions->Limit(
24 FIELD => 'Argument',
25 VALUE => 'All',
26 );
27 while ( my $action = $actions->Next ) {
28 my ($status, $msg) = $action->__Set( Field => 'Name', Value => 'Notify Owner, Requestors, Ccs and AdminCcs' );
af59614d 29 RT->Logger->warning( "Couldn't change action name: $msg" )
01e3b242
MKG
30 unless $status;
31
32 ($status, $msg) = $action->__Set( Field => 'Description', Value => 'Send mail to owner and all watchers' );
af59614d 33 RT->Logger->warning( "Couldn't change action description: $msg" )
01e3b242
MKG
34 unless $status;
35 }
36
37 $actions = RT::ScripActions->new( RT->SystemUser );
38 $actions->Limit(
39 FIELD => 'ExecModule',
40 VALUE => 'NotifyAsComment',
41 );
42 $actions->Limit(
43 FIELD => 'Argument',
44 VALUE => 'All',
45 );
46 while ( my $action = $actions->Next ) {
47 my ($status, $msg) = $action->__Set( Field => 'Name', Value => 'Notify Owner, Requestors, Ccs and AdminCcs as Comment' );
af59614d 48 RT->Logger->warning( "Couldn't change action name: $msg" )
01e3b242
MKG
49 unless $status;
50
51 ($status, $msg) = $action->__Set( Field => 'Description', Value => 'Send mail to owner and all watchers as a "comment"' );
af59614d 52 RT->Logger->warning( "Couldn't change action description: $msg" )
01e3b242
MKG
53 unless $status;
54 }
55
af59614d 56 RT->Logger->debug("Corrected descriptions of notify actions in the DB.");
01e3b242
MKG
57 return 1;
58 },
59);
60
af59614d 61our (@ScripActions, @Scrips);
01e3b242 62{
af59614d 63RT->Logger->debug("Going to add in Extract Subject Tag actions if they were missed during a previous upgrade");
01e3b242 64
af59614d 65my $actions = RT::ScripActions->new( RT->SystemUser );
01e3b242
MKG
66$actions->Limit(
67 FIELD => 'ExecModule',
68 VALUE => 'ExtractSubjectTag',
69);
70my $extract_action = $actions->First;
71
72if ( $extract_action && $extract_action->Id ) {
af59614d 73 RT->Logger->debug("You appear to already have an Extract Subject Tag action, skipping");
01e3b242
MKG
74 return 1;
75} else {
af59614d 76 RT->Logger->debug("Didn't find an existing Extract Subject Tag action, adding it");
01e3b242
MKG
77 push @ScripActions, (
78 { Name => 'Extract Subject Tag', # loc
79 Description => 'Extract tags from a Transaction\'s subject and add them to the Ticket\'s subject.', # loc
80 ExecModule => 'ExtractSubjectTag'
81 },
82 );
83
af59614d
MKG
84 RT->Logger->debug("Adding Extract Subject Tag Scrip");
85 push @Final, sub {
86 my $action = RT::ScripAction->new( RT->SystemUser );
87 $action->Load( 'Extract Subject Tag' );
88 my $condition = RT::ScripCondition->new( RT->SystemUser );
89 $condition->Load( 'On Transaction' );
90 my $template = RT::Template->new( RT->SystemUser );
91 $template->LoadByName( Name => 'Blank', Queue => 0 );
92 my $scrip = RT::Scrip->new( RT->SystemUser );
93 $scrip->RT::Record::Create(
94 Description => "On transaction, add any tags in the transaction's subject to the ticket's subject",
95 ScripCondition => $condition->id,
96 ScripAction => $action->id,
97 Template => $template->id,
98 Stage => 'TransactionCreate',
99 Queue => 0,
100 );
101 };
01e3b242
MKG
102}
103}
104