--- loncom/interface/domainprefs.pm 2012/09/25 20:38:47 1.160.6.6 +++ loncom/interface/domainprefs.pm 2012/08/27 00:53:22 1.168 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.6 2012/09/25 20:38:47 raeburn Exp $ +# $Id: domainprefs.pm,v 1.168 2012/08/27 00:53:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -86,7 +86,7 @@ $dom,$settings,$rowtotal,$action. $dom is the domain, $settings is a reference to a hash of current settings for the current context, $rowtotal is a reference to the scalar used to record the -number of rows displayed on the page, and $action is the context (quotas, +number of rows displayed on the page, and $action is the context (quotas, requestcourses or requestauthor). The print_quotas routine was orginally created to display/store information @@ -210,13 +210,15 @@ sub handler { 'quotas','autoenroll','autoupdate','autocreate', 'directorysrch','usercreation','usermodification', 'contacts','defaults','scantron','coursecategories', - 'serverstatuses','requestcourses','usersessions', - 'loadbalancing','requestauthor'],$dom); + 'serverstatuses','requestcourses','helpsettings', + 'coursedefaults','usersessions','loadbalancing', + 'requestauthor'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','usersessions'); if (keys(%servers) > 1) { push(@prefs_order,'loadbalancing'); } @@ -349,6 +351,26 @@ sub handler { col3 => 'Specific IPs', }], }, + 'helpsettings' => + {text => 'Help page settings', + help => 'Domain_Configuration_Help_Settings', + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], + }, + 'coursedefaults' => + {text => 'Course/Community defaults', + help => 'Domain_Configuration_Course_Defaults', + header => [{col1 => 'Defaults which can be overridden in each course by a CC', + col2 => 'Value',}, + {col1 => 'Defaults which can be overridden for each course by a DC', + col2 => 'Value',},], + }, + 'privacy' => + {text => 'User Privacy', + help => 'Domain_Configuration_User_Privacy', + header => [{col1 => 'Setting', + col2 => 'Value',}], + }, 'usersessions' => {text => 'User session hosting/offloading', help => 'Domain_Configuration_User_Sessions', @@ -393,10 +415,10 @@ sub handler { if (keys(%servers) > 1) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - $js .= &lonbalance_targets_js($dom,$types,\%servers). - &new_spares_js(). - &common_domprefs_js(). - &Apache::loncommon::javascript_array_indexof(); + $js = &lonbalance_targets_js($dom,$types,\%servers). + &new_spares_js(). + &common_domprefs_js(). + &Apache::loncommon::javascript_array_indexof(); } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { @@ -478,6 +500,10 @@ sub process_changes { $output = &modify_quotas($dom,$action,%domconfig); } elsif ($action eq 'requestauthor') { $output = &modify_quotas($dom,$action,%domconfig); + } elsif ($action eq 'helpsettings') { + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); + } elsif ($action eq 'coursedefaults') { + $output = &modify_coursedefaults($dom,%domconfig); } elsif ($action eq 'usersessions') { $output = &modify_usersessions($dom,%domconfig); } elsif ($action eq 'loadbalancing') { @@ -508,7 +534,7 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } @@ -547,6 +573,8 @@ sub print_config_box { $output .= &print_usersessions('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'student',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'coursedefaults') { + $output .= &print_coursedefaults('top',$dom,$settings,\$rowtotal); } $output .= ' @@ -1026,9 +1054,7 @@ sub print_login { $datatable .= ''; } $datatable .= ''; - $itemcount ++; } - $datatable .= &captcha_choice('login',$settings,$itemcount); } return $datatable; } @@ -1470,7 +1496,7 @@ sub print_quotas { } elsif ($context eq 'requestauthor') { @usertools = ('author'); @options = ('norequest','approval','automatic'); - %titles = &authorrequest_titles(); + %titles = &authorrequest_titles(); } else { @usertools = ('aboutme','blog','webdav','portfolio'); %titles = &tool_titles(); @@ -2358,7 +2384,7 @@ sub radiobutton_prefs { return unless ((ref($toggles) eq 'ARRAY') && (ref($defaultchecked) eq 'HASH') && (ref($choices) eq 'HASH')); - my (%checkedon,%checkedoff,$datatable,$css_class); + my (%checkedon,%checkedoff,$datatable,$css_class,$cell_colspan); foreach my $item (@{$toggles}) { if ($defaultchecked->{$item} eq 'on') { @@ -3132,7 +3158,7 @@ sub authorrequest_titles { automatic => 'Automatic approval', ); return %titles; -} +} sub courserequest_conditions { my %conditions = &Apache::lonlocal::texthash ( @@ -3273,10 +3299,9 @@ sub print_usercreation { $dom,$numinrow,$othertitle, 'statustocreate'); $$rowtotal ++; - $rownum ++; } } - $datatable .= &captcha_choice('cancreate',$createsettings,$rownum); + $datatable .= &captcha_choice('cancreate',$createsettings); } else { my @contexts = ('author','course','domain'); my @authtypes = ('int','krb4','krb5','loc'); @@ -3329,14 +3354,14 @@ sub print_usercreation { } sub captcha_choice { - my ($context,$settings,$itemcount) = @_; + my ($context,$settings) = @_; my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext); my %lt = &captcha_phrases(); $keyentry = 'hidden'; if ($context eq 'cancreate') { $rowname = &mt('CAPTCHA validation (e-mail as username)'); - } elsif ($context eq 'login') { - $rowname = &mt('"Contact helpdesk" CAPTCHA validation'); + } elsif ($context eq 'help') { + $rowname = &mt('CAPTCHA validation'); } if (ref($settings) eq 'HASH') { if ($settings->{'captcha'}) { @@ -3356,9 +3381,8 @@ sub captcha_choice { } else { $checked{'original'} = ' checked="checked"'; } - my $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $output = ''. - ''.$rowname.''."\n". + my $output = ''. + ''.$rowname.''."\n". '
'."\n"; foreach my $option ('original','recaptcha','notused') { $output .= ''."\n". ''.$pubtext.' '."\n". @@ -4589,6 +4613,7 @@ sub modify_login { $new = ''; } } + $loginhash{login}{loginvia}{$lonhost}{$item} = $new; } } @@ -4681,7 +4706,7 @@ sub modify_login { } else { my $puberror = &mt("Upload of [_1] failed because an error occurred publishing the file in RES space. Error was: [_2].",$newfile{$lang},$result); $errors .= '
  • '.$puberror.'
  • '; - if ((grep(/^\Q$lang\E$/,@currlangs)) && + if ((grep(/^\Q$lang\E$/,@currlangs)) && (!grep(/^\Q$lang\E$/,@delurls))) { $loginhash{'login'}{'helpurl'}{$lang} = $domconfig{'login'}{'helpurl'}{$lang}; @@ -4699,7 +4724,6 @@ sub modify_login { $errors .= '
  • '.$error.'
  • '; } } - &process_captcha('login',\%changes,$loginhash{'login'},$domconfig{'login'}); my $defaulthelpfile = '/adm/loginproblems.html'; my $defaulttext = &mt('Default in use'); @@ -4795,42 +4819,6 @@ sub modify_login { } } } - } elsif ($item eq 'captcha') { - if (ref($loginhash{'login'}) eq 'HASH') { - my $chgtxt; - if ($loginhash{'login'}{$item} eq 'notused') { - $chgtxt .= &mt('No CAPTCHA validation in use for helpdesk form.'); - } else { - my %captchas = &captcha_phrases(); - if ($captchas{$loginhash{'login'}{$item}}) { - $chgtxt .= &mt("Validation for helpdesk form set to $captchas{$loginhash{'login'}{$item}}."); - } else { - $chgtxt .= &mt('Validation for helpdesk form set to unknown type.'); - } - } - $resulttext .= '
  • '.$chgtxt.'
  • '; - } - } elsif ($item eq 'recaptchakeys') { - if (ref($loginhash{'login'}) eq 'HASH') { - my ($privkey,$pubkey); - if (ref($loginhash{'login'}{$item}) eq 'HASH') { - $pubkey = $loginhash{'login'}{$item}{'public'}; - $privkey = $loginhash{'login'}{$item}{'private'}; - } - my $chgtxt .= &mt('ReCAPTCHA keys changes').'
      '; - if (!$pubkey) { - $chgtxt .= '
    • '.&mt('Public key deleted').'
    • '; - } else { - $chgtxt .= '
    • '.&mt('Public key set to [_1]',$pubkey).'
    • '; - } - if (!$privkey) { - $chgtxt .= '
    • '.&mt('Private key deleted').'
    • '; - } else { - $chgtxt .= '
    • '.&mt('Private key set to [_1]',$pubkey).'
    • '; - } - $chgtxt .= '
    '; - $resulttext .= '
  • '.$chgtxt.'
  • '; - } } else { $resulttext .= '
  • '.&mt("$title{$item} set to $offon[$env{'form.'.$item}]").'
  • '; } @@ -5275,7 +5263,7 @@ sub publishlogo { # See if there is anything left unless ($fname) { return ('error: no uploaded file'); } $fname="$subdir/$fname"; - my $docroot=$r->dir_config('lonDocRoot'); + my $docroot=$r->dir_config('lonDocRoot'); my $filepath="$docroot/priv"; my $relpath = "$dom/$confname"; my ($fnamepath,$file,$fetchthumb); @@ -5283,7 +5271,7 @@ sub publishlogo { if ($fname=~m|/|) { ($fnamepath,$file) = ($fname =~ m|^(.*)/([^/]+)$|); } - my @parts=split(/\//,"$filepath/$relpath/$fnamepath"); + my @parts=split(/\//,"$filepath/$relpath/$fnamepath"); my $count; for ($count=5;$count<=$#parts;$count++) { $filepath.="/$parts[$count]"; @@ -5549,7 +5537,7 @@ sub modify_quotas { %limithash,$toolregexp,%conditions,$resulttext,%changes); if ($action eq 'quotas') { $context = 'tools'; - } else { + } else { $context = $action; } if ($context eq 'requestcourses') { @@ -5739,7 +5727,7 @@ sub modify_quotas { &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); $resulttext = &mt('Changes made:').'
      '; - unless (($context eq 'requestcourses') || + unless (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if (ref($changes{'defaultquota'}) eq 'HASH') { $resulttext .= '
    • '.&mt('Portfolio default quotas').'
        '; @@ -5760,7 +5748,7 @@ sub modify_quotas { my (%haschgs,%inconf); if ($context eq 'requestauthor') { %haschgs = %changes; - %inconf = %confhash; + %inconf = %confhash; } else { if (ref($changes{$item}) eq 'HASH') { %haschgs = %{$changes{$item}}; @@ -5774,7 +5762,7 @@ sub modify_quotas { &Apache::lonnet::usertools_access($env{'user.name'}, $env{'user.domain'}, $item,'reload',$context); - if (($context eq 'requestcourses') || + if (($context eq 'requestcourses') || ($context eq 'requestauthor')) { if ($env{'environment.canrequest.'.$item} ne $newacc) { $newenv{'environment.canrequest.'.$item} = $newacc; @@ -6795,7 +6783,7 @@ sub modify_usercreation { if ($captchas{$cancreate{$type}}) { $chgtext .= &mt("Validation for self-creation screen set to $captchas{$cancreate{$type}}."); } else { - $chgtext .= &mt('Validation for self-creation screen set to unknown type.'); + $chgtext .= &mt('Validation for self-creation screen set to unknown type.'); } } } elsif ($type eq 'recaptchakeys') { @@ -6923,44 +6911,30 @@ sub process_captcha { $newsettings->{'captcha'} = 'original'; } if ($current->{'captcha'} ne $newsettings->{'captcha'}) { - if ($container eq 'cancreate') { - if (ref($changes->{'cancreate'}) eq 'ARRAY') { - push(@{$changes->{'cancreate'}},'captcha'); - } elsif (!defined($changes->{'cancreate'})) { - $changes->{'cancreate'} = ['captcha']; - } - } else { - $changes->{'captcha'} = 1; + if (ref($changes->{'cancreate'}) eq 'ARRAY') { + push(@{$changes->{'cancreate'}},'captcha'); + } elsif (!defined($changes->{'cancreate'})) { + $changes->{'cancreate'} = ['captcha']; } } my ($newpub,$newpriv,$currpub,$currpriv); if ($newsettings->{'captcha'} eq 'recaptcha') { $newpub = $env{'form.'.$container.'_recaptchapub'}; $newpriv = $env{'form.'.$container.'_recaptchapriv'}; - $newpub =~ s/\W//g; - $newpriv =~ s/\W//g; - $newsettings->{'recaptchakeys'} = { - public => $newpub, - private => $newpriv, - }; } + $newsettings->{'recaptchakeys'} = { + public => $newpub, + private => $newpriv, + }; if (ref($current->{'recaptchakeys'}) eq 'HASH') { $currpub = $current->{'recaptchakeys'}{'public'}; $currpriv = $current->{'recaptchakeys'}{'private'}; - $newsettings->{'recaptchakeys'} = { - public => '', - private => '', - } } if (($newpub ne $currpub) || ($newpriv ne $currpriv)) { - if ($container eq 'cancreate') { - if (ref($changes->{'cancreate'}) eq 'ARRAY') { - push(@{$changes->{'cancreate'}},'recaptchakeys'); - } elsif (!defined($changes->{'cancreate'})) { - $changes->{'cancreate'} = ['recaptchakeys']; - } - } else { - $changes->{'recaptchakeys'} = 1; + if (ref($changes->{'cancreate'}) eq 'ARRAY') { + push(@{$changes->{'cancreate'}},'recaptchakeys'); + } elsif (!defined($changes->{'cancreate'})) { + $changes->{'cancreate'} = ['recaptchakeys']; } } return; @@ -7644,8 +7618,8 @@ sub modify_helpsettings { } elsif ($domconfig{'helpsettings'}{$item} ne $env{'form.'.$item}) { $changes{$item} = 1; } - } - if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) { + } + if (($env{'form.'.$item} eq '0') || ($env{'form.'.$item} eq '1')) { $helphash{'helpsettings'}{$item} = $env{'form.'.$item}; } } @@ -8254,7 +8228,7 @@ sub recurse_cat_deletes { delete($coursecategories->{$subitem}); $deletions->{$subitem} = 1; &recurse_cat_deletes($subitem,$coursecategories,$deletions); - } + } } } return;