Diff for /loncom/interface/lonparmset.pm between versions 1.204 and 1.207

version 1.204, 2005/06/03 15:47:29 version 1.207, 2005/06/04 15:26:13
Line 635  sub print_row { Line 635  sub print_row {
     if ($parmlev eq 'full') {      if ($parmlev eq 'full') {
         my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.          my $sessionval=&Apache::lonnet::EXT('resource.'.$$part{$which}.
                                         '.'.$$name{$which},$$symbp{$rid});                                          '.'.$$name{$which},$$symbp{$rid});
   
 # this doesn't seem to work, and I don't think is correct  
 #    my $sessionvaltype=&Apache::lonnet::EXT('resource.'.$$part{$which}.  
 #                                      '.'.$$name{$which}.'.type',$symbp{$rid});  
 # this seems to work  
         my $sessionvaltype=$typeoutpar[$result];          my $sessionvaltype=$typeoutpar[$result];
         if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }          if (!defined($sessionvaltype)) { $sessionvaltype=$$defaulttype{$which}; }
         $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.          $r->print('<td bgcolor=#999999 align="center"><font color=#FFFFFF>'.
Line 939  sub assessparms { Line 934  sub assessparms {
   
 # ---------------------------------------------------------- Anything to store?  # ---------------------------------------------------------- Anything to store?
     if ($env{'form.pres_marker'}) {      if ($env{'form.pres_marker'}) {
  $message.=&storeparm(split(/\&/,$env{'form.pres_marker'}),          my @markers=split(/\&\&\&/,$env{'form.pres_marker'});
      $env{'form.pres_value'},          my @values=split(/\&\&\&/,$env{'form.pres_value'});
      $env{'form.pres_type'},          my @types=split(/\&\&\&/,$env{'form.pres_type'});
                              $uname,$udom,$csec);   for (my $i=0;$i<=$#markers;$i++) {
       $message.=&storeparm(split(/\&/,$markers[$i]),
    $values[$i],
    $types[$i],
    $uname,$udom,$csec);
    }
 # ---------------------------------------------------------------- Done storing  # ---------------------------------------------------------------- Done storing
  $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';   $message.='<h3>'.&mt('Changes can take up to 10 minutes before being active for all students.').&Apache::loncommon::help_open_topic('Caching').'</h3>';
     }      }
Line 1805  $output Line 1805  $output
 ENDenv  ENDenv
 }  }
 ##################################################  ##################################################
   # Overview mode
   ##################################################
 my $tableopen;  my $tableopen;
   
 sub tablestart {  sub tablestart {
Line 1827  sub tableend { Line 1828  sub tableend {
     }      }
 }  }
   
   sub readdata {
       my ($crs,$dom)=@_;
   # Read coursedata
       my $resourcedata=&Apache::lonnet::get_courseresdata($crs,$dom);
   # Read userdata
   
       my $classlist=&Apache::loncoursedata::get_classlist();
       foreach (keys %$classlist) {
           # the following undefs are for 'domain', and 'username' respectively.
           if ($_=~/^(\w+)\:(\w+)$/) {
       my ($tuname,$tudom)=($1,$2);
       my $useropt=&Apache::lonnet::get_userresdata($tuname,$tudom);
               foreach my $userkey (keys %{$useropt}) {
    if ($userkey=~/^$env{'request.course.id'}/) {
                       my $newkey=$userkey;
       $newkey=~s/^($env{'request.course.id'}\.)/$1\[useropt\:$tuname\:$tudom\]\./;
       $$resourcedata{$newkey}=$$useropt{$userkey};
    }
       }
    }
       }
       return $resourcedata;
   }
   
   sub extractuser {
       my $key=shift;
       return ($key=~/^$env{'request.course.id'}.\[useropt\:(\w+)\:(\w+)\]\./);
   }
   
 sub overview {  sub overview {
     my $r=shift;      my $r=shift;
     my $bodytag=&Apache::loncommon::bodytag(      my $bodytag=&Apache::loncommon::bodytag(
Line 1846  $breadcrumbs Line 1876  $breadcrumbs
 <input type="hidden" name="overview" value="1" />  <input type="hidden" name="overview" value="1" />
 ENDOVER  ENDOVER
 # Setting  # Setting
     my %olddata=&Apache::lonnet::dump('resourcedata',$dom,$crs);  # Set userlevel immediately
   # Do an intermediate store of course level
       my $olddata=&readdata($crs,$dom);
     my %newdata=();      my %newdata=();
     undef %newdata;      undef %newdata;
     my @deldata=();      my @deldata=();
Line 1855  ENDOVER Line 1887  ENDOVER
  if ($_=~/^form\.([a-z]+)\_(.+)$/) {   if ($_=~/^form\.([a-z]+)\_(.+)$/) {
     my $cmd=$1;      my $cmd=$1;
     my $thiskey=$2;      my $thiskey=$2;
       my ($tuname,$tudom)=&extractuser($thiskey);
       my $tkey=$thiskey;
               if ($tuname) {
    $tkey=~s/\.\[useropt\:$tuname\:$tudom\]\./\./;
       }
     if ($cmd eq 'set') {      if ($cmd eq 'set') {
  my $data=$env{$_};   my $data=$env{$_};
  if ($olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }   if ($$olddata{$thiskey} ne $data) { 
       if ($tuname) {
    if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') {
       $r->print('<br />'.&mt('Stored modified parameter for').' '.
         &Apache::loncommon::plainname($tuname,$tudom));
    } else {
       $r->print('<h2><font color="red">'.
         &mt('Error storing parameters').'</font></h2>');
    }
    &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
       } else {
    $newdata{$thiskey}=$data;
                       } 
    }
     } elsif ($cmd eq 'del') {      } elsif ($cmd eq 'del') {
  push (@deldata,$thiskey);   if ($tuname) {
       if (&Apache::lonnet::del('resourcedata',[$tkey],$tudom,$tuname) eq 'ok') {
    $r->print('<br />'.&mt('Deleted parameter for').' '.&Apache::loncommon::plainname($tuname,$tudom));
       } else {
    $r->print('<h2><font color="red">'.
     &mt('Error deleting parameters').'</font></h2>');
       }
       &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
    } else {
       push (@deldata,$thiskey);
    }
     } elsif ($cmd eq 'datepointer') {      } elsif ($cmd eq 'datepointer') {
  my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});   my $data=&Apache::lonhtmlcommon::get_date_from_form($env{$_});
  if (defined($data) and $olddata{$thiskey} ne $data) { $newdata{$thiskey}=$data; }   if (defined($data) and $$olddata{$thiskey} ne $data) { 
       if ($tuname) {
    if (&Apache::lonnet::put('resourcedata',{$tkey=>$data},$tudom,$tuname) eq 'ok') {
       $r->print('<br />'.&mt('Stored modified date for').' '.&Apache::loncommon::plainname($tuname,$tudom));
    } else {
       $r->print('<h2><font color="red">'.
         &mt('Error storing parameters').'</font></h2>');
    }
    &Apache::lonnet::devalidateuserresdata($tuname,$tudom);
       } else {
    $newdata{$thiskey}=$data; 
       }
    }
     }      }
  }   }
     }      }
 # Store  # Store all course level
     my $delentries=$#deldata+1;      my $delentries=$#deldata+1;
     my @newdatakeys=keys %newdata;      my @newdatakeys=keys %newdata;
     my $putentries=$#newdatakeys+1;      my $putentries=$#newdatakeys+1;
Line 1877  ENDOVER Line 1949  ENDOVER
     $r->print('<h2><font color="red">'.      $r->print('<h2><font color="red">'.
       &mt('Error deleting parameters').'</font></h2>');        &mt('Error deleting parameters').'</font></h2>');
  }   }
    &Apache::lonnet::devalidatecourseresdata($crs,$dom);
     }      }
     if ($putentries) {      if ($putentries) {
  if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {   if (&Apache::lonnet::put('resourcedata',\%newdata,$dom,$crs) eq 'ok') {
Line 1885  ENDOVER Line 1958  ENDOVER
     $r->print('<h2><font color="red">'.      $r->print('<h2><font color="red">'.
       &mt('Error storing parameters').'</font></h2>');        &mt('Error storing parameters').'</font></h2>');
  }   }
    &Apache::lonnet::devalidatecourseresdata($crs,$dom);
     }      }
 # Read and display  # Read modified data
     my %resourcedata=&Apache::lonnet::dump('resourcedata',$dom,$crs);  
       my $resourcedata=&readdata($crs,$dom);
   
   # Start list output
   
     my $oldsection='';      my $oldsection='';
     my $oldrealm='';      my $oldrealm='';
     my $oldpart='';      my $oldpart='';
     my $pointer=0;      my $pointer=0;
     $tableopen=0;      $tableopen=0;
     my $foundkeys=0;      my $foundkeys=0;
     foreach my $thiskey (sort keys %resourcedata) {      foreach my $thiskey (sort keys %{$resourcedata}) {
  if ($resourcedata{$thiskey.'.type'}) {   if ($$resourcedata{$thiskey.'.type'}) {
     my ($course,$middle,$part,$name)=      my ($middle,$part,$name)=
  ($thiskey=~/^(\w+)\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);   ($thiskey=~/^$env{'request.course.id'}\.(?:(.+)\.)*([\w\s]+)\.(\w+)$/);
     my $section=&mt('All Students');      my $section=&mt('All Students');
     if ($middle=~/^\[(.*)\]\./) {      if ($middle=~/^\[(.*)\]/) {
  $section=&mt('Group/Section').': '.$1;   my $issection=$1;
  $middle=~s/^\[(.*)\]\.//;   if ($issection=~/^useropt\:(\w+)\:(\w+)/) {
       $section=&mt('User').": ".&Apache::loncommon::plainname($1,$2);
    } else {
       $section=&mt('Group/Section').': '.$issection;
    }
    $middle=~s/^\[(.*)\]//;
     }      }
     $middle=~s/\.$//;      $middle=~s/\.+$//;
       $middle=~s/^\.+//;
     my $realm='<font color="red">'.&mt('All Resources').'</font>';      my $realm='<font color="red">'.&mt('All Resources').'</font>';
     if ($middle=~/^(.+)\_\_\_\(all\)$/) {      if ($middle=~/^(.+)\_\_\_\(all\)$/) {
  $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';   $realm='<font color="green">'.&mt('Folder/Map').': '.&Apache::lonnet::gettitle($1).' <br /><font color="#aaaaaa" size="-2">('.$1.')</font></font>';
Line 1933  ENDOVER Line 2017  ENDOVER
       ':</b></td><td><input type="checkbox" name="del_'.        ':</b></td><td><input type="checkbox" name="del_'.
       $thiskey.'" /></td><td>');        $thiskey.'" /></td><td>');
     $foundkeys++;      $foundkeys++;
     if ($resourcedata{$thiskey.'.type'}=~/^date/) {      if ($$resourcedata{$thiskey.'.type'}=~/^date/) {
  my $jskey='key_'.$pointer;   my $jskey='key_'.$pointer;
  $pointer++;   $pointer++;
  $r->print(   $r->print(
   &Apache::lonhtmlcommon::date_setter('overviewform',    &Apache::lonhtmlcommon::date_setter('overviewform',
       $jskey,        $jskey,
       $resourcedata{$thiskey}).        $$resourcedata{$thiskey}).
 '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'  '<input type="hidden" name="datepointer_'.$thiskey.'" value="'.$jskey.'" />'
   );    );
     } else {      } else {
  $r->print(   $r->print(
   '<input type="text" name="set_'.$thiskey.'" value="'.    '<input type="text" name="set_'.$thiskey.'" value="'.
   $resourcedata{$thiskey}.'">');    $$resourcedata{$thiskey}.'">');
     }      }
     $r->print('</td></tr>');      $r->print('</td></tr>');
  }   }
Line 2149  sub handler { Line 2233  sub handler {
  return OK;   return OK;
     }      }
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
     ['action','state']);      ['action','state',
                                                'pres_marker',
                                                'pres_value',
                                                'pres_type',
                                                'udom','uname']);
   
   
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();

Removed from v.1.204  
changed lines
  Added in v.1.207


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