Diff for /loncom/interface/lonparmset.pm between versions 1.238 and 1.239

version 1.238, 2005/06/29 11:57:17 version 1.239, 2005/07/19 16:42:02
Line 1769  sub crsenv { Line 1769  sub crsenv {
         #          #
         # Let the user know we made the changes          # Let the user know we made the changes
         if ($name && defined($value)) {          if ($name && defined($value)) {
               my $failed_cloners;
             if ($name eq 'cloners') {              if ($name eq 'cloners') {
                   $value =~ s/\s//g;
                 $value =~ s/^,//;                  $value =~ s/^,//;
                 $value =~ s/,$//;                  $value =~ s/,$//;
                   # check requested clones are valid users.
                   $failed_cloners = &check_cloners(\$value,\@oldcloner);
             }              }
             my $put_result = &Apache::lonnet::put('environment',              my $put_result = &Apache::lonnet::put('environment',
                                                   {$name=>$value},$dom,$crs);                                                    {$name=>$value},$dom,$crs);
Line 1788  sub crsenv { Line 1792  sub crsenv {
                 $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').                  $setoutput.=&mt('Unable to set').' <b>'.$name.'</b> '.&mt('to').
     ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';      ' <b>'.$value.'</b> '.&mt('due to').' '.$put_result.'.<br />';
             }              }
               if (($name eq 'cloners') && ($failed_cloners)) {
                   $setoutput.= &mt('Unable to include').' - <b>'.$failed_cloners.'</b>, '.
                    &mt('reason').' - '.&mt('LON-CAPA user(s) do(es) not exist').
                    '.<br />'.&mt('Please ').
                    ' <a href="/adm/createuser">'.
                    &mt('add the user(s)').'</a>, '.
                    &mt('and then return to the ').
                    '<a href="/admparmset?action=crsenv">'.
                    &mt('Course Parameters page').'</a> '.
                    &mt('to add the new user(s) to the list of possible cloners').
                    '.<br />';
               }
         }          }
     }      }
 # ------------------------- Re-init course environment entries for this session  # ------------------------- Re-init course environment entries for this session
Line 2490  ENDOVER Line 2506  ENDOVER
 ##################################################  ##################################################
                                                                                                                                                                                           
 =pod  =pod
                                                                                               
 =item change clone  =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  Modifies the list of courses a user can clone (stored
 in the user's environemnt.db file), called when a  in the user's environment.db file), called when a
 change is made to the list of users allowed to clone  change is made to the list of users allowed to clone
 a course.  a course.
                                                                                               
 Inputs: $action,$cloner  Inputs: $action,$cloner
 where $action is add or drop, and $cloner is identity of   where $action is add or drop, and $cloner is identity of 
 user for whom cloning ability is to be changed in course.   user for whom cloning ability is to be changed in course. 
                                                                                               
 Returns:   
   
 =cut  =cut
                                                                                                                                                                                           
 ##################################################  ##################################################
 ##################################################  ##################################################
   
   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/^$currclone$/,@$oldcloner) {
               my ($uname,$udom) = split/:/,$currclone;
               if ($uname && $udom) {
                   if (&Apache::lonnet::homeserver($uname,$udom) eq 'no_host') {
                       $disallowed .= $currclone.',';   
                   } else {
                       $clean_clonelist .= $currclone.',';
                   }
               }
           } else {
               $clean_clonelist .= $currclone.',';
           }
       }
       if ($disallowed) {
           $disallowed =~ s/,$//;
       }
       if ($clean_clonelist) {
           $clean_clonelist =~ s/,$//;
       }
       $$clonelist = $clean_clonelist;
       return $disallowed;
   }  
   
 sub change_clone {  sub change_clone {
     my ($clonelist,$oldcloner) = @_;      my ($clonelist,$oldcloner) = @_;
Line 2518  sub change_clone { Line 2585  sub change_clone {
     my $clone_crs = $cnum.':'.$cdom;      my $clone_crs = $cnum.':'.$cdom;
           
     if ($cnum && $cdom) {      if ($cnum && $cdom) {
         my @allowclone = ();          my @allowclone;
         if ($clonelist =~ /,/) {          &extract_cloners($clonelist,\@allowclone);
             @allowclone = split/,/,$clonelist;  
         } else {  
             $allowclone[0] = $clonelist;  
         }  
         foreach my $currclone (@allowclone) {          foreach my $currclone (@allowclone) {
             if (!grep/^$currclone$/,@$oldcloner) {              if (!grep/^$currclone$/,@$oldcloner) {
                 ($uname,$udom) = split/:/,$currclone;                  ($uname,$udom) = split/:/,$currclone;

Removed from v.1.238  
changed lines
  Added in v.1.239


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