]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Block.pm
1 package PMG
::RuleDB
::Block
;
13 use PMG
::RuleDB
::Object
;
15 use base
qw(PMG::RuleDB::Object);
42 my ($type, $ogroup) = @_;
44 my $class = ref($type) || $type;
46 my $self = $class->SUPER::new
($class->otype(), $ogroup);
52 my ($type, $ruledb, $id, $ogroup, $value) = @_;
54 my $class = ref($type) || $type;
56 my $obj = $class->new ($ogroup);
59 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $ogroup);
65 my ($self, $ruledb) = @_;
67 defined($self->{ogroup
}) || return undef;
69 if (defined ($self->{id
})) {
77 my $sth = $ruledb->{dbh
}->prepare(
78 "INSERT INTO Object (Objectgroup_ID, ObjectType) VALUES (?, ?);");
80 $sth->execute($self->ogroup, $self->otype);
82 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
89 my ($self, $queue, $ruledb, $mod_group, $targets,
90 $msginfo, $vars, $marks) = @_;
92 if ($msginfo->{testmode
}) {
93 my $fh = $msginfo->{test_fh
};
94 print $fh "block from: $msginfo->{sender}\n";
95 printf $fh "block to: %s\n", join (',', @$targets);
98 foreach my $to (@$targets) {
99 syslog
('info', "%s: block mail to <%s>", $queue->{logid
}, encode
('UTF-8', $to));
102 $queue->set_status($targets, 'blocked');
108 return "block message";
115 =head1 PMG::RuleDB::Block