--- loncom/publisher/lonrights.pm 2003/03/21 14:13:30 1.7 +++ loncom/publisher/lonrights.pm 2005/02/18 23:15:54 1.16 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to show and edit custom distribution rights # -# $Id: lonrights.pm,v 1.7 2003/03/21 14:13:30 www Exp $ +# $Id: lonrights.pm,v 1.16 2005/02/18 23:15:54 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,15 +36,28 @@ use Apache::lonnet(); use Apache::loncommon(); use HTML::LCParser; use Apache::File; +use Apache::lonlocal; sub handler { my $r=shift; - $r->content_type('text/html'); + my $target = $ENV{'form.grade_target'}; + if ($target eq 'meta') { + &Apache::loncommon::content_type($r,'text/html'); + $r->send_http_header; + $ENV{'request.uri'}=$r->uri; + my $file = &Apache::lonnet::filelocation("",$r->uri); + my $content=&Apache::lonnet::getfile($file); + my $result=&Apache::lonxml::xmlparse(undef,'meta',$content); + $r->print($result); + return OK; + } + &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; $r->print( - 'LON-CAPA Custom Distribution Rights'); + 'LON-CAPA Custom Distribution Rights'. + &Apache::loncommon::coursebrowser_javascript().''); $r->print(&Apache::loncommon::bodytag('Custom Distribution Rights')); $r->rflush(); @@ -103,7 +116,7 @@ sub handler { if ($_=~/^form\.action\_(\d+)$/) { my $number=$1; if ($ENV{$_} eq 'delete') { $newrules[$number]=''; } - if (($ENV{$_} eq 'moveup') && ($number>2)) { + if (($ENV{$_} eq 'moveup') && ($number>1)) { my $buffer=$newrules[$number]; $newrules[$number]=$newrules[$number-1]; $newrules[$number-1]=$buffer; @@ -152,7 +165,7 @@ sub handler { $contents=join('',<$fh>); $fh->close(); } - $r->print('
'); + $r->print(''); } unless ($contents=~/\new(\$contents); my $token; my $rulecounter=0; - my $colzero=($constructmode?'Edit action':'Rule'); + my $colzero=&mt($constructmode?'Edit action':'Rule'); + my %lt=&Apache::lonlocal::texthash('ef' => 'Effect', + 'do' => 'Domain', + 'co' => 'Course', + 'se' => 'Section/Group', + 'ro' => 'Role'); # ---------------------------------------------------------- Start table output $r->print(< - $colzeroEffectDomainCourse -SectionRole + $colzero$lt{'ef'}$lt{'do'}$lt{'co'} +$lt{'se'}$lt{'ro'} ENDSTARTTABLE # --------------------------------------------------------------------- Default # Fast forward to first rule @@ -192,14 +210,15 @@ ENDSTARTTABLE } $r->print('Default'); if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) { - $r->print(' - Error! No default set.'); + $r->print(' - '.&mt('Error! No default set.'). + ''); } $r->print(''); # Additional roles while ($token=$parser->get_token) { if (($token->[0] eq 'S') && ($token->[1] eq 'accessrule')) { $rulecounter++; - $r->print(''); + $r->print(''); # insert, delete, etc $r->print($rulecounter.'. '); if ($constructmode) { @@ -212,7 +231,7 @@ ENDSTARTTABLE 'moveup' => 'Move rule up', 'movedown' => 'Move rule down'))); } - $r->print(''); + $r->print(''); # effect if ($constructmode) { $r->print(&Apache::loncommon::select_form @@ -254,7 +273,7 @@ ENDSTARTTABLE $r->print($rsec); } - $r->print(''); + $r->print(''); # role if ($constructmode) { my %hash=('' => ''); @@ -268,6 +287,17 @@ ENDSTARTTABLE } else { $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'})); } +# course selection link + $r->print(''); + if ($rcourse) { + my %descript= + &Apache::lonnet::coursedescription($rdom.'_'.$rcourse); + $r->print($descript{'description'}.'   '); + } + if ($constructmode) { + $r->print(&Apache::loncommon::selectcourse_link('rules', + 'course_'.$rulecounter,'domain_'.$rulecounter)); + } # close row $r->print(''); } @@ -275,7 +305,7 @@ ENDSTARTTABLE $r->print(''); # ------------------------------------------------------------ End table output if ($constructmode) { - $r->print(''); + $r->print(''); } $r->print(''); return OK;