]>
Commit | Line | Data |
---|---|---|
f4fe6fc4 DM |
1 | package PMG::RuleDB::Attach; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | use Carp; | |
6 | use DBI; | |
7 | use Digest::SHA; | |
8 | ||
9 | use PMG::Utils; | |
10 | use PMG::ModGroup; | |
11 | use PMG::RuleDB::Object; | |
12 | ||
13 | use base qw(PMG::RuleDB::Object); | |
14 | ||
15 | sub otype { | |
16 | return 4004; | |
17 | } | |
18 | ||
19 | sub oclass { | |
20 | return 'action'; | |
21 | } | |
22 | ||
23 | sub otype_text { | |
24 | return 'Attach'; | |
25 | } | |
26 | ||
27 | sub oicon { | |
28 | return 'attach.gif'; | |
29 | } | |
30 | ||
31 | sub oconfigsite { | |
32 | return ''; | |
33 | } | |
34 | ||
35 | sub oinfo { | |
36 | return 'Attach Data to Mail'; | |
37 | } | |
38 | ||
39 | sub oisedit { | |
40 | return 0; | |
41 | } | |
42 | ||
43 | sub final { | |
44 | return 0; | |
45 | } | |
46 | ||
47 | sub priority { | |
48 | return 49; | |
49 | } | |
50 | ||
51 | sub new { | |
52 | my ($type, $ogroup) = @_; | |
53 | ||
54 | my $class = ref($type) || $type; | |
55 | ||
56 | my $self = $class->SUPER::new(otype(), $ogroup); | |
57 | ||
58 | return $self; | |
59 | } | |
60 | ||
61 | sub load_attr { | |
62 | my ($type, $ruledb, $id, $ogroup, $value) = @_; | |
63 | ||
64 | my $class = ref($type) || $type; | |
65 | ||
66 | my $obj = $class->new ($ogroup); | |
67 | $obj->{id} = $id; | |
68 | ||
69 | $obj->{digest} = Digest::SHA::sha1_hex($id, $ogroup); | |
70 | ||
71 | return $obj; | |
72 | } | |
73 | ||
74 | sub save { | |
75 | my ($self, $ruledb) = @_; | |
76 | ||
77 | defined($self->{ogroup}) || croak "undefined object attribute: ERROR"; | |
78 | ||
79 | if (defined ($self->{id})) { | |
80 | # update not needed | |
81 | } else { | |
82 | # insert | |
83 | ||
84 | my $sth = $ruledb->{dbh}->prepare( | |
85 | "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);"); | |
86 | ||
87 | $sth->execute($self->ogroup, $self->otype); | |
88 | ||
89 | $self->{id} = PMG::Utils::lastid($ruledb->{dbh}, 'object_id_seq'); | |
90 | } | |
91 | ||
92 | return $self->{id}; | |
93 | } | |
94 | ||
95 | sub execute { | |
96 | my ($self, $queue, $ruledb, $mod_group, $targets, | |
97 | $msginfo, $vars, $marks) = @_; | |
98 | ||
99 | my $subgroups = $mod_group->subgroups($targets); | |
100 | ||
101 | foreach my $ta (@$subgroups) { | |
102 | my ($tg, $entity) = (@$ta[0], @$ta[1]); | |
103 | ||
104 | my $path = "/var/spool/proxmox/active/$queue->{uid}"; | |
105 | $entity->attach( | |
106 | Path => $path, | |
107 | Filename => "original_message.eml", | |
108 | Disposition => "attachment", | |
109 | Type => "message/rfc822"); | |
110 | } | |
111 | } | |
112 | ||
113 | sub short_desc { | |
114 | my $self = shift; | |
115 | ||
116 | return "attach original mail"; | |
117 | } | |
118 | ||
119 | ||
120 | 1; | |
121 | ||
122 | __END__ | |
123 | ||
124 | =head1 PMG::RuleDB::Attach | |
125 | ||
126 | Attach original mail. |