Diff for /loncom/auth/lonroles.pm between versions 1.179 and 1.183

version 1.179, 2007/09/10 16:07:32 version 1.183, 2008/01/30 01:18:58
Line 122  sub handler { Line 122  sub handler {
                                 "request.role.adv"    => $env{'user.adv'},                                  "request.role.adv"    => $env{'user.adv'},
  "request.role.domain" => $env{'user.domain'});   "request.role.domain" => $env{'user.domain'});
   
 # Check if user is a DC trying to enter a course and needs privs to be created  # Check if user is a DC trying to enter a course or author space and needs privs to be created
         if ($numdc > 0) {          if ($numdc > 0) {
             foreach my $envkey (keys %env) {              foreach my $envkey (keys %env) {
   # Is this an ad-hoc CC-role?
                 if (my ($domain,$coursenum) =                  if (my ($domain,$coursenum) =
     ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {      ($envkey =~ m-^form\.cc\./($match_domain)/($match_courseid)$-)) {
                     if ($dcroles{$domain}) {                      if ($dcroles{$domain}) {
                         &check_privs($domain,$coursenum,$then,$now);                          &check_privs($domain,$coursenum,$then,$now,'cc');
                       }
                       last;
                   }
   # Is this a recent ad-hoc CA-role?
                   if (my ($domain,$user) =
       ($envkey =~ m-^form\.ca\./($match_domain)/($match_username)$-)) {
                       if (($dcroles{$domain}) && (&is_author_homeserver($user,$domain))) {
                           &check_privs($domain,$user,$then,$now,'ca');
                       } else {
                           delete($env{$envkey});
                       }
                       last;
                   }
   # Is this a new ad-hoc CA-role?
                   if (my ($domain) =
                       ($envkey =~ m-^form\.adhocca\./($match_domain)$-)) {
                       if ($dcroles{$domain}) {
                           my $user=$env{'form.adhoccauname.'.$domain};
                           if (!$user) { $user=$env{'form.adhoccaunamerecent.'.$domain} };
                           if (($user) && ($user=~/$match_username/) && (&is_author_homeserver($user,$domain))) { 
                              &check_privs($domain,$user,$then,$now,'ca');
                              $env{'form.ca./'.$domain.'/'.$user}=1;
          }
                     }                      }
                     last;                      last;
                 }                  }
Line 642  ENDHEADER Line 666  ENDHEADER
     }      }
 # More than one possible role  # More than one possible role
 # ----------------------------------------------------------------------- Table  # ----------------------------------------------------------------------- Table
     unless (($advanced) || ($nochoose)) {      unless ((!&Apache::lonmenu::show_course()) || ($nochoose)) {
  $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");   $r->print("<h2>".&mt('Select a Course to Enter')."</h2>\n");
     }      }
     $r->print('<br /><table id="LC_rolesmenu"><tr>');      $r->print('<br /><table id="LC_rolesmenu"><tr>');
Line 669  ENDHEADER Line 693  ENDHEADER
  $output.=$roletext{'user.role.'.$_};   $output.=$roletext{'user.role.'.$_};
                 if ($_ =~ m-dc\./($match_domain)/-                   if ($_ =~ m-dc\./($match_domain)/- 
     && $dcroles{$1}) {      && $dcroles{$1}) {
     $output .= &allcourses_row($1,'recent');      $output .= &allcourses_row($1,'recent').
                                  &allcoauthors_row($1,'recent');
                 }                  }
     } elsif ($numdc > 0) {      } elsif ($numdc > 0) {
                 unless ($_ =~/^error\:/) {                  unless ($_ =~/^error\:/) {
Line 697  ENDHEADER Line 722  ENDHEADER
  $output.=$roletext{$sortrole{$which}};   $output.=$roletext{$sortrole{$which}};
                 if ($sortrole{$which} =~ m-dc\./($match_domain)/-) {                  if ($sortrole{$which} =~ m-dc\./($match_domain)/-) {
                     if ($dcroles{$1}) {                      if ($dcroles{$1}) {
                         $output .= &allcourses_row($1,'');                          $output .= &allcourses_row($1,'').
                                      &allcoauthors_row($1,'');
                     }                      }
                 }                  }
     }      }
Line 881  sub build_roletext { Line 907  sub build_roletext {
     return $roletext;      return $roletext;
 }  }
   
   sub is_author_homeserver {
       my ($uname,$udom)=@_;
       my $home = &Apache::lonnet::homeserver($uname,$udom);
       my @ids=&Apache::lonnet::current_machine_ids();
       foreach my $id (@ids) { 
          if ($id eq $home) { 
             if (-e "/home/".$uname."/public_html") {
                return 1;
             }
          }
       }
       return 0;
   }
   
 sub check_privs {  sub check_privs {
     my ($cdom,$cnum,$then,$now) = @_;      my ($cdom,$cnum,$then,$now,$checkrole) = @_;
     my $cckey = 'user.role.cc./'.$cdom.'/'.$cnum;       my $cckey = 'user.role.'.$checkrole.'./'.$cdom.'/'.$cnum; 
     if ($env{$cckey}) {      if ($env{$cckey}) {
         my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);          my ($role,$where,$trolecode,$tstart,$tend,$tremark,$tstatus,$tpstart,$tpend,$tfont);
         &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);          &role_status($cckey,$then,$now,\$role,\$where,\$trolecode,\$tstatus,\$tstart,\$tend);
         unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {          unless (($tstatus eq 'is') || ($tstatus eq 'will_not')) {
             &set_privileges($cdom,$cnum);              &set_privileges($cdom,$cnum,$checkrole);
         }          }
     } else {      } else {
         &set_privileges($cdom,$cnum);          &set_privileges($cdom,$cnum,$checkrole);
     }      }
 }  }
   
Line 965  END Line 1005  END
     return $verify_script;      return $verify_script;
 }  }
   
 sub processpick {  
     my $process_pick = <<"END";  
 <script type="text/javascript">  
 function process_pick(dom) {  
     var pickedCourse=opener.document.rolechoice.$env{'form.cnumelement'}.value;  
     var pickedDomain=opener.document.rolechoice.$env{'form.cdomelement'}.value;  
     var okDomain = 0;  
   
     if (pickedDomain == dom) {  
         if (pickedCourse != '') {  
             var courseTarget = "cc./"+pickedDomain+"/"+pickedCourse  
             opener.document.title='Role selected. Please stand by.';  
             opener.status='Role selected. Please stand by.';  
     opener.document.rolechoice.newrole.value=courseTarget  
             opener.document.rolechoice.submit()  
         }  
     } else {  
         alert("You may only use this screen to select courses in the current domain: "+dom+"\\nPlease return to the roles page window and click the 'Select Course' link for domain: "+pickedDomain+",\\n if you are a Domain Coordinator in that domain, and wish to become a Course Coordinator in a course in the domain");  
     }  
 }  
    
 </script>  
 END  
     return $process_pick;  
 }  
   
 sub display_cc_role {  sub display_cc_role {
     my $rolekey = shift;      my $rolekey = shift;
     my $roletext;      my $roletext;
Line 1031  sub allcourses_row { Line 1045  sub allcourses_row {
     my $ccrole = &Apache::lonnet::plaintext('cc');      my $ccrole = &Apache::lonnet::plaintext('cc');
     $output.= '<span class="LC_rolesinfo">'.      $output.= '<span class="LC_rolesinfo">'.
             &mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom).              &mt('[_1]: [_2] from domain [_3]',$ccrole,$selectlink,$dcdom).
               '</span><br /></tr>'."\n";
       return $output;
   }
   
   sub allcoauthors_row {
       my ($dcdom,$rowtype) = @_;
       my $output = '<tr bgcolor="#77FF77">'.
                    ' <td colspan="5">';
       my $carole = &Apache::lonnet::plaintext('ca');
       my $inputlink='<input type="text" size="10" name="adhoccauname'.$rowtype.'.'.$dcdom.'" />';
       my $gobutton='<input type="submit" name="adhocca./'.$dcdom.'" value="'.&mt('Go').'" />';
       $output.= '<span class="LC_rolesinfo">'.
               &mt('[_1]: [_2] in domain [_3] [_4]',$carole,$inputlink,$dcdom,$gobutton).
             '</span><br /></tr><tr><td colspan="5" height="3"></td></tr>'."\n";              '</span><br /></tr><tr><td colspan="5" height="3"></td></tr>'."\n";
     return $output;      return $output;
 }  }
Line 1041  sub recent_filename { Line 1068  sub recent_filename {
 }  }
   
 sub set_privileges {  sub set_privileges {
     my ($dcdom,$pickedcourse) = @_;  # role can be cc or ca
       my ($dcdom,$pickedcourse,$role) = @_;
     my $area = '/'.$dcdom.'/'.$pickedcourse;      my $area = '/'.$dcdom.'/'.$pickedcourse;
     my $role = 'cc';  
     my $spec = $role.'.'.$area;      my $spec = $role.'.'.$area;
     my %userroles = &Apache::lonnet::set_arearole($role,$area,'','',      my %userroles = &Apache::lonnet::set_arearole($role,$area,'','',
   $env{'user.domain'},    $env{'user.domain'},

Removed from v.1.179  
changed lines
  Added in v.1.183


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