Diff for /loncom/interface/loncreateuser.pm between versions 1.388 and 1.395

version 1.388, 2014/02/05 18:02:16 version 1.395, 2014/02/28 19:20:06
Line 126  sub user_quotas { Line 126  sub user_quotas {
     my ($ccuname,$ccdomain) = @_;      my ($ccuname,$ccdomain) = @_;
     my %lt = &Apache::lonlocal::texthash(      my %lt = &Apache::lonlocal::texthash(
                    'usrt'      => "User Tools",                     'usrt'      => "User Tools",
                    'cuqu'      => "Current quota",  
                    'cust'      => "Custom quota",                     'cust'      => "Custom quota",
                    'defa'      => "Default",  
                    'chqu'      => "Change quota",                     'chqu'      => "Change quota",
     );      );
         
Line 211  END_SCRIPT Line 209  END_SCRIPT
                        '    <td>'.$titles{$name}.'</td>'."\n".                         '    <td>'.$titles{$name}.'</td>'."\n".
                        '  </tr>'."\n".                         '  </tr>'."\n".
                        &Apache::loncommon::start_data_table_row()."\n".                         &Apache::loncommon::start_data_table_row()."\n".
                        '  <td>'.$lt{'cuqu'}.': '.                         '  <td><span class="LC_nobreak">'.
                        $currquota.'&nbsp;MB.&nbsp;&nbsp;'.                         &mt('Current quota: [_1] MB',$currquota).'</span>&nbsp;&nbsp;'.
                        $defaultinfo.'</td>'."\n".                         $defaultinfo.'</td>'."\n".
                        &Apache::loncommon::end_data_table_row()."\n".                         &Apache::loncommon::end_data_table_row()."\n".
                        &Apache::loncommon::start_data_table_row()."\n".                         &Apache::loncommon::start_data_table_row()."\n".
Line 220  END_SCRIPT Line 218  END_SCRIPT
                        ': <label>'.                         ': <label>'.
                        '<input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_off" '.                         '<input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_off" '.
                        'value="0" '.$custom_off.' onchange="javascript:quota_changes('."'custom','$name'".');"'.                         'value="0" '.$custom_off.' onchange="javascript:quota_changes('."'custom','$name'".');"'.
                        ' />'.$lt{'defa'}.'&nbsp;('.$defquota.' MB).</label>&nbsp;'.                         ' /><span class="LC_nobreak">'.
                          &mt('Default ([_1] MB)',$defquota).'</span></label>&nbsp;'.
                        '&nbsp;<label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.                         '&nbsp;<label><input type="radio" name="custom_'.$name.'quota" id="custom_'.$name.'quota_on" '.
                        'value="1" '.$custom_on.'  onchange="javascript:quota_changes('."'custom','$name'".');"'.                         'value="1" '.$custom_on.'  onchange="javascript:quota_changes('."'custom','$name'".');"'.
                        ' />'.$lt{'cust'}.':</label>&nbsp;'.                         ' />'.$lt{'cust'}.':</label>&nbsp;'.
                        '<input type="text" name="'.$name.'quota" id="'.$name.'quota" size ="5" '.                         '<input type="text" name="'.$name.'quota" id="'.$name.'quota" size ="5" '.
                        'value="'.$showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".');"'.                         'value="'.$showquota.'" onfocus="javascript:quota_changes('."'quota','$name'".');"'.
                        ' />&nbsp;MB</span></td>'."\n".                         ' />&nbsp;'.&mt('MB').'</span></td>'."\n".
                        &Apache::loncommon::end_data_table_row()."\n";                         &Apache::loncommon::end_data_table_row()."\n";
         }          }
     }      }
Line 1230  ENDFORMINFO Line 1229  ENDFORMINFO
             }              }
         }          }
     }      }
       my $title = '';
     if ($newuser) {      if ($newuser) {
         my ($portfolioform,$domroleform);          my ($portfolioform,$domroleform);
         if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||          if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
Line 1243  ENDFORMINFO Line 1243  ENDFORMINFO
         }          }
         &initialize_authen_forms($ccdomain,$formname);          &initialize_authen_forms($ccdomain,$formname);
         my %lt=&Apache::lonlocal::texthash(          my %lt=&Apache::lonlocal::texthash(
                 'cnu'            => 'Create New User',  
                 'ast'            => 'as a student',  
                 'ame'            => 'as a member',  
                 'ind'            => 'in domain',  
                 'lg'             => 'Login Data',                  'lg'             => 'Login Data',
                 'hs'             => "Home Server",                  'hs'             => "Home Server",
         );          );
Line 1260  $loginscript Line 1256  $loginscript
 // ]]>  // ]]>
 </script>  </script>
 <input type='hidden' name='makeuser' value='1' />  <input type='hidden' name='makeuser' value='1' />
 <h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain  
 ENDTITLE  ENDTITLE
         if ($env{'form.action'} eq 'singlestudent') {          if ($env{'form.action'} eq 'singlestudent') {
             if ($crstype eq 'Community') {              if ($crstype eq 'Community') {
                 $r->print(' ('.$lt{'ame'}.')');                  $title = &mt('Create New User [_1] in domain [_2] as a member',
                                    '"'.$ccuname.'"','"'.$ccdomain.'"');
             } else {              } else {
                 $r->print(' ('.$lt{'ast'}.')');                  $title = &mt('Create New User [_1] in domain [_2] as a student',
                                    '"'.$ccuname.'"','"'.$ccdomain.'"');
             }              }
           } else {
                   $title = &mt('Create New User [_1] in domain [_2]',
                                    '"'.$ccuname.'"','"'.$ccdomain.'"');
         }          }
         $r->print('</h2>'."\n".'<div class="LC_left_float">');          $r->print('<h2>'.$title.'</h2>'."\n");
         my $personal_table =           $r->print('<div class="LC_left_float">');
             &personal_data_display($ccuname,$ccdomain,$newuser,$context,          $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context,
                                    $inst_results{$ccuname.':'.$ccdomain});                                           $inst_results{$ccuname.':'.$ccdomain}));
         # (Do not offer Disable Safeguard here)          # Option to disable student/employee ID conflict checking not offerred for new users.
         $r->print($personal_table);  
         my ($home_server_pick,$numlib) =           my ($home_server_pick,$numlib) = 
             &Apache::loncommon::home_server_form_item($ccdomain,'hserver',              &Apache::loncommon::home_server_form_item($ccdomain,'hserver',
                                                       'default','hide');                                                        'default','hide');
Line 1360  ENDAUTH Line 1359  ENDAUTH
         }          }
         $r->print('</div><div class="LC_clear_float_footer"></div>');          $r->print('</div><div class="LC_clear_float_footer"></div>');
     } else { # user already exists      } else { # user already exists
  my %lt=&Apache::lonlocal::texthash(   $r->print($start_page.$forminfo);
                     'cup'  => "Modify existing user: ",  
                     'ens'  => "Enroll one student: ",  
                     'enm'  => "Enroll one member: ",  
                     'id'   => "in domain",  
        );  
  $r->print(<<ENDCHANGEUSER);  
 $start_page  
 $forminfo  
 <h2>  
 ENDCHANGEUSER  
         if ($env{'form.action'} eq 'singlestudent') {          if ($env{'form.action'} eq 'singlestudent') {
             if ($crstype eq 'Community') {              if ($crstype eq 'Community') {
                 $r->print($lt{'enm'});                  $title = &mt('Enroll one member: [_1] in domain [_2]',
                                    '"'.$ccuname.'"','"'.$ccdomain.'"');
             } else {              } else {
                 $r->print($lt{'ens'});                  $title = &mt('Enroll one student: [_1] in domain [_2]',
                                    '"'.$ccuname.'"','"'.$ccdomain.'"');
             }              }
         } else {          } else {
             $r->print($lt{'cup'});              $title = &mt('Modify existing user: [_1] in domain [_2]',
                                '"'.$ccuname.'"','"'.$ccdomain.'"');
         }          }
         $r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"</h2>'.          $r->print('<h2>'.$title.'</h2>'."\n");
                   "\n".'<div class="LC_left_float">');          $r->print('<div class="LC_left_float">');
         my $personal_table =           $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context,
             &personal_data_display($ccuname,$ccdomain,$newuser,$context,                                           $inst_results{$ccuname.':'.$ccdomain}));
                                    $inst_results{$ccuname.':'.$ccdomain});  
         $r->print($personal_table);  
         if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {          if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
             $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.              $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
                       &Apache::loncommon::start_data_table());                        &Apache::loncommon::start_data_table());
