import rt 3.8.7
[freeside.git] / rt / etc / upgrade / 3.8.2 / content
1 @Initial = (
2     sub {
3         $RT::Logger->warning(
4             "Going to add [OLD] prefix to all temlates in approvals queue."
5             ." If you never used approvals then you can delete all these"
6             ." templates with [OLD] prefix. Leave new there may be you will"
7             ." want to use approvals some time."
8         );
9
10         my $approvals_q = RT::Queue->new( $RT::SystemUser );
11         $approvals_q->Load('___Approvals');
12         unless ( $approvals_q->id ) {
13             $RT::Logger->error("You have no approvals queue.");
14             return 1;
15         }
16
17         my $templates = RT::Templates->new( $RT::SystemUser );
18         $templates->LimitToQueue( $approvals_q->id );
19         while ( my $tmpl = $templates->Next ) {
20             my ($status, $msg) = $tmpl->SetName( "[OLD] ". $tmpl->Name );
21             unless ( $status ) {
22                 $RT::Logger->error("Couldn't rename template #". $tmpl->id .": $msg");
23             }
24         }
25         return 1;
26     },
27 );
28 @ACL = (
29     { GroupDomain => 'SystemInternal',
30       GroupType => 'privileged',
31       Right  => 'ShowApprovalsTab', },
32 );
33
34 @Templates = (
35     {  Queue       => '___Approvals',
36        Name        => "New Pending Approval",    # loc
37        Description =>
38          "Notify Owners and AdminCcs of new items pending their approval", # loc
39        Content => 'Subject: New Pending Approval: {$Ticket->Subject}
40
41 Greetings,
42
43 There is a new item pending your approval: "{$Ticket->Subject()}", 
44 a summary of which appears below.
45
46 Please visit {RT->Config->Get(\'WebURL\')}Approvals/Display.html?id={$Ticket->id}
47 to approve or reject this ticket, or {RT->Config->Get(\'WebURL\')}Approvals/ to
48 batch-process all your pending approvals.
49
50 -------------------------------------------------------------------------
51 {$Transaction->Content()}
52 '
53     },
54     {  Queue       => '___Approvals',
55        Name        => "Approval Passed",    # loc
56        Description =>
57          "Notify Requestor of their ticket has been approved by some approver", # loc
58        Content => 'Subject: Ticket Approved: {$Ticket->Subject}
59
60 Greetings,
61
62 Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
63 Other approvals may be pending.
64
65 Approver\'s notes: { $Notes }
66 '
67     },
68     {  Queue       => '___Approvals',
69        Name        => "All Approvals Passed",    # loc
70        Description =>
71          "Notify Requestor of their ticket has been approved by all approvers", # loc
72        Content => 'Subject: Ticket Approved: {$Ticket->Subject}
73
74 Greetings,
75
76 Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
77 Its Owner may now start to act on it.
78
79 Approver\'s notes: { $Notes }
80 '
81     },
82     {  Queue       => '___Approvals',
83        Name        => "Approval Rejected",    # loc
84        Description =>
85          "Notify Owner of their rejected ticket", # loc
86        Content => 'Subject: Ticket Rejected: {$Ticket->Subject}
87
88 Greetings,
89
90 Your ticket has been rejected by { eval { $Approval->OwnerObj->Name } }.
91
92 Approver\'s notes: { $Notes }
93 '
94     },
95     {  Queue       => '___Approvals',
96        Name        => "Approval Ready for Owner",    # loc
97        Description =>
98          "Notify Owner of their ticket has been approved and is ready to be acted on", # loc
99        Content => 'Subject: Ticket Approved: {$Ticket->Subject}
100
101 Greetings,
102
103 The ticket has been approved, you may now start to act on it.
104
105 '
106     },
107 );
108
109 @Final = (
110     sub {
111         $RT::Logger->debug("Going to adjust dashboards");
112         my $sys = RT::System->new($RT::SystemUser);
113
114         my $attrs = RT::Attributes->new( $RT::SystemUser );
115         $attrs->UnLimit;
116         my @dashboards = $attrs->Named('Dashboard');
117
118         if (@dashboards == 0) {
119             $RT::Logger->debug("You have no dashboards. Skipped.");
120             return 1;
121         }
122
123         for my $attr (@dashboards) {
124             my $props = $attr->Content;
125             if (exists $props->{Searches}) {
126                 $props->{Panes} = {
127                     body => [
128                         map {
129                             my ($privacy, $id, $desc) = @$_;
130
131                             {
132                                 portlet_type => 'search',
133                                 privacy      => $privacy,
134                                 id           => $id,
135                                 description  => $desc,
136                                 pane         => 'body',
137                             }
138                         } @{ delete $props->{Searches} }
139                     ],
140                 };
141             }
142             my ($status, $msg) = $attr->SetContent( $props );
143             $RT::Logger->error($msg) unless $status;
144         }
145
146         $RT::Logger->debug("Fixed.");
147         return 1;
148     },
149     sub {
150         my $approvals_q = RT::Queue->new( $RT::SystemUser );
151         $approvals_q->Load('___Approvals');
152         unless ( $approvals_q->id ) {
153             $RT::Logger->error("You have no approvals queue.");
154             return 1;
155         }
156
157         require File::Temp;
158         my ($tmp_fh, $tmp_fn) = File::Temp::tempfile( 'rt-approvals-scrips-XXXX', CLEANUP => 0 );
159         unless ( $tmp_fh ) {
160             $RT::Logger->error("Couldn't create temporary file.");
161             return 0;
162         }
163
164         $RT::Logger->warning(
165             "IMPORTANT: We're going to delete all scrips in Approvals queue"
166             ." and save them in '$tmp_fn' file."
167         );
168
169         require Data::Dumper;
170
171         my $scrips = RT::Scrips->new( $RT::SystemUser );
172         $scrips->LimitToQueue( $approvals_q->id );
173         while ( my $scrip = $scrips->Next ) {
174             my %tmp =
175                 map { $tmp->{ $_ } = $scrip->_Value( $_ ) }
176                 $scrip->ReadableAttributes;
177
178             print $tmp_fh Data::Dumper::Dumper( \%tmp );
179
180             my ($status, $msg) = $scrip->Delete;
181             unless ( $status ) {
182                 $RT::Logger->error( "Couldn't delete scrip: $msg");
183             }
184         }
185     },
186 );