use App::EzPz::UserStore;
use strictures 1;
-die "Usage: ezpz-admin-repl ezmlm-bindir htpasswd-file"
- unless @ARGV == 2;
+die "Usage: ezpz-admin-repl htpasswd-file [ezmlm-bindir list-base-dir]"
+ unless @ARGV == 1 or @ARGV == 3;
{
package Eval::WithLexicals::Scratchpad;
use vars qw($users);
$users = App::EzPz::UserStore->new(
- ezmlm_bindir => $ARGV[0],
- htpasswd_file => $ARGV[1],
+ htpasswd_file => $ARGV[0],
+ (@ARGV > 1)
+ ? (ezmlm_config => {
+ bindir => $ARGV[1],
+ list_base_dir => $ARGV[2],
+ })
+ : ()
);
}
--- /dev/null
+package App::EzPz::EzmlmConfig;
+
+use IO::All;
+use Module::Runtime qw(use_module);
+use Moo;
+
+has bindir => (
+ is => 'ro', required => 1,
+);
+
+has list_base_dir => (
+ is => 'ro', required => 1,
+);
+
+sub new_list_object {
+ my ($self, $args) = @_;
+ my $list_dir = io->dir($self->list_base_dir)->catdir($args->{list_name});
+ use_module('Email::EzPz::List')->new(
+ list_dir => $list_dir,
+ ezmlm_bindir => $self->bindir,
+ );
+}
+
+1;
handles => [ qw(username password check_password) ],
);
-has ezmlm_bindir => (is => 'rwp');
+has ezmlm_config => (
+ is => 'rwp',
+ handles => {
+ _new_list_object => 'new_list_object'
+ }
+);
around BUILDARGS => sub {
my ($orig, $self) = (shift, shift);
return;
}
-sub add_list_name {
+sub has_list_name {
my ($self, $name) = @_;
my %names; @names{my @names = $self->list_names} = ();
- $self->set_list_names(@names, $name) unless exists $names{$name};
+ return exists $names{$name};
+}
+
+sub add_list_name {
+ my ($self, $name) = @_;
+ unless ($self->has_list_name($name)) {
+ $self->set_list_names($self->list_names, $name);
+ }
return $name;
}
sub remove_list_name {
my ($self, $name) = @_;
- my %names; @names{my @names = $self->list_names} = ();
- if (exists $names{$name}) {
+ if ($self->has_list_name($name)) {
$self->set_list_names(grep !($_ eq $name), $self->list_names)
}
return $name;
}
+sub get_list {
+ my ($self, $name) = @_;
+ return undef unless $self->has_list_name($name);
+ return $self->_new_list_object({ list_name => $name });
+}
+
1;
use Scalar::Util 'blessed';
use Moo;
-has ezmlm_bindir => (is => 'ro', required => 1);
+has ezmlm_config => (
+ is => 'ro',
+ coerce => sub {
+ return $_[0] if blessed($_[0]);
+ return use_module('App::EzPz::EzmlmConfig')->new($_[0]);
+ }
+);
has htpasswd_file => (is => 'ro', required => 1);
my $htp_user = $user->_htpasswd_user;
$htp_file->add_user($htp_user);
$htp_user->file($htp_file);
- $user->_set_ezmlm_bindir($self->ezmlm_bindir);
+ $user->_set_ezmlm_config($self->ezmlm_config);
return $user;
}
my ($self, $htp_user) = @_;
return use_module('App::EzPz::User')->new(
htpasswd_user => $htp_user,
- ezmlm_bindir => $self->ezmlm_bindir,
+ ezmlm_config => $self->ezmlm_config,
);
}