--- loncom/interface/loncommon.pm 2017/08/07 20:22:13 1.1287 +++ loncom/interface/loncommon.pm 2017/08/13 23:21:04 1.1293 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1287 2017/08/07 20:22:13 raeburn Exp $ +# $Id: loncommon.pm,v 1.1293 2017/08/13 23:21:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -84,6 +84,8 @@ use Crypt::DES; use DynaLoader; # for Crypt::DES version use MIME::Lite; use MIME::Types; +use File::Copy(); +use File::Path::Tiny(); # ---------------------------------------------- Designs use vars qw(%defaultdesign); @@ -2477,10 +2479,24 @@ sub create_text_file { # ------------------------------------------ sub domain_select { - my ($name,$value,$multiple)=@_; + my ($name,$value,$multiple,$incdoms,$excdoms)=@_; + my @possdoms; + if (ref($incdoms) eq 'ARRAY') { + @possdoms = @{$incdoms}; + } else { + @possdoms = &Apache::lonnet::all_domains(); + } + my %domains=map { $_ => $_.' '. &Apache::lonnet::domain($_,'description') - } &Apache::lonnet::all_domains(); + } @possdoms; + + if ((ref($excdoms) eq 'ARRAY') && (@{$excdoms} > 0)) { + foreach my $dom (@{$excdoms}) { + delete($domains{$dom}); + } + } + if ($multiple) { $domains{''}=&mt('Any domain'); $domains{'select_form_order'} = [sort {lc($a) cmp lc($b) } (keys(%domains))]; @@ -10138,15 +10154,15 @@ sub user_picker { $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,[$currdom]); } else { my $defdom = $env{'request.role.domain'}; - my ($trustedref,$untrustedref); + my ($trusted,$untrusted); if (($context eq 'requestcrs') || ($context eq 'course')) { - ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('enroll',$defdom); + ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom); } elsif ($context eq 'author') { - ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('othcoau',$defdom); + ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom); } elsif ($context eq 'domain') { - ($trustedref,$untrustedref) = &Apache::lonnet::trusted_domains('domroles',$defdom); + ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('domroles',$defdom); } - $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,$trustedref,$untrustedref); + $domform = &select_dom_form($currdom,'srchdomain',$allow_blank,1,undef,$trusted,$untrusted); } my $srchinsel = '