[LON-CAPA-cvs] cvs: loncom /publisher lonpublisher.pm
raeburn
raeburn at source.lon-capa.org
Tue Mar 22 12:41:10 EDT 2016
raeburn Tue Mar 22 16:41:10 2016 EDT
Modified files:
/loncom/publisher lonpublisher.pm
Log:
- New options when publishing directory -- apply common
copyright/distribution and/or apply a common source availability.
Index: loncom/publisher/lonpublisher.pm
diff -u loncom/publisher/lonpublisher.pm:1.294 loncom/publisher/lonpublisher.pm:1.295
--- loncom/publisher/lonpublisher.pm:1.294 Fri Dec 12 18:27:34 2014
+++ loncom/publisher/lonpublisher.pm Tue Mar 22 16:41:10 2016
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Publication Handler
#
-# $Id: lonpublisher.pm,v 1.294 2014/12/12 18:27:34 raeburn Exp $
+# $Id: lonpublisher.pm,v 1.295 2016/03/22 16:41:10 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -318,8 +318,12 @@
=item B<textfield>
+=item B<text_with_browse_field>
+
=item B<hiddenfield>
+=item B<checkbox>
+
=item B<selectbox>
=back
@@ -399,6 +403,59 @@
if (!defined($value)) { $env{'form.'.$name}=0; }
return &Apache::loncommon::select_level_form($value,$name);
}
+
+sub common_access {
+ my ($name,$text,$options)=@_;
+ return unless (ref($options) eq 'ARRAY');
+ my $formname = 'pubdirpref';
+ my $chkname = 'common'.$name;
+ my $chkid = 'LC_'.$chkname;
+ my $divid = $chkid.'div';
+ my $customdivid = 'LC_customfile';
+ my $selname = $chkname.'select';
+ my $selid = $chkid.'select';
+ my $selonchange;
+ if ($name eq 'dist') {
+ $selonchange = ' onchange="showHideCustom(this,'."'$customdivid'".');"';
+ }
+ my %lt = &Apache::lonlocal::texthash(
+ 'default' => 'System wide - can be used for any courses system wide',
+ 'domain' => 'Domain only - use limited to courses in the domai',
+ 'custom' => 'Customized right of use ...',
+ 'public' => 'Public - no authentication or authorization required for use',
+ 'closed' => 'Closed - XML source is closed to everyone',
+ 'open' => 'Open - XML source is open to people who want to use it',
+ 'sel' => 'Select',
+ );
+ my $output = <<"END";
+<br />
+<span class="LC_nobreak">
+<label>
+<input type="checkbox" name="commonaccess" value="$name" id="$chkid"
+onclick="showHideAccess(this,'$divid');" />
+$text</label></span>
+<div id="$divid" style="padding:0;clear:both;margin:0;border:0;display:none">
+<select name="$selname" id="$selid" $selonchange>
+<option value="" selected="selected">$lt{'sel'}</option>
+END
+ foreach my $val (@{$options}) {
+ $output .= '<option value="'.$val.'">'.$lt{$val}.'</option>'."\n";
+ }
+ $output .= '
+</select>';
+ if ($name eq 'dist') {
+ $output .= <<"END";
+<div id="$customdivid" style="padding:0;clear:both;margin:0;border:0;display:none">
+<input type="text" name="commoncustomrights" size="60" value="" />
+<a href="javascript:openbrowser('$formname','commoncustomrights','rights');">
+$lt{'sel'}</a></div>
+END
+ }
+ $output .= '
+</div>
+';
+}
+
#########################################
#########################################
@@ -1629,7 +1686,33 @@
%metadatakeys=();
&metaeval(&unescape($env{'form.allmeta'}));
-
+
+ if ($batch) {
+ my %commonaccess;
+ map { $commonaccess{$_} = 1; } &Apache::loncommon::get_env_multiple('form.commonaccess');
+ if ($commonaccess{'dist'}) {
+ unless ($style eq 'prv') {
+ if ($env{'form.commondistselect'} eq 'custom') {
+ unless ($source =~ /\.rights$/) {
+ if ($env{'form.commoncustomrights'} =~ m{^/res/.+\.rights$}) {
+ $env{'form.customdistributionfile'} = $env{'form.commoncustomrights'};
+ $env{'form.copyright'} = $env{'form.commondistselect'};
+ }
+ }
+ } elsif ($env{'form.commondistselect'} =~ /^default|domain|public$/) {
+ $env{'form.copyright'} = $env{'form.commondistselect'};
+ }
+ }
+ }
+ unless ($style eq 'prv') {
+ if ($commonaccess{'source'}) {
+ if (($env{'form.commonsourceselect'} eq 'open') || ($env{'form.commonsourceselect'} eq 'closed')) {
+ $env{'form.sourceavail'} = $env{'form.commonsourceselect'};
+ }
+ }
+ }
+ }
+
$metadatafields{'title'}=$env{'form.title'};
$metadatafields{'author'}=$env{'form.author'};
$metadatafields{'subject'}=$env{'form.subject'};
@@ -1993,7 +2076,11 @@
&checkbox('pubrec','include subdirectories').
&checkbox('forcerepub','force republication of previously published files').
&checkbox('obsolete','make file(s) obsolete').
- &checkbox('forceoverride','force directory level metadata over existing')
+ &checkbox('forceoverride','force directory level metadata over existing').
+ &common_access('dist',&mt('apply common copyright/distribution'),
+ ['default','domain','custom']).
+ &common_access('source',&mt('apply common source availability'),
+ ['closed','open'])
);
$r->print(&Apache::lonhtmlcommon::row_closure(1)
.&Apache::lonhtmlcommon::end_pick_box()
@@ -2247,7 +2334,53 @@
my $js='<script type="text/javascript">'.
&Apache::loncommon::browser_and_searcher_javascript().
'</script>';
- $r->print(&Apache::loncommon::start_page('Resource Publication',$js)
+ my $startargs = {};
+ if ($fn=~/\/$/) {
+ unless ($env{'form.phase'} eq 'two') {
+ $startargs->{'add_entries'} = { onload => 'javascript:setDefaultAccess();' };
+ $js .= <<"END";
+<script type="text/javascript">
+// <![CDATA[
+function showHideAccess(caller,div) {
+ if (document.getElementById(div)) {
+ if (caller.checked) {
+ document.getElementById(div).style.display='inline-block';
+ } else {
+ document.getElementById(div).style.display='none';
+ }
+ }
+}
+
+function showHideCustom(caller,divid) {
+ if (document.getElementById(divid)) {
+ if (caller.options[caller.selectedIndex].value == 'custom') {
+ document.getElementById(divid).style.display="inline-block";
+ } else {
+ document.getElementById(divid).style.display="none";
+ }
+ }
+}
+function setDefaultAccess() {
+ var chkids = Array('LC_commondist','LC_commonsource');
+ for (var i=0; i<chkids.length; i++) {
+ if (document.getElementById(chkids[i])) {
+ document.getElementById(chkids[i]).checked = false;
+ }
+ if (document.getElementById(chkids[i]+'select')) {
+ document.getElementById(chkids[i]+'select').selectedIndex = 0;
+ }
+ if (document.getElementById(chkids[i]+'div')) {
+ document.getElementById(chkids[i]+'div').style.display = 'none';
+ }
+ }
+}
+// ]]>
+</script>
+
+END
+ }
+ }
+ $r->print(&Apache::loncommon::start_page('Resource Publication',$js,$startargs)
.&Apache::lonhtmlcommon::breadcrumbs()
.&Apache::loncommon::head_subbox(
&Apache::loncommon::CSTR_pageheader($docroot.$fn))
More information about the LON-CAPA-cvs
mailing list