--- loncom/interface/loncommon.pm 2016/10/29 05:29:28 1.1258 +++ loncom/interface/loncommon.pm 2017/11/04 20:40:57 1.1299 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.1258 2016/10/29 05:29:28 raeburn Exp $ +# $Id: loncommon.pm,v 1.1299 2017/11/04 20:40:57 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -71,6 +71,7 @@ use Apache::lonuserutils(); use Apache::lonuserstate(); use Apache::courseclassifier(); use LONCAPA qw(:DEFAULT :match); +use LONCAPA::LWPReq; use DateTime::TimeZone; use DateTime::Locale; use Encode(); @@ -83,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); @@ -267,7 +270,7 @@ BEGIN { next if ($line =~ /^\#/); chomp($line); my ($extension,$category)=(split(/\s+/,$line,2)); - push @{$category_extensions{lc($category)}},$extension; + push(@{$category_extensions{lc($category)}},$extension); } close($fh); } @@ -1054,7 +1057,7 @@ sub list_languages { if ($code) { my $selector = $supported_codes{$id}; my $description = &plainlanguagedescription($id); - push (@lang_choices, [$selector, $description]); + push(@lang_choices, [$selector, $description]); } } return \@lang_choices; @@ -1176,7 +1179,7 @@ sub linked_select_forms { $result.="select2data${suffix}['d_$s1'].texts = new Array("; my @s2texts; foreach my $value (@s2values) { - push @s2texts, $hashref->{$s1}->{'select2'}->{$value}; + push(@s2texts, $hashref->{$s1}->{'select2'}->{$value}); } $result.="\"@s2texts\");\n"; } @@ -2185,7 +2188,7 @@ sub crsauthor_url { } sub import_crsauthor_form { - my ($form,$firstselectname,$secondselectname,$onchangefirst,$only,$suffix) = @_; + my ($form,$firstselectname,$secondselectname,$onchangefirst,$only,$suffix,$disabled) = @_; return (0) unless ($env{'request.course.id'}); my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -2476,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))]; @@ -3158,13 +3175,16 @@ sub authform_kerberos { @_, ); my ($check4,$check5,$krbcheck,$krbarg,$krbver,$result,$authtype, - $autharg,$jscall); + $autharg,$jscall,$disabled); my ($authnum,%can_assign) = &get_assignable_auth($in{'domain'}); if ($in{'kerb_def_auth'} eq 'krb5') { $check5 = ' checked="checked"'; } else { $check4 = ' checked="checked"'; } + if ($in{'readonly'}) { + $disabled = ' disabled="disabled"'; + } $krbarg = $in{'kerb_def_dom'}; if (defined($in{'curr_authtype'})) { if ($in{'curr_authtype'} eq 'krb') { @@ -3209,7 +3229,7 @@ sub authform_kerberos { if (defined($in{'mode'})) { if ($in{'mode'} eq 'modifycourse') { if ($authnum == 1) { - $authtype = ''; + $authtype = ''; } } } @@ -3218,7 +3238,7 @@ sub authform_kerberos { if ($authtype eq '') { $authtype = ''; + $krbcheck.$disabled.' />'; } if (($can_assign{'krb4'} && $can_assign{'krb5'}) || ($can_assign{'krb4'} && !$can_assign{'krb5'} && @@ -3231,9 +3251,9 @@ sub authform_kerberos { '', - '