--- loncom/interface/lonparmset.pm 2012/05/07 23:46:11 1.522.2.1 +++ loncom/interface/lonparmset.pm 2020/02/12 21:17:54 1.522.2.26.2.2 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Handler to set parameters for assessments # -# $Id: lonparmset.pm,v 1.522.2.1 2012/05/07 23:46:11 raeburn Exp $ +# $Id: lonparmset.pm,v 1.522.2.26.2.2 2020/02/12 21:17:54 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -36,7 +36,8 @@ lonparmset - Handler to set parameters f =head1 SYNOPSIS -lonparmset provides an interface to setting course parameters. +lonparmset provides an interface to setting content parameters in a +course. =head1 DESCRIPTION @@ -46,8 +47,6 @@ This module sets coursewide and assessme =over -=pod - =item parmval() Figure out a cascading parameter. @@ -131,7 +130,7 @@ javascript function 'pjump'. =item print_td() -=item print_usergroups() +=item check_other_groups() =item parm_control_group() @@ -139,15 +138,21 @@ javascript function 'pjump'. extractResourceInformation extracts lots of information about all of the the course's resources into a variety of hashes. -Input: See list below: +Input: See list below + +=over 4 =item * B : Current username =item * B : Domain of current user. -=item * b : Course -Outputs: See list below: +=back + +Outputs: See list below + +=over 4 =item * B (out) : An array that will contain all of the ids in the course. @@ -173,6 +178,8 @@ Outputs: See list below: =item * B +=back + =item isdateparm() =item parmmenu() @@ -210,6 +217,8 @@ Returns: nothing Variables used (guessed by Jeremy): +=over + =item * B: ParameterS CATegories? ends up a list of the types of parameters that exist, e.g., tol, weight, acc, opendate, duedate, answerdate, sig, maxtries, type. =item * B: ParameterS PaRTs? a list of the parts of a problem that we are displaying? Used to display only selected parts? @@ -222,6 +231,8 @@ Variables used (guessed by Jeremy): When storing information, store as part 0 When requesting information, request from full part +=back + =item tablestart() =item tableend() @@ -288,7 +299,6 @@ Set portfolio metadata Main handler. Calls &assessparms subroutine. - =back =cut @@ -640,7 +650,7 @@ sub storeparm_by_symb { } sub log_parmset { - return &Apache::lonnet::instructor_log('parameterlog',@_); + return &Apache::lonnet::write_log('course','parameterlog',@_); } sub storeparm_by_symb_inner { @@ -747,14 +757,27 @@ sub valout { my $result = ''; # Values of zero are valid. if (! $value && $value ne '0') { - if ($editable) { - $result = '*'; - } else { - $result=' '; - } + if ($editable) { + $result = + ''.&mt('Change').''; + } else { + $result=' '; + } } else { if ($type eq 'date_interval') { - my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($value); + my ($totalsecs,$donesuffix) = split(/_/,$value,2); + my ($usesdone,$donebuttontext,$proctor,$secretkey); + if ($donesuffix =~ /^done\:([^\:]+)\:(.*)$/) { + $donebuttontext = $1; + (undef,$proctor,$secretkey) = split(/_/,$2); + $usesdone = 'done'; + } elsif ($donesuffix =~ /^done(|_.+)$/) { + $donebuttontext = &mt('Done'); + ($usesdone,$proctor,$secretkey) = split(/_/,$donesuffix); + } + my ($sec,$min,$hour,$mday,$mon,$year)=gmtime($totalsecs); my @timer; $year=$year-70; $mday--; @@ -787,6 +810,13 @@ sub valout { push(@timer,&mt('[quant,_1,sec]',0)); } $result.=join(", ",@timer); + if ($usesdone eq 'done') { + if ($secretkey) { + $result .= ' '.&mt('+ "[_1]" with proctor key: [_2]',$donebuttontext,$secretkey); + } else { + $result .= ' + "'.$donebuttontext.'"'; + } + } } elsif (&isdateparm($type)) { $result = &Apache::lonlocal::locallocaltime($value). &date_sanity_info($value); @@ -804,8 +834,12 @@ sub plink { my ($type,$dis,$value,$marker,$return,$call)=@_; my $winvalue=$value; unless ($winvalue) { - if (&isdateparm($type)) { + if ((&isdateparm($type)) || (&is_specialstring($type))) { $winvalue=$env{'form.recent_'.$type}; + } elsif ($type eq 'string_yesno') { + if ($env{'form.recent_string'} =~ /^(yes|no)$/i) { + $winvalue=$env{'form.recent_string'}; + } } else { $winvalue=$env{'form.recent_'.(split(/\_/,$type))[0]}; } @@ -838,20 +872,22 @@ sub page_js { $pjump_def function psub() { + var specstring = /^string_!(yesno|any)/i; if (document.parmform.pres_marker.value!='') { document.parmform.action+='#'+document.parmform.pres_marker.value; var typedef=new Array(); typedef=document.parmform.pres_type.value.split('_'); - if (document.parmform.pres_type.value!='') { - if (typedef[0]=='date') { - eval('document.parmform.recent_'+ - document.parmform.pres_type.value+ - '.value=document.parmform.pres_value.value;'); - } else { - eval('document.parmform.recent_'+typedef[0]+ - '.value=document.parmform.pres_value.value;'); + if (document.parmform.pres_type.value!='') { + if ((typedef[0]=='date') || + (specstring.test(document.parmform.pres_type.value))) { + eval('document.parmform.recent_'+ + document.parmform.pres_type.value+ + '.value=document.parmform.pres_value.value;'); + } else { + eval('document.parmform.recent_'+typedef[0]+ + '.value=document.parmform.pres_value.value;'); + } } - } document.parmform.submit(); } else { document.parmform.pres_value.value=''; @@ -873,6 +909,117 @@ ENDJS } +sub showhide_js { + return <<"COURSECONTENTSCRIPT"; + +function showHide_courseContent() { + var parmlevValue=document.getElementById("parmlev").value; + if (parmlevValue == 'general') { + document.getElementById('mapmenu').style.display="none"; + } else { + if ((parmlevValue == "full") || (parmlevValue == "map")) { + document.getElementById('mapmenu').style.display =""; + } else { + document.getElementById('mapmenu').style.display="none"; + } + } + return; +} + +COURSECONTENTSCRIPT +} + +sub validateparms_js { + return <<'ENDSCRIPT'; + +function validateParms() { + var ipallowRegExp = /^setipallow_/; + var ipdenyRegExp = /^setipdeny_/; + var patternIP = /[\[\]\*\.a-zA-Z\d\-]+/; + if ((document.parmform.elements.length != 'undefined') && (document.parmform.elements.length) != 'null') { + if (document.parmform.elements.length) { + for (i=0; i$remove'); + }); + + \$(wrapper).delegate(".LC_remove_ipacc","click", function(e){ + e.preventDefault(); \$(this).closest("div").remove(); + }) +}); + + +END +} + +sub done_proctor_js { + return <<"END"; +function toggleSecret(form,radio,key) { + var radios = form[radio+key]; + if (radios.length) { + for (var i=0; i "group_or_section('cgroup')", ); if (!$psymb) { - $loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup')"; + $loaditems{'onload'} = "showHide_courseContent(); group_or_section('cgroup'); resize_scrollbox('mapmenuscroll','1','1');"; } if ((($env{'form.command'} eq 'set') && ($env{'form.url'}) @@ -892,9 +1039,16 @@ sub startpage { text=>"Table Mode", help => 'Course_Setting_Parameters'}); } + my $js = &page_js().' + +'; my $start_page = - &Apache::loncommon::start_page('Set/Modify Course Parameters', - &page_js(), + &Apache::loncommon::start_page('Set/Modify Course Parameters',$js, {'add_entries' => \%loaditems,}); my $breadcrumbs = &Apache::lonhtmlcommon::breadcrumbs('Table Mode Parameter Setting','Table_Mode'); @@ -915,7 +1069,8 @@ ENDHEAD sub print_row { my ($r,$which,$part,$name,$symbp,$rid,$default,$defaulttype,$display,$defbgone, - $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups)=@_; + $defbgtwo,$defbgthree,$parmlev,$uname,$udom,$csec,$cgroup,$usersgroups,$noeditgrp, + $readonly)=@_; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $courseopt=&Apache::lonnet::get_courseresdata($cnum,$cdom); @@ -960,31 +1115,31 @@ sub print_row { if ($parmlev eq 'general') { if ($uname) { - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } elsif ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); } elsif ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } else { - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } } elsif ($parmlev eq 'map') { if ($uname) { - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } elsif ($cgroup) { - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); } elsif ($csec) { - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } else { - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } } else { if ($uname) { if (@{$usersgroups} > 1) { my ($coursereply,$grp_parm,$controlgrp); ($coursereply,$othergrp,$grp_parm,$controlgrp) = - &print_usergroups($r,$$part{$which}.'.'.$$name{$which}, + &check_other_groups($$part{$which}.'.'.$$name{$which}, $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt); if ($coursereply && $result > 3) { if (defined($controlgrp)) { @@ -997,32 +1152,32 @@ sub print_row { } } - &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,14,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); - &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,12,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,11,'#FFDDDD',$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,10,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); if ($csec) { - &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,8,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,7,$defbgtwo,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } if ($cgroup) { - &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); + &print_td($r,4,$defbgthree,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,$noeditgrp,$readonly); } if ($uname) { if ($othergrp) { $r->print($othergrp); } - &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); - &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display); + &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); + &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$_,\@typeoutpar,$display,'',$readonly); } } # end of $parmlev if/else @@ -1042,15 +1197,29 @@ sub print_row { } sub print_td { - my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display)=@_; + my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_; $r->print(''); my $nolink = 0; - if ($which == 11 || $which == 12) { + if ($readonly) { $nolink = 1; - } elsif ($mprefix =~ /availablestudent\&$/) { - if ($which > 3) { + } else { + if ($which == 11 || $which == 12) { + $nolink = 1; + } elsif (($env{'request.course.sec'} ne '') && ($which > 9)) { $nolink = 1; + } elsif ($which == 4 || $which == 5 || $which == 6) { + if ($noeditgrp) { + $nolink = 1; + } + } elsif ($mprefix =~ /availablestudent\&$/) { + if ($which > 3) { + $nolink = 1; + } + } elsif ($mprefix =~ /examcode\&$/) { + unless ($which == 2) { + $nolink = 1; + } } } if ($nolink) { @@ -1063,8 +1232,8 @@ sub print_td { $r->print(''."\n"); } -sub print_usergroups { - my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; +sub check_other_groups { + my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_; my $courseid = $env{'request.course.id'}; my $output; my $symb = &symbcache($rid); @@ -1079,7 +1248,6 @@ sub print_usergroups { if (($coursereply) && ($cgroup ne $resultgroup)) { if ($result > 3) { $bgcolor = '#AAFFAA'; - $grp_parm = &valout($coursereply,$resulttype); } $grp_parm = &valout($coursereply,$resulttype); $output = ''; @@ -1205,7 +1373,7 @@ sub extractResourceInformation { $$mapp{$mapid}=$$mapp{$id}; $$allmaps{$mapid}=$$mapp{$id}; if ($mapid eq '1') { - $$maptitles{$mapid}=&mt('Main Course Documents'); + $$maptitles{$mapid}=&mt('Main Content'); } else { $$maptitles{$mapid}=&Apache::lonnet::gettitle($$mapp{$id}); } @@ -1225,14 +1393,21 @@ sub isdateparm { return (($type=~/^date/) && (!($type eq 'date_interval'))); } +# Determine if parameter type is specialized string type (i.e., +# not just string or string_yesno. + +sub is_specialstring { + my $type=shift; + return (($type=~/^string_/) && (($type ne 'string_yesno'))); +} + # # parmmenu displays a list of the selected parameters. # It also offers a link to show/hide the complete parameter list # from which you can select all desired parameters. # sub parmmenu { - my ($r,$allparms,$pscat,$keyorder)=@_; - my $tempkey; + my ($r)=@_; $r->print(< // print('
'); - &shortCuts($r,$allparms,$pscat,$keyorder); + &shortCuts($r); $r->print('
'); } # return a hash @@ -1339,8 +1514,8 @@ sub lookUpTableParameter { 'contentopen' => 'time_settings', 'contentclose' => 'time_settings', 'discussend' => 'time_settings', - 'printopendate' => 'time_settings', - 'printclosedate' => 'time_settings', + 'printstartdate' => 'time_settings', + 'printenddate' => 'time_settings', 'weight' => 'grading', 'handgrade' => 'grading', 'maxtries' => 'tries', @@ -1375,8 +1550,8 @@ sub lookUpTableParameter { 'lenient' => 'grading', 'retrypartial' => 'tries', 'discussvote' => 'misc', - - ); + 'examcode' => 'high_level_randomization', + ); } sub whatIsMyCategory { @@ -1452,26 +1627,24 @@ sub parmboxes { #Print parameters for my $key (sort { $category_order{$a} <=> $category_order{$b} } keys %categoryList) { - if(@{$categoryList{$key}} == 0) { - next; - } else { - $r->print('
' - .'

