Commit 614cc549 authored by sikeda's avatar sikeda
Browse files

[-dev] Refactoring: Sympa::Robot::is_listmaster() was moved to Sympa::is_listmaster().


git-svn-id: https://subversion.renater.fr/sympa/branches/sympa-6.2-branch@12294 05aa8bb8-cd2b-0410-b1d7-8918dfa770ce
parent 3e8eacaa
......@@ -2988,7 +2988,7 @@ sub check_param_in {
}
 
## listmaster has owner and editor privileges for the list
if (Sympa::Robot::is_listmaster($param->{'user'}{'email'}, $robot)) {
if (Sympa::is_listmaster($robot, $param->{'user'}{'email'})) {
$param->{'is_listmaster'} = 1;
}
 
......@@ -3185,7 +3185,7 @@ sub check_param_out {
$param->{'process_id'} = $PID;
 
## listmaster has owner and editor privileges for the list
if (Sympa::Robot::is_listmaster($param->{'user'}{'email'}, $robot)) {
if (Sympa::is_listmaster($robot, $param->{'user'}{'email'})) {
$param->{'is_listmaster'} = 1;
} else {
undef $param->{'is_listmaster'};
......@@ -9458,8 +9458,7 @@ sub do_editfile {
'info', subdir => $subdir);
}
} else {
unless (
Sympa::Robot::is_listmaster($param->{'user'}{'email'}, $robot)) {
unless (Sympa::is_listmaster($robot, $param->{'user'}{'email'})) {
Sympa::Report::reject_report_web('user', 'missing_arg',
{'argument' => 'list'},
$param->{'action'});
......@@ -9561,8 +9560,7 @@ sub do_savefile {
 
}
} else {
unless (Sympa::Robot::is_listmaster($param->{'user'}{'email'}),
$robot) {
unless (Sympa::is_listmaster($robot, $param->{'user'}{'email'})) {
Sympa::Report::reject_report_web('user', 'missing_arg',
{'argument' => 'list'},
$param->{'action'});
......@@ -13005,8 +13003,8 @@ sub _prepare_edit_form {
$language->gettext_strftime("%A",
gmtime(0 + ($day + 3) * (3600 * 24)));
$t = sprintf '%s (%s)', $t, $day
if Sympa::Robot::is_listmaster(
$param->{'user'}{'email'}, $robot);
if Sympa::is_listmaster($list,
$param->{'user'}{'email'});
$v->{'value'}{$day}{'title'} = $t;
}
}
......@@ -13017,8 +13015,7 @@ sub _prepare_edit_form {
$language->set_lang($lang);
my $t = $language->native_name || $lang;
$t = sprintf '%s (%s)', $t, $lang
if Sympa::Robot::is_listmaster($param->{'user'}{'email'},
$robot);
if Sympa::is_listmaster($list, $param->{'user'}{'email'});
$p->{'value'}{$lang}{'title'} = $t;
# compatibility: 6.1.
$p->{'value'}{$lang}{'lang_tag'} = $lang;
......@@ -13032,8 +13029,8 @@ sub _prepare_edit_form {
$v->{'value'}{$x}{'title'} = $list->get_option_title(
$x,
'reception',
Sympa::Robot::is_listmaster(
$param->{'user'}{'email'}, $robot
Sympa::is_listmaster(
$list, $param->{'user'}{'email'}
)
);
}
......@@ -13042,8 +13039,8 @@ sub _prepare_edit_form {
$v->{'value'}{$x}{'title'} = $list->get_option_title(
$x,
'visibility',
Sympa::Robot::is_listmaster(
$param->{'user'}{'email'}, $robot
Sympa::is_listmaster(
$list, $param->{'user'}{'email'}
)
);
}
......@@ -13051,12 +13048,9 @@ sub _prepare_edit_form {
}
} elsif ($pname eq 'status') {
foreach my $x (keys %{$p->{'value'}}) {
$p->{'value'}{$x}{'title'} = $list->get_option_title(
$x, 'status',
Sympa::Robot::is_listmaster(
$param->{'user'}{'email'}, $robot
)
);
$p->{'value'}{$x}{'title'} =
$list->get_option_title($x, 'status',
Sympa::is_listmaster($list, $param->{'user'}{'email'}));
}
}
 
......@@ -13419,7 +13413,7 @@ sub do_rename_list_request {
}
 
## Super listmaster can move a list to another robot
if (Sympa::Robot::is_listmaster($param->{'user'}{'email'}, '*')) {
if (Sympa::is_listmaster('*', $param->{'user'}{'email'})) {
$param->{'robots'} = {};
foreach my $r (Sympa::List::get_robots()) {
if ($r eq $robot) {
......@@ -20665,8 +20659,7 @@ sub do_change_email {
## page
## instead of the preferences page
$edited_by_listmaster = 1;
unless (
Sympa::Robot::is_listmaster($param->{'user'}{'email'}, $robot)) {
unless (Sympa::is_listmaster($robot, $param->{'user'}{'email'})) {
Sympa::Report::reject_report_web('auth', 'User is not Listmaster',
{}, $param->{'action'});
wwslog('err', 'Not listmaster');
......@@ -23959,7 +23952,7 @@ sub check_authz {
 
sub get_server_details {
## All Robots are shown to super listmaster
if (Sympa::Robot::is_listmaster($param->{'user'}{'email'}, '*')) {
if (Sympa::is_listmaster('*', $param->{'user'}{'email'})) {
$param->{'main_robot'} = 1;
#FIXME: Entry for main robot is missing.
$param->{'robots'} = $Conf::Conf{'robots'};
......
......@@ -1010,6 +1010,27 @@ sub get_listmasters_email {
return wantarray ? @listmasters : [@listmasters];
}
=over
=item is_listmaster ( $that, $who )
Is the user listmaster?
=back
=cut
# Old names: [6.2b-6.2.3] Sympa::Robot::is_listmaster($who, $robot_id)
sub is_listmaster {
my $that = shift;
my $who = tools::clean_email(shift || '');
return undef unless length $who;
return 1 if grep { lc $_ eq $who } Sympa::get_listmasters_email($that);
return 1 if grep { lc $_ eq $who } Sympa::get_listmasters_email('*');
return 0;
}
1;
__END__
......
......@@ -5415,7 +5415,7 @@ sub am_i {
## Listmaster has all privileges except editor
# sa contestable.
if (($function eq 'owner' || $function eq 'privileged_owner')
and Sympa::Robot::is_listmaster($who, $self->{'domain'})) {
and Sympa::is_listmaster($self, $who)) {
return 1;
}
}
......@@ -5545,7 +5545,7 @@ sub may_edit {
}
## What privilege?
if (Sympa::Robot::is_listmaster($who, $self->{'domain'})) {
if (Sympa::is_listmaster($self, $who)) {
$role = 'listmaster';
} elsif ($self->am_i('privileged_owner', $who)) {
$role = 'privileged_owner';
......@@ -5602,7 +5602,7 @@ sub may_create_parameter {
my ($self, $parameter, $who, $robot) = @_;
$log->syslog('debug3', '(%s, %s, %s)', $parameter, $who, $robot);
if (Sympa::Robot::is_listmaster($who, $robot)) {
if (Sympa::is_listmaster($robot, $who)) {
return 1;
}
my $edit_conf = tools::load_edit_list_conf($self);
......
......@@ -55,18 +55,8 @@ our %listmaster_messages_stack;
# sub send_notify_to_listmaster($operation, $robot, $data, $checkstack, $purge);
## Is the user listmaster
sub is_listmaster {
my $who = shift;
my $robot = shift;
return unless $who;
$who =~ y/A-Z/a-z/;
return 1 if grep { lc $_ eq $who } Sympa::get_listmasters_email($robot);
return 1 if grep { lc $_ eq $who } Sympa::get_listmasters_email('*');
return 0;
}
# MOVED: Use Sympa::is_listmaster().
#sub is_listmaster;
## get idp xref to locally validated email address
sub get_netidtoemail_db {
......
......@@ -749,8 +749,8 @@ sub closeList {
}
# check authorization
unless (($list->am_i('owner', $sender))
|| (Sympa::Robot::is_listmaster($sender))) {
unless ($list->am_i('owner', $sender)
or Sympa::is_listmaster($list, $sender)) {
$log->syslog('info', 'CloseList %s from %s not allowed',
$listname, $sender);
die SOAP::Fault->faultcode('Client')->faultstring('Not allowed')
......@@ -1196,8 +1196,8 @@ sub fullReview {
->faultdetail("List $listname unknown");
}
unless (Sympa::Robot::is_listmaster($sender, $robot)
|| $list->am_i('owner', $sender)) {
unless (Sympa::is_listmaster($list, $sender)
or $list->am_i('owner', $sender)) {
die SOAP::Fault->faultcode('Client')
->faultstring('Not enough privileges')
->faultdetail('Listmaster or listowner required');
......
......@@ -1047,7 +1047,7 @@ sub verify {
grep {$_} Mail::Address->parse($args[0]);
}
foreach my $arg (@arg) {
if (Sympa::Robot::is_listmaster($arg, $robot)) {
if (Sympa::is_listmaster($robot, $arg)) {
$ok = $arg;
last;
}
......
......@@ -385,7 +385,7 @@ sub do_remove_arc {
unless ($list->am_i('privileged_owner', $sender)
or $list->am_i('owner', $sender)
or $list->am_i('editor', $sender)
or Sympa::Robot::is_listmaster($sender, $list->{'domain'})) {
or Sympa::is_listmaster($list, $sender)) {
unless (lc $sender eq lc($arc_message->{sender} || '')) {
$log->syslog('err',
'Remove command for %s by unauthorized sender: %s',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment