--- loncom/interface/lonmeta.pm 2024/02/28 16:10:27 1.254.2.1 +++ loncom/interface/lonmeta.pm 2023/03/28 23:17:18 1.255 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Metadata display handler # -# $Id: lonmeta.pm,v 1.254.2.1 2024/02/28 16:10:27 raeburn Exp $ +# $Id: lonmeta.pm,v 1.255 2023/03/28 23:17:18 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -550,13 +550,17 @@ sub direct { } sub selectbox { - my ($name,$value,$functionref,@idlist)=@_; + my ($name,$value,$readonly,$functionref,@idlist)=@_; if (! defined($functionref)) { $functionref=\&direct; } + my $disabled; + if ($readonly) { + $disabled = ' disabled="disabled"'; + } my $selout='".&mt('Select').''. - &relatedfield(0,$relatedsearchflag,$relatedsep); + my $disabled; + if ($readonly) { + $disabled = ' disabled="disabled"'; + } + my $output; + $output = ''; + unless ($readonly) { + $output .= '".&mt('Select').''; + } + $output .= &relatedfield(0,$relatedsearchflag,$relatedsep); + return $output; } # Source Customdistribution file if ($type eq 'sourcerights') { @@ -1312,6 +1325,16 @@ sub present_editable_metadata { # Authoring Space Call # Header my $disuri=$uri; + my ($courseauthor,$crsaurights,$readonly); + if ($env{'request.course.id'}) { + my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; + my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + if ($uri =~ m{^\Q/priv/$cdom/$cnum/\E}) { + $courseauthor = $cnum.':'.$cdom; + $crsaurights = "/res/$cdom/$cnum/default.rights"; + $readonly = 1; + } + } my $fn=&Apache::lonnet::filelocation('',$uri); $disuri=~s{^/\~}{/priv/}; $disuri=~s/\.meta$//; @@ -1473,48 +1496,13 @@ ENDEDIT 'lowestgradelevel','highestgradelevel','sourceavail','sourcerights', 'obsolete','obsoletereplacement'); } - my (%domdefs,$got_domdefs); - if (! $Apache::lonpublisher::metadatafields{'copyright'}) { - my $copyright = 'default'; - if ($env{'environment.copyright'} ne '') { - $copyright = $env{'environment.copyright'}; - } else { - my $defdom = $env{'request.role.domain'}; - if ($disuri =~ m{^/priv/($match_domain)/}) { - $defdom = $1; - } - if ($defdom ne '') { - %domdefs = &Apache::lonnet::get_domain_defaults($defdom); - $got_domdefs = 1; - if ($domdefs{'copyright'} ne '') { - $copyright = $domdefs{'copyright'}; - } - } - } - $Apache::lonpublisher::metadatafields{'copyright'}= - $copyright; + if ($courseauthor) { + $Apache::lonpublisher::metadatafields{'copyright'}='custom'; + $Apache::lonpublisher::metadatafields{'customdistributionfile'}=$crsaurights; } - if (! $Apache::lonpublisher::metadatafields{'sourceavail'}) { - my $sourceavail = 'closed'; - if ($env{'environment.sourceavail'} ne '') { - $sourceavail = $env{'environment.sourceavail'}; - } else { - my $defdom = $env{'request.role.domain'}; - if ($disuri =~ m{^/priv/($match_domain)/}) { - $defdom = $1; - } - if ($defdom ne '') { - unless ($got_domdefs) { - %domdefs = &Apache::lonnet::get_domain_defaults($defdom); - $got_domdefs = 1; - } - if ($domdefs{'sourceavail'} ne '') { - $sourceavail = $domdefs{'sourceavail'}; - } - } - } - $Apache::lonpublisher::metadatafields{'sourceavail'}= - $sourceavail; + if (! $Apache::lonpublisher::metadatafields{'copyright'}) { + $Apache::lonpublisher::metadatafields{'copyright'}= + 'default'; } if (($file_type eq 'portfolio') || ($file_type eq 'groups')) { if (! $Apache::lonpublisher::metadatafields{'mime'}) { @@ -1593,17 +1581,16 @@ ENDEDIT $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name}) .&prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, - 'new_'.$field_name,'defaultmeta', + $readonly,'new_'.$field_name,'defaultmeta', undef,undef,undef,undef, $Apache::lonpublisher::metadatafields{'courserestricted'}); $output .= &Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0); } } else { - $output .= &Apache::lonhtmlcommon::row_title($lt{$field_name}) .&prettyinput($field_name, $Apache::lonpublisher::metadatafields{$field_name}, - 'new_'.$field_name,'defaultmeta') + $readonly,'new_'.$field_name,'defaultmeta') .&Apache::lonhtmlcommon::row_closure($rowcount == $last?1:0); }