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