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