--- loncom/interface/domainprefs.pm 2015/05/12 00:20:42 1.160.6.63 +++ loncom/interface/domainprefs.pm 2015/03/03 22:06:50 1.256 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.63 2015/05/12 00:20:42 raeburn Exp $ +# $Id: domainprefs.pm,v 1.256 2015/03/03 22:06:50 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -213,15 +213,15 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','coursedefaults', - 'usersessions','loadbalancing','requestauthor', - 'selfenrollment','inststatus'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor','selfenrollment','inststatus'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','selfcreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','coursedefaults','selfenrollment', - 'usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','selfenrollment','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -411,6 +411,14 @@ sub handler { print => \&print_serverstatuses, modify => \&modify_serverstatuses, }, + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], + print => \&print_helpsettings, + modify => \&modify_helpsettings, + }, 'coursedefaults' => {text => 'Course/Community defaults', help => 'Domain_Configuration_Course_Defaults', @@ -433,6 +441,14 @@ sub handler { print => \&print_selfenrollment, modify => \&modify_selfenrollment, }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + print => \&print_privacy, + modify => \&modify_privacy, + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -619,6 +635,8 @@ sub process_changes { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'requestauthor') { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); } elsif ($action eq 'selfenrollment') { @@ -2826,7 +2844,7 @@ sub print_helpsettings { sub radiobutton_prefs { my ($settings,$toggles,$defaultchecked,$choices,$itemcount,$onclick, - $additional,$align) = @_; + $additional) = @_; return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); @@ -2860,14 +2878,8 @@ sub radiobutton_prefs { $datatable .= ''. ''.$choices->{$item}. - ''; - if ($align eq 'left') { - $datatable .= ''; - } else { - $datatable .= ''; - } - $datatable .= - ''. + ''. + ''. ' '. ' '.&mt('(new)'). ''. &mt('Name displayed:'). @@ -5303,12 +5253,12 @@ sub serverstatus_pages { return ('userstatus','lonstatus','loncron','server-status','codeversions', 'checksums','clusterstatus','metadata_keywords','metadata_harvest', 'takeoffline','takeonline','showenv','toggledebug','ping','domconf', - 'uniquecodes','diskusage','coursecatalog'); + 'uniquecodes','diskusage'); } sub defaults_javascript { my ($settings) = @_; - return unless (ref($settings) eq 'HASH'); + return unless (ref($settings) eq 'HASH'); if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { my $maxnum = scalar(@{$settings->{'inststatusorder'}}); if ($maxnum eq '') { @@ -6047,7 +5997,6 @@ sub modify_login { $errors .= '
  • '.$puberror.'
  • '; if ((grep(/^\Q$lang\E$/,@currlangs)) && (!grep(/^\Q$lang\E$/,@delurls))) { - $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; } } @@ -6090,7 +6039,7 @@ sub modify_login { } elsif ($currheadtagurls{$lonhost}) { $loginhash{'login'}{'headtag'}{$lonhost}{'url'} = $currheadtagurls{$lonhost}; if ($currexempt{$lonhost}) { - if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) { + if ((!exists($possexempt{$lonhost})) || ($possexempt{$lonhost} ne $currexempt{$lonhost})) { $changes{'headtag'}{$lonhost} = 1; } } elsif ($possexempt{$lonhost}) { @@ -6141,7 +6090,6 @@ sub modify_login { $errors .= '
  • '.$error.'
  • '; } } - &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); my $defaulthelpfile = '/adm/loginproblems.html'; @@ -6316,6 +6264,7 @@ sub modify_login { return $resulttext; } + sub check_exempt_addresses { my ($iplist) = @_; $iplist =~ s/^\s+//; @@ -7225,7 +7174,7 @@ sub modify_quotas { my $newpos = $env{'form.'.$itemid}; $newpos =~ s/\D+//g; foreach my $item ('subject','title','publisher','author') { - next if ((($item eq 'author') || ($item eq 'publisher')) && + next if ((($item eq 'author') || ($item eq 'publisher')) && ($type eq 'templates')); $confhash{$type}{$key}{$item} = $env{'form.'.$type.'_'.$item.'_'.$i}; if ($domconfig{$action}{$type}{$key}{$item} ne $confhash{$type}{$key}{$item}) { @@ -10225,18 +10174,14 @@ sub modify_helpsettings { sub modify_coursedefaults { my ($dom,$lastactref,%domconfig) = @_; my ($resulttext,$errors,%changes,%defaultshash); - my %defaultchecked = ( - 'uselcmath' => 'on', - 'usejsme' => 'on' - ); - my @toggles = ('uselcmath','usejsme'); + my %defaultchecked = ('canuse_pdfforms' => 'off'); + my @toggles = ('canuse_pdfforms'); my @numbers = ('anonsurvey_threshold','uploadquota_official','uploadquota_unofficial', 'uploadquota_community','uploadquota_textbook'); my @types = ('official','unofficial','community','textbook'); my %staticdefaults = ( anonsurvey_threshold => 10, uploadquota => 500, - postsubmit => 60, ); $defaultshash{'coursedefaults'} = {}; @@ -10298,81 +10243,26 @@ sub modify_coursedefaults { } } - my %credits; - foreach my $type (@types) { - unless ($type eq 'community') { - $credits{$type} = $env{'form.'.$type.'_credits'}; - $credits{$type} =~ s/[^\d.]+//g; - } - } - if ((ref($domconfig{'coursedefaults'}{'coursecredits'}) ne 'HASH') && - ($env{'form.coursecredits'} eq '1')) { - $changes{'coursecredits'} = 1; - foreach my $type (keys(%credits)) { - $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; - } - } else { - if ($env{'form.coursecredits'} eq '1') { - foreach my $type (@types) { - unless ($type eq 'community') { - if ($domconfig{'coursedefaults'}{'coursecredits'}{$type} ne $credits{$type}) { - $changes{'coursecredits'} = 1; - } - $defaultshash{'coursedefaults'}{'coursecredits'}{$type} = $credits{$type}; - } - } - } elsif (ref($domconfig{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - foreach my $type (@types) { - unless ($type eq 'community') { - if ($domconfig{'coursedefaults'}{'coursecredits'}{$type}) { - $changes{'coursecredits'} = 1; - last; - } - } - } - } - } - if ($env{'form.postsubmit'} eq '1') { - $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'on'; - my %currtimeout; - if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { - if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'off') { - $changes{'postsubmit'} = 1; - } - if (ref($domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { - %currtimeout = %{$domconfig{'coursedefaults'}{'postsubmit'}{'timeout'}}; - } - } else { - $changes{'postsubmit'} = 1; - } - foreach my $type (@types) { - my $timeout = $env{'form.'.$type.'_timeout'}; - $timeout =~ s/\D//g; - if ($timeout == $staticdefaults{'postsubmit'}) { - $timeout = ''; - } elsif (($timeout eq '') || ($timeout =~ /^0+$/)) { - $timeout = '0'; - } - unless ($timeout eq '') { - $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type} = $timeout; - } - if (exists($currtimeout{$type})) { - if ($timeout ne $currtimeout{$type}) { - $changes{'postsubmit'} = 1; - } - } elsif ($timeout ne '') { - $changes{'postsubmit'} = 1; - } - } - } else { - $defaultshash{'coursedefaults'}{'postsubmit'}{'client'} = 'off'; - if (ref($domconfig{'coursedefaults'}{'postsubmit'}) eq 'HASH') { - if ($domconfig{'coursedefaults'}{'postsubmit'}{'client'} eq 'on') { - $changes{'postsubmit'} = 1; - } - } else { - $changes{'postsubmit'} = 1; - } + my $officialcreds = $env{'form.official_credits'}; + $officialcreds =~ s/[^\d.]+//g; + my $unofficialcreds = $env{'form.unofficial_credits'}; + $unofficialcreds =~ s/[^\d.]+//g; + my $textbookcreds = $env{'form.textbook_credits'}; + $textbookcreds =~ s/[^\d.]+//g; + if (ref($domconfig{'coursedefaults'}{'coursecredits'} ne 'HASH') && + ($env{'form.coursecredits'} eq '1')) { + $changes{'coursecredits'} = 1; + } else { + if (($domconfig{'coursedefaults'}{'coursecredits'}{'official'} ne $officialcreds) || + ($domconfig{'coursedefaults'}{'coursecredits'}{'unofficial'} ne $unofficialcreds) || + ($domconfig{'coursedefaults'}{'coursecredits'}{'textbook'} ne $textbookcreds)) { + $changes{'coursecredits'} = 1; + } + } + $defaultshash{'coursedefaults'}{'coursecredits'} = { + official => $officialcreds, + unofficial => $unofficialcreds, + textbook => $textbookcreds, } } my $putresult = &Apache::lonnet::put_dom('configuration',\%defaultshash, @@ -10380,30 +10270,19 @@ sub modify_coursedefaults { if ($putresult eq 'ok') { if (keys(%changes) > 0) { my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) || - ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'})) { - foreach my $item ('uselcmath','usejsme') { - if ($changes{$item}) { - $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; - } + if (($changes{'canuse_pdfforms'}) || ($changes{'coursecredits'}) || + ($changes{'uploadquota'})) { + if ($changes{'canuse_pdfforms'}) { + $domdefaults{'canuse_pdfforms'}=$defaultshash{'coursedefaults'}{'canuse_pdfforms'}; } if ($changes{'coursecredits'}) { if (ref($defaultshash{'coursedefaults'}{'coursecredits'}) eq 'HASH') { - foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'coursecredits'}})) { - $domdefaults{$type.'credits'} = - $defaultshash{'coursedefaults'}{'coursecredits'}{$type}; - } - } - } - if ($changes{'postsubmit'}) { - if (ref($defaultshash{'coursedefaults'}{'postsubmit'}) eq 'HASH') { - $domdefaults{'postsubmit'} = $defaultshash{'coursedefaults'}{'postsubmit'}{'client'}; - if (ref($defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}) eq 'HASH') { - foreach my $type (keys(%{$defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}})) { - $domdefaults{$type.'postsubtimeout'} = - $defaultshash{'coursedefaults'}{'postsubmit'}{'timeout'}{$type}; - } - } + $domdefaults{'officialcredits'} = + $defaultshash{'coursedefaults'}{'coursecredits'}{'official'}; + $domdefaults{'unofficialcredits'} = + $defaultshash{'coursedefaults'}{'coursecredits'}{'unofficial'}; + $domdefaults{'textbookcredits'} = + $domdefaults{'coursedefaults'}{'coursecredits'}{'textbook'}; } } if ($changes{'uploadquota'}) { @@ -10421,17 +10300,11 @@ sub modify_coursedefaults { } $resulttext = &mt('Changes made:').''; } } - if ($changes{'offloadnow'}) { - if (ref($defaultshash{'usersessions'}{'offloadnow'}) eq 'HASH') { - if (keys(%{$defaultshash{'usersessions'}{'offloadnow'}}) > 0) { - $resulttext .= '
  • '.&mt('Switch active users on next access, for server(s):').'
      '; - foreach my $lonhost (sort(keys(%{$defaultshash{'usersessions'}{'offloadnow'}}))) { - $resulttext .= '
    • '.$lonhost.'
    • '; - } - $resulttext .= '
    '; - } else { - $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.'); - } - } else { - $resulttext .= '
  • '.&mt('No servers now set to switch active users on next access.').'
  • '; - } - } $resulttext .= ''; } else { $resulttext = $nochgmsg; @@ -11179,7 +10963,7 @@ sub modify_loadbalancing { } if ($rule eq 'specific') { my $specifiedhost = $env{'form.loadbalancing_singleserver_'.$i.'_'.$type}; - if (exists($servers{$specifiedhost})) { + if (exists($servers{$specifiedhost})) { $rule = $specifiedhost; } } @@ -11255,7 +11039,7 @@ sub modify_loadbalancing { if ($rule eq '') { $balancetext = $ruletitles{'default'}; } elsif (($rule eq 'homeserver') || ($rule eq 'externalbalancer') || - ($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { + ($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { if (($type eq '_LC_ipchange') || ($type eq '_LC_ipchangesso')) { foreach my $sparetype (@sparestypes) { if (ref($defaultshash{'loadbalancing'}{$balancer}{'targets'}{$sparetype}) eq 'ARRAY') { @@ -12013,9 +11797,6 @@ function toggleDisplay(domForm,caller) { if (caller == 'emailoptions') { optionsElement = domForm.cancreate_email; } - if (caller == 'studentsubmission') { - optionsElement = domForm.postsubmit; - } if (optionsElement.length) { var currval; for (var i=0; i 1) { foreach my $server (keys(%servers)) { next if ($thismachine{$server}); my @cached;