]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Block.pm
1 package PMG
::RuleDB
::Block
;
12 use PMG
::RuleDB
::Object
;
14 use base
qw(PMG::RuleDB::Object);
41 my ($type, $ogroup) = @_;
43 my $class = ref($type) || $type;
45 my $self = $class->SUPER::new
($class->otype(), $ogroup);
51 my ($type, $ruledb, $id, $ogroup, $value) = @_;
53 my $class = ref($type) || $type;
55 my $obj = $class->new ($ogroup);
58 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $ogroup);
64 my ($self, $ruledb) = @_;
66 defined($self->{ogroup
}) || return undef;
68 if (defined ($self->{id
})) {
76 my $sth = $ruledb->{dbh
}->prepare(
77 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
79 $sth->execute($self->ogroup, $self->otype);
81 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
88 my ($self, $queue, $ruledb, $mod_group, $targets,
89 $msginfo, $vars, $marks) = @_;
91 if ($msginfo->{testmode
}) {
92 my $fh = $msginfo->{test_fh
};
93 print $fh "block from: $msginfo->{sender}\n";
94 printf $fh "block to: %s\n", join (',', @$targets);
97 foreach my $to (@$targets) {
98 syslog
('info', "%s: block mail to <%s>", $queue->{logid
}, $to);
101 $queue->set_status($targets, 'blocked');
107 return "block message";
114 =head1 PMG::RuleDB::Block