Line 1481  ENDNOTOOLSPRIV Line 1471  ENDNOTOOLSPRIV
         }          }
         $r->print('<br /><input type="button" value="'.$btntxt.'" onclick="setSections(this.form)" />'."\n");          $r->print('<br /><input type="button" value="'.$btntxt.'" onclick="setSections(this.form)" />'."\n");
     } else {      } else {
         $r->print('<fieldset><legend>'.&mt('Add Roles').'</legend>');          $r->print('<div class="LC_left_float">'.
                     '<fieldset><legend>'.&mt('Add Roles').'</legend>');
         my $addrolesdisplay = 0;          my $addrolesdisplay = 0;
         if ($context eq 'domain' || $context eq 'author') {          if ($context eq 'domain' || $context eq 'author') {
             $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);              $addrolesdisplay = &new_coauthor_roles($r,$ccuname,$ccdomain);
Line 1492  ENDNOTOOLSPRIV Line 1483  ENDNOTOOLSPRIV
                 $addrolesdisplay = $add_domainroles;                  $addrolesdisplay = $add_domainroles;
             }              }
             $r->print(&course_level_dc($env{'request.role.domain'},$showcredits));              $r->print(&course_level_dc($env{'request.role.domain'},$showcredits));
             $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'" onclick="setCourse()" />'."\n");              $r->print('</fieldset></div><div class="LC_clear_float_footer"></div>'.
                         '<br /><input type="button" value="'.&mt('Save').'" onclick="setCourse()" />'."\n");
         } elsif ($context eq 'author') {          } elsif ($context eq 'author') {
             if ($addrolesdisplay) {              if ($addrolesdisplay) {
                 $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'"');                  $r->print('</fieldset></div><div class="LC_clear_float_footer"></div>'.
                             '<br /><input type="button" value="'.&mt('Save').'"');
                 if ($newuser) {                  if ($newuser) {
                     $r->print(' onclick="auth_check()" \>'."\n");                      $r->print(' onclick="auth_check()" \>'."\n");
                 } else {                  } else {
                     $r->print('onclick="this.form.submit()" \>'."\n");                      $r->print('onclick="this.form.submit()" \>'."\n");
                 }                  }
             } else {              } else {
                 $r->print('</fieldset><br /><a href="javascript:backPage(document.cu)">'.                  $r->print('</fieldset></div>'.
                             '<div class="LC_clear_float_footer"></div>'.
                             '<br /><a href="javascript:backPage(document.cu)">'.
                           &mt('Back to previous page').'</a>');                            &mt('Back to previous page').'</a>');
             }              }
         } else {          } else {
             $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits));              $r->print(&course_level_table(\%inccourses,$showcredits,$defaultcredits));
             $r->print('</fieldset><br /><input type="button" value="'.&mt('Save').'" onclick="setSections(this.form)" />'."\n");              $r->print('</fieldset></div><div class="LC_clear_float_footer"></div>'.
                         '<br /><input type="button" value="'.&mt('Save').'" 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'}.'" /></form>');      $r->print('<input type="hidden" name="prevphase" value="'.$env{'form.phase'}.'" /></form><br /><br />');
     return;      return;
 }  }
   
