--- loncom/interface/domainprefs.pm 2017/08/16 01:26:24 1.160.6.84.4.2 +++ loncom/interface/domainprefs.pm 2019/02/15 21:18:32 1.160.6.90 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set domain-wide configuration settings # -# $Id: domainprefs.pm,v 1.160.6.84.4.2 2017/08/16 01:26:24 raeburn Exp $ +# $Id: domainprefs.pm,v 1.160.6.90 2019/02/15 21:18:32 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -265,7 +265,7 @@ sub handler { {col1 => 'Internal Authentication', col2 => 'Value'}, {col1 => 'Institutional user types', - col2 => 'Name displayed'}], + col2 => 'Assignable to e-mail usernames'}], print => \&print_defaults, modify => \&modify_defaults, }, @@ -347,7 +347,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, @@ -528,9 +528,6 @@ $javascript_validations $coursebrowserjs END } - if (grep(/^selfcreation$/,@actions)) { - $js .= &selfcreate_javascript(); - } if (grep(/^contacts$/,@actions)) { $js .= &contacts_javascript(); } @@ -627,7 +624,7 @@ sub process_changes { } 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') { @@ -1281,7 +1278,7 @@ sub print_login { } else { $datatable .= ''; } - $datatable .= ''; + $datatable .= ''; } $datatable .= ''; } @@ -1441,7 +1438,7 @@ sub display_color_options { my $datatable = ''. ''.$choices->{'font'}.''; if (!$is_custom->{'font'}) { - $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.''; + $datatable .= ''.&mt('Default in use:').' '.$defaults->{'font'}.''; } else { $datatable .= ' '; } @@ -1450,12 +1447,12 @@ sub display_color_options { $datatable .= ''. ' '. - ' '; + ' '; unless ($role eq 'login') { $datatable .= ''. ''.$choices->{'fontmenu'}.''; if (!$is_custom->{'fontmenu'}) { - $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.''; + $datatable .= ''.&mt('Default in use:').' '.$defaults->{'fontmenu'}.''; } else { $datatable .= ' '; } @@ -1465,7 +1462,7 @@ sub display_color_options { ' '. - ' '; + ' '; } my $switchserver = &check_switchserver($dom,$confname); foreach my $img (@{$images}) { @@ -1524,7 +1521,8 @@ sub display_color_options { if ($fullwidth ne '' && $fullheight ne '') { if ($fullwidth > $width && $fullheight > $height) { my $size = $width.'x'.$height; - system("convert -sample $size $input $output"); + my @args = ('convert','-sample',$size,$input,$output); + system({$args[0]} @args); $showfile = "/$imgdir/tn-".$filename; } } @@ -1582,7 +1580,7 @@ sub display_color_options { my $bgs_def; foreach my $item (@{$bgs}) { if (!$is_custom->{$item}) { - $bgs_def .= ''.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.''; + $bgs_def .= ''.$choices->{$item}.'    
'.$defaults->{'bgs'}{$item}.''; } } if ($bgs_def) { @@ -1610,7 +1608,7 @@ sub display_color_options { my $links_def; foreach my $item (@{$links}) { if (!$is_custom->{$item}) { - $links_def .= ''.$choices->{$item}.'
'.$defaults->{'links'}{$item}.''; + $links_def .= ''.$choices->{$item}.'
'.$defaults->{'links'}{$item}.''; } } if ($links_def) { @@ -1696,17 +1694,15 @@ sub image_changes { my ($is_custom,$alt_text,$img_import,$showfile,$fullsize,$role,$img,$imgfile,$logincolors) = @_; my $output; if ($img eq 'login') { - # suppress image for Log-in header + $output = ''.$logincolors; # 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 eq 'login') { # suppress image for Log-in header - $output .= ''.$logincolors; - } else { + if ($img ne 'login') { if ($img_import) { $output .= ''; } @@ -2150,7 +2146,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') { @@ -2162,19 +2158,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'); @@ -2329,7 +2313,7 @@ sub print_textbookcourses { $datatable .= ''; } $datatable .= ' '."\n". - ''.&mt('Add').''."\n". + ''.&mt('Add').''."\n". ''. ''.&mt('Subject:').' '."\n". (' 'x2). @@ -2346,13 +2330,13 @@ sub print_textbookcourses { } else { $datatable .= ''; } + $datatable .= ''."\n"; } - $datatable .= ''."\n". - ''.&mt('LON-CAPA course:').' '. + $datatable .= ''.&mt('LON-CAPA course:').' '. &Apache::loncommon::select_dom_form($env{'request.role.domain'},$type.'_addbook_cdom'). ''. &Apache::loncommon::selectcourse_link - ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'); + ('display',$type.'_addbook_cnum',$type.'_addbook_cdom',undef,undef,undef,'Course'). ''."\n". ''."\n"; $itemcount ++; @@ -2531,7 +2515,7 @@ sub print_autoenroll { ''.&mt('Failsafe for no drops when institutional data missing').''. ''. ''; + ' value="'.$failsafe.'" size="4" />'; $$rowtotal += 4; return $datatable; } @@ -2580,7 +2564,7 @@ sub print_autoupdate { my $locknamesettings; $datatable .= &insttypes_row($settings,$types,$usertypes, $dom,$numinrow,$othertitle, - 'lockablenames',$rowtotal); + 'lockablenames'); $$rowtotal ++; } else { my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); @@ -2723,8 +2707,7 @@ sub print_directorysrch { if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { $datatable .= &insttypes_row($settings,$types,$usertypes,$dom, - $numinrow,$othertitle,'cansearch', - $rowtotal); + $numinrow,$othertitle,'cansearch'); $cansrchrow = 1; } } @@ -2959,7 +2942,7 @@ sub print_contacts { 'value="'.$bccemails{$type}.'" />'. '
'.&mt('Optional added text').''. &mt('Text automatically added to e-mail:').' '. - '
'. + '
'. ''.&mt('Location:').' '. ''. (' 'x2). @@ -3020,7 +3003,7 @@ sub print_contacts { if ($currfield{$field} eq 'no') { $display = ' style="display:none"'; } - $datatable .= ''. + $datatable .= ''. ''.&mt('Maximum size for upload (MB)').''. ''; } @@ -3117,7 +3100,7 @@ sub print_helpsettings { @jsarray = ('bystatus'); } } - my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh'.'da']); + my %domhelpdesk = &Apache::lonnet::get_active_domroles($dom,['dh','da']); if (keys(%domhelpdesk)) { push(@accesstypes,('inc','exc')); push(@jsarray,('notinc','notexc')); @@ -3226,7 +3209,9 @@ sub print_helpsettings { \@templateroles,$newcust). &Apache::lonuserutils::custom_role_table('Course',\%full,\%levels, \%levelscurrent,$newcust). - '
'; + ''. + &helpsettings_javascript(\@roles_by_num,$maxnum,$hiddenstr,$formname). + ''; $count ++; $$rowtotal += $count; } @@ -3507,6 +3492,7 @@ sub print_coursedefaults { coursecredits => 'Credits can be specified for courses', uselcmath => 'Math preview uses LON-CAPA previewer (javascript) in place of DragMath (Java)', usejsme => 'Molecule editor uses JSME (HTML5) in place of JME (Java)', + texengine => 'Default method to display mathematics', postsubmit => 'Disable submit button/keypress following student submission', canclone => "People who may clone a course (besides course's owner and coordinators)", mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', @@ -3524,8 +3510,36 @@ sub print_coursedefaults { 'canclone' => 'none', ); @toggles = ('uselcmath','usejsme'); + my $deftex = $Apache::lonnet::deftex; + if (ref($settings) eq 'HASH') { + if ($settings->{'texengine'}) { + if ($settings->{'texengine'} =~ /^(MathJax|mimetex|tth)$/) { + $deftex = $settings->{'texengine'}; + } + } + } + $css_class = $itemcount%2?' class="LC_odd_row"':''; + my $mathdisp = ''. + ''.$choices{'texengine'}. + ''. + ''."\n"; + $itemcount ++; ($datatable,$itemcount) = &radiobutton_prefs($settings,\@toggles,\%defaultchecked, \%choices,$itemcount); + $datatable = $mathdisp.$datatable; $css_class = $itemcount%2?' class="LC_odd_row"':''; $datatable .= ''. @@ -3943,7 +3957,7 @@ sub print_validation_rows { '
'; } } elsif ($item eq 'markup') { - $datatable .= ''; } @@ -3965,7 +3979,7 @@ sub print_validation_rows { my ($numdc,$dctable,$rows) = &active_dc_picker($dom,$numinrow,'radio', 'validationdc',%currhash); my $css_class = $itemcount%2 ? ' class="LC_odd_row"' : ''; - $datatable .= ''; + $datatable .= ''; if ($numdc > 1) { $datatable .= &mt('Course creation processed as: (choose Dom. Coord.)'); } else { @@ -5006,8 +5020,7 @@ sub print_usercreation { sub print_selfcreation { my ($position,$dom,$settings,$rowtotal) = @_; - my (@selfcreate,$createsettings,$processing,$emailoptions,$emailverified, - $emaildomain,$datatable); + my (@selfcreate,$createsettings,$processing,$datatable); if (ref($settings) eq 'HASH') { if (ref($settings->{'cancreate'}) eq 'HASH') { $createsettings = $settings->{'cancreate'}; @@ -5024,15 +5037,6 @@ sub print_selfcreation { 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'}; - } } } } @@ -5054,7 +5058,7 @@ sub print_selfcreation { ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, \%choices,$itemcount,$onclick); $$rowtotal += $itemcount; - + if (ref($usertypes) eq 'HASH') { if (keys(%{$usertypes}) > 0) { $datatable .= &insttypes_row($createsettings,$types,$usertypes, @@ -5072,7 +5076,7 @@ sub print_selfcreation { $datatable .= ''. ''.&mt('Mapping of Shibboleth environment variable names to user data fields (SSO auth)').''. ''."\n". - '\n". - '\n"; + $$rowtotal ++; return $output; } sub captcha_choice { - my ($context,$settings,$itemcount,$customcss,$rowstyle) = @_; + my ($context,$settings,$itemcount) = @_; my ($keyentry,$currpub,$currpriv,%checked,$rowname,$pubtext,$privtext, $vertext,$currver); my %lt = &captcha_phrases(); @@ -5548,20 +5281,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 = ''. '
'."\n"; + ''."\n"; for (my $i=0; $i<@fields; $i++) { $rem = $i%($numperrow); if ($rem == 0) { @@ -5123,399 +5127,128 @@ sub print_selfcreation { } } else { my %choices = &Apache::lonlocal::texthash ( - 'cancreate_email' => 'Non-institutional username (via e-mail verification)', + cancreate_email => 'E-mail address as username', ); 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 $itemcount = 0; 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 $onclick = "toggleDisplay(this.form,'emailoptions');"; + my $additional = '
'; 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'); + my (@ordered,%usertypeshash); + if (ref($domdefaults{'inststatusguest'}) eq 'ARRAY') { + @ordered = @{$domdefaults{'inststatusguest'}}; + } + if (@ordered) { + unless (grep(/^default$/,@ordered)) { + push(@ordered,'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 ++; - } + $additional .= '
'; + foreach my $status (@ordered) { + $additional .= ''; + } + $additional .= ''; + foreach my $status (@ordered) { + $additional .= ''; } + $additional .= '
'.$usertypeshash{$status}.'
'.&email_as_username($rowtotal,$processing,$status).'
'; } 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 ++; + $additional .= &email_as_username($rowtotal,$processing); } + $additional .= ''."\n"; + + ($datatable,$itemcount) = &radiobutton_prefs(\%radiohash,\@toggles,\%defaultchecked, + \%choices,$$rowtotal,$onclick,$additional); + $$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; - } - $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); + foreach my $status (@ordered) { + $datatable .= &modifiable_userdata_row('cancreate','emailusername_'.$status,$settings, + $numinrow,$$rowtotal,\%usertypeshash,$infofields,$infotitles); + $$rowtotal ++; } - } - 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'. - ''; - 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"; } - $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 ++; - } - } - } - } + if ($processing->{'default'} eq $option) { + $checked = ' checked="checked"'; } } - } - $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($processing->{$type})) { + if ($option eq 'automatic') { + $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'; + if ($processing->{$type} eq $option) { + $checked = ' checked="checked"'; } - $output .= '
'. - ''.$text{$option}.' '. - ''. - '
'; } } + } elsif ($option eq 'automatic') { + $checked = ' checked="checked"'; + } + my $name = 'cancreate_emailprocess'; + if (($type ne '') && ($type ne 'default')) { + $name .= '_'.$type; + } + $output .= ''; + if ($type eq '') { + $output .= ' '; + } else { + $output .= '
'; } - $output .= '
'.$rowname.''."\n". ''."\n". - ''. - ''; return $output; } @@ -5856,7 +5564,7 @@ sub print_defaults { 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 .= '
'."\n"; @@ -5580,7 +5300,7 @@ 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". @@ -5596,19 +5316,23 @@ sub captcha_choice { } 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++) { @@ -5626,41 +5350,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 .= '
'; + $datatable .= '
'; foreach my $option (@options) { my $checked = ' '; my $onclick; @@ -5882,12 +5590,17 @@ sub print_defaults { } else { my %defaults; if (ref($settings) eq 'HASH') { - if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH')) { + if ((ref($settings->{'inststatusorder'}) eq 'ARRAY') && (ref($settings->{'inststatustypes'}) eq 'HASH') && + (ref($settings->{'inststatusguest'}) eq 'ARRAY')) { 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 $guestok; + if (grep(/^\Q$item\E$/,@{$settings->{'inststatusguest'}})) { + $guestok = 1; + } my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'$item'".');"'; $datatable .= ''. ''. - ''; + ''. + ''; } $css_class = $rownum%2?' class="LC_odd_row"':''; my $chgstr = ' onchange="javascript:reorderTypes(this.form,'."'addinststatus_pos'".');"'; @@ -5922,9 +5646,14 @@ sub print_defaults { $datatable .= ' '.&mt('Internal ID:'). ''. ' '.&mt('(new)'). - ''. + ''; ''."\n"; $rownum ++; } @@ -6186,7 +5915,7 @@ sub print_coursecategories { ''.$lt{$type}.' '; } - $datatable .= ''; + $datatable .= ''; $itemcount ++; } $$rowtotal += $itemcount; @@ -6397,7 +6126,7 @@ sub print_coursecategories { $datatable .= &initialize_categories($itemcount); } } else { - $datatable .= '' + $datatable .= '' .&initialize_categories($itemcount); } $$rowtotal += $itemcount; @@ -6445,7 +6174,7 @@ sub print_serverstatuses { ''. ''. - ''."\n"; + ''."\n"; } $$rowtotal += $rownum; return $datatable; @@ -6670,7 +6399,7 @@ sub initialize_categories { my $select1 = ''; foreach my $default ('instcode','communities') { $css_class = $itemcount%2?' class="LC_odd_row"':''; - $chgstr = ' onchange="javascript:reorderCats(this.form,'."'',$default"."_pos','0'".');"'; + $chgstr = ' onchange="javascript:reorderCats(this.form,'."'','$default"."_pos','0'".');"'; if ($default eq 'communities') { $select1 = $select0; $select0 = ''; @@ -6695,8 +6424,9 @@ sub initialize_categories { .'' .'' .' ' - .&mt('Add category').''; + .&mt('Add category').'>'.&mt('Name:') + .' ' + .''; return $datatable; } @@ -6751,7 +6481,7 @@ sub build_category_rows { pop(@{$path}); } } else { - $text .= &mt('Add subcategory:').' '.&mt('Add subcategory:').''; + $text .= ''; } } } @@ -6783,14 +6513,13 @@ sub build_category_rows { } sub modifiable_userdata_row { - my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref, - $rowid,$customcss,$rowstyle) = @_; + my ($context,$item,$settings,$numinrow,$rowcount,$usertypes,$fieldsref,$titlesref) = @_; my ($role,$rolename,$statustype); $role = $item; if ($context eq 'cancreate') { - if ($item =~ /^(emailusername)_(.+)$/) { - $role = $1; - $statustype = $2; + if ($item =~ /^emailusername_(.+)$/) { + $statustype = $1; + $role = 'emailusername'; if (ref($usertypes) eq 'HASH') { if ($usertypes->{$statustype}) { $rolename = &mt('Data provided by [_1]',$usertypes->{$statustype}); @@ -6825,25 +6554,8 @@ sub modifiable_userdata_row { %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); } my $output; - my $css_class; - if ($rowcount%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.'"'; - } - if ($rowid) { - $rowid = ' id="'.$rowid.'"'; - } - - $output = ''. + my $css_class = $rowcount%2?' class="LC_odd_row"':''; + $output = ''. ''. ''; return $output; @@ -8062,14 +7755,14 @@ sub publishlogo { } else { my $source = $filepath.'/'.$file; my $logfile; - if (!open($logfile,">>$source".'.log')) { + if (!open($logfile,">>",$source.'.log')) { return (&mt('No write permission to Authoring Space')); } print $logfile "\n================= Publish ".localtime()." ================\n". $env{'user.name'}.':'.$env{'user.domain'}."\n"; # Save the file - if (!open(FH,'>'.$source)) { + if (!open(FH,">",$source)) { &Apache::lonnet::logthis('Failed to create '.$source); return (&mt('Failed to create file')); } @@ -8130,7 +7823,8 @@ $env{'user.name'}.':'.$env{'user.domain' if ($fullwidth ne '' && $fullheight ne '') { if ($fullwidth > $thumbwidth && $fullheight > $thumbheight) { my $thumbsize = $thumbwidth.'x'.$thumbheight; - system("convert -sample $thumbsize $inputfile $outfile"); + my @args = ('convert','-sample',$thumbsize,$inputfile,$outfile); + system({$args[0]} @args); chmod(0660, $filepath.'/tn-'.$file); if (-e $outfile) { my $copyfile=$targetdir.'/tn-'.$file; @@ -8209,7 +7903,7 @@ sub write_metadata { { print $logfile "\nWrite metadata file for ".$targetdir.'/'.$file; my $mfh; - if (open($mfh,'>'.$targetdir.'/'.$file.'.meta')) { + if (open($mfh,">",$targetdir.'/'.$file.'.meta')) { foreach (sort(keys(%metadatafields))) { unless ($_=~/\./) { my $unikey=$_; @@ -8243,7 +7937,7 @@ sub notifysubscribed { next unless (ref($targetsource) eq 'ARRAY'); my ($target,$source)=@{$targetsource}; if ($source ne '') { - if (open(my $logfh,'>>'.$source.'.log')) { + if (open(my $logfh,">>",$source.'.log')) { print $logfh "\nCleanup phase: Notifications\n"; my @subscribed=&subscribed_hosts($target); foreach my $subhost (@subscribed) { @@ -8269,7 +7963,7 @@ sub notifysubscribed { sub subscribed_hosts { my ($target) = @_; my @subscribed; - if (open(my $fh,"<$target.subscription")) { + if (open(my $fh,"<","$target.subscription")) { while (my $subline=<$fh>) { if ($subline =~ /^($match_lonid):/) { my $host = $1; @@ -8468,16 +8162,20 @@ sub modify_quotas { #FIXME need to obsolete item in RES space } elsif ($env{'form.'.$type.'_image_'.$i.'.filename'}) { my ($cdom,$cnum) = split(/_/,$key); - my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i, - $cdom,$cnum,$type,$configuserok, - $switchserver,$author_ok); - if ($imgurl) { - $confhash{$type}{$key}{'image'} = $imgurl; - $changes{$type}{$key} = 1; - } - if ($error) { - &Apache::lonnet::logthis($error); - $errors .= '
  • '.$error.'
  • '; + if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') { + $errors .= '
  • '.&mt('Image not saved: could not find textbook course').'
  • '; + } else { + my ($imgurl,$error) = &process_textbook_image($r,$dom,$confname,$type.'_image_'.$i, + $cdom,$cnum,$type,$configuserok, + $switchserver,$author_ok); + if ($imgurl) { + $confhash{$type}{$key}{'image'} = $imgurl; + $changes{$type}{$key} = 1; + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } } } elsif ($domconfig{$action}{$type}{$key}{'image'}) { $confhash{$type}{$key}{'image'} = @@ -8511,15 +8209,19 @@ sub modify_quotas { if ($type eq 'textbooks') { if ($env{'form.'.$type.'_addbook_image.filename'} ne '') { my ($cdom,$cnum) = split(/_/,$newbook{$type}); - my ($imageurl,$error) = - &process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type, - $configuserok,$switchserver,$author_ok); - if ($imageurl) { - $confhash{$type}{$newbook{$type}}{'image'} = $imageurl; - } - if ($error) { - &Apache::lonnet::logthis($error); - $errors .= '
  • '.$error.'
  • '; + if (&Apache::lonnet::homeserver($cnum,$cdom) eq 'no_host') { + $errors .= '
  • '.&mt('Image not saved: could not find textbook course').'
  • '; + } else { + my ($imageurl,$error) = + &process_textbook_image($r,$dom,$confname,$type.'_addbook_image',$cdom,$cnum,$type, + $configuserok,$switchserver,$author_ok); + if ($imageurl) { + $confhash{$type}{$newbook{$type}}{'image'} = $imageurl; + } + if ($error) { + &Apache::lonnet::logthis($error); + $errors .= '
  • '.$error.'
  • '; + } } } } @@ -9011,7 +8713,7 @@ sub process_textbook_image { } elsif ($author_ok eq 'ok') { my ($result,$imageurl) = &publishlogo($r,'upload',$caller,$dom,$confname, - "$type/$dom/$cnum/cover",$width,$height); + "$type/$cdom/$cnum/cover",$width,$height); if ($result eq 'ok') { $url = $imageurl; } else { @@ -9908,10 +9610,12 @@ sub modify_usercreation { if ($key eq 'cancreate') { if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') { foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) { - if (($item eq 'requestcrs') || ($item eq 'course') || ($item eq 'author')) { - $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; - } else { + if (($item eq 'selfcreate') || ($item eq 'statustocreate') || + ($item eq 'captcha') || ($item eq 'recaptchakeys') || + ($item eq 'recaptchaversion')) { $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; + } else { + $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; } } } @@ -10114,18 +9818,14 @@ sub modify_usercreation { } sub modify_selfcreation { - my ($dom,$lastactref,%domconfig) = @_; - my ($resulttext,$warningmsg,%curr_usercreation,%curr_usermodify,%curr_inststatus,%changes,%cancreate); - my (%save_usercreate,%save_usermodify,%save_inststatus,@types,%usertypes); - my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); - my ($othertitle,$usertypesref,$typesref) = &Apache::loncommon::sorted_inst_types($dom); - if (ref($typesref) eq 'ARRAY') { - @types = @{$typesref}; - } - if (ref($usertypesref) eq 'HASH') { - %usertypes = %{$usertypesref}; + my ($dom,%domconfig) = @_; + my ($resulttext,$warningmsg,%curr_usercreation,%curr_usermodify,%changes,%cancreate); + my (%save_usercreate,%save_usermodify); + my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); + if (ref($types) eq 'ARRAY') { + $usertypes->{'default'} = $othertitle; + push(@{$types},'default'); } - $usertypes{'default'} = $othertitle; # # Retrieve current domain configuration for self-creation of usernames from $domconfig{'usercreation'}. # @@ -10135,11 +9835,10 @@ sub modify_selfcreation { if (ref($domconfig{'usercreation'}{$key}) eq 'HASH') { foreach my $item (keys(%{$domconfig{'usercreation'}{$key}})) { if (($item eq 'selfcreate') || ($item eq 'statustocreate') || - ($item eq 'captcha') || ($item eq 'recaptchakeys') || - ($item eq 'recaptchaversion') || ($item eq 'notify') || - ($item eq 'emailusername') || ($item eq 'shibenv') || - ($item eq 'selfcreateprocessing') || ($item eq 'emailverified') || - ($item eq 'emailoptions') || ($item eq 'emaildomain')) { + ($item eq 'captcha') || ($item eq 'recaptchakeys') || + ($item eq 'recaptchaversion') || + ($item eq 'emailusername') || ($item eq 'notify') || + ($item eq 'selfcreateprocessing') || ($item eq 'shibenv')) { $curr_usercreation{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; } else { $save_usercreate{$key}{$item} = $domconfig{'usercreation'}{$key}{$item}; @@ -10165,161 +9864,41 @@ sub modify_selfcreation { } } } -# -# Retrieve current domain configuration for institutional status types from $domconfig{'inststatus'}. -# - if (ref($domconfig{'inststatus'}) eq 'HASH') { - foreach my $key (keys(%{$domconfig{'inststatus'}})) { - if ($key eq 'inststatusguest') { - $curr_inststatus{$key} = $domconfig{'inststatus'}{$key}; - } else { - $save_inststatus{$key} = $domconfig{'inststatus'}{$key}; - } - } - } my @contexts = ('selfcreate'); @{$cancreate{'selfcreate'}} = (); %{$cancreate{'emailusername'}} = (); - if (@types) { - @{$cancreate{'statustocreate'}} = (); - } + @{$cancreate{'statustocreate'}} = (); %{$cancreate{'selfcreateprocessing'}} = (); %{$cancreate{'shibenv'}} = (); - %{$cancreate{'emailverified'}} = (); - %{$cancreate{'emailoptions'}} = (); - %{$cancreate{'emaildomain'}} = (); my %selfcreatetypes = ( sso => 'users authenticated by institutional single sign on', login => 'users authenticated by institutional log-in', - email => 'users verified by e-mail', + email => 'users who provide a valid e-mail address for use as username', ); # # Populate $cancreate{'selfcreate'} array reference with types of user, for which self-creation of user accounts # is permitted. # - my ($emailrules,$emailruleorder) = &Apache::lonnet::inst_userrules($dom,'email'); + my @statuses; + if (ref($domconfig{'inststatus'}) eq 'HASH') { + if (ref($domconfig{'inststatus'}{'inststatusguest'}) eq 'ARRAY') { + @statuses = @{$domconfig{'inststatus'}{'inststatusguest'}}; + } + } + push(@statuses,'default'); - my (@statuses,%email_rule); foreach my $item ('login','sso','email') { if ($item eq 'email') { if ($env{'form.cancreate_email'}) { - if (@types) { - my @poss_statuses = &Apache::loncommon::get_env_multiple('form.selfassign'); - foreach my $status (@poss_statuses) { - if (grep(/^\Q$status\E$/,(@types,'default'))) { - push(@statuses,$status); - } - } - $save_inststatus{'inststatusguest'} = \@statuses; - } else { - push(@statuses,'default'); - } - if (@statuses) { - my %curr_rule; - if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') { - foreach my $type (@statuses) { - $curr_rule{$type} = $curr_usercreation{'email_rule'}; - } - } elsif (ref($curr_usercreation{'email_rule'}) eq 'HASH') { - foreach my $type (@statuses) { - $curr_rule{$type} = $curr_usercreation{'email_rule'}{$type}; - } - } - push(@{$cancreate{'selfcreate'}},'email'); - push(@contexts,('selfcreateprocessing','emailverified','emailoptions')); - my %curremaildom; - if (ref($curr_usercreation{'cancreate'}{'emaildomain'}) eq 'HASH') { - %curremaildom = %{$curr_usercreation{'cancreate'}{'emaildomain'}}; - } - foreach my $type (@statuses) { - if ($env{'form.cancreate_emailprocess_'.$type} =~ /^(?:approval|automatic)$/) { - $cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess_'.$type}; - } - if ($env{'form.cancreate_usernameoptions_'.$type} =~ /^(?:all|first|free)$/) { - $cancreate{'emailverified'}{$type} = $env{'form.cancreate_usernameoptions_'.$type}; - } - if ($env{'form.cancreate_emailoptions_'.$type} =~ /^(any|inst|noninst|custom)$/) { -# -# Retrieve rules (if any) governing types of e-mail address which may be used to verify a username. -# - my $chosen = $1; - if (($chosen eq 'inst') || ($chosen eq 'noninst')) { - my $emaildom; - if ($env{'form.cancreate_emaildomain_'.$chosen.'_'.$type} =~ /^\@[^\@]+$/) { - $emaildom = $env{'form.cancreate_emaildomain_'.$chosen.'_'.$type}; - $cancreate{'emaildomain'}{$type}{$chosen} = $emaildom; - if (ref($curremaildom{$type}) eq 'HASH') { - if (exists($curremaildom{$type}{$chosen})) { - if ($curremaildom{$type}{$chosen} ne $emaildom) { - push(@{$changes{'cancreate'}},'emaildomain'); - } - } elsif ($emaildom ne '') { - push(@{$changes{'cancreate'}},'emaildomain'); - } - } elsif ($emaildom ne '') { - push(@{$changes{'cancreate'}},'emaildomain'); - } - } - $cancreate{'emailoptions'}{$type} = $env{'form.cancreate_emailoptions_'.$type}; - } elsif ($chosen eq 'custom') { - my @possemail_rules = &Apache::loncommon::get_env_multiple('form.email_rule_'.$type); - $email_rule{$type} = []; - if (ref($emailrules) eq 'HASH') { - foreach my $rule (@possemail_rules) { - if (exists($emailrules->{$rule})) { - push(@{$email_rule{$type}},$rule); - } - } - } - if (@{$email_rule{$type}}) { - $cancreate{'emailoptions'}{$type} = 'custom'; - if (ref($curr_rule{$type}) eq 'ARRAY') { - if (@{$curr_rule{$type}} > 0) { - foreach my $rule (@{$curr_rule{$type}}) { - if (!grep(/^\Q$rule\E$/,@{$email_rule{$type}})) { - push(@{$changes{'email_rule'}},$type); - } - } - } - foreach my $type (@{$email_rule{$type}}) { - if (!grep(/^\Q$type\E$/,@{$curr_rule{$type}})) { - push(@{$changes{'email_rule'}},$type); - } - } - } else { - push(@{$changes{'email_rule'}},$type); - } - } - } else { - $cancreate{'emailoptions'}{$type} = $env{'form.cancreate_emailoptions_'.$type}; - } - } - } - if (@types) { - if (ref($curr_inststatus{'inststatusguest'}) eq 'ARRAY') { - my @changed = &Apache::loncommon::compare_arrays(\@statuses,$curr_inststatus{'inststatusguest'}); - if (@changed) { - push(@{$changes{'inststatus'}},'inststatusguest'); - } - } else { - push(@{$changes{'inststatus'}},'inststatusguest'); - } - } - } else { - delete($env{'form.cancreate_email'}); - if (ref($curr_inststatus{'inststatusguest'}) eq 'ARRAY') { - if (@{$curr_inststatus{'inststatusguest'}} > 0) { - push(@{$changes{'inststatus'}},'inststatusguest'); - } - } - } - } else { - $save_inststatus{'inststatusguest'} = []; - if (ref($curr_inststatus{'inststatusguest'}) eq 'ARRAY') { - if (@{$curr_inststatus{'inststatusguest'}} > 0) { - push(@{$changes{'inststatus'}},'inststatusguest'); + push(@{$cancreate{'selfcreate'}},'email'); + push(@contexts,'selfcreateprocessing'); + foreach my $type (@statuses) { + if ($type eq 'default') { + $cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess'}; + } else { + $cancreate{'selfcreateprocessing'}{$type} = $env{'form.cancreate_emailprocess_'.$type}; } } } @@ -10329,7 +9908,7 @@ sub modify_selfcreation { } } } - my (%userinfo,%savecaptcha); + my (@email_rule,%userinfo,%savecaptcha); my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info(); # # Populate $cancreate{'emailusername'}{$type} hash ref with information fields (if new user will provide data @@ -10338,8 +9917,8 @@ sub modify_selfcreation { if ($env{'form.cancreate_email'}) { push(@contexts,'emailusername'); - if (@statuses) { - foreach my $type (@statuses) { + if (ref($types) eq 'ARRAY') { + foreach my $type (@{$types}) { if (ref($infofields) eq 'ARRAY') { foreach my $field (@{$infofields}) { if ($env{'form.canmodify_emailusername_'.$type.'_'.$field} =~ /^(required|optional)$/) { @@ -10351,7 +9930,7 @@ sub modify_selfcreation { } # # Populate $cancreate{'notify'} hash ref with names of Domain Coordinators who are to be notified of -# queued requests for self-creation of account verified by e-mail. +# queued requests for self-creation of account using e-mail address as username # my @approvalnotify = &Apache::loncommon::get_env_multiple('form.selfcreationnotifyapproval'); @@ -10371,13 +9950,36 @@ sub modify_selfcreation { push(@{$changes{'cancreate'}},'notify'); } +# +# Retrieve rules (if any) governing types of e-mail address which may be used as a username +# + @email_rule = &Apache::loncommon::get_env_multiple('form.email_rule'); &process_captcha('cancreate',\%changes,\%savecaptcha,$curr_usercreation{'cancreate'}); + if (ref($curr_usercreation{'email_rule'}) eq 'ARRAY') { + if (@{$curr_usercreation{'email_rule'}} > 0) { + foreach my $type (@{$curr_usercreation{'email_rule'}}) { + if (!grep(/^\Q$type\E$/,@email_rule)) { + push(@{$changes{'email_rule'}},$type); + } + } + } + if (@email_rule > 0) { + foreach my $type (@email_rule) { + if (!grep(/^\Q$type\E$/,@{$curr_usercreation{'email_rule'}})) { + push(@{$changes{'email_rule'}},$type); + } + } + } + } elsif (@email_rule > 0) { + push(@{$changes{'email_rule'}},@email_rule); + } } # # Check if domain default is set appropriately, if self-creation of accounts is to be available for # institutional log-in. # if (grep(/^login$/,@{$cancreate{'selfcreate'}})) { + my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); if (!((($domdefaults{'auth_def'} =~/^krb/) && ($domdefaults{'auth_arg_def'} ne '')) || ($domdefaults{'auth_def'} eq 'localauth'))) { $warningmsg = &mt('Although account creation has been set to be available for institutional logins, currently default authentication in this domain has not been set to support this.').' '. @@ -10396,10 +9998,14 @@ sub modify_selfcreation { # which the user may supply, if institutional data is unavailable. # if (($env{'form.cancreate_login'}) || ($env{'form.cancreate_sso'})) { - if (@types) { - @{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate'); - push(@contexts,'statustocreate'); - foreach my $type (@types) { + if (ref($types) eq 'ARRAY') { + if (@{$types} > 1) { + @{$cancreate{'statustocreate'}} = &Apache::loncommon::get_env_multiple('form.statustocreate'); + push(@contexts,'statustocreate'); + } else { + undef($cancreate{'statustocreate'}); + } + foreach my $type (@{$types}) { my @modifiable = &Apache::loncommon::get_env_multiple('form.canmodify_'.$type); foreach my $field (@fields) { if (grep(/^\Q$field\E$/,@modifiable)) { @@ -10410,7 +10016,7 @@ sub modify_selfcreation { } } if (ref($curr_usermodify{'selfcreate'}) eq 'HASH') { - foreach my $type (@types) { + foreach my $type (@{$types}) { if (ref($curr_usermodify{'selfcreate'}{$type}) eq 'HASH') { foreach my $field (@fields) { if ($save_usermodify{'selfcreate'}{$type}{$field} ne @@ -10422,7 +10028,7 @@ sub modify_selfcreation { } } } else { - foreach my $type (@types) { + foreach my $type (@{$types}) { push(@{$changes{'selfcreate'}},$type); } } @@ -10471,28 +10077,34 @@ sub modify_selfcreation { } } elsif (ref($curr_usercreation{'cancreate'}{$item}) eq 'HASH') { if (ref($cancreate{$item}) eq 'HASH') { - foreach my $type (keys(%{$curr_usercreation{'cancreate'}{$item}})) { - if (ref($curr_usercreation{'cancreate'}{$item}{$type}) eq 'HASH') { - foreach my $field (keys(%{$curr_usercreation{'cancreate'}{$item}{$type}})) { - unless ($curr_usercreation{'cancreate'}{$item}{$type}{$field} eq $cancreate{$item}{$type}{$field}) { + foreach my $curr (keys(%{$curr_usercreation{'cancreate'}{$item}})) { + if (ref($curr_usercreation{'cancreate'}{$item}{$curr}) eq 'HASH') { + foreach my $field (keys(%{$curr_usercreation{'cancreate'}{$item}{$curr}})) { + unless ($curr_usercreation{'cancreate'}{$item}{$curr}{$field} eq $cancreate{$item}{$curr}{$field}) { if (!grep(/^$item$/,@{$changes{'cancreate'}})) { push(@{$changes{'cancreate'}},$item); } } } - } elsif (($item eq 'selfcreateprocessing') || ($item eq 'emailverified') || ($item eq 'emailoptions')) { - if ($cancreate{$item}{$type} ne $curr_usercreation{'cancreate'}{$item}{$type}) { + } elsif ($item eq 'selfcreateprocessing') { + if ($cancreate{$item}{$curr} ne $curr_usercreation{'cancreate'}{$item}{$curr}) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } else { + if (!$cancreate{$item}{$curr}) { if (!grep(/^$item$/,@{$changes{'cancreate'}})) { push(@{$changes{'cancreate'}},$item); } } } } - foreach my $type (keys(%{$cancreate{$item}})) { - if (ref($cancreate{$item}{$type}) eq 'HASH') { - foreach my $field (keys(%{$cancreate{$item}{$type}})) { - if (ref($curr_usercreation{'cancreate'}{$item}{$type}) eq 'HASH') { - unless ($curr_usercreation{'cancreate'}{$item}{$type}{$field} eq $cancreate{$item}{$type}{$field}) { + foreach my $field (keys(%{$cancreate{$item}})) { + if (ref($cancreate{$item}{$field}) eq 'HASH') { + foreach my $inner (keys(%{$cancreate{$item}{$field}})) { + if (ref($curr_usercreation{'cancreate'}{$item}{$field}) eq 'HASH') { + unless ($curr_usercreation{'cancreate'}{$item}{$field}{$inner} eq $cancreate{$item}{$field}{$inner}) { if (!grep(/^$item$/,@{$changes{'cancreate'}})) { push(@{$changes{'cancreate'}},$item); } @@ -10503,8 +10115,14 @@ sub modify_selfcreation { } } } - } elsif (($item eq 'selfcreateprocessing') || ($item eq 'emailverified') || ($item eq 'emailoptions')) { - if ($cancreate{$item}{$type} ne $curr_usercreation{'cancreate'}{$item}{$type}) { + } elsif ($item eq 'selfcreateprocessing') { + if ($cancreate{$item}{$field} ne $curr_usercreation{'cancreate'}{$item}{$field}) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } + } + } else { + if (!$curr_usercreation{'cancreate'}{$item}{$field}) { if (!grep(/^$item$/,@{$changes{'cancreate'}})) { push(@{$changes{'cancreate'}},$item); } @@ -10519,11 +10137,11 @@ sub modify_selfcreation { push(@{$changes{'cancreate'}},$item); } } - } - } elsif (($item eq 'selfcreateprocessing') || ($item eq 'emailverified') || ($item eq 'emailoptions')) { - if (ref($cancreate{$item}) eq 'HASH') { - if (!grep(/^$item$/,@{$changes{'cancreate'}})) { - push(@{$changes{'cancreate'}},$item); + } elsif (ref($cancreate{$item}) eq 'HASH') { + if (!$cancreate{$item}{$curr_usercreation{'cancreate'}{$item}}) { + if (!grep(/^$item$/,@{$changes{'cancreate'}})) { + push(@{$changes{'cancreate'}},$item); + } } } } elsif ($item eq 'emailusername') { @@ -10556,15 +10174,6 @@ sub modify_selfcreation { if (ref($cancreate{'selfcreateprocessing'}) eq 'HASH') { $save_usercreate{'cancreate'}{'selfcreateprocessing'} = $cancreate{'selfcreateprocessing'}; } - if (ref($cancreate{'emailverified'}) eq 'HASH') { - $save_usercreate{'cancreate'}{'emailverified'} = $cancreate{'emailverified'}; - } - if (ref($cancreate{'emailoptions'}) eq 'HASH') { - $save_usercreate{'cancreate'}{'emailoptions'} = $cancreate{'emailoptions'}; - } - if (ref($cancreate{'emaildomain'}) eq 'HASH') { - $save_usercreate{'cancreate'}{'emaildomain'} = $cancreate{'emaildomain'}; - } if (ref($cancreate{'statustocreate'}) eq 'ARRAY') { $save_usercreate{'cancreate'}{'statustocreate'} = $cancreate{'statustocreate'}; } @@ -10572,18 +10181,16 @@ sub modify_selfcreation { $save_usercreate{'cancreate'}{'shibenv'} = $cancreate{'shibenv'}; } $save_usercreate{'cancreate'}{'emailusername'} = $cancreate{'emailusername'}; - $save_usercreate{'email_rule'} = \%email_rule; + $save_usercreate{'email_rule'} = \@email_rule; my %userconfig_hash = ( usercreation => \%save_usercreate, usermodification => \%save_usermodify, - inststatus => \%save_inststatus, ); - my $putresult = &Apache::lonnet::put_dom('configuration',\%userconfig_hash, $dom); # -# Accumulate details of changes to domain configuration for self-creation of usernames in $resulttext +# Accumulate details of changes to domain cofiguration for self-creation of usernames in $resulttext # if ($putresult eq 'ok') { if (keys(%changes) > 0) { @@ -10591,7 +10198,7 @@ sub modify_selfcreation { if (ref($changes{'cancreate'}) eq 'ARRAY') { my %lt = &selfcreation_types(); foreach my $type (@{$changes{'cancreate'}}) { - my $chgtext = ''; + my $chgtext; if ($type eq 'selfcreate') { if (@{$cancreate{$type}} == 0) { $chgtext .= &mt('Self creation of a new user account is not permitted.'); @@ -10606,25 +10213,18 @@ sub modify_selfcreation { if (grep(/^(login|sso)$/,@{$cancreate{$type}})) { if (ref($cancreate{'statustocreate'}) eq 'ARRAY') { if (@{$cancreate{'statustocreate'}} == 0) { - $chgtext .= ''. - &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts via log-in or single sign-on."). - '
    '; + $chgtext .= '
    '. + ''. + &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts."). + ''; } } } - if (grep(/^email$/,@{$cancreate{$type}})) { - if (!@statuses) { - $chgtext .= ''. - &mt("However, e-mail verification is currently set to 'unavailable' for all user types (including 'other'), so self-creation of accounts is not possible for non-institutional log-in."). - '
    '; - - } - } } } } elsif ($type eq 'shibenv') { if (keys(%{$cancreate{$type}}) == 0) { - $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information').'
    '; + $chgtext .= &mt('Shibboleth-autheticated user does not use environment variables to set user information'); } else { $chgtext .= &mt('Shibboleth-autheticated user information set from environment variables, as follows:'). '
      '; @@ -10637,7 +10237,7 @@ sub modify_selfcreation { } } $chgtext .= '
    '; - } + } } elsif ($type eq 'statustocreate') { if ((ref($cancreate{'selfcreate'}) eq 'ARRAY') && (ref($cancreate{'statustocreate'}) eq 'ARRAY')) { @@ -10650,7 +10250,7 @@ sub modify_selfcreation { &mt("However, no institutional affiliations (including 'other') are currently permitted to create accounts."). ''; } - } elsif (keys(%usertypes) > 0) { + } elsif (ref($usertypes) eq 'HASH') { if (grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) { $chgtext .= &mt('Creation of a new account for an institutional user is restricted to the following institutional affiliation(s):'); } else { @@ -10661,12 +10261,12 @@ sub modify_selfcreation { if ($case eq 'default') { $chgtext .= '
  • '.$othertitle.'
  • '; } else { - $chgtext .= '
  • '.$usertypes{$case}.'
  • '; + $chgtext .= '
  • '.$usertypes->{$case}.'
  • '; } } $chgtext .= ''; if (!grep(/^(login|sso)$/,@{$cancreate{'selfcreate'}})) { - $chgtext .= ''. + $chgtext .= '
    '. &mt('However, users authenticated by institutional login/single sign on are not currently permitted to create accounts.'). ''; } @@ -10678,129 +10278,26 @@ sub modify_selfcreation { $chgtext .= &mt('Although institutional affiliations permitted to create accounts were changed, self creation of accounts is not currently permitted for any authentication types.'); } } - $chgtext .= '
    '; } } elsif ($type eq 'selfcreateprocessing') { my %choices = &Apache::lonlocal::texthash ( automatic => 'Automatic approval', approval => 'Queued for approval', ); - if (@types) { - if (@statuses) { - $chgtext .= &mt('Processing of requests to create account with e-mail verification set as follows:'). - '
      '; - foreach my $status (@statuses) { - if ($status eq 'default') { - $chgtext .= '
    • '.$othertitle.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$status}}.'
    • '; - } else { - $chgtext .= '
    • '.$usertypes{$status}.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$status}}.'
    • '; - } - } - $chgtext .= '
    '; - } - } else { - $chgtext .= &mt('Processing of requests to create account with e-mail verification set to: "[_1]"', - $choices{$cancreate{'selfcreateprocessing'}{'default'}}); - } - } elsif ($type eq 'emailverified') { - my %options = &Apache::lonlocal::texthash ( - all => 'Same as e-mail', - first => 'Omit @domain', - free => 'Free to choose', - ); - if (@types) { - if (@statuses) { - $chgtext .= &mt('For self-created accounts verified by e-mail address, username is set as follows:'). - '
      '; - foreach my $status (@statuses) { - if ($type eq 'default') { - $chgtext .= '
    • '.$othertitle.' -- '.$options{$cancreate{'emailverified'}{$status}}.'
    • '; - } else { - $chgtext .= '
    • '.$usertypes{$status}.' -- '.$options{$cancreate{'emailverified'}{$status}}.'
    • '; - } - } - $chgtext .= '
    '; - } - } else { - $chgtext .= &mt("For self-created accounts verified by e-mail address, user's username is: '[_1]'", - $options{$cancreate{'emailverified'}{'default'}}); - } - } elsif ($type eq 'emailoptions') { - my %options = &Apache::lonlocal::texthash ( - any => 'Any e-mail', - inst => 'Institutional only', - noninst => 'Non-institutional only', - custom => 'Custom restrictions', - ); - if (@types) { - if (@statuses) { - $chgtext .= &mt('For self-created accounts verified by e-mail address, requirements for e-mail address are as follows:'). - '
      '; - foreach my $status (@statuses) { - if ($type eq 'default') { - $chgtext .= '
    • '.$othertitle.' -- '.$options{$cancreate{'emailoptions'}{$status}}.'
    • '; - } else { - $chgtext .= '
    • '.$usertypes{$status}.' -- '.$options{$cancreate{'emailoptions'}{$status}}.'
    • '; - } - } - $chgtext .= '
    '; - } + if (@statuses > 1) { + $chgtext .= &mt('Processing of requests to create account with e-mail address as username set as follows:'). + '
      '; + foreach my $type (@statuses) { + if ($type eq 'default') { + $chgtext .= '
    • '.$othertitle.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.'
    • '; + } else { + $chgtext .= '
    • '.$usertypes->{$type}.' -- '.$choices{$cancreate{'selfcreateprocessing'}{$type}}.'
    • '; + } + } + $chgtext .= '
    '; } else { - if ($cancreate{'emailoptions'}{'default'} eq 'any') { - $chgtext .= &mt('For self-created accounts verified by e-mail address, any e-mail may be used'); - } else { - $chgtext .= &mt('For self-created accounts verified by e-mail address, e-mail restricted to: "[_1]"', - $options{$cancreate{'emailoptions'}{'default'}}); - } - } - } elsif ($type eq 'emaildomain') { - my $output; - if (@statuses) { - foreach my $type (@statuses) { - if (ref($cancreate{'emaildomain'}{$type}) eq 'HASH') { - if ($cancreate{'emailoptions'}{$type} eq 'inst') { - if ($type eq 'default') { - if ((ref($cancreate{'emaildomain'}{$type}) ne 'HASH') || - ($cancreate{'emaildomain'}{$type}{'inst'} eq '')) { - $output = '
  • '.$othertitle.' -- '.&mt('No restriction on e-mail domain').'
  • '; - } else { - $output = '
  • '.$othertitle.' -- '.&mt("User's e-mail address needs to end: [_1]", - $cancreate{'emaildomain'}{$type}{'inst'}).'
  • '; - } - } else { - if ((ref($cancreate{'emaildomain'}{$type}) ne 'HASH') || - ($cancreate{'emaildomain'}{$type}{'inst'} eq '')) { - $output = '
  • '.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').'
  • '; - } else { - $output = '
  • '.$usertypes{$type}.' -- '.&mt("User's e-mail address needs to end: [_1]", - $cancreate{'emaildomain'}{$type}{'inst'}).'
  • '; - } - } - } elsif ($cancreate{'emailoptions'}{$type} eq 'noninst') { - if ($type eq 'default') { - if ((ref($cancreate{'emaildomain'}{$type}) ne 'HASH') || - ($cancreate{'emaildomain'}{$type}{'noninst'} eq '')) { - $output = '
  • '.$othertitle.' -- '.&mt('No restriction on e-mail domain').'
  • '; - } else { - $output = '
  • '.$othertitle.' -- '.&mt("User's e-mail address must not end: [_1]", - $cancreate{'emaildomain'}{$type}{'noninst'}).'
  • '; - } - } else { - if ((ref($cancreate{'emaildomain'}{$type}) ne 'HASH') || - ($cancreate{'emaildomain'}{$type}{'noninst'} eq '')) { - $output = '
  • '.$usertypes{$type}.' -- '.&mt('No restriction on e-mail domain').'
  • '; - } else { - $output = '
  • '.$usertypes{$type}.' -- '.&mt("User's e-mail address must not end: [_1]", - $cancreate{'emaildomain'}{$type}{'noninst'}).'
  • '; - } - } - } - } - } - } - if ($output ne '') { - $chgtext .= &mt('For self-created accounts verified by e-mail address:'). - '
      '.$output.'
    '; + $chgtext .= &mt('Processing of requests to create account with e-mail address as username set to: "[_1]"', + $choices{$cancreate{'selfcreateprocessing'}{'default'}}); } } elsif ($type eq 'captcha') { if ($savecaptcha{$type} eq 'notused') { @@ -10837,11 +10334,11 @@ sub modify_selfcreation { } } elsif ($type eq 'emailusername') { if (ref($cancreate{'emailusername'}) eq 'HASH') { - if (@statuses) { - foreach my $type (@statuses) { + if (ref($types) eq 'ARRAY') { + foreach my $type (@{$types}) { if (ref($cancreate{'emailusername'}{$type}) eq 'HASH') { if (keys(%{$cancreate{'emailusername'}{$type}}) > 0) { - $chgtext .= &mt('When self-creating account with e-mail verification, the following information will be provided by [_1]:',"'$usertypes{$type}'"). + $chgtext .= &mt('When self-creating account with e-mail as username, the following information will be provided by [_1]:',"'$usertypes->{$type}'"). '
      '; foreach my $field (@{$infofields}) { if ($cancreate{'emailusername'}{$type}{$field}) { @@ -10850,86 +10347,48 @@ sub modify_selfcreation { } $chgtext .= '
    '; } else { - $chgtext .= &mt('When self creating account with e-mail verification, no information besides e-mail address will be provided by [_1].',"'$usertypes{$type}'").'
    '; + $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',"'$usertypes->{$type}'").'
    '; } } else { - $chgtext .= &mt('When self creating account with e-mail verficiation, no information besides e-mail address will be provided by [_1].',"'$usertypes{$type}'").'
    '; + $chgtext .= &mt('When self creating account with e-mail as username, no information besides e-mail address will be provided by [_1].',"'$usertypes->{$type}'").'
    '; } } } } } elsif ($type eq 'notify') { - my $numapprove = 0; + $chgtext = &mt('No Domain Coordinators will receive notification of username requests requiring approval.'); if (ref($changes{'cancreate'}) eq 'ARRAY') { if ((grep(/^notify$/,@{$changes{'cancreate'}})) && (ref($cancreate{'notify'}) eq 'HASH')) { if ($cancreate{'notify'}{'approval'}) { - $chgtext .= &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'}; - $numapprove ++; + $chgtext = &mt('Notification of username requests requiring approval will be sent to: ').$cancreate{'notify'}{'approval'}; } } } - unless ($numapprove) { - $chgtext .= &mt('No Domain Coordinators will receive notification of username requests requiring approval.'); - } } if ($chgtext) { $resulttext .= '
  • '.$chgtext.'
  • '; } } } - if ((ref($changes{'email_rule'}) eq 'ARRAY') && (@{$changes{'email_rule'}} > 0)) { + if (ref($changes{'email_rule'}) eq 'ARRAY') { my ($emailrules,$emailruleorder) = &Apache::lonnet::inst_userrules($dom,'email'); - foreach my $type (@{$changes{'email_rule'}}) { - if (ref($email_rule{$type}) eq 'ARRAY') { - my $chgtext = '
      '; - foreach my $rule (@{$email_rule{$type}}) { - if (ref($emailrules->{$rule}) eq 'HASH') { - $chgtext .= '
    • '.$emailrules->{$rule}{'name'}.'
    • '; - } - } - $chgtext .= '
    '; - my $typename; - if (@types) { - if ($type eq 'default') { - $typename = $othertitle; - } else { - $typename = $usertypes{$type}; - } - $chgtext .= &mt('(Affiliation: [_1])',$typename); - } - if (@{$email_rule{$type}} > 0) { - $resulttext .= '
  • '. - &mt('Accounts may not be created by users verified by e-mail, for e-mail addresses of the following types: ', - $usertypes{$type}). - $chgtext. - '
  • '; - } else { - $resulttext .= '
  • '. - &mt('There are now no restrictions on e-mail addresses which may be used for verification when a user requests an account.'). - '
  • '. - &mt('(Affiliation: [_1])',$typename); - } + my $chgtext = '
      '; + foreach my $type (@email_rule) { + if (ref($emailrules->{$type}) eq 'HASH') { + $chgtext .= '
    • '.$emailrules->{$type}{'name'}.'
    • '; } } - } - if (ref($changes{'inststatus'}) eq 'ARRAY') { - if (ref($save_inststatus{'inststatusguest'}) eq 'ARRAY') { - if (@{$save_inststatus{'inststatusguest'}} > 0) { - my $chgtext = '
        '; - foreach my $type (@{$save_inststatus{'inststatusguest'}}) { - $chgtext .= '
      • '.$usertypes{$type}.'
      • '; - } - $chgtext .= '
      '; - $resulttext .= '
    • '. - &mt('A user will self-report one of the following affiliations when requesting an account verified by e-mail: '). - $chgtext. - '
    • '; - } else { - $resulttext .= '
    • '. - &mt('No affiliations available for self-reporting when requesting an account verified by e-mail.'). - '
    • '; - } + $chgtext .= '
    '; + if (@email_rule > 0) { + $resulttext .= '
  • '. + &mt('Accounts may not be created by users self-enrolling with e-mail addresses of the following types: '). + $chgtext. + '
  • '; + } else { + $resulttext .= '
  • '. + &mt('There are now no restrictions on e-mail addresses which may be used as a username when self-enrolling.'). + '
  • '; } } if (ref($changes{'selfcreate'}) eq 'ARRAY') { @@ -10937,9 +10396,9 @@ sub modify_selfcreation { my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); foreach my $type (@{$changes{'selfcreate'}}) { my $typename = $type; - if (keys(%usertypes) > 0) { - if ($usertypes{$type} ne '') { - $typename = $usertypes{$type}; + if (ref($usertypes) eq 'HASH') { + if ($usertypes->{$type} ne '') { + $typename = $usertypes->{$type}; } } my @modifiable; @@ -10962,12 +10421,6 @@ sub modify_selfcreation { $resulttext .= ''; } $resulttext .= ''; - my $cachetime = 24*60*60; - $domdefaults{'inststatusguest'} = $save_inststatus{'inststatusguest'}; - &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; - } } else { $resulttext = &mt('No changes made to self-creation settings'); } @@ -11251,18 +10704,9 @@ sub modify_defaults { } my @todelete = &Apache::loncommon::get_env_multiple('form.inststatus_delete'); my @allpos; + my %guests; my %alltypes; - my @inststatusguest; - if (ref($currinststatus) eq 'HASH') { - if (ref($currinststatus->{'inststatusguest'}) eq 'ARRAY') { - foreach my $type (@{$currinststatus->{'inststatusguest'}}) { - unless (grep(/^\Q$type\E$/,@todelete)) { - push(@inststatusguest,$type); - } - } - } - } - my ($currtitles,$currorder); + my ($currtitles,$currguests,$currorder); if (ref($currinststatus) eq 'HASH') { if (ref($currinststatus->{'inststatusorder'}) eq 'ARRAY') { foreach my $type (@{$currinststatus->{'inststatusorder'}}) { @@ -11277,8 +10721,14 @@ sub modify_defaults { $allpos[$position] = $type; $alltypes{$type} = $env{'form.inststatus_title_'.$type}; $alltypes{$type} =~ s/`//g; + if ($env{'form.inststatus_guest_'.$type}) { + $guests{$type} = 1; + } } } + if (ref($currinststatus->{'inststatusguest'}) eq 'ARRAY') { + $currguests = join(',',@{$currinststatus->{'inststatusguest'}}); + } $currorder = join(',',@{$currinststatus->{'inststatusorder'}}); $currtitles =~ s/,$//; } @@ -11287,6 +10737,9 @@ sub modify_defaults { my $newtype = $env{'form.addinststatus'}; $newtype =~ s/\W//g; unless (exists($alltypes{$newtype})) { + if ($env{'form.addinststatus_guest'}) { + $guests{$newtype} = 1; + } $alltypes{$newtype} = $env{'form.addinststatus_title'}; $alltypes{$newtype} =~ s/`//g; my $position = $env{'form.addinststatus_pos'}; @@ -11296,10 +10749,13 @@ sub modify_defaults { } } } - my @orderedstatus; + my (@orderedstatus,@orderedguests); foreach my $type (@allpos) { unless (($type eq '') || (grep(/^\Q$type\E$/,@orderedstatus))) { push(@orderedstatus,$type); + if ($guests{$type}) { + push(@orderedguests,$type); + } } } foreach my $type (keys(%alltypes)) { @@ -11310,7 +10766,7 @@ sub modify_defaults { $defaults_hash{'inststatus'} = { inststatustypes => \%alltypes, inststatusorder => \@orderedstatus, - inststatusguest => \@inststatusguest, + inststatusguest => \@orderedguests, }; if (ref($defaults_hash{'inststatus'}) eq 'HASH') { foreach my $item ('inststatustypes','inststatusorder','inststatusguest') { @@ -11320,6 +10776,9 @@ sub modify_defaults { if ($currorder ne join(',',@orderedstatus)) { $changes{'inststatus'}{'inststatusorder'} = 1; } + if ($currguests ne join(',',@orderedguests)) { + $changes{'inststatus'}{'inststatusguest'} = 1; + } my $newtitles; foreach my $item (@orderedstatus) { $newtitles .= $alltypes{$item}.','; @@ -11338,15 +10797,26 @@ sub modify_defaults { foreach my $item (sort(keys(%changes))) { if ($item eq 'inststatus') { if (ref($changes{'inststatus'}) eq 'HASH') { - if (@orderedstatus) { + if (($changes{'inststatus'}{'inststatustypes'}) || $changes{'inststatus'}{'inststatusorder'}) { $resulttext .= '
  • '.&mt('Institutional user status types set to:').' '; foreach my $type (@orderedstatus) { $resulttext .= $alltypes{$type}.', '; } $resulttext =~ s/, $//; $resulttext .= '
  • '; - } else { - $resulttext .= '
  • '.&mt('Institutional user status types deleted').'
  • '; + } + if ($changes{'inststatus'}{'inststatusguest'}) { + $resulttext .= '
  • '; + if (@orderedguests) { + $resulttext .= &mt('Types assignable to "non-institutional" usernames set to:').' '; + foreach my $type (@orderedguests) { + $resulttext .= $alltypes{$type}.', '; + } + $resulttext =~ s/, $//; + } else { + $resulttext .= &mt('Types assignable to "non-institutional" usernames set to none.'); + } + $resulttext .= '
  • '; } } } else { @@ -12241,7 +11711,11 @@ sub modify_coursedefaults { postsubmit => 60, mysqltables => 172800, ); - + my %texoptions = ( + MathJax => 'MathJax', + mimetex => &mt('Convert to Images'), + tth => &mt('TeX to HTML'), + ); $defaultshash{'coursedefaults'} = {}; if (ref($domconfig{'coursedefaults'}) ne 'HASH') { @@ -12288,7 +11762,6 @@ sub modify_coursedefaults { $defaultshash{'coursedefaults'}{$setting}{$type} = $newdef; } if ($currdef ne $newdef) { - my $staticdef; if ($item eq 'anonsurvey_threshold') { unless (($currdef eq '') && ($newdef == $staticdefaults{$item})) { $changes{$item} = 1; @@ -12301,6 +11774,21 @@ sub modify_coursedefaults { } } } + my $texengine; + if ($env{'form.texengine'} =~ /^(MathJax|mimetex|tth)$/) { + $texengine = $env{'form.texengine'}; + my $currdef = $domconfig{'coursedefaults'}{'texengine'}; + if ($currdef eq '') { + unless ($texengine eq $Apache::lonnet::deftex) { + $changes{'texengine'} = 1; + } + } elsif ($currdef ne $texengine) { + $changes{'texengine'} = 1; + } + } + if ($texengine ne '') { + $defaultshash{'coursedefaults'}{'texengine'} = $texengine; + } my $currclone = $domconfig{'coursedefaults'}{'canclone'}; my @currclonecode; if (ref($currclone) eq 'HASH') { @@ -12421,8 +11909,8 @@ sub modify_coursedefaults { my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); if (($changes{'uploadquota'}) || ($changes{'postsubmit'}) || ($changes{'coursecredits'}) || ($changes{'uselcmath'}) || ($changes{'usejsme'}) || - ($changes{'canclone'}) || ($changes{'mysqltables'})) { - foreach my $item ('uselcmath','usejsme') { + ($changes{'canclone'}) || ($changes{'mysqltables'}) || ($changes{'texengine'})) { + foreach my $item ('uselcmath','usejsme','texengine') { if ($changes{$item}) { $domdefaults{$item}=$defaultshash{'coursedefaults'}{$item}; } @@ -12485,6 +11973,11 @@ sub modify_coursedefaults { } else { $resulttext .= '
  • '.&mt('Molecule editor uses JME (Java), if supported by client OS.').'
  • '; } + } elsif ($item eq 'texengine') { + if ($defaultshash{'coursedefaults'}{'texengine'} ne '') { + $resulttext .= '
  • '.&mt('Default method to display mathematics set to: "[_1]"', + $texoptions{$defaultshash{'coursedefaults'}{'texengine'}}).'
  • '; + } } elsif ($item eq 'anonsurvey_threshold') { $resulttext .= '
  • '.&mt('Responder count required for display of anonymous survey submissions set to [_1].',$defaultshash{'coursedefaults'}{'anonsurvey_threshold'}).'
  • '; } elsif ($item eq 'uploadquota') { @@ -12809,12 +12302,12 @@ sub modify_selfenrollment { $resulttext .= ''; } } - } - if ((exists($changes{'admin'})) || (exists($changes{'default'}))) { - my $cachetime = 24*60*60; - &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); - if (ref($lastactref) eq 'HASH') { - $lastactref->{'domdefaults'} = 1; + if ((exists($changes{'admin'})) || (exists($changes{'default'}))) { + my $cachetime = 24*60*60; + &Apache::lonnet::do_cache_new('domdefaults',$dom,\%domdefaults,$cachetime); + if (ref($lastactref) eq 'HASH') { + $lastactref->{'domdefaults'} = 1; + } } } $resulttext .= ''; @@ -14096,7 +13589,6 @@ function toggleDisplay(domForm,caller) { var optionsElement = domForm.coursecredits; var checkval = 1; var dispval = 'block'; - var selfcreateRegExp = /^cancreate_emailverified/; if (caller == 'emailoptions') { optionsElement = domForm.cancreate_email; } @@ -14107,11 +13599,6 @@ function toggleDisplay(domForm,caller) { optionsElement = domForm.canclone; checkval = 'instcode'; } - if (selfcreateRegExp.test(caller)) { - optionsElement = domForm.elements[caller]; - checkval = 'other'; - dispval = 'inline' - } if (optionsElement.length) { var currval; for (var i=0; i
    '. @@ -5900,12 +5613,23 @@ sub print_defaults { } $datatable .= ''; } + my ($checkedon,$checkedoff); + $checkedoff = ' checked="checked"'; + if ($guestok) { + $checkedon = $checkedoff; + $checkedoff = ''; + } $datatable .= ' '.&mt('Internal ID:').' '.$item.' '. ''. &mt('delete').''.&mt('Name displayed:'). + ''.&mt('Name displayed:'). ''. - '
    '. + ''.(' 'x2). + '
    '. + ''. &mt('Name displayed:'). ''. + ''.(' 'x2). + '
    '.$hdritem->{'header'}->[1]->{'col2'}.'
    '.$hdritem->{'header'}->[1]->{'col2'}.'
    '.&mt('Name:') - .' 
    '.&mt('Add subcategory:').'
    '.$rolename.''; my $rem; @@ -6877,10 +6589,9 @@ sub modifiable_userdata_row { } } } - - my $total = scalar(@fields); - for (my $i=0; $i<$total; $i++) { - $rem = $i%($numinrow); + + for (my $i=0; $i<@fields; $i++) { + my $rem = $i%($numinrow); if ($rem == 0) { if ($i > 0) { $output .= ''; @@ -6922,13 +6633,10 @@ sub modifiable_userdata_row { ''; } $output .= ''; + $rem = @fields%($numinrow); } - $rem = $total%$numinrow; - my $colsleft; - if ($rem) { - $colsleft = $numinrow - $rem; - } - if ($colsleft > 1) { + my $colsleft = $numinrow - $rem; + if ($colsleft > 1 ) { $output .= ''; } elsif ($colsleft == 1) { @@ -6939,13 +6647,11 @@ sub modifiable_userdata_row { } sub insttypes_row { - my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rowtotal,$onclick, - $customcss,$rowstyle) = @_; + my ($settings,$types,$usertypes,$dom,$numinrow,$othertitle,$context,$rownum) = @_; my %lt = &Apache::lonlocal::texthash ( cansearch => 'Users allowed to search', statustocreate => 'Institutional affiliation(s) able to create own account (login/SSO)', lockablenames => 'User preference to lock name', - selfassign => 'Self-reportable affiliations', ); my $showdom; if ($context eq 'cansearch') { @@ -6955,22 +6661,9 @@ sub insttypes_row { if ($context eq 'statustocreate') { $class = 'LC_right_item'; } - 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.'"'; - } - if ($onclick) { - $onclick = 'onclick="'.$onclick.'" '; + my $css_class = ' class="LC_odd_row"'; + if ($rownum ne '') { + $css_class = ($rownum%2? ' class="LC_odd_row"':''); } my $output = ''. ''; } } $rem = @{$types}%($numinrow); } my $colsleft = $numinrow - $rem; - if (($rem == 0) && (@{$types} > 0)) { + if ($rem == 0) { $output .= ''; } if ($colsleft > 1) { @@ -7026,7 +6719,7 @@ sub insttypes_row { } $output .= ''. '
    '. ' '.$lt{$context}.$showdom. @@ -6999,14 +6692,14 @@ sub insttypes_row { $output .= ''. '