Diff for /loncom/interface/loncreateuser.pm between versions 1.295.2.24 and 1.295.2.29

version 1.295.2.24, 2010/01/19 22:41:02 version 1.295.2.29, 2010/01/20 14:59:27
Line 219  END_SCRIPT Line 219  END_SCRIPT
 sub build_tools_display {  sub build_tools_display {
     my ($ccuname,$ccdomain,$context) = @_;      my ($ccuname,$ccdomain,$context) = @_;
     my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,      my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
         $colspan);          $colspan,$isadv,%domconfig);
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",                     'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",                     'aboutme'    => "Personal Information Page",
Line 231  sub build_tools_display { Line 231  sub build_tools_display {
                    'uscu'       => "Use custom",                     'uscu'       => "Use custom",
                    'official'   => 'Can request creation of official courses',                     'official'   => 'Can request creation of official courses',
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
                      'community'  => 'Can request creation of communities',
     );      );
     if ($context eq 'requestcourses') {      if ($context eq 'requestcourses') {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                       'requestcourses.official','requestcourses.unofficial');                        'requestcourses.official','requestcourses.unofficial',
         @usertools = ('official','unofficial');                        'requestcourses.community');
           @usertools = ('official','unofficial','community');
         @options =('norequest','approval','autolimit','validate');          @options =('norequest','approval','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);          %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
         %reqtitles = &courserequest_titles();          %reqtitles = &courserequest_titles();
         %reqdisplay = &courserequest_display();          %reqdisplay = &courserequest_display();
         $colspan = ' colspan="2"';          $colspan = ' colspan="2"';
           %domconfig =
               &Apache::lonnet::get_dom('configuration',['requestcourses'],$ccdomain);
           $isadv = &Apache::lonnet::is_advanced_user($ccuname,$ccdomain);
     } else {      } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                           'tools.aboutme','tools.portfolio','tools.blog');                            'tools.aboutme','tools.portfolio','tools.blog');
