--- loncom/html/adm/helper/newslot.helper 2018/06/27 14:35:09 1.30.4.1 +++ loncom/html/adm/helper/newslot.helper 2020/01/13 16:59:17 1.30.4.1.2.1 @@ -26,8 +26,32 @@ my $name=$helper->{VARS}{'origname'}; my %slot=&Apache::lonnet::get('slots', [$name], $cdom, $cnum); if (!ref($slot{$name})) { return $default; } - if (!exists($slot{$name}{$which})) { return $default; } - return $slot{$name}{$which}; + if (($which eq 'ipdeny') || ($which eq 'ipallow')) { + if (!exists($slot{$name}{'ip'})) { return $default; } + } else { + if (!exists($slot{$name}{$which})) { return $default; } + } + if (($which eq 'ipdeny') || ($which eq 'ipallow')) { + my @allows; + my @denies; + foreach my $item (split(',',$slot{$name}{'ip'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + if ($item =~ /^\!(.+)$/) { + push(@denies,$1); + } else { + push(@allows,$item); + } + } + if ($which eq 'ipdeny') { + return join(',',@denies); + } + if ($which eq 'ipallow') { + return join(',',@allows); + } + } else { + return $slot{$name}{$which}; + } } @@ -250,16 +274,30 @@ return 'any'; - + -

IP restrictions:
    +

IP restrictions -- allow from all except:
    - + + return undef; - return &{$helper->{DATA}{origslot}}('ip'); + return &{$helper->{DATA}{origslot}}('ipdeny'); + + + + +

IP restrictions -- deny from all except:
    + + + + + return undef; + + + return &{$helper->{DATA}{origslot}}('ipallow');

@@ -349,12 +387,32 @@ $slot{$which} = $helper->{'VARS'}{$which}; } - foreach my $which ('ip','description','maxspace','secret','symb') { + foreach my $which ('description','maxspace','secret','symb') { if ( $helper->{'VARS'}{$which} =~/\S/ ) { $slot{$which} = $helper->{'VARS'}{$which}; } } + if ($helper->{'VARS'}{'ipdeny'} =~/\S/ ) { + foreach my $item (split(',',$helper->{'VARS'}{'ipdeny'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + $slot{'ip'} .= '!'.$item.','; + } + } + + if ($helper->{'VARS'}{'ipallow'} =~/\S/ ) { + foreach my $item (split(',',$helper->{'VARS'}{'ipallow'})) { + $item =~ s/^\s*//; + $item =~ s/\s*$//; + $slot{'ip'} .= $item.','; + } + } + + if ($slot{'ip'} ne '') { + $slot{'ip'} =~s /,$//; + } + if ($helper->{'VARS'}{'type'} eq 'schedulable_student') { if (($helper->{'VARS'}{'reservationmsg'} eq 'only_student') || ($helper->{'VARS'}{'reservationmsg'} eq 'student_and_user_notes_screen')) {