Diff for /loncom/interface/loncreateuser.pm between versions 1.217 and 1.218

version 1.217, 2007/12/21 15:33:32 version 1.218, 2007/12/21 16:23:54
Line 809  ENDNOPORTPRIV Line 809  ENDNOPORTPRIV
             &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses);              &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses);
         }          }
     } ## End of new user/old user logic      } ## End of new user/old user logic
     my $addrolesdisplay = 0;  
     $r->print('<h3>'.&mt('Add Roles').'</h3>');  
 #  
 # Co-Author  
 #   
     if (&Apache::lonuserutils::authorpriv($env{'user.name'},  
                                           $env{'request.role.domain'}) &&  
         ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {  
         # No sense in assigning co-author role to yourself  
         $addrolesdisplay = 1;  
  my $cuname=$env{'user.name'};  
         my $cudom=$env{'request.role.domain'};  
    my %lt=&Apache::lonlocal::texthash(  
     'cs'   => "Construction Space",  
                     'act'  => "Activate",                      
                     'rol'  => "Role",  
                     'ext'  => "Extent",  
                     'sta'  => "Start",  
                     'end'  => "End",  
                     'cau'  => "Co-Author",  
                     'caa'  => "Assistant Co-Author",  
                     'ssd'  => "Set Start Date",  
                     'sed'  => "Set End Date"  
        );  
        $r->print('<h4>'.$lt{'cs'}.'</h4>'."\n".   
            &Apache::loncommon::start_data_table()."\n".  
            &Apache::loncommon::start_data_table_header_row()."\n".  
            '<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th>'.  
            '<th>'.$lt{'ext'}.'</th><th>'.$lt{'sta'}.'</th>'.  
            '<th>'.$lt{'end'}.'</th>'."\n".  
            &Apache::loncommon::end_data_table_header_row()."\n".  
            &Apache::loncommon::start_data_table_row()."\n".  
            '<td>  
             <input type=checkbox name="act_'.$cudom.'_'.$cuname.'_ca" />  
            </td>  
            <td>'.$lt{'cau'}.'</td>  
            <td>'.$cudom.'_'.$cuname.'</td>  
            <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" />  
              <a href=  
 "javascript:pjump('."'date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>  
 <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_ca" value="" />  
 <a href=  
 "javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n".  
           &Apache::loncommon::end_data_table_row()."\n".  
           &Apache::loncommon::start_data_table_row()."\n".  
 '<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td>  
 <td>'.$lt{'caa'}.'</td>  
 <td>'.$cudom.'_'.$cuname.'</td>  
 <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_aa" value="" />  
 <a href=  
 "javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>  
 <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_aa" value="" />  
 <a href=  
 "javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n".  
          &Apache::loncommon::end_data_table_row()."\n".  
          &Apache::loncommon::end_data_table());  
     } elsif ($env{'request.role'} =~ /^au\./) {  
         if (!(&Apache::lonuserutils::authorpriv($env{'user.name'},  
                                                 $env{'request.role.domain'}))) {  
             $r->print('<span class="LC_error">'.  
                       &mt('You do not have privileges to assign co-author roles.').  
                       '</span>');  
         } elsif (($env{'user.name'} eq $ccuname) &&   
              ($env{'user.domain'} eq $ccdomain)) {  
            $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));  
         }  
     }  
 #  
 # Domain level  
 #  
     my $num_domain_level = 0;  
     my $domaintext =   
     '<h4>'.&mt('Domain Level').'</h4>'.  
     &Apache::loncommon::start_data_table().  
     &Apache::loncommon::start_data_table_header_row().  
     '<th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.  
     &mt('Extent').'</th>'.  
     '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.  
     &Apache::loncommon::end_data_table_header_row();  
     foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {  
         foreach my $role ('dc','li','dg','au','sc') {  
             if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {  
                my $plrole=&Apache::lonnet::plaintext($role);  
        my %lt=&Apache::lonlocal::texthash(  
                     'ssd'  => "Set Start Date",  
                     'sed'  => "Set End Date"  
        );  
                $num_domain_level ++;  
                $domaintext .=   
 &Apache::loncommon::start_data_table_row().  
 '<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td>  
 <td>'.$plrole.'</td>  
 <td>'.$thisdomain.'</td>  
 <td><input type="hidden" name="start_'.$thisdomain.'_'.$role.'" value="" />  
 <a href=  
 "javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>  
 <td><input type="hidden" name="end_'.$thisdomain.'_'.$role.'" value="" />  
 <a href=  
 "javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'.  
 &Apache::loncommon::end_data_table_row();  
             }  
         }   
     }  
     $domaintext.= &Apache::loncommon::end_data_table();  
     if ($num_domain_level > 0) {  
         $r->print($domaintext);  
         $addrolesdisplay = 1;  
     }  
 #  
 # Course level  
 #  
   
     if ($env{'request.role'} =~ m{^dc\./($match_domain)/$}) {      if ($env{'form.action'} eq 'singlestudent') {
         $r->print(&course_level_dc($1,'Course'));          $r->print('<br /><input type="button" value="'.&mt('Enroll Student').'" onClick="setSections(this.form)" />'."\n");
         $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n");      } else {
     } elsif ($env{'request.role'} =~ m{^au\./($match_domain)/$}) {          $r->print('<h3>'.&mt('Add Roles').'</h3>');
         if ($addrolesdisplay) {          my $addrolesdisplay = 0;
             $r->print('<br /><input type="button" value="'.&mt('Modify User').'"');          if ($context eq 'domain' || $context eq 'author') {
             if ($newuser) {              $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
                 $r->print(' onClick="verify_message(this.form)" \>'."\n");          }
           if ($context eq 'domain') {
               my $add_domainroles = &new_domain_roles($r);
               if (!$addrolesdisplay) {
                   $addrolesdisplay = $add_domainroles;
               }
               $r->print(&course_level_dc($env{'request.role.domain'},'Course'));
               $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setCourse()" />'."\n");
           } elsif ($context eq 'author') {
               if ($addrolesdisplay) {
                   $r->print('<br /><input type="button" value="'.&mt('Modify User').'"');
                   if ($newuser) {
                       $r->print(' onClick="verify_message(this.form)" \>'."\n");
                   } else {
                       $r->print('onClick="this.form.submit()" \>'."\n");
                   }
             } else {              } else {
                 $r->print('onClick="this.form.submit()" \>'."\n");                   $r->print('<br /><a href="javascript:backPage(document.cu)">'.
                             &mt('Back to previous page').'</a>');
             }              }
         } else {          } else {
             $r->print('<br /><a href="javascript:backPage(document.cu)">'.              $r->print(&course_level_table(%inccourses));
                       &mt('Back to previous page').'</a>');              $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n");
         }          }
     } else {  
         $r->print(&course_level_table(%inccourses));  
         $r->print('<br /><input type="button" value="'.&mt('Modify User').'" onClick="setSections(this.form)" />'."\n");  
     }      }
     $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));      $r->print(&Apache::lonhtmlcommon::echo_form_input(['phase','userrole','ccdomain','prevphase','currstate','ccuname','ccdomain']));
     $r->print('<input type="hidden" name="currstate" value="" />');      $r->print('<input type="hidden" name="currstate" value="" />');
     $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />');      $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" />');
     $r->print("</form>".&Apache::loncommon::end_page());      $r->print("</form>".&Apache::loncommon::end_page());
       return;
 }  }
   
 sub singleuser_breadcrumb {  sub singleuser_breadcrumb {
Line 1208  sub display_existing_roles { Line 1111  sub display_existing_roles {
     return;      return;
 }  }
   
   sub new_coauthor_roles {
       my ($r,$ccuname,$ccdomain) = @_;
       my $addrolesdisplay = 0;
       #
       # Co-Author
       #
       if (&Apache::lonuserutils::authorpriv($env{'user.name'},
                                             $env{'request.role.domain'}) &&
           ($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) {
           # No sense in assigning co-author role to yourself
           $addrolesdisplay = 1;
           my $cuname=$env{'user.name'};
           my $cudom=$env{'request.role.domain'};
           my %lt=&Apache::lonlocal::texthash(
                       'cs'   => "Construction Space",
                       'act'  => "Activate",
                       'rol'  => "Role",
                       'ext'  => "Extent",
                       'sta'  => "Start",
                       'end'  => "End",
                       'cau'  => "Co-Author",
                       'caa'  => "Assistant Co-Author",
                       'ssd'  => "Set Start Date",
                       'sed'  => "Set End Date"
                                          );
           $r->print('<h4>'.$lt{'cs'}.'</h4>'."\n".
                     &Apache::loncommon::start_data_table()."\n".
                     &Apache::loncommon::start_data_table_header_row()."\n".
                     '<th>'.$lt{'act'}.'</th><th>'.$lt{'rol'}.'</th>'.
                     '<th>'.$lt{'ext'}.'</th><th>'.$lt{'sta'}.'</th>'.
                     '<th>'.$lt{'end'}.'</th>'."\n".
                     &Apache::loncommon::end_data_table_header_row()."\n".
                     &Apache::loncommon::start_data_table_row().'
              <td>
               <input type=checkbox name="act_'.$cudom.'_'.$cuname.'_ca" />
              </td>
              <td>'.$lt{'cau'}.'</td>
              <td>'.$cudom.'_'.$cuname.'</td>
              <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_ca" value="" />
                <a href=
   "javascript:pjump('."'date_start','Start Date Co-Author',document.cu.start_$cudom\_$cuname\_ca.value,'start_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>
   <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_ca" value="" />
   <a href=
   "javascript:pjump('."'date_end','End Date Co-Author',document.cu.end_$cudom\_$cuname\_ca.value,'end_$cudom\_$cuname\_ca','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n".
                 &Apache::loncommon::end_data_table_row()."\n".
                 &Apache::loncommon::start_data_table_row()."\n".
   '<td><input type=checkbox name="act_'.$cudom.'_'.$cuname.'_aa" /></td>
   <td>'.$lt{'caa'}.'</td>
   <td>'.$cudom.'_'.$cuname.'</td>
   <td><input type="hidden" name="start_'.$cudom.'_'.$cuname.'_aa" value="" />
   <a href=
   "javascript:pjump('."'date_start','Start Date Assistant Co-Author',document.cu.start_$cudom\_$cuname\_aa.value,'start_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>
   <td><input type="hidden" name="end_'.$cudom.'_'.$cuname.'_aa" value="" />
   <a href=
   "javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n".
                &Apache::loncommon::end_data_table_row()."\n".
                &Apache::loncommon::end_data_table());
       } elsif ($env{'request.role'} =~ /^au\./) {
           if (!(&Apache::lonuserutils::authorpriv($env{'user.name'},
                                                   $env{'request.role.domain'}))) {
               $r->print('<span class="LC_error">'.
                         &mt('You do not have privileges to assign co-author roles.').
                         '</span>');
           } elsif (($env{'user.name'} eq $ccuname) &&
                ($env{'user.domain'} eq $ccdomain)) {
               $r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted'));
           }
       }
       return $addrolesdisplay;;
   }
   
   sub new_domain_roles {
       my ($r) = @_;
       my $addrolesdisplay = 0;
       #
       # Domain level
       #
       my $num_domain_level = 0;
       my $domaintext =
       '<h4>'.&mt('Domain Level').'</h4>'.
       &Apache::loncommon::start_data_table().
       &Apache::loncommon::start_data_table_header_row().
       '<th>'.&mt('Activate').'</th><th>'.&mt('Role').'</th><th>'.
       &mt('Extent').'</th>'.
       '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.
       &Apache::loncommon::end_data_table_header_row();
       foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
           foreach my $role ('dc','li','dg','au','sc') {
               if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
                  my $plrole=&Apache::lonnet::plaintext($role);
                  my %lt=&Apache::lonlocal::texthash(
                       'ssd'  => "Set Start Date",
                       'sed'  => "Set End Date"
                                          );
                  $num_domain_level ++;
                  $domaintext .=
   &Apache::loncommon::start_data_table_row().
   '<td><input type=checkbox name="act_'.$thisdomain.'_'.$role.'" /></td>
   <td>'.$plrole.'</td>
   <td>'.$thisdomain.'</td>
   <td><input type="hidden" name="start_'.$thisdomain.'_'.$role.'" value="" />
   <a href=
   "javascript:pjump('."'date_start','Start Date $plrole',document.cu.start_$thisdomain\_$role.value,'start_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'ssd'}.'</a></td>
   <td><input type="hidden" name="end_'.$thisdomain.'_'.$role.'" value="" />
   <a href=
   "javascript:pjump('."'date_end','End Date $plrole',document.cu.end_$thisdomain\_$role.value,'end_$thisdomain\_$role','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'.
   &Apache::loncommon::end_data_table_row();
               }
           }
       }
       $domaintext.= &Apache::loncommon::end_data_table();
       if ($num_domain_level > 0) {
           $r->print($domaintext);
           $addrolesdisplay = 1;
       }
       return $addrolesdisplay;
   }
   
 sub user_authentication {  sub user_authentication {
     my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_;      my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_;
     my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);      my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain);

Removed from v.1.217  
changed lines
  Added in v.1.218


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