Line 287  sub build_tools_display { Line 292  sub build_tools_display {
                    &Apache::loncommon::start_data_table_row()."\n";                     &Apache::loncommon::start_data_table_row()."\n";
         if ($context eq 'requestcourses') {          if ($context eq 'requestcourses') {
             my ($curroption,$currlimit);              my ($curroption,$currlimit);
             $curroption = $userenv{$context.'.'.$item};              if ($userenv{$context.'.'.$item} ne '') {
                   $curroption = $userenv{$context.'.'.$item};
               } else {
                   my (@inststatuses);
                   $curroption =
                       &Apache::loncoursequeueadmin::get_processtype($ccuname,$ccdomain,$isadv,$ccdomain,
                                                                  $item,\@inststatuses,\%domconfig);
               }
             if (!$curroption) {              if (!$curroption) {
                 $curroption = 'norequest';                  $curroption = 'norequest';
             }              }
Line 1027  sub print_user_modification_page { Line 1039  sub print_user_modification_page {
 <input type="hidden" name="pres_type"   value="" />  <input type="hidden" name="pres_type"   value="" />
 <input type="hidden" name="pres_marker" value="" />  <input type="hidden" name="pres_marker" value="" />
 ENDFORMINFO  ENDFORMINFO
     my %inccourses;      my (%inccourses,$roledom);
     foreach my $key (keys(%env)) {      if ($context eq 'course') {
  if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {          $inccourses{$env{'request.course.id'}}=1;
     $inccourses{$1.'_'.$2}=1;          $roledom = $env{'course.'.$env{'request.course.id'}.'.domain'};
       } elsif ($context eq 'author') {
           $roledom = $env{'request.role.domain'};
       } elsif ($context eq 'domain') {
           foreach my $key (keys(%env)) {
               $roledom = $env{'request.role.domain'};
               if ($key=~/^user\.priv\.cm\.\/($roledom)\/($match_username)/) {
                   $inccourses{$1.'_'.$2}=1;
               }
           }
       } else {
           foreach my $key (keys(%env)) {
               if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
                   $inccourses{$1.'_'.$2}=1;
               }
         }          }
     }      }
     if ($newuser) {      if ($newuser) {
Line 1267  ENDNOTOOLSPRIV Line 1293  ENDNOTOOLSPRIV
         }          }
         $r->print('</div><div class="LC_clear_float_footer"></div>');          $r->print('</div><div class="LC_clear_float_footer"></div>');
         if ($env{'form.action'} ne 'singlestudent') {          if ($env{'form.action'} ne 'singlestudent') {
             &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses);              &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
                                       $roledom,$crstype);
         }          }
     } ## End of new user/old user logic      } ## End of new user/old user logic
   
     if ($env{'form.action'} eq 'singlestudent') {      if ($env{'form.action'} eq 'singlestudent') {
         my $btntxt;          my $btntxt;
         if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
Line 1388  sub validation_javascript { Line 1414  sub validation_javascript {
 }  }
   
 sub display_existing_roles {  sub display_existing_roles {
     my ($r,$ccuname,$ccdomain,$inccourses) = @_;      my ($r,$ccuname,$ccdomain,$inccourses,$context,$roledom,$crstype) = @_;
     my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);      my $now=time;
     # Build up table of user roles to allow revocation and re-enabling of roles.      my %lt=&Apache::lonlocal::texthash(
     my ($tmp) = keys(%rolesdump);  
     if ($tmp !~ /^(con_lost|error)/i) {  
         my $now=time;  
         my %lt=&Apache::lonlocal::texthash(  
                     'rer'  => "Existing Roles",                      'rer'  => "Existing Roles",
                     'rev'  => "Revoke",                      'rev'  => "Revoke",
                     'del'  => "Delete",                      'del'  => "Delete",
Line 1404  sub display_existing_roles { Line 1426  sub display_existing_roles {
                     'sta'  => "Start",                      'sta'  => "Start",
                     'end'  => "End",                      'end'  => "End",
                                        );                                         );
         my (%roletext,%sortrole,%roleclass,%rolepriv);      my (%rolesdump,%roletext,%sortrole,%roleclass,%rolepriv);
         foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);      if ($context eq 'course' || $context eq 'author') {
                                     my $b1=join('_',(split('_',$b))[1,0]);          my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
                                     return $a1 cmp $b1;          my %roleshash =
                                 } keys(%rolesdump)) {              &Apache::lonnet::get_my_roles($ccuname,$ccdomain,'userroles',
             next if ($area =~ /^rolesdef/);                                ['active','previous','future'],\@roles,$roledom,1);
             my $envkey=$area;          foreach my $key (keys(%roleshash)) {
             my $role = $rolesdump{$area};              my ($start,$end) = split(':',$roleshash{$key});
             my $thisrole=$area;              next if ($start eq '-1' || $end eq '-1');
             $area =~ s/\_\w\w$//;              my ($rnum,$rdom,$role,$sec) = split(':',$key);
             my ($role_code,$role_end_time,$role_start_time) =              if ($context eq 'course') {
                 split(/_/,$role);                  next unless (($rnum eq $env{'course.'.$env{'request.course.id'}.'.num'})
                                && ($rdom eq $env{'course.'.$env{'request.course.id'}.'.domain'}));
               } elsif ($context eq 'author') {
                   next unless (($rnum eq $env{'user.name'}) && ($rdom eq $env{'request.role.domain'}));
               }
               my ($newkey,$newvalue,$newrole);
               $newkey = '/'.$rdom.'/'.$rnum;
               if ($sec ne '') {
                   $newkey .= '/'.$sec;
               }
               $newvalue = $role;
               if ($role =~ /^cr/) {
                   $newrole = 'cr';
               } else {
                   $newrole = $role;
               }
               $newkey .= '_'.$newrole;
               if ($start ne '' && $end ne '') {
                   $newvalue .= '_'.$end.'_'.$start;
               }
               $rolesdump{$newkey} = $newvalue;
           }
       } else {
           %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname);
       }
       # Build up table of user roles to allow revocation and re-enabling of roles.
       my ($tmp) = keys(%rolesdump);
       return if ($tmp =~ /^(con_lost|error)/i);
       foreach my $area (sort { my $a1=join('_',(split('_',$a))[1,0]);
                                   my $b1=join('_',(split('_',$b))[1,0]);
                                   return $a1 cmp $b1;
                               } keys(%rolesdump)) {
           next if ($area =~ /^rolesdef/);
           my $envkey=$area;
           my $role = $rolesdump{$area};
           my $thisrole=$area;
           $area =~ s/\_\w\w$//;
           my ($role_code,$role_end_time,$role_start_time) =
               split(/_/,$role);
 # Is this a custom role? Get role owner and title.  # Is this a custom role? Get role owner and title.
             my ($croleudom,$croleuname,$croletitle)=          my ($croleudom,$croleuname,$croletitle)=
                 ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});              ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
             my $allowed=0;          my $allowed=0;
             my $delallowed=0;          my $delallowed=0;
             my $sortkey=$role_code;          my $sortkey=$role_code;
             my $class='Unknown';          my $class='Unknown';
             if ($area =~ m{^/($match_domain)/($match_courseid)} ) {          if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
                 $class='Course';              $class='Course';
                 my ($coursedom,$coursedir) = ($1,$2);              my ($coursedom,$coursedir) = ($1,$2);
                 $sortkey.="\0$coursedom";              my $cid = $1.'_'.$2;
                 # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).              # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
                 my %coursedata=              my %coursedata=
                     &Apache::lonnet::coursedescription($1.'_'.$2);                  &Apache::lonnet::coursedescription($cid);
                 my $carea;              if ($coursedir =~ /^$match_community$/) {
                 if (defined($coursedata{'description'})) {                  $class='Community';
                     $carea=$coursedata{'description'}.              }
                         '<br />'.&mt('Domain').': '.$coursedom.('&nbsp;'x8).              $sortkey.="\0$coursedom";
               my $carea;
               if (defined($coursedata{'description'})) {
                   $carea=$coursedata{'description'}.
                       '<br />'.&mt('Domain').': '.$coursedom.('&nbsp;'x8).
      &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);       &Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);
                     $sortkey.="\0".$coursedata{'description'};                  $sortkey.="\0".$coursedata{'description'};
                     $class=$coursedata{'type'};                  $class=$coursedata{'type'};
               } else {
                   if ($class eq 'Community') {
                       $carea=&mt('Unavailable community').': '.$area;
                       $sortkey.="\0".&mt('Unavailable community').': '.$area;
                 } else {                  } else {
                     $carea=&mt('Unavailable course').': '.$area;                      $carea=&mt('Unavailable course').': '.$area;
                     $sortkey.="\0".&mt('Unavailable course').': '.$area;                      $sortkey.="\0".&mt('Unavailable course').': '.$area;
                 }                  }
                 $sortkey.="\0$coursedir";              }
                 $inccourses->{$1.'_'.$2}=1;              $sortkey.="\0$coursedir";
                 if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||              $inccourses->{$cid}=1;
               if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
                   (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
                   $allowed=1;
               }
               unless ($allowed) {
                   my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'});
                   if ($isowner) {
                       if (($role_code eq 'co') && ($class eq 'Community')) {
                           $allowed = 1;
                       } elsif (($role_code eq 'cc') && ($class eq 'Course')) {
                           $allowed = 1;
                       }
                   }
               }
               if ((&Apache::lonnet::allowed('dro',$coursedom)) ||
                   (&Apache::lonnet::allowed('dro',$ccdomain))) {
                  $delallowed=1;
               }
   # - custom role. Needs more info, too
               if ($croletitle) {
                   if (&Apache::lonnet::allowed('ccr',$coursedom.'/'.$coursedir)) {
                       $allowed=1;
                       $thisrole.='.'.$role_code;
                   }
               }
               if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
                   $carea.='<br />Section: '.$3;
                   $sortkey.="\0$3";
                   if (!$allowed) {
                      if ($env{'request.course.sec'} eq $3) {
                          if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
                              $allowed = 1;
                          }
                      }
                   }
               }
               $area=$carea;
           } else {
               $sortkey.="\0".$area;
               # Determine if current user is able to revoke privileges
               if ($area=~m{^/($match_domain)/}) {
                   if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
                     (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {                      (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
                     $allowed=1;                      $allowed=1;
                 }                  }
                 if ((&Apache::lonnet::allowed('dro',$1)) ||                  if (((&Apache::lonnet::allowed('dro',$1))  ||
                     (&Apache::lonnet::allowed('dro',$ccdomain))) {                      (&Apache::lonnet::allowed('dro',$ccdomain))) &&
                       ($role_code ne 'dc')) {
                     $delallowed=1;                      $delallowed=1;
                 }                  }
 # - custom role. Needs more info, too  
                 if ($croletitle) {  
                     if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {  
                         $allowed=1;  
                         $thisrole.='.'.$role_code;  
                     }  
                 }  
                 # Compute the background color based on $area  
                 if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {  
                     $carea.='<br />Section: '.$3;  
                     $sortkey.="\0$3";  
                     if (!$allowed) {  
                         if ($env{'request.course.sec'} eq $3) {  
                             if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {  
                                 $allowed = 1;  
                             }  
                         }  
                     }  
                 }  
                 $area=$carea;  
             } else {              } else {
                 $sortkey.="\0".$area;                  if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
                 # Determine if current user is able to revoke privileges  
                 if ($area=~m{^/($match_domain)/}) {  
                     if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||  
                        (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {  
                         $allowed=1;  
                     }  
                     if (((&Apache::lonnet::allowed('dro',$1))  ||  
                          (&Apache::lonnet::allowed('dro',$ccdomain))) &&  
                         ($role_code ne 'dc')) {  
                         $delallowed=1;  
                     }  
                 } else {  
                     if (&Apache::lonnet::allowed('c'.$role_code,'/')) {  
                         $allowed=1;  
                     }  
                 }  
                 if ($role_code eq 'ca' || $role_code eq 'au') {  
                     $class='Construction Space';  
                 } elsif ($role_code eq 'su') {  
                     $class='System';  
                 } else {  
                     $class='Domain';  
                 }  
             }  
             if (($role_code eq 'ca') || ($role_code eq 'aa')) {  
                 $area=~m{/($match_domain)/($match_username)};  
                 if (&Apache::lonuserutils::authorpriv($2,$1)) {  
                     $allowed=1;                      $allowed=1;
                 } else {  
                     $allowed=0;  
                 }                  }
             }              }
             my $row = '';              if ($role_code eq 'ca' || $role_code eq 'au') {
             $row.= '<td>';                  $class='Construction Space';
             my $active=1;              } elsif ($role_code eq 'su') {
             $active=0 if (($role_end_time) && ($now>$role_end_time));                  $class='System';
             if (($active) && ($allowed)) {  
                 $row.= '<input type="checkbox" name="rev:'.$thisrole.'" />';  
             } else {              } else {
                 if ($active) {                  $class='Domain';
                    $row.='&nbsp;';  
                 } else {  
                    $row.=&mt('expired or revoked');  
                 }  
             }              }
             $row.='</td><td>';          }
             if ($allowed && !$active) {          if (($role_code eq 'ca') || ($role_code eq 'aa')) {
                 $row.= '<input type="checkbox" name="ren:'.$thisrole.'" />';              $area=~m{/($match_domain)/($match_username)};
               if (&Apache::lonuserutils::authorpriv($2,$1)) {
                   $allowed=1;
             } else {              } else {
                 $row.='&nbsp;';                  $allowed=0;
             }              }
             $row.='</td><td>';          }
             if ($delallowed) {          my $row = '';
                 $row.= '<input type="checkbox" name="del:'.$thisrole.'" />';          $row.= '<td>';
           my $active=1;
           $active=0 if (($role_end_time) && ($now>$role_end_time));
           if (($active) && ($allowed)) {
               $row.= '<input type="checkbox" name="rev:'.$thisrole.'" />';
           } else {
               if ($active) {
                  $row.='&nbsp;';
             } else {              } else {
                 $row.='&nbsp;';                 $row.=&mt('expired or revoked');
             }              }
             my $plaintext='';          }
             if (!$croletitle) {          $row.='</td><td>';
                 $plaintext=&Apache::lonnet::plaintext($role_code,$class)          if ($allowed && !$active) {
             } else {              $row.= '<input type="checkbox" name="ren:'.$thisrole.'" />';
                 $plaintext=          } else {
               $row.='&nbsp;';
           }
           $row.='</td><td>';
           if ($delallowed) {
               $row.= '<input type="checkbox" name="del:'.$thisrole.'" />';
           } else {
               $row.='&nbsp;';
           }
           my $plaintext='';
           if (!$croletitle) {
               $plaintext=&Apache::lonnet::plaintext($role_code,$class)
           } else {
               $plaintext=
         "Customrole '$croletitle'<br />defined by $croleuname\@$croleudom";          "Customrole '$croletitle'<br />defined by $croleuname\@$croleudom";
           }
           $row.= '</td><td>'.$plaintext.
                  '</td><td>'.$area.
                  '</td><td>'.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
                                               : '&nbsp;' ).
                 '</td><td>'.($role_end_time  ?&Apache::lonlocal::locallocaltime($role_end_time)
                                               : '&nbsp;' )
                  ."</td>";
           $sortrole{$sortkey}=$envkey;
           $roletext{$envkey}=$row;
           $roleclass{$envkey}=$class;
           $rolepriv{$envkey}=$allowed;
       } # end of foreach        (table building loop)
       my $rolesdisplay = 0;
       my %output = ();
       foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
           $output{$type} = '';
           foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
               if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
                   $output{$type}.=
                         &Apache::loncommon::start_data_table_row().
                         $roletext{$sortrole{$which}}.
                         &Apache::loncommon::end_data_table_row();
             }              }
             $row.= '</td><td>'.$plaintext.          }
                    '</td><td>'.$area.          unless($output{$type} eq '') {
                    '</td><td>'.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)              $output{$type} = '<tr class="LC_info_row">'.
                                                 : '&nbsp;' ).                        "<td align='center' colspan='7'>".&mt($type)."</td></tr>".
                    '</td><td>'.($role_end_time  ?&Apache::lonlocal::locallocaltime($role_end_time)                        $output{$type};
                                                 : '&nbsp;' )              $rolesdisplay = 1;
                    ."</td>";          }
             $sortrole{$sortkey}=$envkey;      }
             $roletext{$envkey}=$row;      if ($rolesdisplay == 1) {
             $roleclass{$envkey}=$class;          my $contextrole='';
             $rolepriv{$envkey}=$allowed;          if ($env{'request.course.id'}) {
             #$r->print($row);              if (&Apache::loncommon::course_type() eq 'Community') {
         } # end of foreach        (table building loop)                  $contextrole = &mt('Existing Roles in this Community');
         my $rolesdisplay = 0;  
         my %output = ();  
         foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {  
             $output{$type} = '';  
             foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {  
                 if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {  
                     $output{$type}.=  
                           &Apache::loncommon::start_data_table_row().  
                           $roletext{$sortrole{$which}}.  
                           &Apache::loncommon::end_data_table_row();  
                 }  
             }  
             unless($output{$type} eq '') {  
                 $output{$type} = '<tr class="LC_info_row">'.  
                           "<td align='center' colspan='7'>".&mt($type)."</td></tr>".  
                            $output{$type};  
                 $rolesdisplay = 1;  
             }  
         }  
         if ($rolesdisplay == 1) {  
             my $contextrole='';  
             if ($env{'request.course.id'}) {  
                 my $crstype = &Apache::loncommon::course_type();  
                 $contextrole = "Existing Roles in this $crstype";  
             } elsif ($env{'request.role'} =~ /^au\./) {  
                 $contextrole = 'Existing Co-Author Roles in your Construction Space';  
             } else {              } else {
                 $contextrole = 'Existing Roles in this Domain';                  $contextrole = &mt('Existing Roles in this Course');
             }              }
             $r->print('          } elsif ($env{'request.role'} =~ /^au\./) {
               $contextrole = 'Existing Co-Author Roles in your Construction Space';
           } else {
               $contextrole = 'Existing Roles in this Domain';
           }
           $r->print('
 <h3>'.$lt{'rer'}.'</h3>'.  <h3>'.$lt{'rer'}.'</h3>'.
 '<div>'.&mt($contextrole).'</div>'.  '<div>'.&mt($contextrole).'</div>'.
 &Apache::loncommon::start_data_table("LC_createuser").  &Apache::loncommon::start_data_table("LC_createuser").
Line 1588  sub display_existing_roles { Line 1668  sub display_existing_roles {
 '</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.  '</th><th>'.$lt{'rol'}.'</th><th>'.$lt{'ext'}.
 '</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.  '</th><th>'.$lt{'sta'}.'</th><th>'.$lt{'end'}.'</th>'.
 &Apache::loncommon::end_data_table_header_row());  &Apache::loncommon::end_data_table_header_row());
            foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {          foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
                 if ($output{$type}) {              if ($output{$type}) {
                     $r->print($output{$type}."\n");                  $r->print($output{$type}."\n");
                 }  
             }              }
             $r->print(&Apache::loncommon::end_data_table());  
         }          }
     }  # End of check for keys in rolesdump          $r->print(&Apache::loncommon::end_data_table());
       }
     return;      return;
 }  }
   
