Diff for /loncom/interface/loncreateuser.pm between versions 1.406.2.7 and 1.427

version 1.406.2.7, 2016/11/13 15:47:04 version 1.427, 2017/01/01 14:08:34
Line 252  sub build_tools_display { Line 252  sub build_tools_display {
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
                    'community'  => 'Can request creation of communities',                     'community'  => 'Can request creation of communities',
                    'textbook'   => 'Can request creation of textbook courses',                     'textbook'   => 'Can request creation of textbook courses',
                      'placement'  => 'Can request creation of placement tests',
                    'requestauthor'  => 'Can request author space',                     'requestauthor'  => 'Can request author space',
     );      );
     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',
                       'requestcourses.community','requestcourses.textbook');                        'requestcourses.community','requestcourses.textbook',
         @usertools = ('official','unofficial','community','textbook');                        'requestcourses.placement');
           @usertools = ('official','unofficial','community','textbook','placement');
         @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();
Line 333  sub build_tools_display { Line 335  sub build_tools_display {
                    '   <td'.$colspan.'>'.$lt{$item}.'</td>'."\n".                     '   <td'.$colspan.'>'.$lt{$item}.'</td>'."\n".
                    '  </tr>'."\n".                     '  </tr>'."\n".
                    &Apache::loncommon::start_data_table_row()."\n";                     &Apache::loncommon::start_data_table_row()."\n";
     
         if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {          if (($context eq 'requestcourses') || ($context eq 'requestauthor')) {
             my ($curroption,$currlimit);              my ($curroption,$currlimit);
             my $envkey = $context.'.'.$item;              my $envkey = $context.'.'.$item;
Line 451  sub coursereq_externaluser { Line 454  sub coursereq_externaluser {
                    'unofficial' => 'Can request creation of unofficial courses',                     'unofficial' => 'Can request creation of unofficial courses',
                    'community'  => 'Can request creation of communities',                     'community'  => 'Can request creation of communities',
                    'textbook'   => 'Can request creation of textbook courses',                     'textbook'   => 'Can request creation of textbook courses',
                      'placement'  => 'Can request creation of placement tests',
     );      );
   
     %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,      %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                       'reqcrsotherdom.official','reqcrsotherdom.unofficial',                        'reqcrsotherdom.official','reqcrsotherdom.unofficial',
                       'reqcrsotherdom.community','reqcrsotherdom.textbook');                        'reqcrsotherdom.community','reqcrsotherdom.textbook',
     @usertools = ('official','unofficial','community','textbook');                        'reqcrsotherdom.placement');
       @usertools = ('official','unofficial','community','textbook','placement');
     @options = ('approval','validate','autolimit');      @options = ('approval','validate','autolimit');
     %validations = &Apache::lonnet::auto_courserequest_checks($cdom);      %validations = &Apache::lonnet::auto_courserequest_checks($cdom);
     my $optregex = join('|',@options);      my $optregex = join('|',@options);
Line 531  sub domainrole_req { Line 536  sub domainrole_req {
            &Apache::loncommon::end_data_table();             &Apache::loncommon::end_data_table();
 }  }
   
 sub domadhocroles {  
     my ($ccuname,$ccdomain) = @_;  
     my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});  
     my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},  
                                        $confname,'rolesdef_');  
     my ($output,$canmodify);  
     if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {  
         $canmodify = 1;  
     }  
     if (keys(%existing) > 0) {  
         my @current;  
         my $curradhoc = 'adhocroles.'.$env{'request.role.domain'};  
         my %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,$curradhoc);  
         if ($userenv{$curradhoc}) {  
             @current = split(/,/,$userenv{$curradhoc});  
         }  
         if (!$canmodify && !@current) {  
             return;  
         }  
         my %customroles;  
         foreach my $key (keys(%existing)) {  
             if ($key=~/^rolesdef\_(\w+)$/) {  
                 my $rolename = $1;  
                 my %privs;  
                 ($privs{'system'},$privs{'domain'},$privs{'course'}) = split(/\_/,$existing{$key});  
                 $customroles{$rolename} = \%privs;  
             }  
         }  
         $output = '<br /><h3>'.  
                   &mt('Ad Hoc Course Roles Selectable via Helpdesk Role').  
                   '</h3>'."\n".  
                   &Apache::loncommon::start_data_table().  
                   &Apache::loncommon::start_data_table_header_row();  
         if ($canmodify) {  
             $output .= '<th>'.&mt('Action').'</th>';  
         }  
         $output .= '<th>'.&mt('Role').'</th>'.  
                    '<th>'.&mt('Privileges in Course').'<th>'.  
                    &Apache::loncommon::end_data_table_header_row();  
         foreach my $key (sort(keys(%customroles))) {  
             next if ((!$canmodify) && (!grep(/^\Q$key\E$/,@current)));  
             $output .= &Apache::loncommon::start_data_table_row();  
             if ($canmodify) {  
                 if (grep(/^\Q$key\E$/,@current)) {  
                     $output .= '<td><label>'.  
                                '<input type="checkbox" name="adhocroledel" value="'.$key.'" />'.  
                                &mt('Delete').'</label>'.  
                                '</td>';  
                 } else {  
                     $output .= '<td><label>'.  
                                '<input type="checkbox" name="adhocroleadd" value="'.$key.'" />'.  
                                &mt('Add').'</label>'.  
                                '</td>';  
                 }  
             }  
             $output .= '<td>'.$key.'</td><td>';  
             foreach my $level ('course','domain','system') {  
                 if ($customroles{$key}{$level}) {  
                     my $suffix;  
                     if (($level eq 'domain') || ($level eq 'system')) {  
                         $suffix = '&nbsp;('.&mt($level).')';  
                     }  
                     my @privs = split(/:/,$customroles{$key}{$level});  
                     foreach my $item (@privs) {  
                         next if ($item eq '');  
                         my ($priv,$cond) = split(/\&/,$item);  
                         $output .= &Apache::lonnet::plaintext($priv,'Course').$suffix.'<br />';  
                     }  
                 }  
             }  
             $output .= '</td>'.  
                        &Apache::loncommon::end_data_table_row();  
         }  
         $output .= &Apache::loncommon::end_data_table();  
     }  
     return $output;  
 }  
   
 sub courserequest_titles {  sub courserequest_titles {
     my %titles = &Apache::lonlocal::texthash (      my %titles = &Apache::lonlocal::texthash (
                                    official   => 'Official',                                     official   => 'Official',
                                    unofficial => 'Unofficial',                                     unofficial => 'Unofficial',
                                    community  => 'Communities',                                     community  => 'Communities',
                                    textbook   => 'Textbook',                                     textbook   => 'Textbook',
                                      placement  => 'Placement Tests',
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
Line 932  ENDBLOCK Line 860  ENDBLOCK
         $output = '<p>'.$userpicker.'</p>';          $output = '<p>'.$userpicker.'</p>';
     }      }
     if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') &&      if (($env{'form.phase'} eq '') && ($env{'form.action'} ne 'accesslogs') &&
         (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&          (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') && 
         (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) {          (!&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))))) {
         my $defdom=$env{'request.role.domain'};          my $defdom=$env{'request.role.domain'};
         my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');          my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain');
Line 1357  ENDFORMINFO Line 1285  ENDFORMINFO
     }      }
     my $title = '';      my $title = '';
     if ($newuser) {      if ($newuser) {
         my ($portfolioform,$domroleform,$adhocroleform);          my ($portfolioform,$domroleform);
         if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||          if ((&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) ||
             (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {              (&Apache::lonnet::allowed('mut',$env{'request.role.domain'}))) {
             # Current user has quota or user tools modification privileges              # Current user has quota or user tools modification privileges
Line 1367  ENDFORMINFO Line 1295  ENDFORMINFO
             ($ccdomain eq $env{'request.role.domain'})) {              ($ccdomain eq $env{'request.role.domain'})) {
             $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);              $domroleform = '<br />'.&domainrole_req($ccuname,$ccdomain);
         }          }
         if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {  
             $adhocroleform = &domadhocroles($ccuname,$ccdomain);  
             if ($adhocroleform) {  
                 $adhocroleform = '<br />'.$adhocroleform;  
             }  
         }  
         &initialize_authen_forms($ccdomain,$formname);          &initialize_authen_forms($ccdomain,$formname);
         my %lt=&Apache::lonlocal::texthash(          my %lt=&Apache::lonlocal::texthash(
                 'lg'             => 'Login Data',                  'lg'             => 'Login Data',
Line 1483  ENDAUTH Line 1405  ENDAUTH
         } else {          } else {
             $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc));               $r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); 
         }          }
         $r->print($portfolioform.$domroleform.$adhocroleform);          $r->print($portfolioform.$domroleform);
         if ($env{'form.action'} eq 'singlestudent') {          if ($env{'form.action'} eq 'singlestudent') {
             $r->print(&date_sections_select($context,$newuser,$formname,              $r->print(&date_sections_select($context,$newuser,$formname,
                                             $permission,$crstype,$ccuname,                                              $permission,$crstype,$ccuname,
Line 1513  ENDAUTH Line 1435  ENDAUTH
         $r->print('<div class="LC_left_float">');          $r->print('<div class="LC_left_float">');
         $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context,          $r->print(&personal_data_display($ccuname,$ccdomain,$newuser,$context,
                                          $inst_results{$ccuname.':'.$ccdomain}));                                           $inst_results{$ccuname.':'.$ccdomain}));
         if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) ||          if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) || 
             (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) {              (&Apache::lonnet::allowed('udp',$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 1526  ENDAUTH Line 1448  ENDAUTH
             $r->print(&Apache::loncommon::end_data_table());              $r->print(&Apache::loncommon::end_data_table());
         }          }
         $r->print('</div>');          $r->print('</div>');
         my @order = ('auth','quota','tools','requestauthor','adhocroles');          my @order = ('auth','quota','tools','requestauthor');
         my %user_text;          my %user_text;
         my ($isadv,$isauthor) =           my ($isadv,$isauthor) = 
             &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);              &Apache::lonnet::is_advanced_user($ccdomain,$ccuname);
         if ((!$isauthor) &&           if ((!$isauthor) && 
             ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) ||              ((&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) ||
              (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) &&               (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) &&
              ($env{'request.role.domain'} eq $ccdomain)) {              ($env{'request.role.domain'} eq $ccdomain)) {
             $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);              $user_text{'requestauthor'} = &domainrole_req($ccuname,$ccdomain);
         }          }
         if ((&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) ||  
             (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) {  
             $user_text{'adhocroles'} = &domadhocroles($ccuname,$ccdomain);  
         }  
         $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);          $user_text{'auth'} =  &user_authentication($ccuname,$ccdomain,$formname);
         if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||          if ((&Apache::lonnet::allowed('mpq',$ccdomain)) ||
             (&Apache::lonnet::allowed('mut',$ccdomain)) ||              (&Apache::lonnet::allowed('mut',$ccdomain)) ||
Line 1608  ENDNOTOOLSPRIV Line 1526  ENDNOTOOLSPRIV
         } elsif (($context eq 'course') && ((&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) ||          } elsif (($context eq 'course') && ((&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) ||
                  ($env{'request.course.sec'} &&                   ($env{'request.course.sec'} &&
                   &Apache::lonnet::allowed('vcl',$env{'request.course.id'}.'/'.$env{'request.course.sec'})))) {                    &Apache::lonnet::allowed('vcl',$env{'request.course.id'}.'/'.$env{'request.course.sec'})))) {
             $statuses = ['active'];              $statuses = ['active'];   
         }          }
         if ($env{'form.action'} ne 'singlestudent') {          if ($env{'form.action'} ne 'singlestudent') {
             &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,              &display_existing_roles($r,$ccuname,$ccdomain,\%inccourses,$context,
Line 1842  sub display_existing_roles { Line 1760  sub display_existing_roles {
         if ($active) {          if ($active) {
             next unless($showall || $showactive);              next unless($showall || $showactive);
         } else {          } else {
             next unless($showall || $showexpired);              next unless($showall || $showexpired); 
         }          }
 # 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)=
Line 1987  sub display_existing_roles { Line 1905  sub display_existing_roles {
             } else {              } else {
                 $row.='&nbsp;';                  $row.='&nbsp;';
             }              }
             $row.= '</td>';              $row.= '</td>'; 
         }          }
         my $plaintext='';          my $plaintext='';
         if (!$croletitle) {          if (!$croletitle) {
Line 2256  $lt{'uuas'} ($currentauth). $lt{'adcs'}. Line 2174  $lt{'uuas'} ($currentauth). $lt{'adcs'}.
 ENDBADAUTH  ENDBADAUTH
         }          }
     } else { # Authentication type is valid      } else { # Authentication type is valid
           
         &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser');          &initialize_authen_forms($ccdomain,$formname,$currentauth,'modifyuser');
         my ($authformcurrent,$can_modify,@authform_others) =          my ($authformcurrent,$can_modify,@authform_others) =
             &modify_login_block($ccdomain,$currentauth);              &modify_login_block($ccdomain,$currentauth);
Line 2299  ENDBADAUTH Line 2218  ENDBADAUTH
                         $result = &mt('Currently Kerberos authenticated, Version [_1].',$krbver);                          $result = &mt('Currently Kerberos authenticated, Version [_1].',$krbver);
                     } else {                      } else {
                         $result = &mt('Currently Kerberos authenticated with domain [_1] Version [_2].',                          $result = &mt('Currently Kerberos authenticated with domain [_1] Version [_2].',
                                       $krbver,$krbrealm);                                        $krbrealm,$krbver);
                     }                      }
                 } elsif ($currentauth =~ /^internal:/) {                  } elsif ($currentauth =~ /^internal:/) {
                     $result = &mt('Currently internally authenticated.');                      $result = &mt('Currently internally authenticated.');
Line 2814  sub update_user_data { Line 2733  sub update_user_data {
     my (%alerts,%rulematch,%inst_results,%curr_rules);      my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');      my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
     my @usertools = ('aboutme','blog','webdav','portfolio');      my @usertools = ('aboutme','blog','webdav','portfolio');
     my @requestcourses = ('official','unofficial','community','textbook');      my @requestcourses = ('official','unofficial','community','textbook','placement');
     my @requestauthor = ('requestauthor');      my @requestauthor = ('requestauthor');
     my ($othertitle,$usertypes,$types) =       my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});          &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
Line 2924  sub update_user_data { Line 2843  sub update_user_data {
                                                     $newcustom{'requestauthor'},                                                      $newcustom{'requestauthor'},
                                                     \%changeHash,'requestauthor');                                                      \%changeHash,'requestauthor');
                 }                  }
                 if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {  
                     my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');  
                     if (&adhocrole_changes(\%changeHash)) {  
                         $changed{'adhocroles.'.$env{'request.role.domain'}} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};  
                     }  
                 }  
             }              }
             if ($canmodify_status{'inststatus'}) {              if ($canmodify_status{'inststatus'}) {
                 if (exists($env{'form.inststatus'})) {                  if (exists($env{'form.inststatus'})) {
Line 2993  sub update_user_data { Line 2906  sub update_user_data {
              'requestcourses.community','requestcourses.textbook',               'requestcourses.community','requestcourses.textbook',
              'reqcrsotherdom.official','reqcrsotherdom.unofficial',               'reqcrsotherdom.official','reqcrsotherdom.unofficial',
              'reqcrsotherdom.community','reqcrsotherdom.textbook',               'reqcrsotherdom.community','reqcrsotherdom.textbook',
              'requestauthor','adhocroles.'.$env{'request.role.domain'}],               'reqcrsotherdom.placement','requestauthor'],
               $env{'form.ccdomain'},$env{'form.ccuname'});                $env{'form.ccdomain'},$env{'form.ccuname'});
         my ($tmp) = keys(%userenv);          my ($tmp) = keys(%userenv);
         if ($tmp =~ /^(con_lost|error)/i) {           if ($tmp =~ /^(con_lost|error)/i) { 
Line 3132  sub update_user_data { Line 3045  sub update_user_data {
                 &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);                  &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus,$name);
             ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});              ($newdefquota{$name},$newsettingstatus{$name}) = ($olddefquota{$name},$oldsettingstatus{$name});
         }          }
         push(@disporder,'adhocroles');  
         my %canshow;          my %canshow;
         if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {          if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
             $canshow{'quota'} = 1;              $canshow{'quota'} = 1;
Line 3151  sub update_user_data { Line 3063  sub update_user_data {
         if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {          if (&Apache::lonnet::allowed('cau',$env{'form.ccdomain'})) {
             $canshow{'requestauthor'} = 1;              $canshow{'requestauthor'} = 1;
         }          }
         if (&Apache::lonnet::allowed('cdh',$env{'request.role.domain'})) {  
             $canshow{'adhocroles'} = 1;  
         }  
         my (%changeHash,%changed);          my (%changeHash,%changed);
         if ($oldinststatus eq '') {          if ($oldinststatus eq '') {
             $oldsettings{'inststatus'} = $othertitle;               $oldsettings{'inststatus'} = $othertitle; 
Line 3267  sub update_user_data { Line 3176  sub update_user_data {
                 &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,                  &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
                               \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);                                \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
             }              }
             if ($userenv{'adhocroles.'.$env{'request.role.domain'}}) {  
                 $changeHash{'adhocroles.'.$env{'request.role.domain'}} = $userenv{'adhocroles.'.$env{'request.role.domain'}};  
             }  
             if (&adhocrole_changes(\%changeHash,\%userenv)) {  
                 $changed{'adhocroles'} = 1;  
                 $oldsettings{'adhocroles'} = $userenv{'adhocroles.'.$env{'request.role.domain'}};  
                 $newsettings{'adhocroles'} = $changeHash{'adhocroles.'.$env{'request.role.domain'}};  
             }  
         }          }
         foreach my $item (@userinfo) {          foreach my $item (@userinfo) {
             if ($env{'form.c'.$item} ne $userenv{$item}) {              if ($env{'form.c'.$item} ne $userenv{$item}) {
Line 3296  sub update_user_data { Line 3197  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') || ($key eq 'textbook')) {                                  ($key eq 'community') || ($key eq 'textbook') ||
                                   ($key eq 'placement')) {
                                 $newenvhash{'environment.requestcourses.'.$key} =                                  $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};                                      $changeHash{'requestcourses.'.$key};
                                 if ($changeHash{'requestcourses.'.$key}) {                                  if ($changeHash{'requestcourses.'.$key}) {
Line 3316  sub update_user_data { Line 3218  sub update_user_data {
           &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},            &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
                                             $key,'reload','requestauthor');                                              $key,'reload','requestauthor');
                                 }                                  }
                             } elsif ($key eq 'adhocroles') {  
                                 $newenvhash{'adhocroles.'.$env{'request.role.domain'}} =  
                                     $changeHash{'adhocroles.'.$env{'request.role.domain'}};  
                             } elsif ($key ne 'quota') {                              } elsif ($key ne 'quota') {
                                 $newenvhash{'environment.tools.'.$key} =                                   $newenvhash{'environment.tools.'.$key} = 
                                     $changeHash{'tools.'.$key};                                      $changeHash{'tools.'.$key};
Line 3366  sub update_user_data { Line 3265  sub update_user_data {
                                   \%newsettingstext);                                    \%newsettingstext);
                 if ($env{'form.cid'} ne $userenv{'id'}) {                  if ($env{'form.cid'} ne $userenv{'id'}) {
                     &Apache::lonnet::idput($env{'form.ccdomain'},                      &Apache::lonnet::idput($env{'form.ccdomain'},
                          {$env{'form.ccuname'} => $env{'form.cid'}});                           {$env{'form.ccuname'} => $env{'form.cid'}},$uhome,'ids');
                     if (($recurseid) &&                      if (($recurseid) &&
                         (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {                          (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
                         my $idresult =                           my $idresult = 
Line 3509  sub display_userinfo { Line 3408  sub display_userinfo {
          'unofficial'     => 'Can Request Unofficial Courses',           'unofficial'     => 'Can Request Unofficial Courses',
          'community'      => 'Can Request Communities',           'community'      => 'Can Request Communities',
          'textbook'       => 'Can Request Textbook Courses',           'textbook'       => 'Can Request Textbook Courses',
            'placement'      => 'Can Request Placement Tests',
          'requestauthor'  => 'Can Request Author Role',           'requestauthor'  => 'Can Request Author Role',
          'adhocroles'     => 'Ad Hoc Roles Selectable via Helpdesk Role',  
          'inststatus'     => "Affiliation",           'inststatus'     => "Affiliation",
          'prvs'           => 'Previous Value:',           'prvs'           => 'Previous Value:',
          'chto'           => 'Changed To:'           'chto'           => 'Changed To:'
Line 3876  sub tool_changes { Line 3775  sub tool_changes {
     return;      return;
 }  }
   
 sub adhocrole_changes {  
     my ($changehashref,$userenv) = @_;  
     my @adds = &Apache::loncommon::get_env_multiple('form.adhocroleadd');  
     my @dels = &Apache::loncommon::get_env_multiple('form.adhocroledel');  
     my (@saved,@added,@alladhoc,$changed);  
     my $adhoc_key = 'adhocroles.'.$env{'request.role.domain'};  
     if (!$env{'form.makeuser'}) {  
         if (ref($userenv) eq 'HASH') {  
             my @current;  
             if ($userenv->{$adhoc_key}) {  
                 @current = split(/,/,$userenv->{$adhoc_key});  
                 if (@dels) {  
                     foreach my $curr (@current) {  
                         next if ($curr eq '');  
                         unless (grep(/\Q$curr\E$/,@dels)) {  
                             push(@saved,$curr);  
                         }  
                     }  
                     $changed = 1;  
                 } else {  
                     @saved = @current;  
                 }  
             }  
         }  
     }  
     if (@adds) {  
         my $confname = &Apache::lonnet::get_domainconfiguser($env{'request.role.domain'});  
         my %existing=&Apache::lonnet::dump('roles',$env{'request.role.domain'},  
                                            $confname,'rolesdef_');  
         foreach my $poss (@adds) {  
             if (exists($existing{'rolesdef_'.$poss})) {  
                 push(@added,$poss);  
                 $changed = 1;  
             }  
         }  
     }  
     if (@added) {  
         if (@saved) {  
             foreach my $add (@added) {  
                 unless (grep(/^\Q$add\E$/,@saved)) {  
                     push(@alladhoc,$add);  
                 }  
             }  
         } else {  
             push(@alladhoc,@added);  
         }  
     }  
     if (@saved) {  
         push(@alladhoc,@saved);  
     }  
     if (@alladhoc) {  
         my $adhocstr = join(',',sort(@alladhoc));  
         $changehashref->{$adhoc_key} = $adhocstr;  
     } elsif (@dels) {  
         &Apache::lonnet::del('environment',[$adhoc_key],$env{'form.ccdomain'},$env{'form.ccuname'});  
         delete($changehashref->{$adhoc_key});  
         if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&  
             ($env{'form.ccuname'} eq $env{'user.name'})) {  
             &Apache::lonnet::delenv($adhoc_key);  
         }  
     }  
     return $changed;  
 }  
   
 sub update_roles {  sub update_roles {
     my ($r,$context,$showcredits) = @_;      my ($r,$context,$showcredits) = @_;
     my $now=time;      my $now=time;
Line 4549  sub custom_role_editor { Line 4384  sub custom_role_editor {
               );                );
     my $args = { bread_crumbs          => $brcrum,      my $args = { bread_crumbs          => $brcrum,
                  bread_crumbs_component => 'User Management'};                   bread_crumbs_component => 'User Management'};
    
     $r->print(&Apache::loncommon::start_page('Custom Role Editor',      $r->print(&Apache::loncommon::start_page('Custom Role Editor',
                                              $head_script,$args).                                               $head_script,$args).
               $body_top);                $body_top);
Line 5190  sub handler { Line 5025  sub handler {
             } elsif ($env{'form.state'} eq 'done') {              } elsif ($env{'form.state'} eq 'done') {
                 $r->print('<h3>'.&mt('Enrollment request processing').'</h3>'."\n");                  $r->print('<h3>'.&mt('Enrollment request processing').'</h3>'."\n");
                 $r->print(&Apache::loncoursequeueadmin::update_request_queue($context,                  $r->print(&Apache::loncoursequeueadmin::update_request_queue($context,
                               $cdom,$cnum,$coursedesc));                                 $cdom,$cnum,$coursedesc));
             }              }
         } else {          } else {
             $r->print(&header(undef,{'no_nav_bar' => 1}).              $r->print(&header(undef,{'no_nav_bar' => 1}).
                      '<span class="LC_error">'.&mt('You do not have permission to manage self-enrollment').'</span>');                       '<span class="LC_error">'.&mt('You do not have permission to manage self-enrollment').'</span>');
         }          }
   
     } elsif ($env{'form.action'} eq 'changelogs') {      } elsif ($env{'form.action'} eq 'changelogs') {
         if ($permission->{cusr} || $permission->{view}) {          if ($permission->{cusr} || $permission->{view}) {
             &print_userchangelogs_display($r,$context,$permission,$brcrum);              &print_userchangelogs_display($r,$context,$permission,$brcrum);
Line 5457  sub print_main_menu { Line 5291  sub print_main_menu {
                 );                  );
   if ($linkcontext eq 'domain') {    if ($linkcontext eq 'domain') {
       unless ($permission->{'cusr'}) {        unless ($permission->{'cusr'}) {
           $links{'domain'}{'singleuser'} = 'View a User';            $links{'domain'}{'singleuser'} = 'View a User'; 
           $linktitles{'domain'}{'singleuser'} = 'View information about a user in the domain';            $linktitles{'domain'}{'singleuser'} = 'View information about a user in the domain';
             
       }        }
   } elsif ($linkcontext eq 'course') {    } elsif ($linkcontext eq 'course') {
       unless ($permission->{'cusr'}) {        unless ($permission->{'cusr'}) {
Line 5520  sub print_main_menu { Line 5354  sub print_main_menu {
             {              {
              linktext => 'User Access Log',               linktext => 'User Access Log',
              icon => 'document-properties.png',               icon => 'document-properties.png',
              #help => 'User_Access_Logs',               #help => 'Domain_User_Access_Logs',
              url => '/adm/createuser?action=accesslogs',               url => '/adm/createuser?action=accesslogs',
              permission => $permission->{'activity'},               permission => $permission->{'activity'},
              linktitle => 'View user access log.',               linktitle => 'View user access log.',
Line 5577  sub print_main_menu { Line 5411  sub print_main_menu {
                                           groups => 'Community Groups',                                            groups => 'Community Groups',
                                         },                                          },
                        );                         );
           $linktext{'Placement'} = $linktext{'Course'};
   
         my %linktitle = (          my %linktitle = (
             'Course' => {              'Course' => {
Line 5591  sub print_main_menu { Line 5426  sub print_main_menu {
                            },                             },
         );          );
   
           $linktitle{'Placement'} = $linktitle{'Course'};
   
         push(@{ $menu[0]->{items} }, #Category: Single Users          push(@{ $menu[0]->{items} }, #Category: Single Users
             {                 {   
              linktext => $linktext{$crstype}{'single'},               linktext => $linktext{$crstype}{'single'},
Line 6202  ENDSCRIPT Line 6039  ENDSCRIPT
             } elsif ($item eq 'approval') {              } elsif ($item eq 'approval') {
                 my ($currnotified,$currapproval,%appchecked);                  my ($currnotified,$currapproval,%appchecked);
                 my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs();                  my %selfdescs = &Apache::lonuserutils::selfenroll_default_descs();
                 if (ref($currsettings) eq 'HASH') {                  if (ref($currsettings) eq 'HASH') { 
                     $currnotified = $currsettings->{'selfenroll_notifylist'};                      $currnotified = $currsettings->{'selfenroll_notifylist'};
                     $currapproval = $currsettings->{'selfenroll_approval'};                      $currapproval = $currsettings->{'selfenroll_approval'};
                 }                  }
Line 6330  ENDSCRIPT Line 6167  ENDSCRIPT
                    .&mt('Save').'" onclick="validate_types(this.form);" />';                     .&mt('Save').'" onclick="validate_types(this.form);" />';
     }      }
     $output .= '<input type="hidden" name="action" value="selfenroll" />'      $output .= '<input type="hidden" name="action" value="selfenroll" />'
                .'<input type="hidden" name="state" value="done" />'."\n"                .'<input type="hidden" name="state" value="done" />'."\n"
                .$additional.'</form>';                .$additional.'</form>';
     $r->print($output);      $r->print($output);
     return;      return;
 }  }
Line 6736  ENDSCRIPT Line 6573  ENDSCRIPT
             }              }
         }          }
         if (($context eq 'course') && ($viewablesec ne '')) {          if (($context eq 'course') && ($viewablesec ne '')) {
             next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec);              next if ($roleslog{$id}{'logentry'}{'section'} ne $viewablesec); 
         }          }
         $count ++;          $count ++;
         next if ($count < $minshown);          next if ($count < $minshown);
Line 6845  sub print_useraccesslogs_display { Line 6682  sub print_useraccesslogs_display {
     push(@{$brcrum},      push(@{$brcrum},
              {href => '/adm/createuser?action=accesslogs',               {href => '/adm/createuser?action=accesslogs',
               text => 'User access logs',                text => 'User access logs',
               help => 'User_Access_Logs'});                help => 'Domain_User_Access_Logs'});
     my $bread_crumbs_component = 'User Access Logs';      my $bread_crumbs_component = 'User Access Logs';
     my $args = { bread_crumbs           => $brcrum,      my $args = { bread_crumbs           => $brcrum,
                  bread_crumbs_component => 'User Management'};                   bread_crumbs_component => 'User Management'};
       if ($env{'form.popup'}) {
           $args->{'no_nav_bar'} = 1;
       }
   
 # set javascript  # set javascript
     my ($jsback,$elements) = &crumb_utilities();      my ($jsback,$elements) = &crumb_utilities();
Line 7054  ENDSCRIPT Line 6894  ENDSCRIPT
                  .'</p>');                   .'</p>');
     }      }
   
       if ($env{'form.popup'} == 1) {
           $r->print('<input type="hidden" name="popup" value="1" />'."\n");
       }
   
     # Form Footer      # Form Footer
     $r->print(      $r->print(
         '<input type="hidden" name="currstate" value="" />'          '<input type="hidden" name="currstate" value="" />'
Line 7786  sub build_search_response { Line 7630  sub build_search_response {
                                         ,' <a'.$helplink.'>'                                          ,' <a'.$helplink.'>'
                                         ,'</a>')                                          ,'</a>')
                                      .'<br />';                                       .'<br />';
                       
                     }                      }
                 }                  }
             }              }

Removed from v.1.406.2.7  
changed lines
  Added in v.1.427


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