6 # We do the delete in pure SQL because Attribute collections
7 # otherwise attempt to hash everything in memory. As this may
8 # be a large list, do it directly.
9 RT->DatabaseHandle->dbh->do(<<EOSQL);
10 DELETE FROM Attributes
11 WHERE Name = 'DeferredRecipients'
17 "Going to add [OLD] prefix to all templates in approvals queue."
18 ." If you have never used approvals, you can safely delete all the"
19 ." templates with the [OLD] prefix. Leave the new Approval templates because"
20 ." you may eventually want to start using approvals."
23 my $approvals_q = RT::Queue->new( RT->SystemUser );
24 $approvals_q->Load('___Approvals');
25 unless ( $approvals_q->id ) {
26 RT->Logger->error("You have no approvals queue.");
30 my $templates = RT::Templates->new( RT->SystemUser );
31 $templates->LimitToQueue( $approvals_q->id );
32 while ( my $tmpl = $templates->Next ) {
33 my ($status, $msg) = $tmpl->SetName( "[OLD] ". $tmpl->Name );
35 RT->Logger->error("Couldn't rename template #". $tmpl->id .": $msg");
42 my $group = RT::Group->new( RT->SystemUser );
43 $group->DBIx::SearchBuilder::Record::LoadByCols(
44 Domain => 'SystemInternal',
48 RT->Logger->warn("Failed to load Privilged group");
51 my ( $return, $msg ) = $group->PrincipalObj->GrantRight(
52 Right => 'ShowApprovalsTab',
55 RT->Logger->warn("Failed to grant ShowApprovalsTab right: $msg")
61 { Queue => '___Approvals',
62 Name => "New Pending Approval", # loc
64 "Notify Owners and AdminCcs of new items pending their approval", # loc
65 Content => 'Subject: New Pending Approval: {$Ticket->Subject}
69 There is a new item pending your approval: "{$Ticket->Subject()}",
70 a summary of which appears below.
72 Please visit {RT->Config->Get(\'WebURL\')}Approvals/Display.html?id={$Ticket->id}
73 to approve or reject this ticket, or {RT->Config->Get(\'WebURL\')}Approvals/ to
74 batch-process all your pending approvals.
76 -------------------------------------------------------------------------
77 {$Transaction->Content()}
80 { Queue => '___Approvals',
81 Name => "Approval Passed", # loc
83 "Notify Requestor of their ticket has been approved by some approver", # loc
84 Content => 'Subject: Ticket Approved: {$Ticket->Subject}
88 Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
89 Other approvals may be pending.
91 Approver\'s notes: { $Notes }
94 { Queue => '___Approvals',
95 Name => "All Approvals Passed", # loc
97 "Notify Requestor of their ticket has been approved by all approvers", # loc
98 Content => 'Subject: Ticket Approved: {$Ticket->Subject}
102 Your ticket has been approved by { eval { $Approval->OwnerObj->Name } }.
103 Its Owner may now start to act on it.
105 Approver\'s notes: { $Notes }
108 { Queue => '___Approvals',
109 Name => "Approval Rejected", # loc
111 "Notify Owner of their rejected ticket", # loc
112 Content => 'Subject: Ticket Rejected: {$Ticket->Subject}
116 Your ticket has been rejected by { eval { $Approval->OwnerObj->Name } }.
118 Approver\'s notes: { $Notes }
121 { Queue => '___Approvals',
122 Name => "Approval Ready for Owner", # loc
124 "Notify Owner of their ticket has been approved and is ready to be acted on", # loc
125 Content => 'Subject: Ticket Approved: {$Ticket->Subject}
129 The ticket has been approved, you may now start to act on it.
137 RT->Logger->debug("Going to adjust dashboards");
138 my $sys = RT::System->new(RT->SystemUser);
140 my $attrs = RT::Attributes->new( RT->SystemUser );
141 $attrs->Limit( FIELD => "Name", VALUE => "Dashboard");
142 my @dashboards = $attrs->Named('Dashboard');
144 if (@dashboards == 0) {
145 RT->Logger->debug("You have no dashboards. Skipped.");
149 for my $attr (@dashboards) {
150 my $props = $attr->Content;
151 if (exists $props->{Searches}) {
155 my ($privacy, $id, $desc) = @$_;
158 portlet_type => 'search',
161 description => $desc,
164 } @{ delete $props->{Searches} }
168 my ($status, $msg) = $attr->SetContent( $props );
169 RT->Logger->error($msg) unless $status;
172 RT->Logger->debug("Fixed.");
176 my $approvals_q = RT::Queue->new( RT->SystemUser );
177 $approvals_q->Load('___Approvals');
178 unless ( $approvals_q->id ) {
179 RT->Logger->error("You have no approvals queue.");
184 my ($tmp_fh, $tmp_fn) = File::Temp::tempfile( 'rt-approvals-scrips-XXXX', CLEANUP => 0 );
186 RT->Logger->error("Couldn't create temporary file.");
191 "IMPORTANT: We're going to delete all scrips in Approvals queue"
192 ." and save them in '$tmp_fn' file."
195 require Data::Dumper;
197 my $scrips = RT::Scrips->new( RT->SystemUser );
198 $scrips->{'with_disabled_column'} = 0;
199 $scrips->Limit( FIELD => 'Queue', VALUE => $approvals_q->id );
200 while ( my $scrip = $scrips->Next ) {
202 map { $_ => $scrip->_Value( $_ ) }
203 qw/id Description ScripCondition ScripAction
204 CustomIsApplicableCode CustomPrepareCode CustomCommitCode
205 Stage Queue Template Creator Created LastUpdatedBy LastUpdated/;
207 print $tmp_fh Data::Dumper::Dumper( \%tmp );
209 my ($status, $msg) = $scrip->DBIx::SearchBuilder::Record::Delete;
211 RT->Logger->error( "Couldn't delete scrip: $msg");