rt 4.2.15
[freeside.git] / rt / etc / upgrade / 4.1.22 / content
1 use strict;
2 use warnings;
3
4 our @Initial = (
5     sub {
6         my $template = RT::Template->new( RT->SystemUser );
7         $template->Load("Error: bad GnuPG data");
8         unless ($template->id) {
9             RT->Logger->error( "Couldn't find 'Error: bad GnuPG data' template to rename" );
10             return;
11         }
12
13         my ($ok, $msg) = $template->SetName("Error: bad encrypted data");
14         RT->Logger->error( "Couldn't rename 'Error: bad GnuPG data' template: $msg")
15             unless $ok;
16
17         ($ok, $msg) = $template->SetDescription("Inform user that a message he sent has invalid encryption data");
18         RT->Logger->error( "Couldn't update 'Error: bad encrypted data' template description: $msg")
19             unless $ok;
20
21         my $content = $template->Content;
22         $content =~ s/GnuPG signature/signature/g;
23         ($ok, $msg) = $template->SetContent( $content );
24         RT->Logger->error( "Couldn't update 'Error: bad encrypted data' template content: $msg")
25             unless $ok;
26     },
27     sub {
28         my $type = RT::User->new( $RT::SystemUser )->CustomFieldLookupType;
29         my $cf = RT::CustomField->new( $RT::SystemUser );
30         $cf->LoadByCols( Name => 'SMIME Key', LookupType => $type );
31         $cf->LoadByCols( Name => 'PublicKey', LookupType => $type ) unless $cf->id;
32         unless ( $cf->id ) {
33             $RT::Logger->debug("You don't have an 'SMIME Key' or 'PublicKey' user CF -- nothing to do.");
34             return;
35         }
36
37         my $users = RT::Users->new( RT->SystemUser );
38         $users->LimitCustomField(
39             CUSTOMFIELD => $cf->id,
40             OPERATOR    => "IS NOT",
41             VALUE       => "NULL",
42         );
43         while (my $u = $users->Next) {
44             $u->SetSMIMECertificate(
45                 $u->FirstCustomFieldValue( $cf->id ),
46             );
47         }
48
49         my $ocfs = $cf->AddedTo;
50         while (my $ocf = $ocfs->Next) {
51             my ($ok, $msg) = $ocf->Delete;
52             RT->Logger->error( "Couldn't delete OCF ".$ocf->id." while deleting ".$cf->Name." CF: $msg")
53                 unless $ok;
54         }
55
56         my ($ok, $msg) = $cf->Delete;
57         RT->Logger->error( "Couldn't delete ".$cf->Name." CF: $msg")
58             unless $ok;
59     },
60     sub {
61         $RT::Logger->info("Going to delete all SMIMEKeyNotAfter attributes");
62         my $attrs = RT::Attributes->new( $RT::SystemUser );
63         $attrs->Limit( FIELD => 'ObjectType', VALUE => 'RT::User' );
64         $attrs->Limit( FIELD => 'Name', VALUE => 'SMIMEKeyNotAfter' );
65         while ( my $attr = $attrs->Next ) {
66             my ($status, $msg) = $attr->Delete;
67             unless ( $status ) {
68                 $RT::Logger->error("Couldn't delete attribute: $msg");
69             }
70         }
71         return 1;
72     },
73 );
74
75 our @Templates = (
76     {  Queue       => 0,
77        Name        => "Error: unencrypted message",    # loc
78        Description =>
79          "Inform user that their unencrypted mail has been rejected", # loc
80        Content => q{Subject: RT requires that all incoming mail be encrypted
81
82 You received this message because RT received mail from you that was not encrypted.  As such, it has been rejected.
83 }
84     },
85 );