Diff for /loncom/auth/lonroles.pm between versions 1.181.2.2 and 1.182

version 1.181.2.2, 2008/03/22 03:52:04 version 1.182, 2008/01/26 21:12:32
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,$coursenum) =
       ($envkey =~ m-^form\.ca\./($match_domain)/($match_courseid)$-)) {
                       if ($dcroles{$domain}) {
                           &check_privs($domain,$coursenum,$then,$now,'ca');
                       }
                       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/)) { 
                              &check_privs($domain,$user,$then,$now,'ca');
                              $env{'form.ca./'.$domain.'/'.$user}=1;
          }
                     }                      }
                     last;                      last;
                 }                  }
Line 365  ENDENTERKEY Line 387  ENDENTERKEY
     my $start_page=&Apache::loncommon::start_page('User Roles');      my $start_page=&Apache::loncommon::start_page('User Roles');
     my $standby=&mt('Role selected. Please stand by.');      my $standby=&mt('Role selected. Please stand by.');
     $standby=~s/\n/\\n/g;      $standby=~s/\n/\\n/g;
     my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will be unavailable.').'</span><br />';      my $noscript='<span class="LC_error">'.&mt('Use of LON-CAPA requires Javascript to be enabled in your web browser.').'<br />'.&mt('As this is not the case, most functionality in the system will ba unavailable.').'</span><br />';
   
     $r->print(<<ENDHEADER);      $r->print(<<ENDHEADER);
 $start_page  $start_page
Line 410  ENDHEADER Line 432  ENDHEADER
 # -------------------------------------------------------- Generate Page Output  # -------------------------------------------------------- Generate Page Output
 # --------------------------------------------------------------- Error Header?  # --------------------------------------------------------------- Error Header?
     if ($error) {      if ($error) {
         $r->print("<h1>".&mt('LON-CAPA Access Control')."</h1>");   $r->print("<h1>LON-CAPA Access Control</h1>");
  $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>");   $r->print("<!-- LONCAPAACCESSCONTROLERRORSCREEN --><hr /><pre>");
  if ($priv ne '') {   if ($priv ne '') {
             $r->print(&mt('Access  : ').&Apache::lonnet::plaintext($priv)."\n");      $r->print("Access  : ".&Apache::lonnet::plaintext($priv)."\n");
  }   }
  if ($fn ne '') {   if ($fn ne '') {
             $r->print(&mt('Resource: ').&Apache::lonenc::check_encrypt($fn)."\n");      $r->print("Resource: ".&Apache::lonenc::check_encrypt($fn)."\n");
  }   }
  if ($msg ne '') {   if ($msg ne '') {
             $r->print(&mt('Action  : ').$msg."\n");      $r->print("Action  : $msg\n");
  }   }
  $r->print("</pre><hr />");   $r->print("</pre><hr />");
  my $url=$fn;   my $url=$fn;
Line 669  ENDHEADER Line 691  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 720  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 882  sub build_roletext { Line 906  sub build_roletext {
 }  }
   
 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 930  sub courselink { Line 954  sub courselink {
 }  }
   
 sub coursepick_jscript {  sub coursepick_jscript {
     my %lt = &Apache::lonlocal::texthash(  
                   plsu => "Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.",  
                   youc => 'You can only use this screen to select courses in the current domain.',  
             );  
     my $verify_script = <<"END";      my $verify_script = <<"END";
 <script type="text/javascript">  <script type="text/javascript">
 function verifyCoursePick(caller) {  function verifyCoursePick(caller) {
Line 949  function verifyCoursePick(caller) { Line 969  function verifyCoursePick(caller) {
             }              }
         }          }
         else {          else {
             alert("$lt{'plsu'}");              alert("Please use the 'Select Course' link to open a separate pick course window where you may select the course you wish to enter.");
         }          }
     }      }
     else {      else {
         alert("$lt{'youc'}");          alert("You can only use this screen to select courses in the current domain")
     }      }
 }  }
 function getIndex(caller) {  function getIndex(caller) {
Line 1009  sub allcourses_row { Line 1029  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 1019  sub recent_filename { Line 1052  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.181.2.2  
changed lines
  Added in v.1.182


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