--- loncom/publisher/lonrights.pm 2007/06/22 00:11:22 1.23 +++ loncom/publisher/lonrights.pm 2013/06/04 22:20:16 1.35 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to show and edit custom distribution rights # -# $Id: lonrights.pm,v 1.23 2007/06/22 00:11:22 albertel Exp $ +# $Id: lonrights.pm,v 1.35 2013/06/04 22:20:16 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,15 +55,30 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + # Breadcrumbs + &Apache::lonhtmlcommon::clear_breadcrumbs(); + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Authoring Space', + 'href' => &Apache::loncommon::authorspace($r->uri), + }); + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Custom Rights Editor', + 'title' => 'Custom Distribution Rights Editor', + 'href' => '',}); + my $js = &Apache::loncommon::coursebrowser_javascript(). &Apache::loncommon::studentbrowser_javascript(); - $r->print(&Apache::loncommon::start_page('Custom Distribution Rights',$js)); + # Breadcrumbs are included by &start_page + $r->print(&Apache::loncommon::start_page('Custom Distribution Rights',$js) + .&Apache::loncommon::head_subbox( + &Apache::loncommon::CSTR_pageheader()) + ); $r->rflush(); my $uri=$r->uri; my $fn=&Apache::lonnet::filelocation('',$uri); my $contents=''; - my $constructmode=($uri=~/^\/\~/); + my $constructmode=($uri=~ m{^/priv/}); # ============================================================ Modify and store if ($constructmode && $env{'form.store'}) { @@ -110,13 +125,14 @@ sub handler { $rulehash{'domain'}=$env{'user.domain'}; } my $realm=''; + my $separator = ($rulehash{'type'} eq 'course') ? '_' : '/'; if ($number) { $realm=$rulehash{'domain'}; if ($rulehash{'course'}) { - $realm.='_'.$rulehash{'course'}; + $realm.=$separator.$rulehash{'course'}; } if ($rulehash{'section'}) { - $realm.='_'.$rulehash{'section'}; + $realm.=$separator.$rulehash{'section'}; } } $newrules[$number]=$rulehash{'effect'}.':'. @@ -126,28 +142,18 @@ sub handler { foreach my $key (keys(%env)) { next if ($key!~/^form\.action\_(\d+)$/); my $number=$1; - if ($env{$key} eq 'delete') { $newrules[$number]=''; } + if ($env{$key} eq 'delete') { splice(@newrules,$number,1); } if (($env{$key} eq 'moveup') && ($number>1)) { - my $buffer=$newrules[$number]; - $newrules[$number]=$newrules[$number-1]; - $newrules[$number-1]=$buffer; + @newrules[$number-1,$number] = @newrules[$number,$number-1]; } if (($env{$key} eq 'movedown') && ($number<$#newrules)) { - my $buffer=$newrules[$number]; - $newrules[$number]=$newrules[$number+1]; - $newrules[$number+1]=$buffer; + @newrules[$number+1,$number] = @newrules[$number,$number+1]; } if ($env{$key} eq 'insertabove') { - for (my $i=$#newrules;$i>=$number;$i--) { - $newrules[$i+1]=$newrules[$i]; - } - $newrules[$number]='deny'; + splice(@newrules,$number,0,'deny'); } if ($env{$key} eq 'insertbelow') { - for (my $i=$#newrules;$i>$number;$i--) { - $newrules[$i+1]=$newrules[$i]; - } - $newrules[$number+1]='deny'; + splice(@newrules,$number+1,0,'deny'); } } @@ -174,7 +180,7 @@ sub handler { $contents=join('',<$fh>); $fh->close(); } - $r->print('