]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/Block.pm
c7c640efe3253f3ee5e6e5c33f8fc21371d60583
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 my $rulename = $vars->{RULE
};
94 if ($msginfo->{testmode
}) {
95 my $fh = $msginfo->{test_fh
};
96 print $fh "block from: $msginfo->{sender}\n";
97 printf $fh "block to: %s\n", join (',', @$targets);
100 foreach my $to (@$targets) {
101 syslog
('info', "%s: block mail to <%s> (rule: %s)", $queue->{logid
}, encode
('UTF-8', $to), $rulename);
104 $queue->set_status($targets, 'blocked');
110 return "block message";
117 =head1 PMG::RuleDB::Block