--- loncom/publisher/lonrights.pm 2009/12/02 18:33:35 1.29 +++ 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.29 2009/12/02 18:33:35 bisitz 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=~/^\/\~/); + 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(). @@ -210,21 +237,20 @@ sub handler { $r->print(&Apache::loncommon::start_data_table_row().''); if ($constructmode) { $r->print(&Apache::loncommon::select_form('','action_0', - ('' => '', - 'insertbelow' => &mt('Insert rule below')))); + {'' => '', + 'insertbelow' => &mt('Insert rule below')})); } else { $r->print(' '); } $r->print(''); + $r->print($iconimg{$token->[2]->{'effect'}}); if ($constructmode) { - $r->print(&Apache::loncommon::select_form - ($token->[2]->{'effect'},'effect_0', - &Apache::lonlocal::texthash + my %lt = &Apache::lonlocal::texthash ('allow' => 'allow', - 'deny' => 'deny'))); - } else { - $r->print($token->[2]->{'effect'}); + 'deny' => 'deny'); + $r->print(&Apache::loncommon::select_form + ($token->[2]->{'effect'},'effect_0',\%lt)); } $r->print(''.&mt('Default')); if (($token->[2]->{'realm'}) || ($token->[2]->{'role'})) { @@ -241,41 +267,42 @@ sub handler { # insert, delete, etc $r->print(''.$rulecounter.'. '); if ($constructmode) { + my %lt = &Apache::lonlocal::texthash + ('' => '', + 'delete' => 'Delete this rule', + 'insertabove' => 'Insert rule above', + 'insertbelow' => 'Insert rule below', + 'moveup' => 'Move rule up', + 'movedown' => 'Move rule down' + ); + $r->print(&Apache::loncommon::select_form( - '','action_'.$rulecounter, - &Apache::lonlocal::texthash - ('' => '', - 'delete' => 'Delete this rule', - 'insertabove' => 'Insert rule above', - 'insertbelow' => 'Insert rule below', - 'moveup' => 'Move rule up', - 'movedown' => 'Move rule down'))); + '','action_'.$rulecounter,\%lt)); } $r->print(''. ''); # effect + $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_'.$rulecounter, - &Apache::lonlocal::texthash - ('allow' => 'allow', - 'deny' => 'deny'))); - } else { - $r->print($token->[2]->{'effect'}); + 'effect_'.$rulecounter,\%lt)); } # type $r->print(''); my $type = ($token->[2]{'type'} || 'course'); if ($constructmode) { + my %lt = &Apache::lonlocal::texthash + ('course' => 'Course', + 'user' => 'User'); $r->print(&Apache::loncommon::select_form($type, - 'type_'.$rulecounter, - &Apache::lonlocal::texthash - ('course' => 'Course', - 'user' => 'User'))); + 'type_'.$rulecounter,\%lt)); } else { - $r->print($type); + $r->print(&mt($type)); } # ---- realm @@ -328,7 +355,7 @@ sub handler { my $role=$token->[2]->{'role'}; unless ($role) { $role=''; } $r->print(&Apache::loncommon::select_form( - $role,'role_'.$rulecounter,%hash)); + $role,'role_'.$rulecounter,\%hash)); } else { $r->print(&Apache::lonnet::plaintext($token->[2]->{'role'})); }