Line 1817  sub display_existing_roles { Line 1813  sub display_existing_roles {
             }              }
         } else {          } else {
             $plaintext=              $plaintext=
                 &mt('Customrole [_1][_2]defined by [_3]',                  &mt('Custom role [_1][_2]defined by [_3]',
                         '"'.$croletitle.'"',                          '"'.$croletitle.'"',
                         '<br />',                          '<br />',
                         $croleuname.':'.$croleudom);                          $croleuname.':'.$croleudom);
Line 1867  sub display_existing_roles { Line 1863  sub display_existing_roles {
         } else {          } else {
             $contextrole = &mt('Existing Roles in this Domain');              $contextrole = &mt('Existing Roles in this Domain');
         }          }
         $r->print('<div>'.          $r->print('<div class="LC_left_float">'.
 '<fieldset><legend>'.$contextrole.'</legend>'.  '<fieldset><legend>'.$contextrole.'</legend>'.
 &Apache::loncommon::start_data_table("LC_createuser").  &Apache::loncommon::start_data_table("LC_createuser").
 &Apache::loncommon::start_data_table_header_row().  &Apache::loncommon::start_data_table_header_row().
Line 2167  sub modify_login_block { Line 2163  sub modify_login_block {
 }  }
   
 sub personal_data_display {  sub personal_data_display {
     my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_;      my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,
           $now,$captchaform,$emailusername) = @_;
     my ($output,%userenv,%canmodify,%canmodify_status);      my ($output,%userenv,%canmodify,%canmodify_status);
     my @userinfo = ('firstname','middlename','lastname','generation',      my @userinfo = ('firstname','middlename','lastname','generation',
                     'permanentemail','id');                      'permanentemail','id');
     my $rowcount = 0;      my $rowcount = 0;
     my $editable = 0;      my $editable = 0;
     %canmodify_status =       my %textboxsize = (
                          firstname      => '15',
                          middlename     => '15',
                          lastname       => '15',
                          generation     => '5',
                          permanentemail => '25',
                          id             => '15',
                         );
   
       my %lt=&Apache::lonlocal::texthash(
                   'pd'             => "Personal Data",
                   'firstname'      => "First Name",
                   'middlename'     => "Middle Name",
                   'lastname'       => "Last Name",
                   'generation'     => "Generation",
                   'permanentemail' => "Permanent e-mail address",
                   'id'             => "Student/Employee ID",
                   'lg'             => "Login Data",
                   'inststatus'     => "Affiliation",
                   'email'          => 'E-mail address',
                   'valid'          => 'Validation',
       );
   
       %canmodify_status =
         &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,          &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
                                                    ['inststatus'],$rolesarray);                                                     ['inststatus'],$rolesarray);
     if (!$newuser) {      if (!$newuser) {
Line 2185  sub personal_data_display { Line 2205  sub personal_data_display {
             &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,              &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
                                                        \@userinfo,$rolesarray);                                                         \@userinfo,$rolesarray);
     } elsif ($context eq 'selfcreate') {      } elsif ($context eq 'selfcreate') {
         %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo,          if ($newuser eq 'email') {
                                            $inst_results,$rolesarray);              if (ref($emailusername) eq 'HASH') { 
                   my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
                   @userinfo = ();          
                   if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
                       foreach my $field (@{$infofields}) { 
                           if ($emailusername->{$field}) {
                               push(@userinfo,$field);
                               $canmodify{$field} = 1;
                               unless ($textboxsize{$field}) {
                                   $textboxsize{$field} = 25;
                               }
                               unless ($lt{$field}) {
                                   $lt{$field} = $infotitles->{$field};
                               }
                           }
                       }
                   }
               }
           } else {
               %canmodify = &selfcreate_canmodify($context,$ccdomain,\@userinfo,
                                                  $inst_results,$rolesarray);
           }
     }      }
     my %lt=&Apache::lonlocal::texthash(  
                 'pd'             => "Personal Data",  
                 'firstname'      => "First Name",  
                 'middlename'     => "Middle Name",  
                 'lastname'       => "Last Name",  
                 'generation'     => "Generation",  
                 'permanentemail' => "Permanent e-mail address",  
                 'id'             => "Student/Employee ID",  
                 'lg'             => "Login Data",  
                 'inststatus'     => "Affiliation",  
     );  
     my %textboxsize = (  
                        firstname      => '15',  
                        middlename     => '15',  
                        lastname       => '15',  
                        generation     => '5',  
                        permanentemail => '25',  
                        id             => '15',  
                       );  
     my $genhelp=&Apache::loncommon::help_open_topic('Generation');      my $genhelp=&Apache::loncommon::help_open_topic('Generation');
     $output = '<h3>'.$lt{'pd'}.'</h3>'.      $output = '<h3>'.$lt{'pd'}.'</h3>'.
               &Apache::lonhtmlcommon::start_pick_box();                &Apache::lonhtmlcommon::start_pick_box();
       if (($context eq 'selfcreate') && ($newuser eq 'email')) {
           $output .= &Apache::lonhtmlcommon::row_title($lt{'email'},undef,
                                                        'LC_oddrow_value')."\n".
                      '<input type="text" name="uname" size="25" value="" autocomplete="off" />';
           $rowcount ++;
           $output .= &Apache::lonhtmlcommon::row_closure(1);
           my $upassone = '<input type="password" name="upass'.$now.'" size="10" autocomplete="off" />';
           my $upasstwo = '<input type="password" name="upasscheck'.$now.'" size="10" autocomplete="off" />';
           $output .= &Apache::lonhtmlcommon::row_title(&mt('Password'),
                                                       'LC_pick_box_title',
                                                       'LC_oddrow_value')."\n".
                      $upassone."\n".
                      &Apache::lonhtmlcommon::row_closure(1)."\n".
                      &Apache::lonhtmlcommon::row_title(&mt('Confirm password'),
                                                        'LC_pick_box_title',
                                                        'LC_oddrow_value')."\n".
                      $upasstwo.
                      &Apache::lonhtmlcommon::row_closure()."\n";
       }
     foreach my $item (@userinfo) {      foreach my $item (@userinfo) {
         my $rowtitle = $lt{$item};          my $rowtitle = $lt{$item};
         my $hiderow = 0;          my $hiderow = 0;
Line 2223  sub personal_data_display { Line 2265  sub personal_data_display {
                     $row .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item};                      $row .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item};
                 } else {                  } else {
                     if ($context eq 'selfcreate') {                      if ($context eq 'selfcreate') {
                         if ($canmodify{$item}) {                           if ($canmodify{$item}) {
                             $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';                              $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" autocomplete="off" />';
                             $editable ++;                              $editable ++;
                         } else {                          } else {
                             $hiderow = 1;                              $hiderow = 1;
Line 2239  sub personal_data_display { Line 2281  sub personal_data_display {
                         $row .= $ccuname;                          $row .= $ccuname;
                     } else {                      } else {
                         if ($canmodify{$item}) {                          if ($canmodify{$item}) {
                             $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';                              if ($newuser eq 'email') {
                                   $row .= '<input type="text" name="'.$item.'" size="'.$textboxsize{$item}.'" value="" autocomplete="off" />';
                               } else {
                                   $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" autocomplete="off" />';
                               }
                             $editable ++;                              $editable ++;
                         } else {                          } else {
                             $hiderow = 1;                              $hiderow = 1;
Line 2252  sub personal_data_display { Line 2298  sub personal_data_display {
         } else {          } else {
             if ($canmodify{$item}) {              if ($canmodify{$item}) {
                 $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';                  $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';
                   if (($item eq 'id') && (!$newuser)) {
                       $row .= '<br />'.&Apache::lonuserutils::forceid_change($context);
                   }
             } else {              } else {
                 $row .= $userenv{$item};                  $row .= $userenv{$item};
             }              }
             if (($item eq 'id') && ($canmodify{$item})) {  
                  $row .= '<br />'.&Apache::lonuserutils::forceid_change($context);  
             }  
         }          }
         $row .= &Apache::lonhtmlcommon::row_closure(1);          $row .= &Apache::lonhtmlcommon::row_closure(1);
         if (!$hiderow) {          if (!$hiderow) {
Line 2292  sub personal_data_display { Line 2338  sub personal_data_display {
                     }                      }
                 }                  }
                 if (!$hiderow) {                  if (!$hiderow) {
                     my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n".                      my $row = &Apache::lonhtmlcommon::row_title(&mt('Affiliations'),undef,'LC_oddrow_value')."\n".
                               $shown.&Apache::lonhtmlcommon::row_closure(1)                                $shown.&Apache::lonhtmlcommon::row_closure(1)
                     if ($context eq 'selfcreate') {                      if ($context eq 'selfcreate') {
                         $rowcount ++;                          $rowcount ++;
Line 2302  sub personal_data_display { Line 2348  sub personal_data_display {
             }              }
         }          }
     }      }
       if (($context eq 'selfcreate') && ($newuser eq 'email')) {
           if ($captchaform) {
               $output .= &Apache::lonhtmlcommon::row_title($lt{'valid'},
                                                            'LC_pick_box_title')."\n".
                          $captchaform."\n".'<br /><br />'.
                          &Apache::lonhtmlcommon::row_closure(1)
               $rowcount ++;
           }
           my $submit_text = &mt('Create account');
           $output .= &Apache::lonhtmlcommon::row_title()."\n".
                      '<br /><input type="submit" name="createaccount" value="'.
                      $submit_text.'" />'.
                      &Apache::lonhtmlcommon::row_closure(1);
       }
     $output .= &Apache::lonhtmlcommon::end_pick_box();      $output .= &Apache::lonhtmlcommon::end_pick_box();
     if (wantarray) {      if (wantarray) {
         if ($context eq 'selfcreate') {          if ($context eq 'selfcreate') {
Line 2472  sub update_user_data { Line 2532  sub update_user_data {
     if (! exists($env{'form.makeuser'})) {      if (! exists($env{'form.makeuser'})) {
         # Modifying an existing user, so check the validity of the name          # Modifying an existing user, so check the validity of the name
         if ($uhome eq 'no_host') {          if ($uhome eq 'no_host') {
             $r->print($error.&mt('Unable to determine home server for ').              $r->print(
                       $env{'form.ccuname'}.&mt(' in domain ').                  $error
                       $env{'form.ccdomain'}.'.');                 .'<p class="LC_error">'
                  .&mt('Unable to determine home server for [_1] in domain [_2].',
                           '"'.$env{'form.ccuname'}.'"','"'.$env{'form.ccdomain'}.'"')
                  .'</p>');
             return;              return;
         }          }
     }      }
Line 2652  sub update_user_data { Line 2715  sub update_user_data {
     $r->print($error.'Invalid login mode or password'.$end.$rtnlink);          $r->print($error.'Invalid login mode or password'.$end.$rtnlink);    
     return;      return;
  }   }
  # Only allow authentification modification if the person has authority   # Only allow authentication modification if the person has authority
  if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {   if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
     $r->print('Modifying authentication: '.      $r->print('Modifying authentication: '.
                       &Apache::lonnet::modifyuserauth(                        &Apache::lonnet::modifyuserauth(
Line 2662  sub update_user_data { Line 2725  sub update_user_data {
   ($env{'form.ccuname'},$env{'form.ccdomain'}));    ($env{'form.ccuname'},$env{'form.ccdomain'}));
  } else {   } else {
     # Okay, this is a non-fatal error.      # Okay, this is a non-fatal error.
     $r->print($error.&mt('You do not have the authority to modify this users authentification information').'.'.$end);          $r->print($error.&mt('You do not have the authority to modify this users authentication information.').$end);    
  }   }
     }      }
     $r->rflush(); # Finish display of header before time consuming actions start      $r->rflush(); # Finish display of header before time consuming actions start
Line 2964  sub update_user_data { Line 3027  sub update_user_data {
             }              }
         }          }
         foreach my $name ('portfolio','author') {          foreach my $name ('portfolio','author') {
             $oldsettings{'quota'}{$name} = $oldquota{$name}.' MB';              $oldsettings{'quota'}{$name} = &mt('[_1] MB',$oldquota{$name});
             $newsettings{'quota'}{$name} = $newquota{$name}.' MB';              $newsettings{'quota'}{$name} = &mt('[_1] MB',$newquota{$name});
         }          }
         if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {          if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
             my ($chgresult,$namechgresult);              my ($chgresult,$namechgresult);
Line 3064  sub update_user_data { Line 3127  sub update_user_data {
                     &Apache::lonnet::appenv(\%newenvhash);                      &Apache::lonnet::appenv(\%newenvhash);
                 }                  }
             } else { # error occurred              } else { # error occurred
                 $r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '.                  $r->print(
                       $env{'form.ccuname'}.' '.&mt('in domain').' '.                      '<p class="LC_error">'
                       $env{'form.ccdomain'}.'</span><br />');                     .&mt('Unable to successfully change environment for [_1] in domain [_2].',
                               '"'.$env{'form.ccuname'}.'"',
                               '"'.$env{'form.ccdomain'}.'"')
                      .'</p>');
             }              }
         } else { # End of if ($env ... ) logic          } else { # End of if ($env ... ) logic
             # They did not want to change the users name, quota, tool availability,              # They did not want to change the users name, quota, tool availability,
Line 3945  sub enroll_single_student { Line 4011  sub enroll_single_student {
         if ($startdate <= $now && !$newuser) {          if ($startdate <= $now && !$newuser) {
             $r->print('<p class="LC_info">');              $r->print('<p class="LC_info">');
             if ($crstype eq 'Community') {              if ($crstype eq 'Community') {
                 $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role will be available when the member next logs in.'));                  $r->print(&mt('If the member is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
             } else {              } else {
                 $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role will be available when the student next logs in.'));                  $r->print(&mt('If the student is currently logged-in to LON-CAPA, the new role can be displayed by using the "Check for changes" link on the Roles/Courses page.'));
            }             }
            $r->print('</p>');             $r->print('</p>');
         }          }
Line 4113  sub custom_role_editor { Line 4179  sub custom_role_editor {
     my $dompriv='';      my $dompriv='';
     my $coursepriv='';      my $coursepriv='';
     my $body_top;      my $body_top;
       my $newrole;
     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 4125  sub custom_role_editor { Line 4192  sub custom_role_editor {
             $syspriv =~ s/bre\&S//;                 $syspriv =~ s/bre\&S//;   
         }          }
     } else {      } else {
           $newrole = 1;
  $body_top .= &mt('New Role').' "';   $body_top .= &mt('New Role').' "';
  $roledef='';   $roledef='';
     }      }
Line 4394  sub set_custom_role { Line 4462  sub set_custom_role {
                  bread_crumbs_component => 'User Management'};                    bread_crumbs_component => 'User Management'}; 
     $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));      $r->print(&Apache::loncommon::start_page('Save Custom Role',$jscript,$args));
   
       my $newrole;
     my ($rdummy,$roledef)=      my ($rdummy,$roledef)=
  &Apache::lonnet::get('roles',["rolesdef_$rolename"]);   &Apache::lonnet::get('roles',["rolesdef_$rolename"]);
   
Line 4404  sub set_custom_role { Line 4473  sub set_custom_role {
     } else {      } else {
  $r->print(&mt('New Role').' "');   $r->print(&mt('New Role').' "');
  $roledef='';   $roledef='';
           $newrole = 1;
     }      }
     $r->print($rolename.'"</h3>');      $r->print($rolename.'"</h3>');
 # ------------------------------------------------------- What can be assigned?  # ------------------------------------------------------- What can be assigned?
Line 4494  sub handler { Line 4564  sub handler {
   
     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},      &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
         ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',          ['action','state','callingform','roletype','showrole','bulkaction','popup','phase',
          'username','domain','srchterm','srchdomain','srchin','srchby','srchtype']);           'username','domain','srchterm','srchdomain','srchin','srchby','srchtype','queue']);
     &Apache::lonhtmlcommon::clear_breadcrumbs();      &Apache::lonhtmlcommon::clear_breadcrumbs();
     my $args;      my $args;
     my $brcrum = [];      my $brcrum = [];
     my $bread_crumbs_component = 'User Management';      my $bread_crumbs_component = 'User Management';
     if ($env{'form.action'} ne 'dateselect') {      if (($env{'form.action'} ne 'dateselect') && ($env{'form.action'} ne 'displayuserreq')) {
         $brcrum = [{href=>"/adm/createuser",          $brcrum = [{href=>"/adm/createuser",
                     text=>"User Management",                      text=>"User Management",
                     help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}                      help=>'Course_Create_Class_List,Course_Change_Privileges,Course_View_Class_List,Course_Editing_Custom_Roles,Course_Add_Student,Course_Drop_Student,Course_Automated_Enrollment,Course_Self_Enrollment,Course_Manage_Group'}
Line 4666  sub handler { Line 4736  sub handler {
         }          }
         $args = { bread_crumbs           => $brcrum,          $args = { bread_crumbs           => $brcrum,
                   bread_crumbs_component => $bread_crumbs_component};                    bread_crumbs_component => $bread_crumbs_component};
         $r->print(&header(undef,$args));          my $js = &usernamerequest_javascript();
           $r->print(&header(&add_script($js),$args));
         if (!exists($env{'form.state'})) {          if (!exists($env{'form.state'})) {
             $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',              $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestauthor',
                                                                             $env{'request.role.domain'}));                                                                              $env{'request.role.domain'}));
Line 4675  sub handler { Line 4746  sub handler {
             $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',              $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestauthor',
                                                                          $env{'request.role.domain'}));                                                                           $env{'request.role.domain'}));
         }          }
       } elsif (($env{'form.action'} eq 'processusernamereq') &&
                ($permission->{'cusr'}) &&
                (&Apache::lonnet::allowed('cau',$env{'request.role.domain'}))) {
           push(@{$brcrum},
                    {href => '/adm/createuser?action=processusernamereq',
                     text => 'LON-CAPA account requests',
                     help => 'Domain_Username_Approvals'});
           $bread_crumbs_component = 'Account requests';
           if ($env{'form.state'} eq 'done') {
               push(@{$brcrum},
                        {href => '/adm/createuser?action=usernamereqqueue',
                         text => 'Result',
                         help => 'Domain_Username_Approvals'});
               $bread_crumbs_component = 'LON-CAPA account request result';
           }
           $args = { bread_crumbs           => $brcrum,
                     bread_crumbs_component => $bread_crumbs_component};
           my $js = &usernamerequest_javascript();
           $r->print(&header(&add_script($js),$args));
           if (!exists($env{'form.state'})) {
               $r->print(&Apache::loncoursequeueadmin::display_queued_requests('requestusername',
                                                                               $env{'request.role.domain'}));
           } elsif ($env{'form.state'} eq 'done') {
               $r->print('<h3>'.&mt('LON-CAPA account request processing').'</h3>'."\n");
               $r->print(&Apache::loncoursequeueadmin::update_request_queue('requestusername',
                                                                            $env{'request.role.domain'}));
           }
       } elsif (($env{'form.action'} eq 'displayuserreq') &&
                ($permission->{'cusr'})) {
           my $dom = $env{'form.domain'};
           my $uname = $env{'form.username'};
           my $warning;
           if (($dom =~ /^$match_domain$/) && (&Apache::lonnet::domain($dom) ne '')) {
               if (($dom eq $env{'request.role.domain'}) && (&Apache::lonnet::allowed('ccc',$dom))) {
                   if (($uname =~ /^$match_username$/) && ($env{'form.queue'} eq 'approval')) {
                       my $uhome = &Apache::lonnet::homeserver($uname,$dom);
                       if ($uhome eq 'no_host') {
                           my $queue = $env{'form.queue'};
                           my $reqkey = &escape($uname).'_'.$queue; 
                           my $namespace = 'usernamequeue';
                           my $domconfig = &Apache::lonnet::get_domainconfiguser($dom);
                           my %queued =
                               &Apache::lonnet::get($namespace,[$reqkey],$dom,$domconfig);
                           unless ($queued{$reqkey}) {
                               $warning = &mt('No information was found for this LON-CAPA account request.');
                           }
                       } else {
                           $warning = &mt('A LON-CAPA account already exists for the requested username and domain.');
                       }
                   } else {
                       $warning = &mt('LON-CAPA account request status check is for an invalid username.');
                   }
               } else {
                   $warning = &mt('You do not have rights to view LON-CAPA account requests in the domain specified.');
               }
           } else {
               $warning = &mt('LON-CAPA account request status check is for an invalid domain.');
           }
           my $args = { only_body => 1 };
           $r->print(&header(undef,$args).
                     '<h3>'.&mt('LON-CAPA Account Request Details').'</h3>');
           if ($warning ne '') {
               $r->print('<div class="LC_warning">'.$warning.'</div>');
           } else {
               my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
               my $domconfiguser = &Apache::lonnet::get_domainconfiguser($dom);
               my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
               if (ref($domconfig{'usercreation'}) eq 'HASH') {
                   if (ref($domconfig{'usercreation'}{'cancreate'}) eq 'HASH') {
                       if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}) eq 'HASH') {
                           my $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}}));
                           my %info =
                               &Apache::lonnet::get('nohist_requestedusernames',[$uname],$dom,$domconfiguser);
                           if (ref($info{$uname}) eq 'HASH') {
                               if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
                                   $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box());
                                   my $num;
                                   foreach my $field (@{$infofields}) {
                                       next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$field});
                                       next unless ($infotitles->{$field});
                                       $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}).
                                                 $info{$uname}{$field});
                                       $num ++;
                                       if ($count == $num) {
                                           $r->print(&Apache::lonhtmlcommon::row_closure(1));
                                       } else {
                                           $r->print(&Apache::lonhtmlcommon::row_closure());
                                       }
                                   }
                                   $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
                               }
                           }
                       }
                   }
               }
               $r->print(&close_popup_form());
           }
     } elsif (($env{'form.action'} eq 'listusers') &&       } elsif (($env{'form.action'} eq 'listusers') && 
              ($permission->{'view'} || $permission->{'cusr'})) {               ($permission->{'view'} || $permission->{'cusr'})) {
         if ($env{'form.phase'} eq 'bulkchange') {          if ($env{'form.phase'} eq 'bulkchange') {
Line 4874  sub add_script { Line 5042  sub add_script {
           .'</script>'."\n";            .'</script>'."\n";
 }  }
   
   sub usernamerequest_javascript {
       my $js = <<ENDJS;
   
   function openusernamereqdisplay(dom,uname,queue) {
       var url = '/adm/createuser?action=displayuserreq';
       url += '&domain='+dom+'&username='+uname+'&queue='+queue;
       var title = 'Account_Request_Browser';
       var options = 'scrollbars=1,resizable=1,menubar=0';
       options += ',width=700,height=600';
       var stdeditbrowser = open(url,title,options,'1');
       stdeditbrowser.focus();
       return;
   }
    
   ENDJS
   }
   
   sub close_popup_form {
       my $close= &mt('Close Window');
       return << "END";
   <p><form name="displayreq" action="" method="post">
   <input type="button" name="closeme" value="$close" onclick="javascript:self.close();" />
   </form></p>
   END
   }
   
 sub verify_user_display {  sub verify_user_display {
     my ($context) = @_;      my ($context) = @_;
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
Line 5127  sub print_main_menu { Line 5321  sub print_main_menu {
              linktitle => 'Approve or reject author role requests',               linktitle => 'Approve or reject author role requests',
             },              },
             {              {
                linktext => 'LON-CAPA Account Requests',
                icon => 'list-add.png',
                #help => 'Domain_Username_Approvals',
                url => '/adm/createuser?action=processusernamereq',
                permission => $permission->{'cusr'},
                linktitle => 'Approve or reject LON-CAPA account requests',
               },
               {
              linktext => 'Change Log',               linktext => 'Change Log',
              icon => 'document-properties.png',               icon => 'document-properties.png',
              #help => 'Course_User_Logs',               #help => 'Course_User_Logs',
Line 6994  sub course_level_dc { Line 7196  sub course_level_dc {
     my $otheritems = &Apache::loncommon::start_data_table_row()."\n".      my $otheritems = &Apache::loncommon::start_data_table_row()."\n".
                      '<td><br /><span class="LC_nobreak"><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc','','','','crstype'".')" />'.                       '<td><br /><span class="LC_nobreak"><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc','','','','crstype'".')" />'.
                      $courseform.('&nbsp;' x4).'</span></td>'."\n".                       $courseform.('&nbsp;' x4).'</span></td>'."\n".
                      '<td valign><br /><select name="role">'."\n";                       '<td valign="top"><br /><select name="role">'."\n";
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole=&Apache::lonnet::plaintext($role);          my $plrole=&Apache::lonnet::plaintext($role);
         $otheritems .= '  <option value="'.$role.'">'.$plrole;          $otheritems .= '  <option value="'.$role.'">'.$plrole.'</option>';
     }      }
     if ( keys %customroles > 0) {      if ( keys %customroles > 0) {
         foreach my $cust (sort keys %customroles) {          foreach my $cust (sort keys %customroles) {
             my $custrole='cr_cr_'.$env{'user.domain'}.              my $custrole='cr_cr_'.$env{'user.domain'}.
                     '_'.$env{'user.name'}.'_'.$cust;                      '_'.$env{'user.name'}.'_'.$cust;
             $otheritems .= '  <option value="'.$custrole.'">'.$cust;              $otheritems .= '  <option value="'.$custrole.'">'.$cust.'</option>';
         }          }
     }      }
     $otheritems .= '</select></td><td>'.      $otheritems .= '</select></td><td>'.
                      '<table border="0" cellspacing="0" cellpadding="0">'.                       '<table border="0" cellspacing="0" cellpadding="0">'.
                      '<tr><td valign="top"><b>'.$lt{'exs'}.'</b><br /><select name="currsec">'.                       '<tr><td valign="top"><b>'.$lt{'exs'}.'</b><br /><select name="currsec">'.
                      ' <option value=""><--'.&mt('Pick course first').'</select></td>'.                       ' <option value="">&lt;--'.&mt('Pick course first').'</option></select></td>'.
                      '<td>&nbsp;&nbsp;</td>'.                       '<td>&nbsp;&nbsp;</td>'.
                      '<td valign="top">&nbsp;<b>'.$lt{'new'}.'</b><br />'.                       '<td valign="top">&nbsp;<b>'.$lt{'new'}.'</b><br />'.
                      '<input type="text" name="newsec" value="" />'.                       '<input type="text" name="newsec" value="" />'.

Removed from v.1.388  
changed lines
  Added in v.1.395


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