--- loncom/publisher/lonrights.pm 2011/11/02 18:40:17 1.31 +++ loncom/publisher/lonrights.pm 2023/07/13 22:21:26 1.36 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to show and edit custom distribution rights # -# $Id: lonrights.pm,v 1.31 2011/11/02 18:40:17 raeburn Exp $ +# $Id: lonrights.pm,v 1.36 2023/07/13 22:21:26 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -55,16 +55,34 @@ sub handler { &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; + my $text = 'Authoring Space'; + my $href = &Apache::loncommon::authorspace($r->uri); + my ($crsauthor,$cdom,$cnum); + if ($env{'request.course.id'}) { + $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($href eq "/priv/$cdom/$cnum/") { + $crsauthor = 1; + $text = 'Course Authoring Space'; + } + } # Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Construction Space', - 'href' => &Apache::loncommon::authorspace(), + 'text' => $text, + 'href' => $href, }); - &Apache::lonhtmlcommon::add_breadcrumb({ - 'text' => 'Custom Rights Editor', - 'title' => 'Custom Distribution Rights Editor', - 'href' => '',}); + if ($crsauthor) { + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Custom Rights', + 'title' => 'Custom Distribution Rights', + 'href' => '',}); + } else { + &Apache::lonhtmlcommon::add_breadcrumb({ + 'text' => 'Custom Rights Editor', + 'title' => 'Custom Distribution Rights Editor', + 'href' => '',}); + } my $js = &Apache::loncommon::coursebrowser_javascript(). &Apache::loncommon::studentbrowser_javascript(); @@ -78,7 +96,12 @@ sub handler { my $uri=$r->uri; my $fn=&Apache::lonnet::filelocation('',$uri); my $contents=''; - my $constructmode=($uri=~ m/^/priv/}); + my $constructmode=($uri=~ m{^/priv/}); + if ($constructmode) { + if (($crsauthor) && ($uri eq "/priv/$cdom/$cnum/default.rights")) { + undef($constructmode); + } + } # ============================================================ Modify and store if ($constructmode && $env{'form.store'}) { @@ -180,7 +203,7 @@ sub handler { $contents=join('',<$fh>); $fh->close(); } - $r->print('
'); + $r->print(''); } unless ($contents=~/\ 'Course / User', 'se' => 'Section', 'ro' => 'Role'); + my %iconimg = ('allow' => ''.&mt('allow').'', + 'deny' => ''.&mt('deny').''); # ---------------------------------------------------------- Start table output $r->print(&Apache::loncommon::start_data_table(). &Apache::loncommon::start_data_table_header_row(). @@ -217,14 +244,13 @@ sub handler { $r->print(' '); } $r->print(''); + $r->print($iconimg{$token->[2]->{'effect'}}); if ($constructmode) { my %lt = &Apache::lonlocal::texthash ('allow' => 'allow', 'deny' => 'deny'); $r->print(&Apache::loncommon::select_form ($token->[2]->{'effect'},'effect_0',\%lt)); - } else { - $r->print($token->[2]->{'effect'}); } $r->print(''.&mt('Default')); if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) { @@ -242,8 +268,8 @@ sub handler { $r->print(''.$rulecounter.'. '); if ($constructmode) { my %lt = &Apache::lonlocal::texthash - ('' => '', - 'delete' => 'Delete this rule', + ('' => '', + 'delete' => 'Delete this rule', 'insertabove' => 'Insert rule above', 'insertbelow' => 'Insert rule below', 'moveup' => 'Move rule up', @@ -256,6 +282,7 @@ sub handler { $r->print(''. ''); # effect + $r->print($iconimg{$token->[2]->{'effect'}}); if ($constructmode) { my %lt = &Apache::lonlocal::texthash ('allow' => 'allow', @@ -263,8 +290,6 @@ sub handler { $r->print(&Apache::loncommon::select_form ($token->[2]->{'effect'}, 'effect_'.$rulecounter,\%lt)); - } else { - $r->print($token->[2]->{'effect'}); } # type @@ -277,7 +302,7 @@ sub handler { $r->print(&Apache::loncommon::select_form($type, 'type_'.$rulecounter,\%lt)); } else { - $r->print($type); + $r->print(&mt($type)); } # ---- realm