]>
git.proxmox.com Git - pmg-api.git/blob - PMG/RuleDB/WhoRegex.pm
1 package PMG
::RuleDB
::WhoRegex
;
10 use PMG
::RuleDB
::Object
;
12 use base
qw(PMG::RuleDB::Object);
23 return 'Regular Expression';
31 my ($type, $address, $ogroup) = @_;
33 my $class = ref($type) || $type;
35 my $self = $class->SUPER::new
($class->otype(), $ogroup);
37 $address //= '.*@domain\.tld';
39 $self->{address
} = $address;
45 my ($type, $ruledb, $id, $ogroup, $value) = @_;
47 my $class = ref($type) || $type;
49 defined($value) || croak
"undefined value: ERROR";
51 my $obj = $class->new ($value, $ogroup);
54 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $value, $ogroup);
60 my ($self, $ruledb) = @_;
62 defined($self->{ogroup
}) || croak
"undefined ogroup: ERROR";
63 defined($self->{address
}) || croak
"undefined address: ERROR";
65 my $adr = $self->{address
};
68 if (defined ($self->{id
})) {
72 "UPDATE Object SET Value = ? WHERE ID = ?",
73 undef, $adr, $self->{id
});
78 my $sth = $ruledb->{dbh
}->prepare (
79 "INSERT INTO Object (Objectgroup_ID, ObjectType, Value) " .
82 $sth->execute($self->{ogroup
}, $self->otype, $adr);
84 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
91 my ($self, $addr) = @_;
93 my $t = $self->address;
95 return $addr =~ m/^$t$/i;
99 my ($self, $addr) = @_;
101 if (defined ($addr)) {
102 $self->{address
} = $addr;
111 my $desc = $self->{address
};
120 =head1 PMG::RuleDB::WhoRegex
122 A WHO object to check email addresses with regular expresssions.
128 A Perl regular expression used to compare email addresses (ignore case).
132 $obj = PMG::RuleDB::WhoRegex->new ('.*@yourdomain.com');