--- loncom/interface/lonmeta.pm 2013/05/03 14:00:58 1.250
+++ loncom/interface/lonmeta.pm 2023/07/14 23:15:10 1.256
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Metadata display handler
#
-# $Id: lonmeta.pm,v 1.250 2013/05/03 14:00:58 bisitz Exp $
+# $Id: lonmeta.pm,v 1.256 2023/07/14 23:15:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -389,9 +389,9 @@ sub select_course {
&mt('You can choose to transfer data from the added fields to the "Notes" field if you are planning to change the course association.').' '.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
- '
Copy to notes? '."\n".
- 'Field name '."\n".
- 'Values '."\n".
+ ''.&mt('Copy to notes?').' '."\n".
+ ''.&mt('Field Name').' '."\n".
+ ''.&mt('Values').' '."\n".
&Apache::loncommon::end_data_table_header_row().
$transfernotes.
&Apache::loncommon::end_data_table().' ';
@@ -455,7 +455,7 @@ sub prettyprint {
}
# MIME
if ($type eq 'mime') {
- return ' '.
+ return ' '.
&Apache::loncommon::filedescription($value);
}
# Person
@@ -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='';
foreach my $id (@idlist) {
- $selout.=''.&{$functionref}($id).' ';
} else {
@@ -582,7 +586,7 @@ sub relatedfield {
}
sub prettyinput {
- my ($type,$value,$fieldname,$formname,
+ my ($type,$value,$readonly,$fieldname,$formname,
$relatedsearchflag,$relatedsep,$relatedvalue,$size,$course_key)=@_;
if (! defined($size)) {
$size = 80;
@@ -661,7 +665,7 @@ sub prettyinput {
# Language
if ($type eq 'language') {
return &selectbox($fieldname,
- $value,
+ $value,'',
\&Apache::loncommon::languagedescription,
(&Apache::loncommon::languageids)).
&relatedfield(0,$relatedsearchflag,$relatedsep);
@@ -669,7 +673,7 @@ sub prettyinput {
# Copyright
if ($type eq 'copyright') {
return &selectbox($fieldname,
- $value,
+ $value,$readonly,
\&Apache::loncommon::copyrightdescription,
(&Apache::loncommon::copyrightids)).
&relatedfield(0,$relatedsearchflag,$relatedsep);
@@ -677,7 +681,7 @@ sub prettyinput {
# Source Copyright
if ($type eq 'sourceavail') {
return &selectbox($fieldname,
- $value,
+ $value,'',
\&Apache::loncommon::source_copyrightdescription,
(&Apache::loncommon::source_copyrightids)).
&relatedfield(0,$relatedsearchflag,$relatedsep);
@@ -704,11 +708,20 @@ sub prettyinput {
}
# Customdistribution file
if ($type eq 'customdistributionfile') {
- return '".&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') {
@@ -763,7 +776,7 @@ sub pageheader {
sub handler {
my $r=shift;
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['currentpath','changecourse']);
+ ['currentpath','changecourse','modal']);
my $uri=$r->uri;
#
# Set document type
@@ -777,9 +790,18 @@ sub handler {
&Apache::lonhtmlcommon::clear_breadcrumbs();
if ($env{'request.state'} eq 'construct') {
+ my $text = 'Authoring Space';
+ my $href = &Apache::loncommon::authorspace($uri);
+ if ($env{'request.course.id'}) {
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ if ($href eq "/priv/$cdom/$cnum/") {
+ $text = 'Course Authoring Space';
+ }
+ }
&Apache::lonhtmlcommon::add_breadcrumb({
- 'text' => 'Construction Space',
- 'href' => &Apache::loncommon::authorspace($uri),
+ 'text' => $text,
+ 'href' => $href,
});
}
@@ -829,7 +851,7 @@ sub handler {
$r->print(&pageheader());
&present_editable_metadata($r,$uri,'groups');
} elsif ($uri=~m|^/priv|) {
- # Construction space
+ # Authoring space
&Apache::lonhtmlcommon::add_breadcrumb({
'text' => 'Edit Metadata',
'href' => '',
@@ -854,7 +876,21 @@ sub handler {
'only_body' => 1,})
.''.&mt('Metadata').' '
);
+ if ($env{'form.modal'}) {
+ my $width = 500;
+ my $height = 400;
+ my $machine = &Apache::lonnet::absolute_url();
+ $r->print(&Apache::loncommon::nicescroll_javascript('metadatawrapper',
+ {cursorcolor => '#00F',
+ railalign => 'right',
+ railoffset => '{top:5,left:40}'},
+ undef,1,$machine.$uri));
+ $r->print('');
+ }
&present_uneditable_metadata($r,$uri);
+ if ($env{'form.modal'}) {
+ $r->print('
');
+ }
}
$r->print(&Apache::loncommon::end_page());
return OK;
@@ -1122,6 +1158,7 @@ sub print_dynamic_metadata {
if (exists($dynmeta{'stats'})) {
my $table=&Apache::loncommon::start_data_table()
.&Apache::loncommon::start_data_table_header_row()
+ .''.&mt('Domain').' '
.''.&mt('Course').' '
.''.&mt('Section(s)').' '
.''.&mt('Num Students').' '
@@ -1142,6 +1179,8 @@ sub print_dynamic_metadata {
next;
}
$table .= &Apache::loncommon::start_data_table_row();
+ $table .=
+ ''.$courseinfo{'domain'}.' ';
$table .=
''.$courseinfo{'description'}.' ';
$table .=
@@ -1292,9 +1331,19 @@ sub print_dynamic_metadata {
#####################################################
sub present_editable_metadata {
my ($r,$uri,$file_type) = @_;
- # Construction Space Call
+ # 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$//;
@@ -1456,6 +1505,10 @@ ENDEDIT
'lowestgradelevel','highestgradelevel','sourceavail','sourcerights',
'obsolete','obsoletereplacement');
}
+ if ($courseauthor) {
+ $Apache::lonpublisher::metadatafields{'copyright'}='custom';
+ $Apache::lonpublisher::metadatafields{'customdistributionfile'}=$crsaurights;
+ }
if (! $Apache::lonpublisher::metadatafields{'copyright'}) {
$Apache::lonpublisher::metadatafields{'copyright'}=
'default';
@@ -1537,17 +1590,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);
}
@@ -1590,6 +1642,17 @@ sub store_metadata {
$Apache::lonpublisher::metadatafields{'keywords'} =
join (',', &Apache::loncommon::get_env_multiple('form.new_keywords'));
}
+ if (($caller eq 'store') && ($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}) {
+ unless ($uri eq "/priv/$cdom/$cnum/default.rights.meta") {
+ $Apache::lonpublisher::metadatafields{'copyright'} = 'custom';
+ $Apache::lonpublisher::metadatafields{'customdistributionfile'} =
+ "/res/$cdom/$cnum/default.rights";
+ }
+ }
+ }
foreach my $field (sort(keys(%Apache::lonpublisher::metadatafields))) {
next if ($field =~ /\./);
my $unikey=$field;