Diff for /loncom/interface/lonparmset.pm between versions 1.493 and 1.497

version 1.493, 2010/02/15 00:17:12 version 1.497, 2010/06/16 14:26:18
Line 248  Variables used (guessed by Jeremy): Line 248  Variables used (guessed by Jeremy):
   
 =item parse_key()  =item parse_key()
   
 =item check_cloners() :  
   
 Checks if new users included in list of allowed cloners  
 are valid users.  Replaces supplied list with   
 cleaned list containing only users with valid usernames  
 and domains.  
   
 Inputs: $clonelist, $oldcloner   
 where $clonelist is ref to array of requested cloners,  
 and $oldcloner is ref to array of currently allowed  
 cloners.  
   
 Returns: string - comma separated list of requested  
 cloners (username:domain) who do not exist in system.  
   
 =item change_clone() :  
   
 Modifies the list of courses a user can clone (stored  
 in the user's environment.db file), called when a  
 change is made to the list of users allowed to clone  
 a course.  
   
 Inputs: $action,$cloner  
 where $action is add or drop, and $cloner is identity of   
 user for whom cloning ability is to be changed in course.   
   
   
 =item check_cloners()  
   
 =item change_clone()  
   
 =item header()  =item header()
   
 Output html header for page  Output html header for page
Line 1767  sub mapmenu { Line 1736  sub mapmenu {
     $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"'));      $r->print(&Apache::lonhtmlcommon::row_title(&mt('Select Enclosing Map or Folder'),'','',' id="mapmenu"'));
     if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {      if ((ref($tree) eq 'ARRAY') && (ref($treeinfo) eq 'HASH')) {
         my $icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';          my $icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" />';
         $r->print(&Apache::loncommon::start_data_table()          my $whitespace =
                  .&Apache::loncommon::start_data_table_row()              '<img src="'
              .&Apache::loncommon::lonhttpdurl('/adm/lonIcons/whitespace_21.gif')
              .'" alt="" />';
   
           $r->print(&Apache::loncommon::start_data_table());
   
           # Display row: "All Maps and Folders"
           $r->print(&Apache::loncommon::start_data_table_row()
                  .'<td>'.$icon                   .'<td>'.$icon
                  .'<label>&nbsp;'                   .'<label>'
                  .'<input type="radio" name="pschp" checked="checked" value="all" />'                   .'<input type="radio" name="pschp"'
           );
           $r->print(' checked="checked"') if ($pschp eq 'all' || !$pschp);
           $r->print( ' value="all" />'
                  .&mt('All Maps or Folders')                   .&mt('All Maps or Folders')
                  .'</label></td>'                   .'</label></td>'
                  .&Apache::loncommon::end_data_table_row()                   .&Apache::loncommon::end_data_table_row()
         );          );
         my $whitespace = '<img src="'  
                         .&Apache::loncommon::lonhttpdurl("/adm/lonIcons/whitespace_21.gif")          # Display row: "Main Course Documents"
                         .'" alt="" />';  
         if (exists($$allmaps{1})) {          if (exists($$allmaps{1})) {
             $r->print(&Apache::loncommon::start_data_table_row()              $r->print(&Apache::loncommon::start_data_table_row()
                 .'<td>'.$icon                  .'<td>'.$icon
                 .'<label>&nbsp;'                  .'<label>'
                 .'<input type="radio" name="pschp" value="1"'                  .'<input type="radio" name="pschp" value="1"'
             );              );
             if ($pschp eq 1) {              $r->print(' checked="checked"') if ($pschp eq '1');
                 $r->print(' checked="checked"');  
             }  
             $r->print('/>'              $r->print('/>'
                 .$$maptitles{1}                  .$$maptitles{1}
                 .($$allmaps{1} !~/^uploaded/?' ['.$$allmaps{1}.']':'')                  .($$allmaps{1} !~/^uploaded/?' ['.$$allmaps{1}.']':'')
Line 1796  sub mapmenu { Line 1772  sub mapmenu {
                 .&Apache::loncommon::end_data_table_row()                  .&Apache::loncommon::end_data_table_row()
             );              );
         }          }
   
           # Display rows for all course maps and folders
         foreach my $id (@{$tree}) {          foreach my $id (@{$tree}) {
             my ($mapid,$resid)=split(/\./,$id);              my ($mapid,$resid)=split(/\./,$id);
             # Indentation              # Indentation
Line 1813  sub mapmenu { Line 1791  sub mapmenu {
             $symb_name = $tail;              $symb_name = $tail;
             $r->print(&Apache::loncommon::start_data_table_row()              $r->print(&Apache::loncommon::start_data_table_row()
                      .'<td>'.$indent.$icon                       .'<td>'.$indent.$icon
                      .'<label>&nbsp;'                       .'<label>'
                      .'<input type ="radio" name="pschp" value="'.$allmaps_inverted{$symb_name}.'"'                       .'<input type ="radio" name="pschp" value="'.$allmaps_inverted{$symb_name}.'"'
             );              );
             if ($pschp eq $allmaps_inverted{$symb_name}) {              if ($allmaps_inverted{$symb_name} && $pschp) {
                 $r->print(' checked="checked"');                  if ($allmaps_inverted{$symb_name} eq $pschp) {
                       $r->print(' checked="checked"');
                   }
             }              }
             $r->print('/>'              $r->print('/>'
                      .$treeinfo->{$id}->{name}                       .$treeinfo->{$id}->{name}
Line 1827  sub mapmenu { Line 1807  sub mapmenu {
                      .&Apache::loncommon::end_data_table_row()                       .&Apache::loncommon::end_data_table_row()
             );              );
         }          }
   
         $r->print(&Apache::loncommon::end_data_table());          $r->print(&Apache::loncommon::end_data_table());
     }      }
 }  }
Line 3020  sub date_interval_selector { Line 3001  sub date_interval_selector {
     my %select = ((map {$_ => $_} (0..$max)),      my %select = ((map {$_ => $_} (0..$max)),
               'select_form_order' => [0..$max]);                'select_form_order' => [0..$max]);
     $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,      $result .= &Apache::loncommon::select_form($amount,$name.'_'.$thiskey,
                            %select);                             \%select);
     $result .= ' '.&mt($name);      $result .= ' '.&mt($name);
     }      }
     $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';      $result .= '<input type="hidden" name="dateinterval_'.$thiskey.'" />';
Line 3503  sub parse_key { Line 3484  sub parse_key {
 }  }
   
   
   
 sub extract_cloners {  
     my ($clonelist,$allowclone) = @_;  
     if ($clonelist =~ /,/) {  
         @{$allowclone} = split(/,/,$clonelist);  
     } else {  
         $$allowclone[0] = $clonelist;  
     }  
 }  
   
 sub check_cloners {  
     my ($clonelist,$oldcloner) = @_;  
     my ($clean_clonelist,%disallowed);  
     my @allowclone = ();  
     &extract_cloners($$clonelist,\@allowclone);  
     foreach my $currclone (@allowclone) {  
         if (!grep(/^\Q$currclone\E$/,@$oldcloner)) {  
             if ($currclone eq '*') {  
                 $clean_clonelist .= $currclone.',';  
             } else {  
                 my ($uname,$udom) = split(/:/,$currclone);  
                 if ($uname eq '*') {  
                     if ($udom =~ /^$match_domain$/) {  
                         if (!&Apache::lonnet::domain($udom)) {  
                             $disallowed{'domain'} .= $currclone.',';  
                         } else {  
                             $clean_clonelist .= $currclone.',';  
                         }  
                     } else {  
                         $disallowed{'format'} .= $currclone.',';  
                     }  
                 } elsif ($currclone !~/^($match_username)\:($match_domain)$/) {  
                     $disallowed{'format'} .= $currclone.',';  
                 } else {  
                     if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {  
                         $disallowed{'newuser'} .= $currclone.',';  
                     } else {  
                         $clean_clonelist .= $currclone.',';  
                     }  
                 }  
             }  
         } else {  
             $clean_clonelist .= $currclone.',';  
         }  
     }  
     foreach my $key (keys(%disallowed)) {  
         $disallowed{$key} =~ s/,$//;  
     }  
     if ($clean_clonelist) {  
         $clean_clonelist =~ s/,$//;  
     }  
     $$clonelist = $clean_clonelist;  
     return %disallowed;  
 }  
   
 sub change_clone {  
     my ($clonelist,$oldcloner) = @_;  
     my ($uname,$udom);  
     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};  
     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};  
     my $clone_crs = $cnum.':'.$cdom;  
   
     if ($cnum && $cdom) {  
         my @allowclone;  
         &extract_cloners($clonelist,\@allowclone);  
         foreach my $currclone (@allowclone) {  
             if (!grep(/^$currclone$/,@$oldcloner)) {  
                 if ($currclone ne '*') {  
                     ($uname,$udom) = split(/:/,$currclone);  
                     if ($uname && $udom && $uname ne '*') {  
                         if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {  
                             my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');  
                             if ($currclonecrs{'cloneable'} !~ /\Q$clone_crs\E/) {  
                                 if ($currclonecrs{'cloneable'} eq '') {  
                                     $currclonecrs{'cloneable'} = $clone_crs;  
                                 } else {  
                                     $currclonecrs{'cloneable'} .= ','.$clone_crs;  
                                 }  
                                 &Apache::lonnet::put('environment',\%currclonecrs,$udom,$uname);  
                             }  
                         }  
                     }  
                 }  
             }  
         }  
         foreach my $oldclone (@$oldcloner) {  
             if (!grep(/^\Q$oldclone\E$/,@allowclone)) {  
                 if ($oldclone ne '*') {  
                     ($uname,$udom) = split(/:/,$oldclone);  
                     if ($uname && $udom && $uname ne '*' ) {  
                         if (&Apache::lonnet::homeserver($uname,$udom) ne 'no_host') {  
                             my %currclonecrs = &Apache::lonnet::dump('environment',$udom,$uname,'cloneable');  
                             my %newclonecrs = ();  
                             if ($currclonecrs{'cloneable'} =~ /\Q$clone_crs\E/) {  
                                 if ($currclonecrs{'cloneable'} =~ /,/) {  
                                     my @currclonecrs = split/,/,$currclonecrs{'cloneable'};  
                                     foreach my $crs (@currclonecrs) {  
                                         if ($crs ne $clone_crs) {  
                                             $newclonecrs{'cloneable'} .= $crs.',';  
                                         }  
                                     }  
                                     $newclonecrs{'cloneable'} =~ s/,$//;  
                                 } else {  
                                     $newclonecrs{'cloneable'} = '';  
                                 }  
                                 &Apache::lonnet::put('environment',\%newclonecrs,$udom,$uname);  
                             }  
                         }  
                     }  
                 }  
             }  
         }  
     }  
 }  
   
   
   
 sub header {  sub header {
     return &Apache::loncommon::start_page('Parameter Manager');      return &Apache::loncommon::start_page('Parameter Manager');
 }  }
Line 3653  ENDMAINFORMHEAD Line 3517  ENDMAINFORMHEAD
             linktitle => "Restrict metadata for this $lc_crstype." ,              linktitle => "Restrict metadata for this $lc_crstype." ,
             icon =>'contact-new.png'   ,              icon =>'contact-new.png'   ,
             },              },
           { linktext => "Manage $crstype Slots",  
             url => '/adm/slotrequest?command=showslots',  
             permission => $vgr,  
             linktitle => "Manage slots for this $lc_crstype."  ,  
             icon => 'rsrv.png'  ,  
             },  
           { linktext => 'Reset Student Access Times',            { linktext => 'Reset Student Access Times',
             url => '/adm/helper/resettimes.helper',              url => '/adm/helper/resettimes.helper',
             permission => $mgr,              permission => $mgr,

Removed from v.1.493  
changed lines
  Added in v.1.497


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