' - .&mt($categories{$key}) - .'

'."\n"); - foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { - $r->print('' - .'
'."\n"); + next if(@{$categoryList{$key}} == 0); + $r->print('
' + .'

' + .&mt($categories{$key}) + .'

'."\n"); + foreach $tempkey (&keysindisplayorderCategory($categoryList{$key},$keyorder)) { + next if ($tempkey eq ''); + $r->print('' + .'
\n"); + $r->print(' />'.($$allparms{$tempkey}=~/\S/ ? $$allparms{$tempkey} + : $tempkey) + .'
'."\n"); } + $r->print("
\n"); } $r->print("\n"); @@ -1480,7 +1653,7 @@ sub parmboxes { # This function offers some links on the parameter section to get with one click a group a parameters # sub shortCuts { - my ($r,$allparms,$pscat,$keyorder)=@_; + my ($r)=@_; # Parameter Selection $r->print( @@ -1513,8 +1686,12 @@ sub shortCuts { sub partmenu { my ($r,$allparts,$psprt)=@_; + my $selsize = 1+scalar(keys(%{$allparts})); + if ($selsize > 8) { + $selsize = 8; + } - $r->print(''); $r->print(''); @@ -1535,21 +1712,60 @@ sub partmenu { } sub usermenu { - my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups)=@_; + my ($r,$uname,$id,$udom,$csec,$cgroup,$parmlev,$usersgroups,$pssymb)=@_; my $chooseopt=&Apache::loncommon::select_dom_form($udom,'udom').' '. - &Apache::loncommon::selectstudent_link('parmform','uname','udom'); - my $selscript=&Apache::loncommon::studentbrowser_javascript(); + &Apache::loncommon::selectstudent_link('parmform','uname','udom','condition'). + &Apache::lonhtmlcommon::scripttag(<'. + $stuonly.'  '. + ''; my $sections=''; my %sectionhash = &Apache::loncommon::get_sections(); my $groups; - my %grouphash = &Apache::longroup::coursegroups(); + my %grouphash; + if (($pssymb) || &Apache::lonnet::allowed('mdg',$env{'request.course.id'})) { + %grouphash = &Apache::longroup::coursegroups(); + } elsif ($env{'request.course.groups'} ne '') { + map { $grouphash{$_} = 1; } split(/:/,$env{'request.course.groups'}); + } my $g_s_header=''; my $g_s_footer=''; - if (%sectionhash) { + my $currsec = $env{'request.course.sec'}; + if ($currsec) { + $sections=&mt('Section:').' '.$currsec; + if (%grouphash) { + $sections .= ';'.(' ' x2); + } + } elsif (%sectionhash && $currsec eq '') { $sections=&mt('Section:').' '); + ''); + unless ($readonly) { + $r->print(''); + } + $r->print(''); $foundkeys++; if (&isdateparm($thistype)) { - my $jskey='key_'.$pointer; - $pointer++; - $r->print( - &Apache::lonhtmlcommon::date_setter('parmform', - $jskey, - $$resourcedata{$thiskey}, - '',1,'',''). + my $jskey='key_'.$pointer; + my $state; + $pointer++; + if ($readonly) { + $state = 'disabled'; + } + $r->print( + &Apache::lonhtmlcommon::date_setter('parmform', + $jskey, + $$resourcedata{$thiskey}, + '',1,$state)); + unless ($readonly) { + $r->print( ''. (($$resourcedata{$thiskey}!=0)?''. &mt('Shift all dates based on this date').'':''). &date_sanity_info($$resourcedata{$thiskey}) ); + } } elsif ($thistype eq 'date_interval') { - $r->print(&date_interval_selector($thiskey, - $$resourcedata{$thiskey})); + $r->print(&date_interval_selector($thiskey,$name, + $$resourcedata{$thiskey},$readonly)); } elsif ($thistype =~ m/^string/) { - $r->print(&string_selector($thistype,$thiskey, - $$resourcedata{$thiskey},$name)); + $r->print(&string_selector($thistype,$thiskey, + $$resourcedata{$thiskey},$name,$readonly)); } else { - $r->print(&default_selector($thiskey,$$resourcedata{$thiskey})); + $r->print(&default_selector($thiskey,$$resourcedata{$thiskey},$readonly)); + } + unless ($readonly) { + $r->print(''); } - $r->print(''); $r->print(''.&Apache::loncommon::end_data_table_row()); } } @@ -3065,8 +3500,9 @@ sub listdata { sub date_interval_selector { - my ($thiskey, $showval) = @_; - my $result; + my ($thiskey, $pname, $showval, $readonly) = @_; + my ($result,%skipval); + my $currval = $showval; foreach my $which (['days', 86400, 31], ['hours', 3600, 23], ['minutes', 60, 59], @@ -3077,10 +3513,57 @@ sub date_interval_selector { my %select = ((map {$_ => $_} (0..$max)), 'select_form_order' => [0..$max]); $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey, - \%select); + \%select,'',$readonly); $result .= ' '.&mt($name); } - $result .= ''; + if ($pname eq 'interval') { + unless ($skipval{'done'}) { + my $checkedon = ''; + my $checkedproc = ''; + my $currproctorkey = ''; + my $currprocdisplay = 'hidden'; + my $currdonetext = &mt('Done'); + my $checkedoff = ' checked="checked"'; + if ($currval =~ /^(?:\d+)_done$/) { + $checkedon = ' checked="checked"'; + $checkedoff = ''; + } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:$/) { + $currdonetext = $1; + $checkedon = ' checked="checked"'; + $checkedoff = ''; + } elsif ($currval =~ /^(?:\d+)_done_proctor_(.+)$/) { + $currproctorkey = $1; + $checkedproc = ' checked="checked"'; + $checkedoff = ''; + $currprocdisplay = 'text'; + } elsif ($currval =~ /^(?:\d+)_done\:([^\:]+)\:_proctor_(.+)$/) { + $currdonetext = $1; + $currproctorkey = $2; + $checkedproc = ' checked="checked"'; + $checkedoff = ''; + $currprocdisplay = 'text'; + } + my $onclick = ' onclick="toggleSecret(this.form,'."'done_','$thiskey'".');"'; + my $disabled; + if ($readonly) { + $disabled = ' disabled="disabled"'; + } + $result .= '
'.&mt('Include "done" button'). + ''.(' 'x2). + ''.(' 'x2). + ''. + '&').'"'.$disabled.' />
'. + ''.&mt('Button text').': '. + '&').'"'.$disabled.' />'; + } + } + unless ($readonly) { + $result .= ''; + } return $result; } @@ -3102,10 +3585,76 @@ sub get_date_interval_from_form { sub default_selector { - my ($thiskey, $showval) = @_; - return ''; + my ($thiskey, $showval, $readonly) = @_; + my $disabled; + if ($readonly) { + $disabled = ' disabled="disabled"'; + } + return ''; +} + +sub string_ip_selector { + my ($thiskey, $showval, $readonly) = @_; + my %access = ( + allow => [], + deny => [], + ); + if ($showval ne '') { + my @current; + if ($showval =~ /,/) { + @current = split(/,/,$showval); + } else { + @current = ($showval); + } + foreach my $item (@current) { + if ($item =~ /^\!([\[\]a-zA-Z\.\d\*\-]+)$/) { + push(@{$access{'deny'}},$1); + } elsif ($item =~ /^([\[\]a-zA-Z\.\d\*\-]+)$/) { + push(@{$access{'allow'}},$item); + } + } + } + if (!@{$access{'allow'}}) { + @{$access{'allow'}} = (''); + } + if (!@{$access{'deny'}}) { + @{$access{'deny'}} = (''); + } + my ($disabled,$addmore); + if ($readonly) { + $disabled=' disabled="disabled"'; + } else { + $addmore = "\n".''; + } + my $output = ' +'; + foreach my $acctype ('allow','deny') { + $output .= ' +'; + } + $output .= ' + +
'.&mt('Allow from').''.&mt('Deny from').'
+
+
'."\n"; + my $num = 0; + foreach my $curr (@{$access{$acctype}}) { + $output .= '
'; + if ($num > 0) { + $output .= ''.&mt('Remove').''; + } + $output .= '
'."\n"; + $num ++; + } + $output .= ' +
'.$addmore.' +
+
'."\n"; + return $output; } +{ + my %strings = ( 'string_yesno' @@ -3133,6 +3682,9 @@ my %strings = => [['yes','Yes'], ['notended','Yes, unless discussion ended'], ['no','No']], + 'string_ip' + => [['_allowfrom_','Hostname(s), or IP(s) from which access is allowed'], + ['_denyfrom_','Hostname(s) or IP(s) from which access is disallowed']], ); sub standard_string_options { @@ -3144,10 +3696,10 @@ sub standard_string_options { } sub string_selector { - my ($thistype, $thiskey, $showval, $name) = @_; + my ($thistype, $thiskey, $showval, $name, $readonly) = @_; if (!exists($strings{$thistype})) { - return &default_selector($thiskey,$showval); + return &default_selector($thiskey,$showval,$readonly); } my %skiptype; @@ -3166,17 +3718,23 @@ sub string_selector { $got_chostname = 1; } my $needsnewer=¶meter_releasecheck($name,$parmval,$needsrelease, - $chostname,$cmajor, - $cminor); + $cmajor,$cminor); if ($needsnewer) { $skiptype{$parmval} = 1; } } } } - - my $result; + if ($thistype eq 'string_ip') { + return &string_ip_selector($thiskey,$showval,$readonly); + } + + my ($result,$disabled); + + if ($readonly) { + $disabled = ' disabled="disabled"'; + } my $numinrow = 3; if ($thistype eq 'string_problemstatus') { $numinrow = 2; @@ -3202,7 +3760,7 @@ sub string_selector { $result .= ''. '