--- loncom/interface/domainprefs.pm 2019/08/17 19:24:29 1.160.6.97 +++ loncom/interface/domainprefs.pm 2014/03/31 01:09:11 1.232 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.97 2019/08/17 19:24:29 raeburn Exp $ +# $Id: domainprefs.pm,v 1.232 2014/03/31 01:09:11 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -19,8 +19,7 @@ # # You should have received a copy of the GNU General Public License # along with LON-CAPA; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA# # /home/httpd/html/adm/gpl.txt # # http://www.lon-capa.org/ @@ -166,7 +165,6 @@ use Apache::lonlocal; use Apache::lonmsg(); use Apache::lonconfigsettings; use Apache::lonuserutils(); -use Apache::loncoursequeueadmin(); use LONCAPA qw(:DEFAULT :match); use LONCAPA::Enrollment; use LONCAPA::lonauthcgi(); @@ -216,13 +214,13 @@ sub handler { 'contacts','defaults','scantron','coursecategories', 'serverstatuses','requestcourses','helpsettings', 'coursedefaults','usersessions','loadbalancing', - 'requestauthor','selfenrollment','inststatus'],$dom); + 'requestauthor','selfenrollment'],$dom); my @prefs_order = ('rolecolors','login','defaults','quotas','autoenroll', 'autoupdate','autocreate','directorysrch','contacts', 'usercreation','selfcreation','usermodification','scantron', 'requestcourses','requestauthor','coursecategories', - 'serverstatuses','helpsettings','coursedefaults', - 'selfenrollment','usersessions'); + 'serverstatuses','helpsettings', + 'coursedefaults','selfenrollment','usersessions'); my %existing; if (ref($domconfig{'loadbalancing'}) eq 'HASH') { %existing = %{$domconfig{'loadbalancing'}}; @@ -251,21 +249,15 @@ sub handler { header => [{col1 => 'Log-in Page Items', col2 => '',}, {col1 => 'Log-in Help', - col2 => 'Value'}, - {col1 => 'Custom HTML in document head', col2 => 'Value'}], print => \&print_login, modify => \&modify_login, }, 'defaults' => - { text => 'Default authentication/language/timezone/portal/types', + { text => 'Default authentication/language/timezone/portal', help => 'Domain_Configuration_LangTZAuth', header => [{col1 => 'Setting', - col2 => 'Value'}, - {col1 => 'Internal Authentication', - col2 => 'Value'}, - {col1 => 'Institutional user types', - col2 => 'Name displayed'}], + col2 => 'Value'}], print => \&print_defaults, modify => \&modify_defaults, }, @@ -307,24 +299,18 @@ sub handler { modify => \&modify_autocreate, }, 'directorysrch' => - { text => 'Directory searches', + { text => 'Institutional directory searches', help => 'Domain_Configuration_InstDirectory_Search', - header => [{col1 => 'Institutional Directory Setting', - col2 => 'Value',}, - {col1 => 'LON-CAPA Directory Setting', + header => [{col1 => 'Setting', col2 => 'Value',}], print => \&print_directorysrch, modify => \&modify_directorysrch, }, 'contacts' => - { text => 'E-mail addresses and helpform', + { text => 'Contact Information', help => 'Domain_Configuration_Contact_Info', - header => [{col1 => 'Default e-mail addresses', - col2 => 'Value',}, - {col1 => 'Recipient(s) for notifications', - col2 => 'Value',}, - {col1 => 'Ask helpdesk form settings', - col2 => 'Value',},], + header => [{col1 => 'Setting', + col2 => 'Value',}], print => \&print_contacts, modify => \&modify_contacts, }, @@ -347,7 +333,7 @@ sub handler { col2 => 'Enabled?'}, {col1 => 'Institutional user type (login/SSO self-creation)', col2 => 'Information user can enter'}, - {col1 => 'Self-creation with e-mail verification', + {col1 => 'Self-creation with e-mail as username', col2 => 'Settings'}], print => \&print_selfcreation, modify => \&modify_selfcreation, @@ -363,12 +349,11 @@ sub handler { modify => \&modify_usermodification, }, 'scantron' => - { text => 'Bubblesheet format', + { text => 'Bubblesheet format file', help => 'Domain_Configuration_Scantron_Format', - header => [ {col1 => 'Bubblesheet format file', - col2 => ''}, - {col1 => 'Bubblesheet data upload formats', - col2 => 'Settings'}], + header => [ {col1 => 'Item', + col2 => '', + }], print => \&print_scantron, modify => \&modify_scantron, }, @@ -380,11 +365,7 @@ sub handler { {col1 => 'Setting', col2 => 'Value'}, {col1 => 'Available textbooks', - col2 => ''}, - {col1 => 'Available templates', - col2 => ''}, - {col1 => 'Validation (not official courses)', - col2 => 'Value'},], + col2 => ''}], print => \&print_quotas, modify => \&modify_quotas, }, @@ -401,9 +382,7 @@ sub handler { 'coursecategories' => { text => 'Cataloging of courses/communities', help => 'Domain_Configuration_Cataloging_Courses', - header => [{col1 => 'Catalog type/availability', - col2 => '',}, - {col1 => 'Category settings for standard catalog', + header => [{col1 => 'Category settings', col2 => '',}, {col1 => 'Categories', col2 => '', @@ -422,12 +401,10 @@ sub handler { modify => \&modify_serverstatuses, }, 'helpsettings' => - {text => 'Support settings', + {text => 'Help page settings', help => 'Domain_Configuration_Help_Settings', - header => [{col1 => 'Help Page Settings (logged-in users)', - col2 => 'Value'}, - {col1 => 'Helpdesk Roles', - col2 => 'Settings'},], + header => [{col1 => 'Help Settings (logged-in users)', + col2 => 'Value'}], print => \&print_helpsettings, modify => \&modify_helpsettings, }, @@ -453,6 +430,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', @@ -465,7 +450,7 @@ sub handler { print => \&print_usersessions, modify => \&modify_usersessions, }, - 'loadbalancing' => + 'loadbalancing' => {text => 'Dedicated Load Balancer(s)', help => 'Domain_Configuration_Load_Balancing', header => [{col1 => 'Balancers', @@ -485,8 +470,6 @@ sub handler { {col1 => 'Log-in Page Items', col2 => ''}, {col1 => 'Log-in Help', - col2 => 'Value'}, - {col1 => 'Custom HTML in document head', col2 => 'Value'}], print => \&print_login, modify => \&modify_login, @@ -509,7 +492,7 @@ sub handler { } } elsif ($phase eq 'display') { my $js = &recaptcha_js(). - &toggle_display_js(); + &credits_js(); if ((keys(%servers) > 1) || (keys(%existing) > 0)) { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -529,15 +512,6 @@ $javascript_validations $coursebrowserjs END } - if (grep(/^selfcreation$/,@actions)) { - $js .= &selfcreate_javascript(); - } - if (grep(/^contacts$/,@actions)) { - $js .= &contacts_javascript(); - } - if (grep(/^scantron$/,@actions)) { - $js .= &scantron_javascript(); - } &Apache::lonconfigsettings::display_settings($r,$dom,$phase,$context,\@prefs_order,\%prefs,\%domconfig,$confname,$js); } else { # check if domconfig user exists for the domain. @@ -627,11 +601,11 @@ sub process_changes { } elsif ($action eq 'autocreate') { $output = &modify_autocreate($dom,%domconfig); } elsif ($action eq 'directorysrch') { - $output = &modify_directorysrch($dom,$lastactref,%domconfig); + $output = &modify_directorysrch($dom,%domconfig); } elsif ($action eq 'usercreation') { $output = &modify_usercreation($dom,%domconfig); } elsif ($action eq 'selfcreation') { - $output = &modify_selfcreation($dom,$lastactref,%domconfig); + $output = &modify_selfcreation($dom,%domconfig); } elsif ($action eq 'usermodification') { $output = &modify_usermodification($dom,%domconfig); } elsif ($action eq 'contacts') { @@ -641,7 +615,7 @@ sub process_changes { } elsif ($action eq 'scantron') { $output = &modify_scantron($r,$dom,$confname,$lastactref,%domconfig); } elsif ($action eq 'coursecategories') { - $output = &modify_coursecategories($dom,$lastactref,%domconfig); + $output = &modify_coursecategories($dom,%domconfig); } elsif ($action eq 'serverstatuses') { $output = &modify_serverstatuses($dom,%domconfig); } elsif ($action eq 'requestcourses') { @@ -649,7 +623,7 @@ sub process_changes { } elsif ($action eq 'requestauthor') { $output = &modify_quotas($r,$dom,$action,$lastactref,%domconfig); } elsif ($action eq 'helpsettings') { - $output = &modify_helpsettings($r,$dom,$confname,$lastactref,%domconfig); + $output = &modify_helpsettings($r,$dom,$confname,%domconfig); } elsif ($action eq 'coursedefaults') { $output = &modify_coursedefaults($dom,$lastactref,%domconfig); } elsif ($action eq 'selfenrollment') { @@ -668,26 +642,8 @@ sub print_config_box { my $output; if ($action eq 'coursecategories') { $output = &coursecategories_javascript($settings); - } elsif ($action eq 'defaults') { - $output = &defaults_javascript($settings); - } elsif ($action eq 'helpsettings') { - my (%privs,%levelscurrent); - my %full=(); - my %levels=( - course => {}, - domain => {}, - system => {}, - ); - my $context = 'domain'; - my $crstype = 'Course'; - my $formname = 'display'; - &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); - my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); - $output = - &Apache::lonuserutils::custom_roledefs_js($context,$crstype,$formname,\%full, - \@templateroles); } - $output .= + $output .= ''; $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || - ($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || - ($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') || - ($action eq 'helpsettings') || ($action eq 'contacts')) { + ($action eq 'usermodification') || ($action eq 'coursedefaults') || + ($action eq 'selfenrollment') || ($action eq 'usersessions')) { $output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); } elsif ($action eq 'coursecategories') { $output .= $item->{'print'}->('top',$dom,$item,$settings,\$rowtotal); - } elsif ($action eq 'scantron') { - $output .= $item->{'print'}->($r,'top',$dom,$confname,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 4) { + if ($numheaders == 3) { $colspan = ' colspan="2"'; $output .= &print_login('service',$dom,$confname,$phase,$settings,\$rowtotal); } else { @@ -754,15 +706,8 @@ sub print_config_box { $rowtotal ++; if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || ($action eq 'selfenrollment') || - ($action eq 'usersessions') || ($action eq 'coursecategories') || - ($action eq 'contacts') || ($action eq 'defaults')) { - if ($action eq 'coursecategories') { - $output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); - $colspan = ' colspan="2"'; - } else { - $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal); - } - $output .= ' + ($action eq 'usersessions')) { + $output .= $item->{'print'}->('middle',$dom,$settings,\$rowtotal).'
'. @@ -702,9 +658,8 @@ sub print_config_box { if ($numheaders > 1) { my $colspan = ''; my $rightcolspan = ''; - if (($action eq 'rolecolors') || ($action eq 'defaults') || - ($action eq 'directorysrch') || - (($action eq 'login') && ($numheaders < 4))) { + if (($action eq 'rolecolors') || ($action eq 'coursecategories') || + (($action eq 'login') && ($numheaders < 3))) { $colspan = ' colspan="2"'; } if ($action eq 'usersessions') { @@ -720,16 +675,13 @@ sub print_config_box {
@@ -772,21 +717,15 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col1'}).' '.&mt($item->{'header'}->[2]->{'col2'}).' - '."\n"; - if ($action eq 'coursecategories') { - $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); - } else { - $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } + '."\n". + $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); $rowtotal ++; - } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults') || - ($action eq 'defaults') || ($action eq 'directorysrch') || - ($action eq 'helpsettings')) { + } elsif (($action eq 'usermodification') || ($action eq 'coursedefaults')) { $output .= $item->{'print'}->('bottom',$dom,$settings,\$rowtotal); - } elsif ($action eq 'scantron') { - $output .= $item->{'print'}->($r,'bottom',$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'coursecategories') { + $output .= &print_coursecategories('bottom',$dom,$item,$settings,\$rowtotal); } elsif ($action eq 'login') { - if ($numheaders == 4) { + if ($numheaders == 3) { $output .= &print_login('page',$dom,$confname,$phase,$settings,\$rowtotal).' @@ -802,31 +741,9 @@ sub print_config_box { } else { $output .= &print_login('help',$dom,$confname,$phase,$settings,\$rowtotal); } - $output .= ' - - - - - - - '; - if ($numheaders == 4) { - $output .= ' - - - '; - } else { - $output .= ' - - - '; - } - $rowtotal ++; - $output .= &print_login('headtag',$dom,$confname,$phase,$settings,\$rowtotal); } elsif ($action eq 'requestcourses') { - $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); - $rowtotal ++; - $output .= &print_studentcode($settings,\$rowtotal).' + $output .= &print_requestmail($dom,$action,$settings,\$rowtotal). + &print_studentcode($settings,\$rowtotal).'
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
'.&mt($item->{'header'}->[2]->{'col1'}).''.&mt($item->{'header'}->[2]->{'col2'}).'
@@ -836,32 +753,9 @@ sub print_config_box { '.&mt($item->{'header'}->[2]->{'col1'}).' '.&mt($item->{'header'}->[2]->{'col2'}).' '. - &textbookcourses_javascript($settings). - &print_textbookcourses($dom,'textbooks',$settings,\$rowtotal).' - - - - - - - - - '. - &print_textbookcourses($dom,'templates',$settings,\$rowtotal).' -
'.&mt($item->{'header'}->[3]->{'col1'}).''.&mt($item->{'header'}->[3]->{'col2'}).'
- - - - - - - - - '. - &print_validation_rows('requestcourses',$dom,$settings,\$rowtotal); + &print_textbookcourses($dom,$settings,\$rowtotal); } elsif ($action eq 'requestauthor') { $output .= &print_requestmail($dom,$action,$settings,\$rowtotal); - $rowtotal ++; } elsif ($action eq 'rolecolors') { $output .= &print_rolecolors($phase,'coordinator',$dom,$confname,$settings,\$rowtotal).'
'.&mt($item->{'header'}->[4]->{'col1'}).''.&mt($item->{'header'}->[4]->{'col2'}).'
@@ -896,7 +790,7 @@ sub print_config_box { '; - if ($action eq 'login') { + if (($action eq 'login') || ($action eq 'directorysrch')) { $output .= ' '; } elsif ($action eq 'serverstatuses') { @@ -940,9 +834,14 @@ sub print_config_box { $rowtotal ++; if ($action eq 'quotas') { $output .= &print_quotas($dom,$settings,\$rowtotal,$action); - } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || - ($action eq 'serverstatuses') || ($action eq 'loadbalancing')) { + } elsif (($action eq 'autoenroll') || ($action eq 'autocreate') || ($action eq 'directorysrch') || + ($action eq 'contacts') || ($action eq 'defaults') || ($action eq 'serverstatuses') || + ($action eq 'loadbalancing')) { $output .= $item->{'print'}->($dom,$settings,\$rowtotal); + } elsif ($action eq 'scantron') { + $output .= &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); + } elsif ($action eq 'helpsettings') { + $output .= &print_helpsettings($dom,$confname,$settings,\$rowtotal); } } $output .= ' @@ -1239,57 +1138,6 @@ sub print_login { $itemcount ++; } $datatable .= &captcha_choice('login',$settings,$itemcount); - } elsif ($caller eq 'headtag') { - my %domservers = &Apache::lonnet::get_servers($dom); - my $choice = $choices{'headtag'}; - $css_class = ' class="LC_odd_row"'; - $datatable .= ''. - ''; } return $datatable; } @@ -1323,9 +1171,6 @@ sub login_choices { link => "Link", alink => "Active link", vlink => "Visited link", - headtag => "Custom markup", - action => "Action", - current => "Current", ); return %choices; } @@ -1447,7 +1292,7 @@ sub display_color_options { my $datatable = ''. ''; if (!$is_custom->{'font'}) { - $datatable .= ''; + $datatable .= ''; } else { $datatable .= ''; } @@ -1456,12 +1301,12 @@ sub display_color_options { $datatable .= ''; + ' '; unless ($role eq 'login') { $datatable .= ''. ''; if (!$is_custom->{'fontmenu'}) { - $datatable .= ''; + $datatable .= ''; } else { $datatable .= ''; } @@ -1471,7 +1316,7 @@ sub display_color_options { ' '. - ' '; + ' '; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1530,8 +1375,7 @@ sub display_color_options { if ($fullwidth ne '' && $fullheight ne '') { if ($fullwidth > $width && $fullheight > $height) { my $size = $width.'x'.$height; - my @args = ('convert','-sample',$size,$input,$output); - system({$args[0]} @args); + system("convert -sample $size $input $output"); $showfile = "/$imgdir/tn-".$filename; } } @@ -1589,7 +1433,7 @@ sub display_color_options { my $bgs_def; foreach my $item (@{$bgs}) { if (!$is_custom->{$item}) { - $bgs_def .= ''; + $bgs_def .= ''; } } if ($bgs_def) { @@ -1617,7 +1461,7 @@ sub display_color_options { my $links_def; foreach my $item (@{$links}) { if (!$is_custom->{$item}) { - $links_def .= ''; + $links_def .= ''; } } if ($links_def) { @@ -1628,7 +1472,7 @@ sub display_color_options { $datatable .= ''."\n"; $itemcount ++; - my $onclick = "toggleDisplay(this.form,'credits');"; + my $onclick = 'toggleCredits(this.form);'; my $display = 'none'; if ($currusecredits) { $display = 'block'; } my $additional = '
'. - ''.&mt('Default credits').'
'.&mt($item->{'header'}->[0]->{'col1'}).''.$choice.''. - ''. - ''. - ''."\n"; - my (%currurls,%currexempt); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'headtag'}) eq 'HASH') { - foreach my $lonhost (keys(%{$settings->{'headtag'}})) { - if (ref($settings->{'headtag'}{$lonhost}) eq 'HASH') { - $currurls{$lonhost} = $settings->{'headtag'}{$lonhost}{'url'}; - $currexempt{$lonhost} = $settings->{'headtag'}{$lonhost}{'exempt'}; - } - } - } - } - my %lt = &Apache::lonlocal::texthash( - del => 'Delete?', - rep => 'Replace:', - upl => 'Upload:', - curr => 'View contents', - none => 'None', - ); - my $switchserver = &check_switchserver($dom,$confname); - foreach my $lonhost (sort(keys(%domservers))) { - my $exempt = &check_exempt_addresses($currexempt{$lonhost}); - $datatable .= ''; - if ($currurls{$lonhost}) { - $datatable .= ''. - ''; - } - $datatable .= '
'.$choices{'hostid'}.''.$choices{'current'}.''.$choices{'action'}.''.$choices{'exempt'}.'
'.$domservers{$lonhost}.''.$lt{'curr'}.' '.$lt{'rep'}.''; - } else { - $datatable .= ''.$lt{'none'}.''.$lt{'upl'}; - } - $datatable .='
'; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= '
'.$choices->{'font'}.''.&mt('Default in use:').' '.$defaults->{'font'}.''.&mt('Default in use:').' '.$defaults->{'font'}.' '. ' '. - ' 
'.$choices->{'fontmenu'}.''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.' 
'.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.'
'.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.'
'.$choices->{$item}.'
'.$defaults->{'links'}{$item}.'
'.$choices->{$item}.'
'.$defaults->{'links'}{$item}.'
'. ''; foreach my $item (@{$links}) { - my $color = $designs->{'links'}{$item} ? $designs->{'links'}{$item} : $defaults->{'links'}{$item}; + my $color = $designs->{'link'}{$item} ? $designs->{'link'}{$item} : $defaults->{'links'}{$item}; $datatable .= ''; + $$rowtotal += $rows; return $datatable; } @@ -2207,11 +2042,9 @@ sub print_studentcode { my $rownum = 0; my ($output,%current); my @crstypes = ('official','unofficial','community','textbook'); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'uniquecode'}) eq 'HASH') { - foreach my $type (@crstypes) { - $current{$type} = $settings->{'uniquecode'}{$type}; - } + if (ref($settings->{'uniquecode'}) eq 'HASH') { + foreach my $type (@crstypes) { + $current{$type} = $settings->{'uniquecode'}{$type}; } } $output .= ''. @@ -2232,14 +2065,14 @@ sub print_studentcode { } sub print_textbookcourses { - my ($dom,$type,$settings,$rowtotal) = @_; + my ($dom,$settings,$rowtotal) = @_; my $rownum = 0; my $css_class; my $itemcount = 1; my $maxnum = 0; my $bookshash; if (ref($settings) eq 'HASH') { - $bookshash = $settings->{$type}; + $bookshash = $settings->{'textbooks'}; } my %ordered; if (ref($bookshash) eq 'HASH') { @@ -2253,7 +2086,7 @@ sub print_textbookcourses { my $confname = $dom.'-domainconfig'; my $switchserver = &check_switchserver($dom,$confname); my $maxnum = scalar(keys(%ordered)); - my $datatable; + my $datatable = &textbookcourses_javascript(\%ordered); if (keys(%ordered)) { my @items = sort { $a <=> $b } keys(%ordered); for (my $i=0; $i<@items; $i++) { @@ -2261,24 +2094,21 @@ sub print_textbookcourses { my $key = $ordered{$items[$i]}; my %coursehash=&Apache::lonnet::coursedescription($key); my $coursetitle = $coursehash{'description'}; - my ($subject,$title,$author,$publisher,$image,$imgsrc,$cdom,$cnum); + my ($subject,$title,$author,$image,$imgsrc,$cdom,$cnum); if (ref($bookshash->{$key}) eq 'HASH') { $subject = $bookshash->{$key}->{'subject'}; $title = $bookshash->{$key}->{'title'}; - if ($type eq 'textbooks') { - $publisher = $bookshash->{$key}->{'publisher'}; - $author = $bookshash->{$key}->{'author'}; - $image = $bookshash->{$key}->{'image'}; - if ($image ne '') { - my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); - my $imagethumb = "$path/tn-".$imagefile; - $imgsrc = ''.&mt('Textbook image').''; - } + $author = $bookshash->{$key}->{'author'}; + $image = $bookshash->{$key}->{'image'}; + if ($image ne '') { + my ($path,$imagefile) = ($image =~ m{^(.+)/([^/]+)$}); + my $imagethumb = "$path/tn-".$imagefile; + $imgsrc = ''.&mt('Textbook image').''; } } - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type".'_'."$key','$type'".');"'; + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$key'".');"'; $datatable .= ''. ''."\n"; $itemcount ++; } } $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'$type"."_addbook_pos','$type'".');"'; + my $chgstr = ' onchange="javascript:reorderBooks(this.form,'."'addbook_pos'".');"'; $datatable .= ''."\n". + ''.&mt('Add').''."\n". ''."\n". ''."\n"; $itemcount ++; @@ -2365,42 +2187,23 @@ sub print_textbookcourses { } sub textbookcourses_javascript { - my ($settings) = @_; - return unless(ref($settings) eq 'HASH'); - my (%ordered,%total,%jstext); - foreach my $type ('textbooks','templates') { - $total{$type} = 0; - if (ref($settings->{$type}) eq 'HASH') { - foreach my $item (keys(%{$settings->{$type}})) { - if (ref($settings->{$type}->{$item}) eq 'HASH') { - my $num = $settings->{$type}->{$item}{'order'}; - $ordered{$type}{$num} = $item; - } - } - $total{$type} = scalar(keys(%{$settings->{$type}})); - } - my @jsarray = (); - foreach my $item (sort {$a <=> $b } (keys(%{$ordered{$type}}))) { - push(@jsarray,$ordered{$type}{$item}); - } - $jstext{$type} = ' var '.$type.' = Array('."'".join("','",@jsarray)."'".');'."\n"; + my ($textbooks) = @_; + return unless(ref($textbooks) eq 'HASH'); + my $num = scalar(keys(%{$textbooks})); + my @jsarray; + foreach my $item (sort {$a <=> $b } (keys(%{$textbooks}))) { + push(@jsarray,$textbooks->{$item}); } + my $jstext = ' var textbooks = Array('."'".join("','",@jsarray)."'".');'."\n"; return <<"ENDSCRIPT"; - -ENDSCRIPT -} - sub print_helpsettings { - my ($position,$dom,$settings,$rowtotal) = @_; - my $confname = $dom.'-domainconfig'; - my $formname = 'display'; + my ($dom,$confname,$settings,$rowtotal) = @_; my ($datatable,$itemcount); - if ($position eq 'top') { - $itemcount = 1; - my (%choices,%defaultchecked,@toggles); - $choices{'submitbugs'} = &mt('Display link to: [_1]?', - &Apache::loncommon::modal_link('http://bugs.loncapa.org', - &mt('LON-CAPA bug tracker'),600,500)); - %defaultchecked = ('submitbugs' => 'on'); - @toggles = ('submitbugs'); - ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); - $$rowtotal ++; - } else { - my $css_class; - my %existing=&Apache::lonnet::dump('roles',$dom,$confname,'rolesdef_'); - my (%customroles,%ordered,%current); - if (ref($settings) eq 'HASH') { - if (ref($settings->{'adhoc'}) eq 'HASH') { - %current = %{$settings->{'adhoc'}}; - } - } - my $count = 0; - foreach my $key (sort(keys(%existing))) { - if ($key=~/^rolesdef\_(\w+)$/) { - my $rolename = $1; - my (%privs,$order); - ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key}); - $customroles{$rolename} = \%privs; - if (ref($current{$rolename}) eq 'HASH') { - $order = $current{$rolename}{'order'}; - } - if ($order eq '') { - $order = $count; - } - $ordered{$order} = $rolename; - $count++; - } - } - my $maxnum = scalar(keys(%ordered)); - my @roles_by_num = (); - foreach my $item (sort {$a <=> $b } (keys(%ordered))) { - push(@roles_by_num,$item); - } - my $context = 'domprefs'; - my $crstype = 'Course'; - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); - my @accesstypes = ('all','dh','da','none'); - my ($numstatustypes,@jsarray); - if (ref($types) eq 'ARRAY') { - if (@{$types} > 0) { - $numstatustypes = scalar(@{$types}); - push(@accesstypes,'status'); - @jsarray = ('bystatus'); - } - } - my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh','da']); - if (keys(%domhelpdesk)) { - push(@accesstypes,('inc','exc')); - push(@jsarray,('notinc','notexc')); - } - my $hiddenstr = join("','",@jsarray); - $datatable .= &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname); - my $context = 'domprefs'; - my $crstype = 'Course'; - my $prefix = 'helproles_'; - my $add_class = 'LC_hidden'; - foreach my $num (@roles_by_num) { - my $role = $ordered{$num}; - my ($desc,$access,@statuses); - if (ref($current{$role}) eq 'HASH') { - $desc = $current{$role}{'desc'}; - $access = $current{$role}{'access'}; - if (ref($current{$role}{'insttypes'}) eq 'ARRAY') { - @statuses = @{$current{$role}{'insttypes'}}; - } - } - if ($desc eq '') { - $desc = $role; - } - my $identifier = 'custhelp'.$num; - my %full=(); - my %levels= ( - course => {}, - domain => {}, - system => {}, - ); - my %levelscurrent=( - course => {}, - domain => {}, - system => {}, - ); - &Apache::lonuserutils::custom_role_privs($customroles{$role},\%full,\%levels,\%levelscurrent); - my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$num."_pos'".');"'; - $datatable .= ''. - ''; - $itemcount ++; - } - $css_class = $itemcount%2?' class="LC_odd_row"':''; - my $newcust = 'custhelp'.$count; - my (%privs,%levelscurrent); - my %full=(); - my %levels= ( - course => {}, - domain => {}, - system => {}, - ); - &Apache::lonuserutils::custom_role_privs(\%privs,\%full,\%levels,\%levelscurrent); - my @templateroles = &Apache::lonuserutils::custom_template_roles($context,$crstype); - my $chgstr = ' onchange="javascript:reorderHelpRoles(this.form,'."'helproles_".$count."_pos'".');"'; - $datatable .= ''. - ''; - $count ++; - $$rowtotal += $count; - } - return $datatable; -} + $itemcount = 1; + my (%choices,%defaultchecked,@toggles); + $choices{'submitbugs'} = &mt('Display link to: [_1]?', + &Apache::loncommon::modal_link('http://bugs.loncapa.org', + &mt('LON-CAPA bug tracker'),600,500)); + %defaultchecked = ('submitbugs' => 'on'); + @toggles = ('submitbugs',); -sub adhocbutton { - my ($prefix,$num,$field,$visibility) = @_; - my %lt = &Apache::lonlocal::texthash( - show => 'Show details', - hide => 'Hide details', - ); - return ''.(' 'x10). - ''.(' 'x2).''.(' 'x2); -} - -sub helpsettings_javascript { - my ($roles_by_num,$total,$hiddenstr,$formname) = @_; - return unless(ref($roles_by_num) eq 'ARRAY'); - my %html_js_lt = &Apache::lonlocal::texthash( - show => 'Show details', - hide => 'Hide details', - ); - &html_escape(\%html_js_lt); - my $jstext = ' var helproles = Array('."'".join("','",@{$roles_by_num})."'".');'."\n"; - return <<"ENDSCRIPT"; - - -ENDSCRIPT -} - -sub helpdeskroles_access { - my ($dom,$prefix,$num,$add_class,$current,$accesstypes,$othertitle, - $usertypes,$types,$domhelpdesk) = @_; - return unless ((ref($accesstypes) eq 'ARRAY') && (ref($domhelpdesk) eq 'HASH')); - my %lt = &Apache::lonlocal::texthash( - 'rou' => 'Role usage', - 'whi' => 'Which helpdesk personnel may use this role?', - 'all' => 'All with domain helpdesk or helpdesk assistant role', - 'dh' => 'All with domain helpdesk role', - 'da' => 'All with domain helpdesk assistant role', - 'none' => 'None', - 'status' => 'Determined based on institutional status', - 'inc' => 'Include all, but exclude specific personnel', - 'exc' => 'Exclude all, but include specific personnel', - ); - my %usecheck = ( - all => ' checked="checked"', - ); - my %displaydiv = ( - status => 'none', - inc => 'none', - exc => 'none', - priv => 'block', - ); - my $output; - if (ref($current) eq 'HASH') { - if (($current->{'access'} ne '') && ($current->{'access'} ne 'all')) { - if (grep(/^\Q$current->{access}\E$/,@{$accesstypes})) { - $usecheck{$current->{access}} = $usecheck{'all'}; - delete($usecheck{'all'}); - if ($current->{access} =~ /^(status|inc|exc)$/) { - my $access = $1; - $displaydiv{$access} = 'inline'; - } elsif ($current->{access} eq 'none') { - $displaydiv{'priv'} = 'none'; - } - } - } - } - $output = '
'.$lt{'rou'}.''. - '

'.$lt{'whi'}.'

'; - foreach my $access (@{$accesstypes}) { - $output .= '

'; - if ($access eq 'status') { - $output .= '

'. - &Apache::lonuserutils::adhoc_status_types($dom,$prefix,$num,$current->{$access}, - $othertitle,$usertypes,$types). - '
'; - } elsif (($access eq 'inc') && (keys(%{$domhelpdesk}) > 0)) { - $output .= '
'. - &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). - '
'; - } elsif (($access eq 'exc') && (keys(%{$domhelpdesk}) > 0)) { - $output .= '
'. - &Apache::lonuserutils::adhoc_staff($access,$prefix,$num,$current->{$access},$domhelpdesk). - '
'; - } - $output .= '

'; - } - $output .= '
'; - return $output; + ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, + \%choices,$itemcount); + return $datatable; } 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')); @@ -3485,14 +2710,8 @@ sub radiobutton_prefs { $datatable .= ''; - if ($align eq 'left') { - $datatable .= ''. + ''."\n"; - $itemcount ++; + %defaultchecked = ('canuse_pdfforms' => 'off'); + @toggles = ('canuse_pdfforms'); ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, - \%choices,$itemcount); - $datatable = $mathdisp.$datatable; - $css_class = $itemcount%2?' class="LC_odd_row"':''; - $datatable .= - ''. - ''; - $itemcount ++; + \%choices,$itemcount); } else { $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - my ($currdefresponder,%defcredits,%curruploadquota,%deftimeout,%currmysql); + my ($currdefresponder,$def_official_credits,$def_unofficial_credits,$def_textbook_credits, + %curruploadquota); my $currusecredits = 0; - my $postsubmitclient = 1; my @types = ('official','unofficial','community','textbook'); if (ref($settings) eq 'HASH') { $currdefresponder = $settings->{'anonsurvey_threshold'}; @@ -3648,50 +2757,13 @@ sub print_coursedefaults { } } if (ref($settings->{'coursecredits'}) eq 'HASH') { - foreach my $type (@types) { - next if ($type eq 'community'); - $defcredits{$type} = $settings->{'coursecredits'}->{$type}; - if ($defcredits{$type} ne '') { - $currusecredits = 1; - } - } - } - if (ref($settings->{'postsubmit'}) eq 'HASH') { - if ($settings->{'postsubmit'}->{'client'} eq 'off') { - $postsubmitclient = 0; - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } else { - foreach my $type (@types) { - if (ref($settings->{'postsubmit'}->{'timeout'}) eq 'HASH') { - if ($settings->{'postsubmit'}->{'timeout'}->{$type} =~ /^\d+$/) { - $deftimeout{$type} = $settings->{'postsubmit'}->{'timeout'}->{$type}; - } else { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } else { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } + $def_official_credits = $settings->{'coursecredits'}->{'official'}; + $def_unofficial_credits = $settings->{'coursecredits'}->{'unofficial'}; + $def_textbook_credits = $settings->{'coursecredits'}->{'textbook'}; + if (($def_official_credits ne '') || ($def_unofficial_credits ne '') || + ($def_textbook_credits ne '')) { + $currusecredits = 1; } - } else { - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; - } - } - if (ref($settings->{'mysqltables'}) eq 'HASH') { - foreach my $type (keys(%{$settings->{'mysqltables'}})) { - $currmysql{$type} = $settings->{'mysqltables'}{$type}; - } - } else { - foreach my $type (@types) { - $currmysql{$type} = $staticdefaults{'mysqltables'}; - } - } - } else { - foreach my $type (@types) { - $deftimeout{$type} = $staticdefaults{'postsubmit'}; } } if (!$currdefresponder) { @@ -3726,20 +2798,27 @@ sub print_coursedefaults { } $datatable .= '
'.$choices->{$item}."\n"; if ($designs->{'links'}{$item}) { $datatable.=' '; @@ -1703,15 +1547,17 @@ sub image_changes { my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_; my $output; if ($img eq 'login') { - $output = ''.$logincolors; # suppress image for Log-in header + # suppress image for Log-in header } elsif (!$is_custom) { if ($img ne 'domlogo') { - $output = &mt('Default image:').'
'; + $output .= &mt('Default image:').'
'; } else { - $output = &mt('Default in use:').'
'; + $output .= &mt('Default in use:').'
'; } } - if ($img ne 'login') { + if ($img eq 'login') { # suppress image for Log-in header + $output .= '
'.$logincolors; + } else { if ($img_import) { $output .= ''; } @@ -2155,7 +2001,7 @@ sub print_quotas { } sub print_requestmail { - my ($dom,$action,$settings,$rowtotal,$customcss,$rowstyle) = @_; + my ($dom,$action,$settings,$rowtotal) = @_; my ($now,$datatable,%currapp); $now = time; if (ref($settings) eq 'HASH') { @@ -2167,19 +2013,7 @@ sub print_requestmail { } my $numinrow = 2; my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row'; - } - if ($customcss) { - $css_class .= " $customcss"; - } - $css_class =~ s/^\s+//; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowstyle) { - $css_class .= ' style="'.$rowstyle.'"'; - } + $css_class = ($$rowtotal%2? ' class="LC_odd_row"':''); my $text; if ($action eq 'requestcourses') { $text = &mt('Receive notification of course requests requiring approval'); @@ -2199,6 +2033,7 @@ sub print_requestmail { $datatable .= &mt('There are no active Domain Coordinators'); } $datatable .='
' - .''; for (my $k=0; $k<=$maxnum; $k++) { my $vpos = $k+1; my $selstr; @@ -2288,43 +2118,39 @@ sub print_textbookcourses { $datatable .= ''; } $datatable .= ''.(' 'x2). - ''. - ''.&mt('Subject:').' '. + ''.&mt('Subject:').' '. (' 'x2). - ''.&mt('Title:').' '; - if ($type eq 'textbooks') { - $datatable .= (' 'x2). - ''.&mt('Publisher:').' '. - (' 'x2). - ''.&mt('Author(s):').' '. - (' 'x2). - ''.&mt('Thumbnail:'); - if ($image) { - $datatable .= ''. - $imgsrc. - ' '. - ' '.&mt('Replace:').' '; - } - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } + ''.&mt('Title:').' '. + (' 'x2). + ''.&mt('Author(s):').' '. + (' 'x2). + ''.&mt('Thumbnail:'); + if ($image) { + $datatable .= ''. + $imgsrc. + ' '. + ' '.&mt('Replace:').' '; } - $datatable .= ' '. + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ' '. ''.&mt('LON-CAPA course:').' '. $coursetitle.'
'."\n". - ''."\n". - ''."\n". + ' '."\n". - ''.&mt('Add').''. - ''.&mt('Subject:').' '."\n". + ''.&mt('Subject:').' '."\n". (' 'x2). - ''.&mt('Title:').' '."\n". - (' 'x2); - if ($type eq 'textbooks') { - $datatable .= ''.&mt('Publisher:').' '."\n". - (' 'x2). - ''.&mt('Author(s):').' '."\n". - (' 'x2). - ''.&mt('Image:').' '; - if ($switchserver) { - $datatable .= &mt('Upload to library server: [_1]',$switchserver); - } else { - $datatable .= ''; - } - $datatable .= ''."\n"; - } - $datatable .= ''.&mt('LON-CAPA course:').' '. - &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). - ''. + ''.&mt('Title:').' '."\n". + (' 'x2). + ''.&mt('Author(s):').' '."\n". + (' 'x2). + ''.&mt('Image:').' '; + if ($switchserver) { + $datatable .= &mt('Upload to library server: [_1]',$switchserver); + } else { + $datatable .= ''; + } + $datatable .= ''."\n". + ''.&mt('LON-CAPA course:').' '. + &Apache::loncommon::select_dom_form($env{'request.role.domain'},'addbook_cdom'). + ''. &Apache::loncommon::selectcourse_link - ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'). + ('display','addbook_cnum','addbook_cdom',undef,undef,undef,'Course'); '
'.$role.'
'. - ''.(' 'x2). - ''. - '
'.&mt('Role name').''. - &mt('Name shown to users:'). - ''. - '
'. - &helpdeskroles_access($dom,$prefix,$num,$add_class,$current{$role},\@accesstypes, - $othertitle,$usertypes,$types,\%domhelpdesk). - '
'. - ''.&mt('Role privileges').&adhocbutton($prefix,$num,'privs','show').''. - &Apache::lonuserutils::custom_role_table($crstype,\%full,\%levels, - \%levelscurrent,$identifier, - 'LC_hidden',$prefix.$num.'_privs'). - '
'.&mt('Role name').''. - ''. - &mt('Internal name:'). - ''. - ''.(' 'x4). - ''. - &mt('Name shown to users:'). - ''. - '
'. - &helpdeskroles_access($dom,$prefix,$count,'',undef,\@accesstypes,$othertitle, - $usertypes,$types,\%domhelpdesk). - '
'.&mt('Role privileges').''. - &Apache::lonuserutils::custom_role_header($context,$crstype, - \@templateroles,$newcust). - &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels, - \%levelscurrent,$newcust). - '
'. - &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname). - '
'. ''.$choices->{$item}. - ''; - } else { - $datatable .= ''; - } - $datatable .= - ''. + ''. ' '. - ''.$choices{'texengine'}. - ''. - '
'. - ''.$choices{'canclone'}. - ''; - my $currcanclone = 'none'; - my $onclick; - my @cloneoptions = ('none','domain'); - my %clonetitles = ( - none => 'No additional course requesters', - domain => "Any course requester in course's domain", - instcode => 'Course requests for official courses ...', - ); - my (%codedefaults,@code_order,@posscodes); - if (&Apache::lonnet::auto_instcode_defaults($dom,\%codedefaults, - \@code_order) eq 'ok') { - if (@code_order > 0) { - push(@cloneoptions,'instcode'); - $onclick = ' onclick="toggleDisplay(this.form,'."'cloneinstcode'".');"'; - } - } - if (ref($settings) eq 'HASH') { - if ($settings->{'canclone'}) { - if (ref($settings->{'canclone'}) eq 'HASH') { - if (ref($settings->{'canclone'}{'instcode'}) eq 'ARRAY') { - if (@code_order > 0) { - $currcanclone = 'instcode'; - @posscodes = @{$settings->{'canclone'}{'instcode'}}; - } - } - } elsif ($settings->{'canclone'} eq 'domain') { - $currcanclone = $settings->{'canclone'}; - } - } - } - foreach my $option (@cloneoptions) { - my ($checked,$additional); - if ($currcanclone eq $option) { - $checked = ' checked="checked"'; - } - if ($option eq 'instcode') { - if (@code_order) { - my $show = 'none'; - if ($checked) { - $show = 'block'; - } - $additional = '
'. - &mt('Institutional codes for new and cloned course have identical:'). - '
'; - foreach my $item (@code_order) { - my $codechk; - if ($checked) { - if (grep(/^\Q$item\E$/,@posscodes)) { - $codechk = ' checked="checked"'; - } - } - $additional .= ''; - } - $additional .= (' 'x2).'('.&mt('check as many as needed').')
'; - } - } - $datatable .= - ' '.$additional.'
'; - } - $datatable .= '
'; - foreach my $type (@types) { - next if ($type eq 'community'); - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; + ''. + &mt('Default credits for official courses [_1]', + ''). + '
'. + ''. + &mt('Default credits for unofficial courses [_1]', + ''). + '
'. + ''. + &mt('Default credits for textbook courses [_1]', + ''). + ''."\n"; %defaultchecked = ('coursecredits' => 'off'); @toggles = ('coursecredits'); my $current = { @@ -3747,46 +2826,9 @@ sub print_coursedefaults { }; (my $table,$itemcount) = &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional,'left'); + \%choices,$itemcount,$onclick,$additional); $datatable .= $table; - $onclick = "toggleDisplay(this.form,'studentsubmission');"; - my $display = 'none'; - if ($postsubmitclient) { - $display = 'block'; - } - $additional = '
'. - &mt('Number of seconds submit is disabled').'
'. - ''.&mt('Enter 0 to remain disabled until page reload.').'
'. - ''; - foreach my $type (@types) { - $additional .= ''; - } - $additional .= '
'.&mt($type).'
'. - '
'."\n"; - %defaultchecked = ('postsubmit' => 'on'); - @toggles = ('postsubmit'); - $current = { - 'postsubmit' => $postsubmitclient, - }; - ($table,$itemcount) = - &radiobutton_prefs($current,\@toggles,\%defaultchecked, - \%choices,$itemcount,$onclick,$additional,'left'); - $datatable .= $table; - $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - $choices{'mysqltables'}. - ''. - ''. - ''; - foreach my $type (@types) { - $datatable .= ''; - } - $datatable .= '
'.&mt($type).'
'. - '
'."\n"; $itemcount ++; - } $$rowtotal += $itemcount; return $datatable; @@ -3932,88 +2974,48 @@ sub print_selfenrollment { $datatable .= ''; } } elsif ($position eq 'bottom') { - $datatable .= &print_validation_rows('selfenroll',$dom,$settings,\$itemcount); - } - $$rowtotal += $itemcount; - return $datatable; -} - -sub print_validation_rows { - my ($caller,$dom,$settings,$rowtotal) = @_; - my ($itemsref,$namesref,$fieldsref); - if ($caller eq 'selfenroll') { - ($itemsref,$namesref,$fieldsref) = &Apache::lonuserutils::selfenroll_validation_types(); - } elsif ($caller eq 'requestcourses') { - ($itemsref,$namesref,$fieldsref) = &Apache::loncoursequeueadmin::requestcourses_validation_types(); - } - my %currvalidation; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'validation'}) eq 'HASH') { - %currvalidation = %{$settings->{'validation'}}; - } - } - my $datatable; - my $itemcount = 0; - foreach my $item (@{$itemsref}) { - my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''. - $namesref->{$item}. - ''. - ''; - if (($item eq 'url') || ($item eq 'button')) { - $datatable .= ''. - ''; - } elsif ($item eq 'fields') { - my @currfields; - if (ref($currvalidation{$item}) eq 'ARRAY') { - @currfields = @{$currvalidation{$item}}; - } - foreach my $field (@{$fieldsref}) { - my $check = ''; - if (grep(/^\Q$field\E$/,@currfields)) { - $check = ' checked="checked"'; - } - $datatable .= ' '; - } - } elsif ($item eq 'markup') { - $datatable .= ''; - } - $datatable .= ''."\n"; - if (ref($rowtotal)) { - $itemcount ++; - } - } - if ($caller eq 'requestcourses') { - my %currhash; + my ($itemsref,$namesref,$fieldsref) = &selfenroll_validation_types(); + my %currvalidation; if (ref($settings) eq 'HASH') { if (ref($settings->{'validation'}) eq 'HASH') { - if ($settings->{'validation'}{'dc'} ne '') { - $currhash{$settings->{'validation'}{'dc'}} = 1; - } + %currvalidation = %{$settings->{'validation'}}; } } - my $numinrow = 2; - my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', - 'validationdc',%currhash); - my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''; - if ($numdc > 1) { - $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'); - } else { - $datatable .= &mt('Course creation processed as: '); + foreach my $item (@{$itemsref}) { + $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; + $datatable .= ''. + $namesref->{$item}. + ''. + ''; + if (($item eq 'url') || ($item eq 'button')) { + $datatable .= ''. + ''; + } elsif ($item eq 'fields') { + my @currfields; + if (ref($currvalidation{$item}) eq 'ARRAY') { + @currfields = @{$currvalidation{$item}}; + } + foreach my $field (@{$fieldsref}) { + my $check = ''; + if (grep(/^\Q$field\E$/,@currfields)) { + $check = ' checked="checked"'; + } + $datatable .= ' '; + } + } elsif ($item eq 'markup') { + $datatable .= ''; + } + $datatable .= ''."\n"; + $itemcount ++; } - $datatable .= ''.$dctable.''; - $itemcount ++; - } - if (ref($rowtotal)) { - $$rowtotal += $itemcount; } + $$rowtotal += $itemcount; return $datatable; } @@ -4031,13 +3033,7 @@ sub print_usersessions { if ($position eq 'top') { if (keys(%serverhomes) > 1) { my %spareid = ¤t_offloads_to($dom,$settings,\%servers); - my $curroffloadnow; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'offloadnow'}) eq 'HASH') { - $curroffloadnow = $settings->{'offloadnow'}; - } - } - $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$curroffloadnow,$rowtotal); + $datatable .= &spares_row($dom,\%servers,\%spareid,\%serverhomes,\%altids,$rowtotal); } else { $datatable .= ''. &mt('Nothing to set here, as the cluster to which this domain belongs only contains one server.'); @@ -4287,7 +3283,7 @@ sub current_offloads_to { } sub spares_row { - my ($dom,$servers,$spareid,$serverhomes,$altids,$curroffloadnow,$rowtotal) = @_; + my ($dom,$servers,$spareid,$serverhomes,$altids,$rowtotal) = @_; my $css_class; my $numinrow = 4; my $itemcount = 1; @@ -4307,21 +3303,12 @@ sub spares_row { } } next unless (ref($spareid->{$server}) eq 'HASH'); - my $checkednow; - if (ref($curroffloadnow) eq 'HASH') { - if ($curroffloadnow->{$server}) { - $checkednow = ' checked="checked"'; - } - } $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; $datatable .= ' '. &mt('[_1] when busy, offloads to:' - ,''.$server.'').'
'. - ''."\n". - ''. + ,''.$server.''). "\n"; my (%current,%canselect); my @choices = @@ -4446,13 +3433,13 @@ sub print_loadbalancing { my $numinrow = 1; my $datatable; my %servers = &Apache::lonnet::internet_dom_servers($dom); - my (%currbalancer,%currtargets,%currrules,%existing,%currcookies); + my (%currbalancer,%currtargets,%currrules,%existing); if (ref($settings) eq 'HASH') { %existing = %{$settings}; } if ((keys(%servers) > 1) || (keys(%existing) > 0)) { &get_loadbalancers_config(\%servers,\%existing,\%currbalancer, - \%currtargets,\%currrules,\%currcookies); + \%currtargets,\%currrules); } else { return; } @@ -4526,12 +3513,6 @@ sub print_loadbalancing { my ($numspares,@spares) = &count_servers($lonhost,%servers); my @sparestypes = ('primary','default'); my %typetitles = &sparestype_titles(); - my %hostherechecked = ( - no => ' checked="checked"', - ); - my %balcookiechecked = ( - no => ' checked="checked"', - ); foreach my $sparetype (@sparestypes) { my $targettable; for (my $i=0; $i<$numspares; $i++) { @@ -4551,10 +3532,9 @@ sub print_loadbalancing { $disabled = ' disabled="disabled"'; } $targettable .= - ''; + ''; my $rem = $i%($numinrow); if ($rem == 0) { if (($i > 0) && ($i < $numspares-1)) { @@ -4577,35 +3557,8 @@ sub print_loadbalancing { $datatable .= ''.$typetitles{$sparetype}.'
'. ''.$targettable.'

'; } - $hostherechecked{$sparetype} = ''; - if (ref($currtargets{$lonhost}) eq 'HASH') { - if (ref($currtargets{$lonhost}{$sparetype}) eq 'ARRAY') { - if (grep(/^\Q$lonhost\E$/,@{$currtargets{$lonhost}{$sparetype}})) { - $hostherechecked{$sparetype} = ' checked="checked"'; - $hostherechecked{'no'} = ''; - } - } - } - } - if ($currcookies{$lonhost}) { - %balcookiechecked = ( - yes => ' checked="checked"', - ); } - $datatable .= &mt('Hosting on balancer itself').'
'. - '
'; - foreach my $sparetype (@sparestypes) { - $datatable .= '
'; - } - $datatable .= &mt('Use balancer cookie').'
'. - '
'. - '
'. - ''. + $datatable .= ''. &loadbalancing_rules($dom,$intdom,$currrules{$lonhost}, $othertitle,$usertypes,$types,\%servers, \%currbalancer,$lonhost, @@ -4619,11 +3572,10 @@ sub print_loadbalancing { } sub get_loadbalancers_config { - my ($servers,$existing,$currbalancer,$currtargets,$currrules,$currcookies) = @_; + my ($servers,$existing,$currbalancer,$currtargets,$currrules) = @_; return unless ((ref($servers) eq 'HASH') && (ref($existing) eq 'HASH') && (ref($currbalancer) eq 'HASH') && - (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH') && - (ref($currcookies) eq 'HASH')); + (ref($currtargets) eq 'HASH') && (ref($currrules) eq 'HASH')); if (keys(%{$existing}) > 0) { my $oldlonhost; foreach my $key (sort(keys(%{$existing}))) { @@ -4642,9 +3594,6 @@ sub get_loadbalancers_config { $currbalancer->{$key} = 1; $currtargets->{$key} = $existing->{$key}{'targets'}; $currrules->{$key} = $existing->{$key}{'rules'}; - if ($existing->{$key}{'cookie'}) { - $currcookies->{$key} = 1; - } } } } else { @@ -4675,7 +3624,7 @@ sub loadbalancing_rules { if (ref($currrules) eq 'HASH') { $current = $currrules->{$type}; } - if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { if ($dom ne &Apache::lonnet::host_domain($lonhost)) { $current = ''; } @@ -4700,14 +3649,9 @@ sub loadbalancing_titles { '_LC_ipchange' => &mt('Non-SSO users with IP mismatch'), ); my @alltypes = ('_LC_adv','_LC_author','_LC_internetdom','_LC_external','_LC_ipchangesso','_LC_ipchange'); - my @available; if (ref($types) eq 'ARRAY') { - @available = @{$types}; - } - unless (grep(/^default$/,@available)) { - push(@available,'default'); + unshift(@alltypes,@{$types},'default'); } - unshift(@alltypes,@available); my %titles; foreach my $type (@alltypes) { if ($type =~ /^_LC_/) { @@ -4732,7 +3676,7 @@ sub loadbalance_rule_row { my @rulenames; my %ruletitles = &offloadtype_text(); if (($type eq '_LC_ipchangesso') || ($type eq '_LC_ipchange')) { - @rulenames = ('balancer','offloadedto','specific'); + @rulenames = ('balancer','offloadedto'); } else { @rulenames = ('default','homeserver'); if ($type eq '_LC_external') { @@ -4743,7 +3687,7 @@ sub loadbalance_rule_row { push(@rulenames,'none'); } my $style = $targets_div_style; - if (($type eq '_LC_external') || ($type eq '_LC_internetdom')) { + if (($type eq '_LC_external') || ($type eq '_LC_internetdom') || ($type eq '_LC_ipchange')) { $style = $homedom_div_style; } my $space; @@ -4794,13 +3738,8 @@ sub loadbalance_rule_row { ' '; - if (($rulenames[$i] eq 'specific') && ($type =~ /^_LC_ipchange/)) { - $output .= $ruletitles{'particular'}; - } else { - $output .= $ruletitles{$rulenames[$i]}; - } - $output .= ''.$extra.'
'."\n"; + ')"'.$checked.' /> '.$ruletitles{$rulenames[$i]}. + ''.$extra.'
'."\n"; } $output .= ''."\n"; return $output; @@ -4815,7 +3754,6 @@ sub offloadtype_text { 'none' => 'No offload', 'balancer' => 'Session hosted on Load Balancer, after re-authentication', 'offloadedto' => 'Session hosted on offload server, after re-authentication', - 'particular' => 'Session hosted (after re-auth) on server:', ); return %ruletitles; } @@ -4830,17 +3768,15 @@ sub sparestype_titles { sub contact_titles { my %titles = &Apache::lonlocal::texthash ( - 'supportemail' => 'Support E-mail address', - 'adminemail' => 'Default Server Admin E-mail address', - 'errormail' => 'Error reports to be e-mailed to', - 'packagesmail' => 'Package update alerts to be e-mailed to', - 'helpdeskmail' => "Helpdesk requests for this domain's users", - 'otherdomsmail' => 'Helpdesk requests for other (unconfigured) domains', - 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)', - 'requestsmail' => 'E-mail from course requests requiring approval', - 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates', + 'supportemail' => 'Support E-mail address', + 'adminemail' => 'Default Server Admin E-mail address', + 'errormail' => 'Error reports to be e-mailed to', + 'packagesmail' => 'Package update alerts to be e-mailed to', + 'helpdeskmail' => 'Helpdesk requests to be e-mailed to', + 'lonstatusmail' => 'E-mail from nightly status check (warnings/errors)', + 'requestsmail' => 'E-mail from course requests requiring approval', + 'updatesmail' => 'E-mail from nightly check of LON-CAPA module integrity/updates', 'idconflictsmail' => 'E-mail from bi-nightly check for multiple users sharing same student/employee ID', - 'hostipmail' => 'E-mail from nightly check of hostname/IP network changes', ); my %short_titles = &Apache::lonlocal::texthash ( adminemail => 'Admin E-mail address', @@ -4849,34 +3785,6 @@ sub contact_titles { return (\%titles,\%short_titles); } -sub helpform_fields { - my %titles = &Apache::lonlocal::texthash ( - 'username' => 'Name', - 'user' => 'Username/domain', - 'phone' => 'Phone', - 'cc' => 'Cc e-mail', - 'course' => 'Course Details', - 'section' => 'Sections', - 'screenshot' => 'File upload', - ); - my @fields = ('username','phone','user','course','section','cc','screenshot'); - my %possoptions = ( - username => ['yes','no','req'], - phone => ['yes','no','req'], - user => ['yes','no'], - cc => ['yes','no'], - course => ['yes','no'], - section => ['yes','no'], - screenshot => ['yes','no'], - ); - my %fieldoptions = &Apache::lonlocal::texthash ( - 'yes' => 'Optional', - 'req' => 'Required', - 'no' => "Not shown", - ); - return (\@fields,\%titles,\%fieldoptions,\%possoptions); -} - sub tool_titles { my %titles = &Apache::lonlocal::texthash ( aboutme => 'Personal web page', @@ -5061,32 +3969,17 @@ sub print_usercreation { sub print_selfcreation { my ($position,$dom,$settings,$rowtotal) = @_; - my (@selfcreate,$createsettings,$processing,$emailoptions,$emailverified, - $emaildomain,$datatable); + my (@selfcreate,$createsettings,$datatable); if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { $createsettings = $settings->{'cancreate'}; - if (ref($createsettings) eq 'HASH') { - if (ref($createsettings->{'selfcreate'}) eq 'ARRAY') { - @selfcreate = @{$createsettings->{'selfcreate'}}; - } elsif ($createsettings->{'selfcreate'} ne '') { - if ($settings->{'cancreate'}{'selfcreate'} eq 'any') { - @selfcreate = ('email','login','sso'); - } elsif ($createsettings->{'selfcreate'} ne 'none') { - @selfcreate = ($createsettings->{'selfcreate'}); - } - } - if (ref($createsettings->{'selfcreateprocessing'}) eq 'HASH') { - $processing = $createsettings->{'selfcreateprocessing'}; - } - if (ref($createsettings->{'emailoptions'}) eq 'HASH') { - $emailoptions = $createsettings->{'emailoptions'}; - } - if (ref($createsettings->{'emailverified'}) eq 'HASH') { - $emailverified = $createsettings->{'emailverified'}; - } - if (ref($createsettings->{'emaildomain'}) eq 'HASH') { - $emaildomain = $createsettings->{'emaildomain'}; + if (ref($settings->{'cancreate'}{'selfcreate'}) eq 'ARRAY') { + @selfcreate = @{$settings->{'cancreate'}{'selfcreate'}}; + } elsif ($settings->{'cancreate'}{'selfcreate'} ne '') { + if ($settings->{'cancreate'}{'selfcreate'} eq 'any') { + @selfcreate = ('email','login','sso'); + } elsif ($settings->{'cancreate'}{'selfcreate'} ne 'none') { + @selfcreate = ($settings->{'cancreate'}{'selfcreate'}); } } } @@ -5094,7 +3987,6 @@ sub print_selfcreation { my %radiohash; my $numinrow = 4; map { $radiohash{'cancreate_'.$_} = 1; } @selfcreate; - my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); if ($position eq 'top') { my %choices = &Apache::lonlocal::texthash ( cancreate_login => 'Institutional Login', @@ -5109,470 +4001,96 @@ sub print_selfcreation { ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, \%choices,$itemcount,$onclick); $$rowtotal += $itemcount; + + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { $datatable .= &insttypes_row($createsettings,$types,$usertypes, $dom,$numinrow,$othertitle, - 'statustocreate',$rowtotal); + 'statustocreate',$$rowtotal); $$rowtotal ++; } } - my @fields = ('lastname','firstname','middlename','permanentemail','id','inststatus'); - my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); - $fieldtitles{'inststatus'} = &mt('Institutional status'); - my $rem; - my $numperrow = 2; - my $css_class = $$rowtotal%2?' class="LC_odd_row"':''; - $datatable .= ''. - ''.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').''. - ''."\n". - ''."\n"; - for (my $i=0; $i<@fields; $i++) { - $rem = $i%($numperrow); - if ($rem == 0) { - if ($i > 0) { - $datatable .= ''; - } - $datatable .= ''; - } - my $currval; - if (ref($createsettings) eq 'HASH') { - if (ref($createsettings->{'shibenv'}) eq 'HASH') { - $currval = $createsettings->{'shibenv'}{$fields[$i]}; - } - } - $datatable .= ''; - } - my $colsleft = $numperrow - $rem; - if ($colsleft > 1 ) { - $datatable .= ''; - } elsif ($colsleft == 1) { - $datatable .= ''; - } - $datatable .= '
'. - ''. - ' '. - $fieldtitles{$fields[$i]}.''. - '  
'; - $$rowtotal ++; } elsif ($position eq 'middle') { my %domconf = &Apache::lonnet::get_dom('configuration',['usermodification'],$dom); - my @posstypes; + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + $usertypes->{'default'} = $othertitle; if (ref($types) eq 'ARRAY') { - @posstypes = @{$types}; - } - unless (grep(/^default$/,@posstypes)) { - push(@posstypes,'default'); - } - my %usertypeshash; - if (ref($usertypes) eq 'HASH') { - %usertypeshash = %{$usertypes}; - } - $usertypeshash{'default'} = $othertitle; - foreach my $status (@posstypes) { - $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'}, - $numinrow,$$rowtotal,\%usertypeshash); - $$rowtotal ++; + push(@{$types},'default'); + $usertypes->{'default'} = $othertitle; + foreach my $status (@{$types}) { + $datatable .= &modifiable_userdata_row('selfcreate',$status,$domconf{'usermodification'}, + $numinrow,$$rowtotal,$usertypes); + $$rowtotal ++; + } } } else { - my %choices = &Apache::lonlocal::texthash ( - 'cancreate_email' => 'Non-institutional username (via e-mail verification)', - ); - my @toggles = sort(keys(%choices)); - my %defaultchecked = ( - 'cancreate_email' => 'off', - ); - my $customclass = 'LC_selfcreate_email'; - my $classprefix = 'LC_canmodify_emailusername_'; - my $optionsprefix = 'LC_options_emailusername_'; - my $display = 'none'; - my $rowstyle = 'display:none'; - if (grep(/^\Qemail\E$/,@selfcreate)) { - $display = 'block'; - $rowstyle = 'display:table-row'; - } - my $onclick = "toggleRows(this.form,'cancreate_email','selfassign','$customclass','$classprefix','$optionsprefix');"; - ($datatable,$$rowtotal) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, - \%choices,$$rowtotal,$onclick); - $datatable .= &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal,$customclass, - $rowstyle); - $$rowtotal ++; - $datatable .= &captcha_choice('cancreate',$createsettings,$$rowtotal,$customclass, - $rowstyle); - $$rowtotal ++; - my (@ordered,@posstypes,%usertypeshash); - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom); - my ($emailrules,$emailruleorder) = - &Apache::lonnet::inst_userrules($dom,'email'); - my $primary_id = &Apache::lonnet::domain($dom,'primary'); - my $intdom = &Apache::lonnet::internet_dom($primary_id); - if (ref($types) eq 'ARRAY') { - @posstypes = @{$types}; - } - if (@posstypes) { - unless (grep(/^default$/,@posstypes)) { - push(@posstypes,'default'); - } - if (ref($usertypes) eq 'HASH') { - %usertypeshash = %{$usertypes}; - } - my $currassign; - if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { - $currassign = { - selfassign => $domdefaults{'inststatusguest'}, - }; - @ordered = @{$domdefaults{'inststatusguest'}}; - } else { - $currassign = { selfassign => [] }; - } - my $onclicktypes = "toggleDataRow(this.form,'selfassign','$customclass','$optionsprefix',);". - "toggleDataRow(this.form,'selfassign','$customclass','$classprefix',1);"; - $datatable .= &insttypes_row($currassign,$types,$usertypes,$dom, - $numinrow,$othertitle,'selfassign', - $rowtotal,$onclicktypes,$customclass, - $rowstyle); - $$rowtotal ++; - $usertypeshash{'default'} = $othertitle; - foreach my $status (@posstypes) { - my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row '; - } - $css_class .= $customclass; - my $rowid = $optionsprefix.$status; - my $hidden = 1; - my $currstyle = 'display:none'; - if (grep(/^\Q$status\E$/,@ordered)) { - $currstyle = $rowstyle; - $hidden = 0; - } - $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain, - $emailrules,$emailruleorder,$settings,$status,$rowid, - $usertypeshash{$status},$css_class,$currstyle,$intdom); - unless ($hidden) { - $$rowtotal ++; + my $css_class = $$rowtotal%2?' class="LC_odd_row"':''; + my %choices = + &Apache::lonlocal::texthash( + email => 'Approved automatically', + emailapproval => 'Queued for approval by DC', + off => 'Not enabled', + ); + $datatable .= ''. + ''.&mt('E-mail address as username'). + ''. + ''; + foreach my $option ('email','emailapproval','off') { + my $checked; + if ($option eq 'email') { + if ($radiohash{'cancreate_email'}) { + $checked = 'checked="checked"'; + } + } elsif ($option eq 'emailapproval') { + if ($radiohash{'cancreate_emailapproval'}) { + $checked = 'checked="checked"'; + } + } else { + if ((!$radiohash{'cancreate_email'}) && (!$radiohash{'cancreate_emailapproval'})) { + $checked = 'checked="checked"'; } } - } else { - my $css_class; - if ($$rowtotal%2) { - $css_class = 'LC_odd_row '; - } - $css_class .= $customclass; - $usertypeshash{'default'} = $othertitle; - $datatable .= &noninst_users($processing,$emailverified,$emailoptions,$emaildomain, - $emailrules,$emailruleorder,$settings,'default','', - $othertitle,$css_class,$rowstyle,$intdom); - $$rowtotal ++; + $datatable .= ' '; } + $$rowtotal ++; + $datatable .= ''. + &print_requestmail($dom,'selfcreation',$createsettings,$rowtotal); + $$rowtotal ++; my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); $numinrow = 1; - if (@posstypes) { - foreach my $status (@posstypes) { - my $rowid = $classprefix.$status; - my $datarowstyle = 'display:none'; - if (grep(/^\Q$status\E$/,@ordered)) { - $datarowstyle = $rowstyle; - } + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + $usertypes->{'default'} = $othertitle; + if (ref($types) eq 'ARRAY') { + push(@{$types},'default'); + $usertypes->{'default'} = $othertitle; + foreach my $status (@{$types}) { $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings, - $numinrow,$$rowtotal,\%usertypeshash,$infofields, - $infotitles,$rowid,$customclass,$datarowstyle); - unless ($datarowstyle eq 'display:none') { - $$rowtotal ++; - } - } - } else { - $datatable .= &modifiable_userdata_row('cancreate','emailusername_default',$settings, - $numinrow,$$rowtotal,\%usertypeshash,$infofields, - $infotitles,'',$customclass,$rowstyle); - } - } - return $datatable; -} - -sub selfcreate_javascript { - return <<"ENDSCRIPT"; - - - -ENDSCRIPT -} - -sub noninst_users { - my ($processing,$emailverified,$emailoptions,$emaildomain,$emailrules, - $emailruleorder,$settings,$type,$rowid,$typetitle,$css_class,$rowstyle,$intdom) = @_; - my $class = 'LC_left_item'; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowid) { - $rowid = ' id="'.$rowid.'"'; - } - if ($rowstyle) { - $rowstyle = ' style="'.$rowstyle.'"'; - } - my ($output,$description); - if ($type eq 'default') { - $description = &mt('Requests for: [_1]',$typetitle); - } else { - $description = &mt('Requests for: [_1] (status self-reported)',$typetitle); - } - $output = ''. - "$description\n". - ''. - ''; - my %headers = &Apache::lonlocal::texthash( - approve => 'Processing', - email => 'E-mail', - username => 'Username', - ); - foreach my $item ('approve','email','username') { - $output .= ''; - } - $output .= ''; - foreach my $item ('approve','email','username') { - $output .= ''."\n"; + $datatable .= &captcha_choice('cancreate',$createsettings,$$rowtotal); } - $output .= "
'.$headers{$item}.'
'; - my (%choices,@options,$hashref,$defoption,$name,$onclick,$hascustom); - if ($item eq 'approve') { - %choices = &Apache::lonlocal::texthash ( - automatic => 'Automatically approved', - approval => 'Queued for approval', - ); - @options = ('automatic','approval'); - $hashref = $processing; - $defoption = 'automatic'; - $name = 'cancreate_emailprocess_'.$type; - } elsif ($item eq 'email') { - %choices = &Apache::lonlocal::texthash ( - any => 'Any e-mail', - inst => 'Institutional only', - noninst => 'Non-institutional only', - custom => 'Custom restrictions', - ); - @options = ('any','inst','noninst'); - my $showcustom; - if (ref($emailrules) eq 'HASH') { - if (keys(%{$emailrules}) > 0) { - push(@options,'custom'); - $showcustom = 'cancreate_emailrule'; - if (ref($settings) eq 'HASH') { - if (ref($settings->{'email_rule'}) eq 'ARRAY') { - foreach my $rule (@{$settings->{'email_rule'}}) { - if (exists($emailrules->{$rule})) { - $hascustom ++; - } - } - } elsif (ref($settings->{'email_rule'}) eq 'HASH') { - if (ref($settings->{'email_rule'}{$type}) eq 'ARRAY') { - foreach my $rule (@{$settings->{'email_rule'}{$type}}) { - if (exists($emailrules->{$rule})) { - $hascustom ++; - } - } - } - } - } - } + $numinrow,$$rowtotal,$usertypes,$infofields,$infotitles); + $$rowtotal ++; } - $onclick = ' onclick="toggleEmailOptions(this.form,'."'cancreate_emailoptions','$showcustom',". - "'cancreate_emaildomain','$type'".');"'; - $hashref = $emailoptions; - $defoption = 'any'; - $name = 'cancreate_emailoptions_'.$type; - } elsif ($item eq 'username') { - %choices = &Apache::lonlocal::texthash ( - all => 'Same as e-mail', - first => 'Omit @domain', - free => 'Free to choose', - ); - @options = ('all','first','free'); - $hashref = $emailverified; - $defoption = 'all'; - $name = 'cancreate_usernameoptions_'.$type; } - foreach my $option (@options) { - my $checked; - if (ref($hashref) eq 'HASH') { - if ($type eq '') { - if (!exists($hashref->{'default'})) { - if ($option eq $defoption) { - $checked = ' checked="checked"'; - } - } else { - if ($hashref->{'default'} eq $option) { - $checked = ' checked="checked"'; - } - } - } else { - if (!exists($hashref->{$type})) { - if ($option eq $defoption) { - $checked = ' checked="checked"'; - } - } else { - if ($hashref->{$type} eq $option) { - $checked = ' checked="checked"'; - } - } - } - } elsif (($item eq 'email') && ($hascustom)) { - if ($option eq 'custom') { - $checked = ' checked="checked"'; - } - } elsif ($option eq $defoption) { - $checked = ' checked="checked"'; - } - $output .= '
'; - if ($item eq 'email') { - if ($option eq 'custom') { - my $id = 'cancreate_emailrule_'.$type; - my $display = 'none'; - if ($checked) { - $display = 'inline'; - } - my $numinrow = 2; - $output .= '
'. - ''.&mt('Disallow').''. - &user_formats_row('email',$settings,$emailrules, - $emailruleorder,$numinrow,'',$type); - '
'; - } elsif (($option eq 'inst') || ($option eq 'noninst')) { - my %text = &Apache::lonlocal::texthash ( - inst => 'must end:', - noninst => 'cannot end:', - ); - my $value; - if (ref($emaildomain) eq 'HASH') { - if (ref($emaildomain->{$type}) eq 'HASH') { - $value = $emaildomain->{$type}->{$option}; - } - } - if ($value eq '') { - $value = '@'.$intdom; - } - my $condition = 'cancreate_emaildomain_'.$option.'_'.$type; - my $display = 'none'; - if ($checked) { - $display = 'inline'; - } - $output .= '
'. - ''.$text{$option}.' '. - ''. - '
'; - } + my ($emailrules,$emailruleorder) = + &Apache::lonnet::inst_userrules($dom,'email'); + if (ref($emailrules) eq 'HASH') { + if (keys(%{$emailrules}) > 0) { + $datatable .= &user_formats_row('email',$settings,$emailrules, + $emailruleorder,$numinrow,$$rowtotal); + $$rowtotal ++; } } - $output .= '
\n"; - return $output; + return $datatable; } sub captcha_choice { - my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_; - my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext, - $vertext,$currver); + my ($context,$settings,$itemcount) = @_; + my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext); my %lt = &captcha_phrases(); $keyentry = 'hidden'; if ($context eq 'cancreate') { @@ -5590,11 +4108,6 @@ sub captcha_choice { $pubtext = $lt{'pub'}; $privtext = $lt{'priv'}; $keyentry = 'text'; - $vertext = $lt{'ver'}; - $currver = $settings->{'recaptchaversion'}; - if ($currver ne '2') { - $currver = 1; - } } if (ref($settings->{'recaptchakeys'}) eq 'HASH') { $currpub = $settings->{'recaptchakeys'}{'public'}; @@ -5603,20 +4116,7 @@ sub captcha_choice { } else { $checked{'original'} = ' checked="checked"'; } - my $css_class; - if ($itemcount%2) { - $css_class = 'LC_odd_row'; - } - if ($customcss) { - $css_class .= " $customcss"; - } - $css_class =~ s/^\s+//; - if ($css_class) { - $css_class = ' class="'.$css_class.'"'; - } - if ($rowstyle) { - $css_class .= ' style="'.$rowstyle.'"'; - } + my $css_class = $itemcount%2?' class="LC_odd_row"':''; my $output = ''. ''.$rowname.''."\n". ''."\n". - '
'."\n"; @@ -5635,35 +4135,35 @@ sub captcha_choice { # specified for use with the key should be broad enough to accommodate all servers in the LON-CAPA domain. # $output .= '
'."\n". + '
'."\n". ''.$pubtext.' '."\n". '
'."\n". ''.$privtext.' '."\n". '
'. - ''.$vertext.' '."\n". - '
'. - '
'."\n". + $currpriv.'" size="40" />'."\n". ''; return $output; } sub user_formats_row { - my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount,$status) = @_; + my ($type,$settings,$rules,$ruleorder,$numinrow,$rowcount) = @_; my $output; my %text = ( 'username' => 'new usernames', 'id' => 'IDs', + 'email' => 'self-created accounts (e-mail)', ); - unless ($type eq 'email') { - my $css_class = $rowcount%2?' class="LC_odd_row"':''; - $output = ''. - ''. - &mt("Format rules to check for $text{$type}: "). - ''; + my $css_class = $rowcount%2?' class="LC_odd_row"':''; + $output = ''. + ''. + ''; - } + $output .= '
'; + if ($type eq 'email') { + $output .= &mt("Formats disallowed for $text{$type}: "); + } else { + $output .= &mt("Format rules to check for $text{$type}: "); } + $output .= ''; my $rem; if (ref($ruleorder) eq 'ARRAY') { for (my $i=0; $i<@{$ruleorder}; $i++) { @@ -5681,41 +4181,25 @@ sub user_formats_row { if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}})) { $check = ' checked="checked" '; } - } elsif ((ref($settings->{$type.'_rule'}) eq 'HASH') && ($status ne '')) { - if (ref($settings->{$type.'_rule'}->{$status}) eq 'ARRAY') { - if (grep(/^\Q$ruleorder->[$i]\E$/,@{$settings->{$type.'_rule'}->{$status}})) { - $check = ' checked="checked" '; - } - } } } - my $name = $type.'_rule'; - if ($type eq 'email') { - $name .= '_'.$status; - } $output .= ''; } } $rem = @{$ruleorder}%($numinrow); } - my $colsleft; - if ($rem) { - $colsleft = $numinrow - $rem; - } + my $colsleft = $numinrow - $rem; if ($colsleft > 1 ) { $output .= ''; } elsif ($colsleft == 1) { $output .= ''; } - $output .= '
'. ''. '  
'; - unless ($type eq 'email') { - $output .= '
'; return $output; } @@ -5790,200 +4274,70 @@ sub print_usermodification { } sub print_defaults { - my ($position,$dom,$settings,$rowtotal) = @_; - my $rownum = 0; - my ($datatable,$css_class,$titles); - unless ($position eq 'bottom') { - $titles = &defaults_titles($dom); - } - if ($position eq 'top') { - my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', - 'datelocale_def','portal_def'); - my %defaults; - if (ref($settings) eq 'HASH') { - %defaults = %{$settings}; - } else { - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - foreach my $item (@items) { - $defaults{$item} = $domdefaults{$item}; - } - } + my ($dom,$settings,$rowtotal) = @_; + my @items = ('auth_def','auth_arg_def','lang_def','timezone_def', + 'datelocale_def','portal_def'); + my %defaults; + if (ref($settings) eq 'HASH') { + %defaults = %{$settings}; + } else { + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); foreach my $item (@items) { - if ($rownum%2) { - $css_class = ''; - } else { - $css_class = ' class="LC_odd_row" '; - } - $datatable .= ''. - ''.$titles->{$item}. - ''; - if ($item eq 'auth_def') { - my @authtypes = ('internal','krb4','krb5','localauth'); - my %shortauth = ( - internal => 'int', - krb4 => 'krb4', - krb5 => 'krb5', - localauth => 'loc' - ); - my %authnames = &authtype_names(); - foreach my $auth (@authtypes) { - my $checked = ' '; - if ($defaults{$item} eq $auth) { - $checked = ' checked="checked" '; - } - $datatable .= '  '; - } - } elsif ($item eq 'timezone_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty); - } elsif ($item eq 'datelocale_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty); - } elsif ($item eq 'lang_def') { - my $includeempty = 1; - $datatable .= &Apache::loncommon::select_language($item,$defaults{$item},$includeempty); - } else { - my $size; - if ($item eq 'portal_def') { - $size = ' size="25"'; - } - $datatable .= ''; - } - $datatable .= ''; - $rownum ++; + $defaults{$item} = $domdefaults{$item}; } - } elsif ($position eq 'middle') { - my @items = ('intauth_cost','intauth_check','intauth_switch'); - my %defaults; - if (ref($settings) eq 'HASH') { - %defaults = %{$settings}; - if ($defaults{'intauth_cost'} !~ /^\d+$/) { - $defaults{'intauth_cost'} = 10; - } - if ($defaults{'intauth_check'} !~ /^(0|1|2)$/) { - $defaults{'intauth_check'} = 0; - } - if ($defaults{'intauth_switch'} !~ /^(0|1|2)$/) { - $defaults{'intauth_switch'} = 0; - } + } + my $titles = &defaults_titles($dom); + my $rownum = 0; + my ($datatable,$css_class); + foreach my $item (@items) { + if ($rownum%2) { + $css_class = ''; } else { - %defaults = ( - 'intauth_cost' => 10, - 'intauth_check' => 0, - 'intauth_switch' => 0, - ); + $css_class = ' class="LC_odd_row" '; } - foreach my $item (@items) { - if ($rownum%2) { - $css_class = ''; - } else { - $css_class = ' class="LC_odd_row" '; - } - $datatable .= ''. - ''.$titles->{$item}. - ''; - if ($item eq 'intauth_switch') { - my @options = (0,1,2); - my %optiondesc = &Apache::lonlocal::texthash ( - 0 => 'No', - 1 => 'Yes', - 2 => 'Yes, and copy existing passwd file to passwd.bak file', - ); - $datatable .= ''; - foreach my $option (@options) { - my $checked = ' '; - if ($defaults{$item} eq $option) { - $checked = ' checked="checked"'; - } - $datatable .= ''; - } - $datatable .= '
'. - '
'; - } elsif ($item eq 'intauth_check') { - my @options = (0,1,2); - my %optiondesc = &Apache::lonlocal::texthash ( - 0 => 'No', - 1 => 'Yes, allow login then update passwd file using default cost (if higher)', - 2 => 'Yes, disallow login if stored cost is less than domain default', - ); - $datatable .= ''; - foreach my $option (@options) { - my $checked = ' '; - my $onclick; - if ($defaults{$item} eq $option) { - $checked = ' checked="checked"'; - } - if ($option == 2) { - $onclick = ' onclick="javascript:warnIntAuth(this);"'; - } - $datatable .= ''; - } - $datatable .= '
'. - '
'; - } else { - $datatable .= ''; + $datatable .= ''. + ''.$titles->{$item}. + ''; + if ($item eq 'auth_def') { + my @authtypes = ('internal','krb4','krb5','localauth'); + my %shortauth = ( + internal => 'int', + krb4 => 'krb4', + krb5 => 'krb5', + localauth => 'loc' + ); + my %authnames = &authtype_names(); + foreach my $auth (@authtypes) { + my $checked = ' '; + if ($defaults{$item} eq $auth) { + $checked = ' checked="checked" '; + } + $datatable .= '  '; } - $datatable .= ''; - $rownum ++; - } - } else { - my %defaults; - if (ref($settings) eq 'HASH') { - if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { - my $maxnum = @{$settings->{'inststatusorder'}}; - for (my $i=0; $i<$maxnum; $i++) { - $css_class = $rownum%2?' class="LC_odd_row"':''; - my $item = $settings->{'inststatusorder'}->[$i]; - my $title = $settings->{'inststatustypes'}->{$item}; - my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'$item'".');"'; - $datatable .= ''. - ''. - ' '.&mt('Internal ID:').' '.$item.' '. - ''. - &mt('delete').''. - ''.&mt('Name displayed:'). - ''. - ''; - } - $css_class = $rownum%2?' class="LC_odd_row"':''; - my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'addinststatus_pos'".');"'; - $datatable .= ''. - ' '.&mt('Internal ID:'). - ''. - ' '.&mt('(new)'). - ''. - &mt('Name displayed:'). - ''. - ''."\n"; - $rownum ++; + } elsif ($item eq 'timezone_def') { + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_timezone($item,$defaults{$item},undef,$includeempty); + } elsif ($item eq 'datelocale_def') { + my $includeempty = 1; + $datatable .= &Apache::loncommon::select_datelocale($item,$defaults{$item},undef,$includeempty); + } elsif ($item eq 'lang_def') { + my %langchoices = &get_languages_hash(); + $langchoices{''} = 'No language preference'; + %langchoices = &Apache::lonlocal::texthash(%langchoices); + $datatable .= &Apache::loncommon::select_form($defaults{$item},$item, + \%langchoices); + } else { + my $size; + if ($item eq 'portal_def') { + $size = ' size="25"'; } + $datatable .= ''; } + $datatable .= ''; + $rownum ++; } $$rowtotal += $rownum; return $datatable; @@ -6009,9 +4363,6 @@ sub defaults_titles { 'timezone_def' => 'Default timezone', 'datelocale_def' => 'Default locale for dates', 'portal_def' => 'Portal/Default URL', - 'intauth_cost' => 'Encryption cost for bcrypt (positive integer)', - 'intauth_check' => 'Check bcrypt cost if authenticated', - 'intauth_switch' => 'Existing crypt-based switched to bcrypt on authentication', ); if ($dom) { my $uprimary_id = &Apache::lonnet::domain($dom,'primary'); @@ -6026,58 +4377,6 @@ sub defaults_titles { return (\%titles); } -sub print_scantron { - my ($r,$position,$dom,$confname,$settings,$rowtotal) = @_; - if ($position eq 'top') { - return &print_scantronformat($r,$dom,$confname,$settings,\$rowtotal); - } else { - return &print_scantronconfig($dom,$settings,\$rowtotal); - } -} - -sub scantron_javascript { - return <<"ENDSCRIPT"; - - - -ENDSCRIPT - -} - sub print_scantronformat { my ($r,$dom,$confname,$settings,$rowtotal) = @_; my $itemcount = 1; @@ -6104,8 +4403,8 @@ sub print_scantronformat { if ($configuserok eq 'ok') { if ($author_ok eq 'ok') { my %legacyfile = ( - default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab', - custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab', + default => $Apache::lonnet::perlvar{'lonTabDir'}.'/default_scantronformat.tab', + custom => $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab', ); my %md5chk; foreach my $type (keys(%legacyfile)) { @@ -6114,7 +4413,7 @@ sub print_scantronformat { } if ($md5chk{'default'} ne $md5chk{'custom'}) { foreach my $type (keys(%legacyfile)) { - ($scantronurls{$type},my $error) = + ($scantronurls{$type},my $error) = &legacy_scantronformat($r,$dom,$confname, $type,$legacyfile{$type}, $scantronurls{$type}, @@ -6125,13 +4424,13 @@ sub print_scantronformat { } if (keys(%error) == 0) { $is_custom = 1; - $confhash{'scantron'}{'scantronformat'} = + $confhash{'scantron'}{'scantronformat'} = $scantronurls{'custom'}; - my $putresult = + my $putresult = &Apache::lonnet::put_dom('configuration', \%confhash,$dom); if ($putresult ne 'ok') { - $error{'custom'} = + $error{'custom'} = ''. &mt('An error occurred updating the domain configuration: [_1]',$putresult).''; } @@ -6251,176 +4550,10 @@ sub legacy_scantronformat { return ($url,$error); } -sub print_scantronconfig { - my ($dom,$settings,$rowtotal) = @_; - my $itemcount = 2; - my $is_checked = ' checked="checked"'; - my %optionson = ( - hdr => ' checked="checked"', - pad => ' checked="checked"', - rem => ' checked="checked"', - ); - my %optionsoff = ( - hdr => '', - pad => '', - rem => '', - ); - my $currcsvsty = 'none'; - my ($datatable,%csvfields,%checked,%onclick,%csvoptions); - my @fields = &scantroncsv_fields(); - my %titles = &scantronconfig_titles(); - if (ref($settings) eq 'HASH') { - if (ref($settings->{config}) eq 'HASH') { - if ($settings->{config}->{dat}) { - $checked{'dat'} = $is_checked; - } - if (ref($settings->{config}->{csv}) eq 'HASH') { - if (ref($settings->{config}->{csv}->{fields}) eq 'HASH') { - %csvfields = %{$settings->{config}->{csv}->{fields}}; - if (keys(%csvfields) > 0) { - $checked{'csv'} = $is_checked; - $currcsvsty = 'block'; - } - } - if (ref($settings->{config}->{csv}->{options}) eq 'HASH') { - %csvoptions = %{$settings->{config}->{csv}->{options}}; - foreach my $option (keys(%optionson)) { - unless ($csvoptions{$option}) { - $optionsoff{$option} = $optionson{$option}; - $optionson{$option} = ''; - } - } - } - } - } else { - $checked{'dat'} = $is_checked; - } - } else { - $checked{'dat'} = $is_checked; - } - $onclick{'csv'} = ' onclick="toggleScantron(this.form);"'; - my $css_class = $itemcount%2? ' class="LC_odd_row"':''; - $datatable = ''.&mt('Supported formats').''. - ''; - foreach my $item ('dat','csv') { - my $id; - if ($item eq 'csv') { - $id = 'id="scantronconfcsv" '; - } - $datatable .= ''.(' 'x3); - if ($item eq 'csv') { - $datatable .= '
'. - ''.&mt('CSV Column Mapping').''. - ''."\n"; - foreach my $col (@fields) { - my $selnone; - if ($csvfields{$col} eq '') { - $selnone = ' selected="selected"'; - } - $datatable .= ''. - ''; - } - $datatable .= '
'.&mt('Field').''.&mt('Location').'
'.$titles{$col}.'
'. - '
'. - ''.&mt('CSV Options').''; - foreach my $option ('hdr','pad','rem') { - $datatable .= ''.$titles{$option}.':'. - ''.(' 'x2)."\n". - '
'; - } - $datatable .= '
'; - $itemcount ++; - } - } - $datatable .= ''; - $$rowtotal ++; - return $datatable; -} - -sub scantronconfig_titles { - return &Apache::lonlocal::texthash( - dat => 'Standard format (.dat)', - csv => 'Comma separated values (.csv)', - hdr => 'Remove first line in file (contains column titles)', - pad => 'Prepend 0s to PaperID', - rem => 'Remove leading spaces (except Question Response columns)', - CODE => 'CODE', - ID => 'Student ID', - PaperID => 'Paper ID', - FirstName => 'First Name', - LastName => 'Last Name', - FirstQuestion => 'First Question Response', - Section => 'Section', - ); -} - -sub scantroncsv_fields { - return ('PaperID','LastName','FirstName','ID','Section','CODE','FirstQuestion'); -} - sub print_coursecategories { my ($position,$dom,$hdritem,$settings,$rowtotal) = @_; my $datatable; if ($position eq 'top') { - my (%checked); - my @catitems = ('unauth','auth'); - my @cattypes = ('std','domonly','codesrch','none'); - $checked{'unauth'} = 'std'; - $checked{'auth'} = 'std'; - if (ref($settings) eq 'HASH') { - foreach my $type (@cattypes) { - if ($type eq $settings->{'unauth'}) { - $checked{'unauth'} = $type; - } - if ($type eq $settings->{'auth'}) { - $checked{'auth'} = $type; - } - } - } - my %lt = &Apache::lonlocal::texthash ( - unauth => 'Catalog type for unauthenticated users', - auth => 'Catalog type for authenticated users', - none => 'No catalog', - std => 'Standard catalog', - domonly => 'Domain-only catalog', - codesrch => "Code search form", - ); - my $itemcount = 0; - foreach my $item (@catitems) { - my $css_class = $itemcount%2? ' class="LC_odd_row"':''; - $datatable .= ''. - ''.$lt{$item}.''. - ''; - foreach my $type (@cattypes) { - my $ischecked; - if ($checked{$item} eq $type) { - $ischecked=' checked="checked"'; - } - $datatable .= ' '; - } - $datatable .= ''; - $itemcount ++; - } - $$rowtotal += $itemcount; - } elsif ($position eq 'middle') { my $toggle_cats_crs = ' '; my $toggle_cats_dom = ' checked="checked" '; my $can_cat_crs = ' '; @@ -6627,7 +4760,7 @@ sub print_coursecategories { $datatable .= &initialize_categories($itemcount); } } else { - $datatable .= ''.$hdritem->{'header'}->[1]->{'col2'}.'' + $datatable .= ''.$hdritem->{'header'}->[0]->{'col2'}.'' .&initialize_categories($itemcount); } $$rowtotal += $itemcount; @@ -6675,7 +4808,7 @@ sub print_serverstatuses { ''. ''. - ''."\n"; + ''."\n"; } $$rowtotal += $rownum; return $datatable; @@ -6685,102 +4818,7 @@ 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'); -} - -sub defaults_javascript { - my ($settings) = @_; - my $intauthcheck = &mt('Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.'); - my $intauthcost = &mt('Warning: bcrypt encryption cost for internal authentication must be an integer.'); - &js_escape(\$intauthcheck); - &js_escape(\$intauthcost); - my $intauthjs = <<"ENDSCRIPT"; - -function warnIntAuth(field) { - if (field.name == 'intauth_check') { - if (field.value == '2') { - alert('$intauthcheck'); - } - } - if (field.name == 'intauth_cost') { - field.value.replace(/\s/g,''); - if (field.value != '') { - var regexdigit=/^\\d+\$/; - if (!regexdigit.test(field.value)) { - alert('$intauthcost'); - } - } - } - return; -} - -ENDSCRIPT - - if (ref($settings) ne 'HASH') { - return &Apache::lonhtmlcommon::scripttag($intauthjs); - } - if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { - my $maxnum = scalar(@{$settings->{'inststatusorder'}}); - if ($maxnum eq '') { - $maxnum = 0; - } - $maxnum ++; - my $jstext = ' var inststatuses = Array('."'".join("','",@{$settings->{'inststatusorder'}})."'".');'; - return <<"ENDSCRIPT"; - - -ENDSCRIPT - } else { - return &Apache::lonhtmlcommon::scripttag($intauthjs); - } + 'uniquecodes','diskusage'); } sub coursecategories_javascript { @@ -6805,12 +4843,9 @@ sub coursecategories_javascript { $jstext = ' var categories = Array(1);'."\n". ' categories[0] = Array("instcode_pos");'."\n"; } - my $instcode_reserved = &mt('The name: [_1] is a reserved category.','"instcode"'); - my $communities_reserved = &mt('The name: [_1] is a reserved category.','"communities"'); - my $choose_again = "\n".&mt('Please use a different name for the new top level category.'); - &js_escape(\$instcode_reserved); - &js_escape(\$communities_reserved); - &js_escape(\$choose_again); + my $instcode_reserved = &mt('The name: "instcode" is a reserved category'); + my $communities_reserved = &mt('The name: "communities" is a reserved category'); + my $choose_again = '\\n'.&mt('Please use a different name for the new top level category'); $output = <<"ENDSCRIPT";