Diff for /loncom/interface/lonparmset.pm between versions 1.576 and 1.581

version 1.576, 2017/07/10 13:55:36 version 1.581, 2017/07/15 04:58:17
Line 36  lonparmset - Handler to set parameters f Line 36  lonparmset - Handler to set parameters f
   
 =head1 SYNOPSIS  =head1 SYNOPSIS
   
 lonparmset provides an interface to setting course parameters.  lonparmset provides an interface to setting content parameters in a 
   course.
   
 It contains all the code for the "Content and Problem Settings" UI, except  It contains all the code for the "Content and Problem Settings" UI, except
 for the helpers parameter.helper and resettimes.helper, and lonhelper.pm,  for the helpers parameter.helper and resettimes.helper, and lonhelper.pm,
Line 137  javascript function 'pjump'. Line 138  javascript function 'pjump'.
   
 =item print_td()  =item print_td()
   
 =item print_usergroups()  =item check_other_groups()
   
 =item parm_control_group()  =item parm_control_group()
   
Line 846  sub storeparm_by_symb_inner { Line 847  sub storeparm_by_symb_inner {
     my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;      my $courselevelm=$env{'request.course.id'}.'.'.$mapparm;
   
     my $storeunder='';      my $storeunder='';
       my $possreplace='';
     if (($snum==18) || ($snum==4)) { $storeunder=$courselevel; }      if (($snum==18) || ($snum==4)) { $storeunder=$courselevel; }
     if (($snum==17) || ($snum==3)) { $storeunder=$courseleveli; }       if (($snum==17) || ($snum==3)) { 
     if (($snum==16) || ($snum==2)) { $storeunder=$courselevelm; }          $storeunder=$courseleveli;
           $possreplace=$courselevelm; 
       } 
       if (($snum==16) || ($snum==2)) { 
           $storeunder=$courselevelm;
           $possreplace=$courseleveli;
       }
     if (($snum==13) || ($snum==1)) { $storeunder=$courselevelr; }      if (($snum==13) || ($snum==1)) { $storeunder=$courselevelr; }
     if ($snum==12) { $storeunder=$seclevel; }      if ($snum==12) { $storeunder=$seclevel; }
     if ($snum==11) { $storeunder=$secleveli; }      if ($snum==11) { 
     if ($snum==10) { $storeunder=$seclevelm; }          $storeunder=$secleveli;
           $possreplace=$seclevelm; 
       }
       if ($snum==10) { 
           $storeunder=$seclevelm;
           $possreplace=$secleveli;
       }
     if ($snum==9) { $storeunder=$seclevelr; }      if ($snum==9) { $storeunder=$seclevelr; }
     if ($snum==8) { $storeunder=$grplevel; }      if ($snum==8) { $storeunder=$grplevel; }
     if ($snum==7) { $storeunder=$grpleveli; }      if ($snum==7) { 
     if ($snum==6) { $storeunder=$grplevelm; }          $storeunder=$grpleveli;
           $possreplace=$grplevelm;
       }
       if ($snum==6) {
           $storeunder=$grplevelm;
           $possreplace=$grpleveli;
       }
     if ($snum==5) { $storeunder=$grplevelr; }      if ($snum==5) { $storeunder=$grplevelr; }
   
   
Line 875  sub storeparm_by_symb_inner { Line 895  sub storeparm_by_symb_inner {
         &Apache::lonnet::expirespread('','','studentcalc');          &Apache::lonnet::expirespread('','','studentcalc');
         if (($snum==13) || ($snum==9) || ($snum==5)) {          if (($snum==13) || ($snum==9) || ($snum==5)) {
             &Apache::lonnet::expirespread('','','assesscalc',$symb);              &Apache::lonnet::expirespread('','','assesscalc',$symb);
         } elsif (($snum==14) || ($snum==10) || ($snum==6)) {          } elsif (($snum==17) || ($snum==16) || ($snum==11) || ($snum==10) || ($snum==7) || ($snum==6)) {
             &Apache::lonnet::expirespread('','','assesscalc',$map);              &Apache::lonnet::expirespread('','','assesscalc',$map);
         } else {          } else {
             &Apache::lonnet::expirespread('','','assesscalc');              &Apache::lonnet::expirespread('','','assesscalc');
Line 889  sub storeparm_by_symb_inner { Line 909  sub storeparm_by_symb_inner {
             $reply=&Apache::lonnet::cput              $reply=&Apache::lonnet::cput
             ('resourcedata',\%storecontent,$cdom,$cnum);              ('resourcedata',\%storecontent,$cdom,$cnum);
             &log_parmset(\%storecontent);              &log_parmset(\%storecontent);
               if ($possreplace) {
                   my $resdata = &Apache::lonnet::get_courseresdata($cnum,$cdom);
                   if (ref($resdata) eq 'HASH') {
                       if (exists($resdata->{$possreplace})) {
                           if (&Apache::lonnet::del
                               ('resourcedata',[$possreplace,$possreplace.'.type'],$cdom,$cnum) eq 'ok') {
                               &log_parmset({$possreplace => '', $possreplace.'.type' => $ntype},1);   
                           }
                       }
                   }
               }
         }          }
         &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);          &Apache::lonnet::devalidatecourseresdata($cnum,$cdom);
     } else {      } else {
Line 899  sub storeparm_by_symb_inner { Line 930  sub storeparm_by_symb_inner {
         if ($snum==1) {          if ($snum==1) {
             &Apache::lonnet::expirespread              &Apache::lonnet::expirespread
             ($uname,$udom,'assesscalc',$symb);              ($uname,$udom,'assesscalc',$symb);
         } elsif ($snum==2) {          } elsif (($snum==2) || ($snum==3)) {
             &Apache::lonnet::expirespread              &Apache::lonnet::expirespread
             ($uname,$udom,'assesscalc',$map);              ($uname,$udom,'assesscalc',$map);
         } else {          } else {
Line 914  sub storeparm_by_symb_inner { Line 945  sub storeparm_by_symb_inner {
             $reply=&Apache::lonnet::cput              $reply=&Apache::lonnet::cput
             ('resourcedata',\%storecontent,$udom,$uname);              ('resourcedata',\%storecontent,$udom,$uname);
             &log_parmset(\%storecontent,0,$uname,$udom);              &log_parmset(\%storecontent,0,$uname,$udom);
               if ($possreplace) {
                   my $resdata = &Apache::lonnet::get_userresdata($uname,$udom);
                   if (ref($resdata) eq 'HASH') {
                       if (exists($resdata->{$possreplace})) {
                           if (&Apache::lonnet::del
                               ('resourcedata',[$possreplace,$possreplace.'.type'],$udom,$uname) eq 'ok') {
                               &log_parmset({$possreplace => '',$possreplace.'.type' => $ntype},1,
                                             $uname,$udom);
                           }
                       }
                   }
               }
         }          }
         &Apache::lonnet::devalidateuserresdata($uname,$udom);          &Apache::lonnet::devalidateuserresdata($uname,$udom);
     }      }
Line 1022  sub valout { Line 1065  sub valout {
 # @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change.  # @param {string} $marker - identifier for the parameter, "resource id&part_parameter name&level", will be passed as pres_marker when the user submits a change.
 # @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres')  # @param {string} $return - prefix for the name of the form and field names that will be used to submit the form ('parmform.pres')
 # @param {string} $call - javascript function to call to submit the form ('psub')  # @param {string} $call - javascript function to call to submit the form ('psub')
   # @param {boolean} $recursive - true if link is for a map/folder where parameter is currently set to be recursive. 
 sub plink {  sub plink {
     my ($type,$dis,$value,$marker,$return,$call)=@_;      my ($type,$dis,$value,$marker,$return,$call,$recursive)=@_;
     my $winvalue=$value;      my $winvalue=$value;
     unless ($winvalue) {      unless ($winvalue) {
         if (&isdateparm($type)) {          if (&isdateparm($type)) {
Line 1045  sub plink { Line 1089  sub plink {
     return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.      return '<table width="100%"><tr valign="top" align="right"><td><a name="'.$unencmarker.'" /></td></tr><tr><td align="center">'.
     '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"      '<a href="javascript:pjump('."'".$type."','".$dis."','".$winvalue."','"
         .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.          .$marker."','".$return."','".$call."','".$hour."','".$min."','".$sec."'".');">'.
         $valout.'</a></td></tr></table>';          $valout.'</a></td></tr>'.($recursive?'<tr><td align="center" class="LC_parm_recursive">'.
                                                 &mt('recursive').'</td></tr>' : '').'</table>';
   
 }  }
   
 # Javascript for table mode.  # Javascript for table mode.
Line 1425  sub print_row { Line 1471  sub print_row {
     $thismarker=~s/^parameter\_//;      $thismarker=~s/^parameter\_//;
     my $mprefix=$rid.'&'.$thismarker.'&';      my $mprefix=$rid.'&'.$thismarker.'&';
     my $effective_parm = &valout($outpar[$result],$typeoutpar[$result],$thismarker);      my $effective_parm = &valout($outpar[$result],$typeoutpar[$result],$thismarker);
     my ($othergrp,$grp_parm,$controlgrp);      my ($othergrp,$grp_parm,$controlgrp,$effparm_rec);
       if ($result == 17 || $result == 11 || $result == 7 || $result == 3) {
           $effparm_rec = 1;
       }
     if ($parmlev eq 'general') {      if ($parmlev eq 'general') {
         if ($uname) {          if ($uname) {
             &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
Line 1439  sub print_row { Line 1487  sub print_row {
         }          }
     } elsif ($parmlev eq 'map') {      } elsif ($parmlev eq 'map') {
         if ($uname) {          if ($uname) {
             &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1); 
             &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);   
         } elsif ($cgroup) {          } elsif ($cgroup) {
             &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);              &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1);
             &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);  
         } elsif ($csec) {          } elsif ($csec) {
             &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
             &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);  
         } else {          } else {
             &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
             &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);  
         }          }
     } else {      } else {
         if ($uname) {          if ($uname) {
             if (@{$usersgroups} > 1) {              if (@{$usersgroups} > 1) {
                 my ($coursereply,$grp_parm,$controlgrp);                  my ($coursereply,$grp_parm,$controlgrp);
                 ($coursereply,$othergrp,$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);                         $rid,$cgroup,$defbgone,$usersgroups,$result,$courseopt);
                 if ($coursereply && $result > 4) {                  if ($coursereply && $result > 4) {
                     if (defined($controlgrp)) {                      if (defined($controlgrp)) {
Line 1470  sub print_row { Line 1514  sub print_row {
         }          }
   
         &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);          &print_td($r,18,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
         &print_td($r,17,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);          &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
         &print_td($r,16,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);  
         &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);          &print_td($r,15,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
         &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);          &print_td($r,14,'#FFDDDD',$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
         &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);          &print_td($r,13,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
   
         if ($csec) {          if ($csec) {
             &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,12,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
             &print_td($r,11,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
             &print_td($r,10,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);  
             &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,9,$defbgtwo,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
         }          }
   
         if ($cgroup) {          if ($cgroup) {
             &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);              &print_td($r,8,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);
             &print_td($r,7,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);              &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly,1);
             &print_td($r,6,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp,$readonly);  
             &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly);              &print_td($r,5,$defbgthree,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,$noeditgrp.$readonly);
         }          }
   
Line 1495  sub print_row { Line 1536  sub print_row {
                 $r->print($othergrp);                  $r->print($othergrp);
             }              }
             &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,4,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
             &print_td($r,3,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly,1);
             &print_td($r,2,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);  
             &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);              &print_td($r,1,$defbgone,$result,\@outpar,$mprefix,$which,\@typeoutpar,$display,'',$readonly);
         }          }
   
     } # end of $parmlev if/else      } # end of $parmlev if/else
     $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.'</td>');      $r->print('<td style="background-color:#CCCCFF;" align="center">'.$effective_parm.
                 ($effparm_rec?'<br /><span class="LC_parm_recursive">'.&mt('recursive').
                               '</span>':'').'</td>');
   
     if ($parmlev eq 'full') {      if ($parmlev eq 'full') {
         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.          my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
Line 1535  sub print_row { Line 1577  sub print_row {
 # @param {hash reference} $display - parameter key -> full title for the parameter  # @param {hash reference} $display - parameter key -> full title for the parameter
 # @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters  # @param {boolean} $noeditgrp - true if no edit is allowed for group level parameters
 # @param {boolean} $readonly -true if editing not allowed.  # @param {boolean} $readonly -true if editing not allowed.
   # @param {boolean} $ismaplevel - true if level is for a map. 
 sub print_td {  sub print_td {
     my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,$noeditgrp,$readonly)=@_;      my ($r,$which,$defbg,$result,$outpar,$mprefix,$value,$typeoutpar,$display,
     $r->print('<td style="background-color:'.(($result==$which)?'#AAFFAA':$defbg).          $noeditgrp,$readonly,$ismaplevel)=@_;
       my ($ineffect,$recursive,$currval,$currtype,$currlevel);
       $ineffect = 0;
       $currval = $$outpar[$which];
       $currtype = $$typeoutpar[$which];
       $currlevel = $which;
       if (($result) && ($result == $which)) {
           $ineffect = 1;
       } 
       if ($ismaplevel) {
           if ($mprefix =~ /(hiddenresource|encrypturl)\&/) {
               if (($result) && ($result == $which)) {
                   $recursive = 1;
               }
           } elsif ($$outpar[$which+1] ne '') {
               $recursive = 1;
               $currlevel = $which+1;
               $currval = $$outpar[$currlevel];
               $currtype = $$typeoutpar[$currlevel];
               if (($result) && ($result == $currlevel)) {
                   $ineffect = 1;
               }
           }
       }
       $r->print('<td style="background-color:'.($ineffect?'#AAFFAA':$defbg).
               ';" align="center">');                ';" align="center">');
     my $nolink = 0;      my $nolink = 0;
     if ($readonly) {      if ($readonly) {
         $nolink = 1;          $nolink = 1;
     } else {       } else { 
         if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&/) {          if ($which == 14 || $which == 15 || $mprefix =~ /mapalias\&$/) {
             $nolink = 1;              $nolink = 1;
         } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {          } elsif (($env{'request.course.sec'} ne '') && ($which > 12)) {
             $nolink = 1;              $nolink = 1;
Line 1559  sub print_td { Line 1626  sub print_td {
             unless ($which == 2) {              unless ($which == 2) {
                 $nolink = 1;                  $nolink = 1;
             }              }
         } elsif ($mprefix =~ /(encrypturl|hiddenresource)/) {  
             if ($which == 16 || $which == 10 || $which == 6 || $which == 2) {  
                 $nolink = 1;  
             }  
         }          }
     }      }
     if ($nolink) {      if ($nolink) {
         $r->print(&valout($$outpar[$which],$$typeoutpar[$which],$mprefix));          my ($parmname)=((split(/\&/,$mprefix))[1]=~/\_([^\_]+)$/);
 # FIXME: probably a good thing that mprefix is not used in valout, because it does not look like a parameter name !          $r->print(&valout($currval,$currtype,$parmname));
     } else {      } else {
         $r->print(&plink($$typeoutpar[$which],          $r->print(&plink($currtype,
                          $$display{$value},$$outpar[$which],                           $$display{$value},$currval,
                          $mprefix."$which",'parmform.pres','psub'));                           $mprefix.$currlevel,'parmform.pres','psub',$recursive));
     }      }
     $r->print('</td>'."\n");      $r->print('</td>'."\n");
 }  }
   
 # FIXME: Despite the name, this does not print anything, the $r parameter is unused.  
 # Returns HTML and other info for the cell added when a user is selected  # Returns HTML and other info for the cell added when a user is selected
 # and that user is in several groups. This is the cell with the title "Control by other group".  # and that user is in several groups. This is the cell with the title "Control by other group".
 #  #
 # @param {Apache2::RequestRec} $r - the Apache request (unused)  
 # @param {string} $what - parameter part.'.'.parameter name  # @param {string} $what - parameter part.'.'.parameter name
 # @param {string} $rid - resource id  # @param {string} $rid - resource id
 # @param {string} $cgroup - group name  # @param {string} $cgroup - group name
Line 1589  sub print_td { Line 1650  sub print_td {
 # @param {integer} $result - level  # @param {integer} $result - level
 # @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db)  # @param {hash reference} $courseopt - course parameters hash (result of lonnet::get_courseresdata, dump of course's resourcedata.db)
 # @returns {Array} - array (parameter value for the other group, HTML for the cell, HTML with the value, name of the other group)  # @returns {Array} - array (parameter value for the other group, HTML for the cell, HTML with the value, name of the other group)
 sub print_usergroups {  sub check_other_groups {
     my ($r,$what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;      my ($what,$rid,$cgroup,$defbg,$usersgroups,$result,$courseopt) = @_;
     my $courseid = $env{'request.course.id'};      my $courseid = $env{'request.course.id'};
     my $output;      my $output;
     my $symb = &symbcache($rid);      my $symb = &symbcache($rid);
Line 1606  sub print_usergroups { Line 1667  sub print_usergroups {
     if (($coursereply) && ($cgroup ne $resultgroup)) {      if (($coursereply) && ($cgroup ne $resultgroup)) {
         if ($result > 3) {          if ($result > 3) {
             $bgcolor = '#AAFFAA';              $bgcolor = '#AAFFAA';
             $grp_parm = &valout($coursereply,$resulttype,$what);  
         }          }
         $grp_parm = &valout($coursereply,$resulttype,$what);          $grp_parm = &valout($coursereply,$resulttype,$what);
         $output = '<td style="background-color:'.$bgcolor.';" align="center">';          $output = '<td style="background-color:'.$bgcolor.';" align="center">';
Line 1623  sub print_usergroups { Line 1683  sub print_usergroups {
 }  }
   
 # Looks for a group with a defined parameter for given user and parameter.  # Looks for a group with a defined parameter for given user and parameter.
 # Used by print_usergroups.  # Used by check_other_groups.
 #  #
 # @param {string} $courseid - the course id  # @param {string} $courseid - the course id
 # @param {array reference} $usersgroups - list of groups the user belongs to, if any  # @param {array reference} $usersgroups - list of groups the user belongs to, if any
Line 1784  sub isdateparm { Line 1844  sub isdateparm {
 }  }
   
 # Prints the HTML and Javascript to select parameters, with various shortcuts.  # Prints the HTML and Javascript to select parameters, with various shortcuts.
 # FIXME: remove unused parameters  
 #  #
 # @param {Apache2::RequestRec} $r - the Apache request (unused)  # @param {Apache2::RequestRec} $r - the Apache request
 # @param {hash reference} $allparms - hash parameter name -> parameter title  
 # @param {array reference} $pscat - list of selected parameter names (unused)  
 # @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused)  
 sub parmmenu {  sub parmmenu {
     my ($r,$allparms,$pscat,$keyorder)=@_;      my ($r)=@_;
     my $tempkey;  
     $r->print(<<ENDSCRIPT);      $r->print(<<ENDSCRIPT);
 <script type="text/javascript">  <script type="text/javascript">
 // <![CDATA[  // <![CDATA[
Line 1869  sub parmmenu { Line 1924  sub parmmenu {
 ENDSCRIPT  ENDSCRIPT
   
     $r->print('<hr />');      $r->print('<hr />');
     &shortCuts($r,$allparms,$pscat,$keyorder);      &shortCuts($r);
     $r->print('<hr />');      $r->print('<hr />');
 }  }
   
Line 2050  sub parmboxes { Line 2105  sub parmboxes {
 }  }
   
 # Prints HTML with shortcuts to select groups of parameters in one click, or deselect all.  # Prints HTML with shortcuts to select groups of parameters in one click, or deselect all.
 # FIXME: remove unused parameters  
 #  #
 # @param {Apache2::RequestRec} $r - the Apache request  # @param {Apache2::RequestRec} $r - the Apache request
 # @param {hash reference} $allparms - hash parameter name -> parameter title (unused)  
 # @param {array reference} $pscat - list of selected parameter names (unused)  
 # @param {hash reference} $keyorder - hash parameter key -> appearance rank (unused)  
 sub shortCuts {  sub shortCuts {
     my ($r,$allparms,$pscat,$keyorder)=@_;      my ($r)=@_;
   
     # Parameter Selection      # Parameter Selection
     $r->print(      $r->print(
Line 2250  function group_or_section(caller) { Line 2301  function group_or_section(caller) {
 # @param {Apache2::RequestRec} $r - the Apache request  # @param {Apache2::RequestRec} $r - the Apache request
 # @param {hash reference} $allparms - hash parameter name -> parameter title  # @param {hash reference} $allparms - hash parameter name -> parameter title
 # @param {array reference} $pscat - list of selected parameter names  # @param {array reference} $pscat - list of selected parameter names
 # @param {array reference} $psprt - list of selected parameter parts (unused)  
 # @param {hash reference} $keyorder - hash parameter key -> appearance rank  # @param {hash reference} $keyorder - hash parameter key -> appearance rank
 # @param {string} [$divid] - name used to give an id to the HTML element for the scroll box  # @param {string} [$divid] - name used to give an id to the HTML element for the scroll box
 sub displaymenu {  sub displaymenu {
     my ($r,$allparms,$pscat,$psprt,$keyorder,$divid)=@_;      my ($r,$allparms,$pscat,$keyorder,$divid)=@_;
   
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parameters to View')));
   
     &parmmenu($r,$allparms,$pscat,$keyorder); # only $allparms is used by parmmenu      &parmmenu($r);
     $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));      $r->print(&Apache::loncommon::start_scrollbox('480px','440px','200px',$divid));
     &parmboxes($r,$allparms,$pscat,$keyorder);      &parmboxes($r,$allparms,$pscat,$keyorder);
     $r->print(&Apache::loncommon::end_scrollbox());      $r->print(&Apache::loncommon::end_scrollbox());
Line 3043  ENDPARMSELSCRIPT Line 3093  ENDPARMSELSCRIPT
   
         # Step 2          # Step 2
         $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));          $r->print(&Apache::lonhtmlcommon::topic_bar(2,&mt('Parameter Specification'),'parmstep2'));
         &displaymenu($r,\%allparms,\@pscat,\@psprt,\%keyorder,'parmmenuscroll');          &displaymenu($r,\%allparms,\@pscat,\%keyorder,'parmmenuscroll');
   
         # Step 3          # Step 3
         $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));          $r->print(&Apache::lonhtmlcommon::topic_bar(3,&mt('User Specification (optional)'),'parmstep3'));
Line 3119  ENDPARMSELSCRIPT Line 3169  ENDPARMSELSCRIPT
 #  #
 # This produces the cascading table output of parameters  # This produces the cascading table output of parameters
 #  #
             my $coursespan=$csec?10:6;              my $coursespan=$csec?8:5;
             my $userspan=4;              my $userspan=3;
             if ($cgroup ne '') {              if ($cgroup ne '') {
                 $coursespan += 4;                  $coursespan += 3;
             }              }
   
             $r->print(&Apache::loncommon::start_data_table());              $r->print(&Apache::loncommon::start_data_table());
Line 3152  ENDPARMSELSCRIPT Line 3202  ENDPARMSELSCRIPT
                 'femof'  => 'from Enclosing Map or Folder',                  'femof'  => 'from Enclosing Map or Folder',
                 'gen'    => 'general',                  'gen'    => 'general',
                 'foremf' => 'for Enclosing Map or Folder',                  'foremf' => 'for Enclosing Map or Folder',
                 'formfr' => 'for Map or Folder (recursive)',  
                 'fr'     => 'for Resource'                  'fr'     => 'for Resource'
             );              );
             $r->print(<<ENDTABLETWO);              $r->print(<<ENDTABLETWO);
 <th rowspan="3">$lt{'pie'}</th>  <th rowspan="3">$lt{'pie'}</th>
 <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>  <th rowspan="3">$lt{'csv'}<br />($csuname:$csudom)</th>
 </tr><tr><td colspan="5"></td><th colspan="3">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>  </tr><tr><td colspan="5"></td><th colspan="2">$lt{'ic'}</th><th colspan="2">$lt{'rl'}</th>
 <th colspan="1">$lt{'ic'}</th>  <th colspan="1">$lt{'ic'}</th>
   
 ENDTABLETWO  ENDTABLETWO
             if ($csec) {              if ($csec) {
                 $r->print('<th colspan="4">'.                  $r->print('<th colspan="3">'.
                 &mt("in Section")." $csec</th>");                  &mt("in Section")." $csec</th>");
             }              }
             if ($cgroup) {              if ($cgroup) {
                 $r->print('<th colspan="4">'.                  $r->print('<th colspan="3">'.
                 &mt("in Group")." $cgroup</th>");                  &mt("in Group")." $cgroup</th>");
             }              }
             $r->print(<<ENDTABLEHEADFOUR);              $r->print(<<ENDTABLEHEADFOUR);
 </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>  </tr><tr><th>$lt{'aut'}</th><th>$lt{'type'}</th>
 <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>  <th>$lt{'emof'}</th><th>$lt{'part'}</th><th>$lt{'pn'}</th>
 <th>$lt{'gen'}</th><th>$lt{'formfr'}</th><th>$lt{'foremf'}</th>  <th>$lt{'gen'}</th><th>$lt{'foremf'}</th>
 <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>  <th>$lt{'def'}</th><th>$lt{'femof'}</th><th>$lt{'fr'}</th>
 ENDTABLEHEADFOUR  ENDTABLEHEADFOUR
   
             if ($csec) {              if ($csec) {
                 $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');                  $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
             }              }
   
             if ($cgroup) {              if ($cgroup) {
                 $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.&mt('foremf').'</th><th>'.$lt{'fr'}.'</th>');                  $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
             }              }
   
             if ($uname) {              if ($uname) {
                 if (@usersgroups > 1) {                  if (@usersgroups > 1) {
                     $r->print('<th>'.&mt('Control by other group?').'</th>');                      $r->print('<th>'.&mt('Control by other group?').'</th>');
                 }                  }
                 $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'formfr'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');                  $r->print('<th>'.$lt{'gen'}.'</th><th>'.$lt{'foremf'}.'</th><th>'.$lt{'fr'}.'</th>');
             }              }
   
             $r->print('</tr>');              $r->print('</tr>');
Line 3410  ENDTABLEHEADFOUR Line 3459  ENDTABLEHEADFOUR
                 $r->print('<p>'.&Apache::loncommon::start_data_table()                  $r->print('<p>'.&Apache::loncommon::start_data_table()
                          .&Apache::loncommon::start_data_table_header_row()                           .&Apache::loncommon::start_data_table_header_row()
                          .'<th>'.&mt('Parameter Name').'</th>'                           .'<th>'.&mt('Parameter Name').'</th>'
                          .'<th>'.&mt('Recursive Value').'</th>'                           .'<th>'.&mt('Value').'</th>'
                          .'<th>'.&mt('Non-Recursive Value').'</th>'  
                          .'<th>'.&mt('Parameter in Effect').'</th>'                           .'<th>'.&mt('Parameter in Effect').'</th>'
                          .&Apache::loncommon::end_data_table_header_row()                           .&Apache::loncommon::end_data_table_header_row()
                 );                  );
Line 5050  ENDOVER Line 5098  ENDOVER
   
     $r->print('<div class="LC_Box">');      $r->print('<div class="LC_Box">');
     $r->print('<div>');      $r->print('<div>');
     &displaymenu($r,\%allparms,\@pscat,\%keyorder); # FIXME: wrong parameters, could make keysindisplayorderCategory crash because $keyorder is undefined      &displaymenu($r,\%allparms,\@pscat,\%keyorder);
     $r->print(&Apache::lonhtmlcommon::start_pick_box());      $r->print(&Apache::lonhtmlcommon::start_pick_box());
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Parts to View')));
     my $sectionselector = &sectionmenu(\@selected_sections);      my $sectionselector = &sectionmenu(\@selected_sections);
Line 5296  ENDOVER Line 5344  ENDOVER
                 $r->print(&mt('All users'));                  $r->print(&mt('All users'));
             } elsif ($data{'scope_type'} eq 'user') {              } elsif ($data{'scope_type'} eq 'user') {
                 $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));                  $r->print(&mt('User: [_1]',join(':',@{$data{'scope'}})));
             } elsif ($data{'scope_type'} eq 'section') {              } elsif ($data{'scope_type'} eq 'secgroup') {
                 $r->print(&mt('Section: [_1]',$data{'scope'}));                  $r->print(&mt('Group/Section: [_1]',$data{'scope'}));
             } elsif ($data{'scope_type'} eq 'group') {  
                 $r->print(&mt('Group: [_1]',$data{'scope'}));  
             }              }
             $r->print('<br />');              $r->print('<br />');
             if ($data{'realm_type'} eq 'all') {              if ($data{'realm_type'} eq 'all') {
Line 5406  sub parse_key { Line 5452  sub parse_key {
             $data{'scope_type'} = 'user';              $data{'scope_type'} = 'user';
             $data{'scope'} = [$1,$2];              $data{'scope'} = [$1,$2];
         } else {          } else {
             #FIXME check for group scope              $data{'scope_type'} = 'secgroup';
             $data{'scope_type'} = 'section';  
         }          }
         $middle=~s/^\[(.*)\]//;          $middle=~s/^\[(.*)\]//;
     }      }
Line 5801  sub addmetafield { Line 5846  sub addmetafield {
             $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');              $r->print('You may undelete previously deleted fields.<br />Check those you wish to undelete and click Undelete.<br />');
             $r->print('<form method="post" action="">');              $r->print('<form method="post" action="">');
             foreach my $key(keys(%$fields)) {              foreach my $key(keys(%$fields)) {
                 $r->print('<input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'<br /');                  $r->print('<label><input type="checkbox" name="undeletefield" value="'.$key.'" />'.$$fields{$key}.'</label><br /');
             }              }
             $r->print('<input type="submit" name="undelete" value="Undelete" />');              $r->print('<input type="submit" name="undelete" value="Undelete" />');
             $r->print('</form>');              $r->print('</form>');
         }          }
         $r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.<form method="post" action="/adm/parmset?action=addmetadata">');          $r->print('<hr /><strong>Or</strong> you may enter a new metadata field name.'.
                     '<form method="post" action="/adm/parmset?action=addmetadata">');
         $r->print('<input type="text" name="fieldname" /><br />');          $r->print('<input type="text" name="fieldname" /><br />');
         $r->print('<input type="submit" value="Add Metadata Field" />');          $r->print('<input type="submit" value="Add Metadata Field" />');
           $r->print('</form>');
     }      }
     $r->print('</form>');  
     &endSettingsScreen($r);      &endSettingsScreen($r);
 }  }
   
Line 6133  ENDYESNO Line 6179  ENDYESNO
 # $issection - section or group name  # $issection - section or group name
 # $realmdescription - title for the parameter level and resource (without using HTML)  # $realmdescription - title for the parameter level and resource (without using HTML)
 #  #
 # FIXME: remove unused fields.  
 #  
 # @param {string} $key - parameter log key  # @param {string} $key - parameter log key
 # @param {string} $uname - user name  # @param {string} $uname - user name
 # @param {string} $udom - user domain  # @param {string} $udom - user domain
 # @param {string} $exeuser - unused  
 # @param {string} $exedomain - unused  
 # @param {boolean} $typeflag - .type log entry  # @param {boolean} $typeflag - .type log entry
 # @returns {Array}  # @returns {Array}
 sub components {  sub components {
     my ($key,$uname,$udom,$exeuser,$exedomain,$typeflag)=@_;      my ($key,$uname,$udom,$typeflag)=@_;
   
     if ($typeflag) {      if ($typeflag) {
         $key=~s/\.type$//;          $key=~s/\.type$//;
Line 6358  sub parm_change_log { Line 6400  sub parm_change_log {
             my $typeflag = ($changed =~/\.type$/ &&              my $typeflag = ($changed =~/\.type$/ &&
                     !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));                      !exists($parmlog{$id}{'logentry'}{$changed.'.type'}));
             my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=              my ($realm,$section,$parmname,$part,$what,$middle,$uname,$udom,$issection,$realmdescription)=
                 &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},undef,undef,$typeflag);                  &components($changed,$parmlog{$id}{'uname'},$parmlog{$id}{'udom'},$typeflag);
             if ($env{'request.course.sec'} ne '') {              if ($env{'request.course.sec'} ne '') {
                 next if (($issection ne '') && ($issection ne $env{'request.course.sec'}));                  next if (($issection ne '') && ($issection ne $env{'request.course.sec'}));
                 if ($uname ne '') {                  if ($uname ne '') {

Removed from v.1.576  
changed lines
  Added in v.1.581


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>