]>
git.proxmox.com Git - pmg-api.git/blob - src/PMG/RuleDB/WhoRegex.pm
1 package PMG
::RuleDB
::WhoRegex
;
9 use PMG
::RuleDB
::Object
;
11 use base
qw(PMG::RuleDB::Object);
22 return 'Regular Expression';
26 my ($type, $address, $ogroup) = @_;
28 my $class = ref($type) || $type;
30 my $self = $class->SUPER::new
($class->otype(), $ogroup);
32 $address //= '.*@domain\.tld';
34 $self->{address
} = $address;
40 my ($type, $ruledb, $id, $ogroup, $value) = @_;
42 my $class = ref($type) || $type;
44 defined($value) || die "undefined value: ERROR";
46 my $obj = $class->new ($value, $ogroup);
49 $obj->{digest
} = Digest
::SHA
::sha1_hex
($id, $value, $ogroup);
55 my ($self, $ruledb) = @_;
57 defined($self->{ogroup
}) || die "undefined ogroup: ERROR";
58 defined($self->{address
}) || die "undefined address: ERROR";
60 my $adr = $self->{address
};
63 if (defined ($self->{id
})) {
67 "UPDATE Object SET Value = ? WHERE ID = ?",
68 undef, $adr, $self->{id
});
73 my $sth = $ruledb->{dbh
}->prepare (
74 "INSERT INTO Object (Objectgroup_ID, ObjectType, Value) " .
77 $sth->execute($self->{ogroup
}, $self->otype, $adr);
79 $self->{id
} = PMG
::Utils
::lastid
($ruledb->{dbh
}, 'object_id_seq');
86 my ($self, $addr) = @_;
88 my $t = $self->address;
90 return $addr =~ m/^$t$/i;
94 my ($self, $addr) = @_;
96 if (defined ($addr)) {
97 $self->{address
} = $addr;
106 my $desc = $self->{address
};
116 description
=> "Email address regular expression.",
126 return { regex
=> $self->{address
} };
130 my ($self, $param) = @_;
132 $self->{address
} = $param->{regex
};
139 =head1 PMG::RuleDB::WhoRegex
141 A WHO object to check email addresses with regular expresssions.
147 A Perl regular expression used to compare email addresses (ignore case).
151 $obj = PMG::RuleDB::WhoRegex->new ('.*@yourdomain.com');