Line 2607  sub update_user_data { Line 2686  sub update_user_data {
                         ($env{'user.domain'} eq $env{'form.ccdomain'})) {                          ($env{'user.domain'} eq $env{'form.ccdomain'})) {
                         my %newenvhash;                          my %newenvhash;
                         foreach my $key (keys(%changed)) {                          foreach my $key (keys(%changed)) {
                             if (($key eq 'official') || ($key eq 'unofficial')) {                              if (($key eq 'official') || ($key eq 'unofficial')
                                   || ($key eq 'community')) {
                                 $newenvhash{'environment.requestcourses.'.$key} =                                  $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};                                      $changeHash{'requestcourses.'.$key};
                                 if ($changeHash{'requestcourses.'.$key} ne '') {                                  if ($changeHash{'requestcourses.'.$key} ne '') {
Line 2668  sub update_user_data { Line 2748  sub update_user_data {
                              'portfolio'  => 'Portfolio Availability',                               'portfolio'  => 'Portfolio Availability',
                              'official'   => 'Can Request Official Courses',                               'official'   => 'Can Request Official Courses',
                              'unofficial' => 'Can Request Unofficial Courses',                               'unofficial' => 'Can Request Unofficial Courses',
                                'community'  => 'Can Request Communities',
                              'inststatus' => "Affiliation",                               'inststatus' => "Affiliation",
                              'prvs'       => 'Previous Value:',                               'prvs'       => 'Previous Value:',
                              'chto'       => 'Changed To:'                               'chto'       => 'Changed To:'
Line 2821  END Line 2902  END
                            'portfolio'  => "Portfolio Availability",                             'portfolio'  => "Portfolio Availability",
                            'official'   => "Can Request Official Courses",                             'official'   => "Can Request Official Courses",
                            'unofficial' => "Can Request Unofficial Courses",                             'unofficial' => "Can Request Unofficial Courses",
                              'community'  => "Can Request Communities",
                            'inststatus' => "Affiliation",                             'inststatus' => "Affiliation",
        );         );
             $r->print(<<"END");              $r->print(<<"END");
Line 3567  sub custom_role_editor { Line 3649  sub custom_role_editor {
     my $dompriv='';      my $dompriv='';
     my $coursepriv='';      my $coursepriv='';
     my $body_top;      my $body_top;
     my ($disp_dummy,$disp_roles) = &Apache::lonnet::get('roles',["st"]);  
     my ($rdummy,$roledef)=      my ($rdummy,$roledef)=
  &Apache::lonnet::get('roles',["rolesdef_$rolename"]);   &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
 # ------------------------------------------------------- Does this role exist?  # ------------------------------------------------------- Does this role exist?
Line 5824  sub course_level_table { Line 5905  sub course_level_table {
             'end'  => "End"              'end'  => "End"
     );      );
   
     foreach my $protectedcourse (sort( keys(%inccourses))) {      foreach my $protectedcourse (sort(keys(%inccourses))) {
  my $thiscourse=$protectedcourse;   my $thiscourse=$protectedcourse;
  $thiscourse=~s:_:/:g;   $thiscourse=~s:_:/:g;
  my %coursedata=&Apache::lonnet::coursedescription($thiscourse);   my %coursedata=&Apache::lonnet::coursedescription($thiscourse);
           my $isowner = &is_courseowner($protectedcourse,$coursedata{'internal.courseowner'});
  my $area=$coursedata{'description'};   my $area=$coursedata{'description'};
         my $crstype=$coursedata{'type'};          my $crstype=$coursedata{'type'};
  if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }   if (!defined($area)) { $area=&mt('Unavailable course').': '.$protectedcourse; }
Line 5842  sub course_level_table { Line 5924  sub course_level_table {
         my @roles = &Apache::lonuserutils::roles_by_context('course','',$crstype);          my @roles = &Apache::lonuserutils::roles_by_context('course','',$crstype);
  foreach my $role (@roles) {   foreach my $role (@roles) {
             my $plrole=&Apache::lonnet::plaintext($role,$crstype);              my $plrole=&Apache::lonnet::plaintext($role,$crstype);
     if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {              if ((&Apache::lonnet::allowed('c'.$role,$thiscourse)) ||
                   ((($role eq 'cc') || ($role eq 'co')) && ($isowner))) {
                 $table .= &course_level_row($protectedcourse,$role,$area,$domain,                  $table .= &course_level_row($protectedcourse,$role,$area,$domain,
                                             $plrole,\%sections_count,\%lt);                                                  $plrole,\%sections_count,\%lt);
             } elsif ($env{'request.course.sec'} ne '') {              } elsif ($env{'request.course.sec'} ne '') {
                 if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.                  if (&Apache::lonnet::allowed('c'.$role,$thiscourse.'/'.
                                              $env{'request.course.sec'})) {                                               $env{'request.course.sec'})) {
Line 6348  sub get_selfenroll_titles { Line 6431  sub get_selfenroll_titles {
     return (\@row,\%lt);      return (\@row,\%lt);
 }  }
   
   sub is_courseowner {
       my ($thiscourse,$courseowner) = @_;
       if ($courseowner eq '') {
           if ($env{'request.course.id'} eq $thiscourse) {
               $courseowner = $env{'course.'.$env{'request.course.id'}.'.internal.courseowner'};
           }
       }
       if ($courseowner ne '') {
           if ($courseowner eq $env{'user.name'}.':'.$env{'user.domain'}) {
               return 1;
           }
       }
       return;
   }
   
 #---------------------------------------------- end functions for &phase_two  #---------------------------------------------- end functions for &phase_two
   
 #--------------------------------- functions for &phase_two and &phase_three  #--------------------------------- functions for &phase_two and &phase_three

Removed from v.1.295.2.24  
changed lines
  Added in v.1.295.2.29


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