Diff for /loncom/interface/loncreateuser.pm between versions 1.406.2.20.2.6 and 1.474

version 1.406.2.20.2.6, 2024/08/24 15:09:55 version 1.474, 2023/11/17 17:02:20
Line 80  my $authformkrb; Line 80  my $authformkrb;
 my $authformint;  my $authformint;
 my $authformfsys;  my $authformfsys;
 my $authformloc;  my $authformloc;
   my $authformlti;
   
 sub initialize_authen_forms {  sub initialize_authen_forms {
     my ($dom,$formname,$curr_authtype,$mode,$readonly) = @_;      my ($dom,$formname,$curr_authtype,$mode,$readonly) = @_;
Line 90  sub initialize_authen_forms { Line 91  sub initialize_authen_forms {
                   domain => $dom,                    domain => $dom,
                 );                  );
     my %abv_auth = &auth_abbrev();      my %abv_auth = &auth_abbrev();
     if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix):(.*)$/) {      if ($curr_authtype =~ /^(krb4|krb5|internal|localauth|unix|lti):(.*)$/) {
         my $long_auth = $1;          my $long_auth = $1;
         my $curr_autharg = $2;          my $curr_autharg = $2;
         my %abv_auth = &auth_abbrev();          my %abv_auth = &auth_abbrev();
Line 112  sub initialize_authen_forms { Line 113  sub initialize_authen_forms {
     $authformint  = &Apache::loncommon::authform_internal(%param);      $authformint  = &Apache::loncommon::authform_internal(%param);
     $authformfsys = &Apache::loncommon::authform_filesystem(%param);      $authformfsys = &Apache::loncommon::authform_filesystem(%param);
     $authformloc  = &Apache::loncommon::authform_local(%param);      $authformloc  = &Apache::loncommon::authform_local(%param);
       $authformlti  = &Apache::loncommon::authform_lti(%param);
 }  }
   
 sub auth_abbrev {  sub auth_abbrev {
Line 121  sub auth_abbrev { Line 123  sub auth_abbrev {
                      internal  => 'int',                       internal  => 'int',
                      localauth => 'loc',                       localauth => 'loc',
                      unix      => 'fsys',                       unix      => 'fsys',
                        lti       => 'lti',
                    );                     );
     return %abv_auth;      return %abv_auth;
 }  }
Line 141  sub user_quotas { Line 144  sub user_quotas {
                  );                   );
     my ($currquota,$quotatype,$inststatus,$defquota) =      my ($currquota,$quotatype,$inststatus,$defquota) =
         &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);          &Apache::loncommon::get_user_quota($ccuname,$ccdomain,$name);
     if ($longinsttype eq '') {       if ($longinsttype eq '') {
         if ($inststatus ne '') {          if ($inststatus ne '') {
             if ($usertypes->{$inststatus} ne '') {              if ($usertypes->{$inststatus} ne '') {
                 $longinsttype = $usertypes->{$inststatus};                  $longinsttype = $usertypes->{$inststatus};
Line 171  sub user_quotas { Line 174  sub user_quotas {
         } else {          } else {
             $defaultinfo = &mt("For this user, the default quota of [_1]".              $defaultinfo = &mt("For this user, the default quota of [_1]".
                                " MB,[_2]is determined by the user's institutional".                                 " MB,[_2]is determined by the user's institutional".
                                " affiliation ([_3]).",$defquota,'<br />',$longinsttype);                                 " affiliation ([_3]).",$defquota,'<br />'.$longinsttype);
         }          }
     }      }
   
Line 242  function toggleCustom(form,item,name) { Line 245  function toggleCustom(form,item,name) {
         if (radioname) {          if (radioname) {
             if (radioname.length > 0) {              if (radioname.length > 0) {
                 var setvis;                  var setvis;
                 var RegExp = /^customtext_(aboutme|blog|portfolio|portaccess|timezone|webdav|archive)\$/;  
                 for (var i=0; i<radioname.length; i++) {                  for (var i=0; i<radioname.length; i++) {
                     if (radioname[i].checked == true) {                      if (radioname[i].checked == true) {
                         if (radioname[i].value == 1) {                          if (radioname[i].value == 1) {
                             if (RegExp.test(item)) {                              divid.style.display = 'block';
                                 divid.style.display = 'inline';  
                             } else {  
                                 divid.style.display = 'block';  
                             }  
                             setvis = 1;                              setvis = 1;
                         }                          }
                         break;                          break;
Line 275  sub build_tools_display { Line 273  sub build_tools_display {
     my ($ccuname,$ccdomain,$context) = @_;      my ($ccuname,$ccdomain,$context) = @_;
     my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,      my (@usertools,%userenv,$output,@options,%validations,%reqtitles,%reqdisplay,
         $colspan,$isadv,%domconfig,@defaulteditors,@customeditors,@custommanagers,          $colspan,$isadv,%domconfig,@defaulteditors,@customeditors,@custommanagers,
         @possmanagers);          @possmanagers,$editorsty,$customsty);
     my %lt = &Apache::lonlocal::texthash (      my %lt = &Apache::lonlocal::texthash (
                    'blog'       => "Personal User Blog",                     'blog'       => "Personal User Blog",
                    'aboutme'    => "Personal Information Page",                     'aboutme'    => "Personal Information Page",
                    'webdav'     => "WebDAV access to Authoring Spaces (https)",                     'webdav'     => "WebDAV access to Authoring Spaces (https)",
                    'editors'    => "Available Editors",                     'editors'    => "Available Editors",
                    'managers'   => "Co-authors who can add/revoke roles",                     'managers'   => "Co-authors who can add/revoke roles",
                    'archive'    => "Managers can download tar.gz file of Authoring Space",  
                    'portfolio'  => "Personal User Portfolio",                     'portfolio'  => "Personal User Portfolio",
                    'portaccess' => "Portfolio Shareable",                     'portaccess' => "Portfolio Shareable",
                    'timezone'   => "Can set Time Zone",                     'timezone'   => "Can set Time Zone",
Line 295  sub build_tools_display { Line 292  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',
                      'lti'        => 'Can request creation of LTI courses',
                    'requestauthor'  => 'Can request author space',                     'requestauthor'  => 'Can request author space',
                    'edit'       => 'Standard editor (Edit)',                     'edit'       => 'Standard editor (Edit)',
                    'xml'        => 'Text editor (EditXML)',                     'xml'        => 'Text editor (EditXML)',
Line 304  sub build_tools_display { Line 303  sub build_tools_display {
     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','requestcourses.lti');
           @usertools = ('official','unofficial','community','textbook','placement','lti');
         @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 325  sub build_tools_display { Line 325  sub build_tools_display {
             &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain);              &Apache::lonnet::get_dom('configuration',['quotas','authordefaults'],$ccdomain);
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav',          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,'tools.webdav',
                                                     'authoreditors','authormanagers',                                                      'authoreditors','authormanagers',
                                                     'authorarchive','domcoord.author');                                                      'domcoord.author');
         @usertools = ('webdav','editors','managers','archive');          @usertools = ('webdav','editors','managers');
         $colspan = ' colspan="2"';          $colspan = ' colspan="2"';
     } else {      } else {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,          %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
Line 337  sub build_tools_display { Line 337  sub build_tools_display {
     }      }
     foreach my $item (@usertools) {      foreach my $item (@usertools) {
         my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,          my ($custom_access,$curr_access,$cust_on,$cust_off,$tool_on,$tool_off,
             $currdisp,$custdisp,$custradio,$onclick,$customsty,$editorsty);              $currdisp,$custdisp,$custradio,$onclick);
         $cust_off = 'checked="checked" ';          $cust_off = 'checked="checked" ';
         $tool_on = 'checked="checked" ';          $tool_on = 'checked="checked" ';
         unless (($context eq 'authordefaults') || ($item eq 'webdav')) {          unless (($context eq 'authordefaults') && ($item ne 'webdav')) {
             $curr_access =              $curr_access =
                 &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,                  &Apache::lonnet::usertools_access($ccuname,$ccdomain,$item,undef,
                                                   $context,\%userenv,'',                                                    $context,\%userenv,'',
Line 352  sub build_tools_display { Line 352  sub build_tools_display {
                 $cust_off = '';                  $cust_off = '';
             }              }
         } elsif ($context eq 'authordefaults') {          } elsif ($context eq 'authordefaults') {
             if (($item eq 'editors') || ($item eq 'archive')) {              if ($item eq 'editors') {
                 if ($userenv{'author'.$item} ne '') {                  if ($userenv{'author'.$item} ne '') {
                     $cust_on = ' checked="checked" ';                      $cust_on = ' checked="checked" ';
                     $cust_off = '';                      $cust_off = '';
                     if ($item eq 'archive') {  
                         $curr_access = $userenv{'author'.$item};  
                     }  
                 } elsif ($item eq 'archive') {  
                     $curr_access = 0;  
                     if (ref($domconfig{'authordefaults'}) eq 'HASH') {  
                         $curr_access = $domconfig{'authordefaults'}{'archive'};  
                     }  
                 }                  }
             } elsif ($item eq 'webdav') {              } elsif ($item eq 'webdav') {
                 if ($userenv{'tools.'.$item} ne '') {                  if ($userenv{'tools.'.$item} ne '') {
Line 460  sub build_tools_display { Line 452  sub build_tools_display {
             my $current = $userenv{$context.'.'.$item};              my $current = $userenv{$context.'.'.$item};
             if ($item eq 'webdav') {              if ($item eq 'webdav') {
                 $current = $userenv{'tools.webdav'};                  $current = $userenv{'tools.webdav'};
             } elsif ($item eq 'archive') {  
                 $current = $userenv{'author'.$item};  
             }              }
             if ($current eq '') {              if ($current eq '') {
                 $custom_access =                  $custom_access =
Line 486  sub build_tools_display { Line 476  sub build_tools_display {
                    '  </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,$customsty);
             my $envkey = $context.'.'.$item;              my $envkey = $context.'.'.$item;
             if ($context eq 'requestauthor') {              if ($context eq 'requestauthor') {
                 $envkey = $context;                  $envkey = $context;
             }              }
             if ($userenv{$envkey} ne '') {              if ($userenv{$envkey} ne '') {
                 $curroption = $userenv{$envkey};                  $curroption = $userenv{$envkey};
                   $customsty = ' style="display:block"';
             } else {              } else {
                   $customsty = ' style="display:none"';
                 my (@inststatuses);                  my (@inststatuses);
                 if ($context eq 'requestcourses') {                  if ($context eq 'requestcourses') {
                     $curroption =                      $curroption =
Line 669  sub coursereq_externaluser { Line 661  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 767  sub courserequest_titles { Line 761  sub courserequest_titles {
                                    unofficial => 'Unofficial',                                     unofficial => 'Unofficial',
                                    community  => 'Communities',                                     community  => 'Communities',
                                    textbook   => 'Textbook',                                     textbook   => 'Textbook',
                                      placement  => 'Placement Tests',
                                      lti        => 'LTI Provider',
                                    norequest  => 'Not allowed',                                     norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',                                     approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',                                     validate   => 'With validation',
Line 1110  ENDBLOCK Line 1106  ENDBLOCK
         (!(($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 ($trusted,$untrusted);
           if ($context eq 'course') {
               ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$defdom);
           } elsif ($context eq 'author') {
               ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('othcoau',$defdom);
           } elsif ($context eq 'domain') {
               ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('domroles',$defdom); 
           }
           my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain',undef,undef,undef,$trusted,$untrusted);
         my %lt=&Apache::lonlocal::texthash(          my %lt=&Apache::lonlocal::texthash(
                   'enro' => 'Enroll one student',                    'enro' => 'Enroll one student',
                   'enrm' => 'Enroll one member',                    'enrm' => 'Enroll one member',
Line 1516  sub print_user_modification_page { Line 1520  sub print_user_modification_page {
             unless ($isauthor) {              unless ($isauthor) {
                 push(@toggles,'requestauthor');                  push(@toggles,'requestauthor');
             }              }
             push(@toggles,('webdav','editors','archive'));              push(@toggles,('webdav','editors'));
         }          }
         if (&Apache::lonnet::allowed('mut',$ccdomain)) {          if (&Apache::lonnet::allowed('mut',$ccdomain)) {
             push(@toggles,('aboutme','blog','portfolio','portaccess','timezone'));              push(@toggles,('aboutme','blog','portfolio','portaccess','timezone'));
         }          }
         if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {          if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
             push(@toggles,('official','unofficial','community','textbook'));              push(@toggles,('official','unofficial','community','textbook','placement','lti'));
         }          }
         if (@toggles) {          if (@toggles) {
             my $onload;              my $onload;
Line 1741  ENDAUTH Line 1745  ENDAUTH
                                          $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('Can Request Creation of Courses/Communities in this Domain?').'</h3>'."\n".              $r->print('<br /><h3>'.&mt('Can Request Creation of Courses/Communities in this Domain?').'</h3>'."\n");
                       &Apache::loncommon::start_data_table());              if (($env{'request.role.domain'} eq $ccdomain) ||
             if ($env{'request.role.domain'} eq $ccdomain) {                  (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'}))) {
                 $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));                  $r->print(&Apache::loncommon::start_data_table());
                   if ($env{'request.role.domain'} eq $ccdomain) {
                       $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
                   } else {
                       $r->print(&coursereq_externaluser($ccuname,$ccdomain,
                                                         $env{'request.role.domain'}));
                   }
                   $r->print(&Apache::loncommon::end_data_table());
             } else {              } else {
                 $r->print(&coursereq_externaluser($ccuname,$ccdomain,                  $r->print(&mt('Domain configuration for this domain prohibits course creation by users from domain: "[_1]"',
                                                   $env{'request.role.domain'}));                                &Apache::lonnet::domain($ccdomain,'description')));
             }              }
             $r->print(&Apache::loncommon::end_data_table());  
         }          }
         $r->print('</div>');          $r->print('</div>');
         my @order = ('auth','quota','tools','requestauthor','authordefaults');          my @order = ('auth','quota','tools','requestauthor','authordefaults');
Line 1968  sub validation_javascript { Line 1978  sub validation_javascript {
         if ((ref($permission) eq 'HASH') && ($permission->{'cusr'})) {          if ((ref($permission) eq 'HASH') && ($permission->{'cusr'})) {
             my $dcdom = $env{'request.role.domain'};              my $dcdom = $env{'request.role.domain'};
             $loaditem->{'onload'} = "document.cu.coursedesc.value='';";              $loaditem->{'onload'} = "document.cu.coursedesc.value='';";
             $dc_setcourse_code =               $dc_setcourse_code =
                 &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context);                  &Apache::lonuserutils::dc_setcourse_js('cu','singleuser',$context);
         }          }
     } else {      } else {
Line 2459  sub new_domain_roles { Line 2469  sub new_domain_roles {
     '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.      '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.
     &Apache::loncommon::end_data_table_header_row();      &Apache::loncommon::end_data_table_header_row();
     my @allroles = &Apache::lonuserutils::roles_by_context('domain');      my @allroles = &Apache::lonuserutils::roles_by_context('domain');
       my $uprimary = &Apache::lonnet::domain($env{'request.role.domain'},'primary');
       my $uintdom = &Apache::lonnet::internet_dom($uprimary);
     foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {      foreach my $thisdomain (sort(&Apache::lonnet::all_domains())) {
         foreach my $role (@allroles) {          foreach my $role (@allroles) {
             next if ($role eq 'ad');              next if ($role eq 'ad');
             next if (($role eq 'au') && ($ccdomain ne $thisdomain));              next if (($role eq 'au') && ($ccdomain ne $thisdomain));
             if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {              if (&Apache::lonnet::allowed('c'.$role,$thisdomain)) {
                  if ($role eq 'dc') {
                      unless ($thisdomain eq $env{'request.role.domain'}) {
                          my $domprim = &Apache::lonnet::domain($thisdomain,'primary');
                          my $intdom = &Apache::lonnet::internet_dom($domprim);
                          next unless ($uintdom eq $intdom);
                      }
                  }
                my $plrole=&Apache::lonnet::plaintext($role);                 my $plrole=&Apache::lonnet::plaintext($role);
                my %lt=&Apache::lonlocal::texthash(                 my %lt=&Apache::lonlocal::texthash(
                     'ssd'  => "Set Start Date",                      'ssd'  => "Set Start Date",
Line 2505  sub user_authentication { Line 2524  sub user_authentication {
                    'ld'    => "Login Data"                     'ld'    => "Login Data"
     );      );
     # Check for a bad authentication type      # Check for a bad authentication type
     if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {      if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth|lti):/) {
         # bad authentication scheme          # bad authentication scheme
         if (&Apache::lonnet::allowed('mau',$ccdomain)) {          if (&Apache::lonnet::allowed('mau',$ccdomain)) {
             &initialize_authen_forms($ccdomain,$formname);              &initialize_authen_forms($ccdomain,$formname);
Line 2532  $lt{'uuas'} ($currentauth). $lt{'adcs'}. Line 2551  $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 2620  ENDJS Line 2640  ENDJS
                     $result = &mt('Currently using local (institutional) authentication.');                      $result = &mt('Currently using local (institutional) authentication.');
                 } elsif ($currentauth =~ /^unix:/) {                  } elsif ($currentauth =~ /^unix:/) {
                     $result = &mt('Currently Filesystem Authenticated.');                      $result = &mt('Currently Filesystem Authenticated.');
                   } elsif ($currentauth =~ /^lti:/) {
                       $result = &mt('Currently LTI authenticated.');
                 }                  }
                 $outcome = '<h3>'.$lt{'ld'}.'</h3>'.                  $outcome = '<h3>'.$lt{'ld'}.'</h3>'.
                            &Apache::loncommon::start_data_table().                             &Apache::loncommon::start_data_table().
Line 2658  sub modify_login_block { Line 2680  sub modify_login_block {
         if ($can_assign{'loc'}) {          if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);              push(@authform_others,$authformloc);
         }          }
           if ($can_assign{'lti'}) {
               push(@authform_others,$authformlti);
           }
         if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {          if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
             $show_override_msg = 1;              $show_override_msg = 1;
         }          }
Line 2669  sub modify_login_block { Line 2694  sub modify_login_block {
         if ($can_assign{'loc'}) {          if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);              push(@authform_others,$authformloc);
         }          }
           if ($can_assign{'lti'}) {
               push(@authform_others,$authformlti);
           }
         if ($can_assign{'int'}) {          if ($can_assign{'int'}) {
             $show_override_msg = 1;              $show_override_msg = 1;
         }          }
Line 2683  sub modify_login_block { Line 2711  sub modify_login_block {
         if ($can_assign{'loc'}) {          if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);              push(@authform_others,$authformloc);
         }          }
           if ($can_assign{'lti'}) {
               push(@authform_others,$authformlti);
           }
         if ($can_assign{'fsys'}) {          if ($can_assign{'fsys'}) {
             $show_override_msg = 1;              $show_override_msg = 1;
         }          }
Line 2694  sub modify_login_block { Line 2725  sub modify_login_block {
         if ($can_assign{'int'}) {          if ($can_assign{'int'}) {
             push(@authform_others,$authformint);              push(@authform_others,$authformint);
         }          }
           if ($can_assign{'lti'}) {
               push(@authform_others,$authformlti);
           }
         if ($can_assign{'loc'}) {          if ($can_assign{'loc'}) {
             $show_override_msg = 1;              $show_override_msg = 1;
         }          }
       } elsif ($currentauth=~/^lti:/) {
           $authformcurrent=$authformlti;
           if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
               push(@authform_others,$authformkrb);
           }
           if ($can_assign{'int'}) {
               push(@authform_others,$authformint);
           }
           if ($can_assign{'loc'}) {
               push(@authform_others,$authformloc);
           }
     }      }
     if ($show_override_msg) {      if ($show_override_msg) {
         $authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent.          $authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent.
Line 2797  sub personal_data_display { Line 2842  sub personal_data_display {
             } else {              } else {
                 undef($condition);                  undef($condition);
             }              }
         }          } 
         if ($excluded) {          if ($excluded) {
             unless ($excluded =~ /^\@[^\@]+$/) {              unless ($excluded =~ /^\@[^\@]+$/) {
                 undef($condition);                  undef($condition);
Line 2837  sub personal_data_display { Line 2882  sub personal_data_display {
                    $upasstwo.                     $upasstwo.
                    &Apache::lonhtmlcommon::row_closure()."\n";                     &Apache::lonhtmlcommon::row_closure()."\n";
         if ($usernameset eq 'free') {          if ($usernameset eq 'free') {
             my $onclick = "toggleUsernameDisp(this,'selfcreateusername');";              my $onclick = "toggleUsernameDisp(this,'selfcreateusername');"; 
             $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n".              $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n".
                        '<span class="LC_nobreak">'.&mt('Use e-mail address: ').                         '<span class="LC_nobreak">'.&mt('Use e-mail address: ').
                        '<label><input type="radio" name="emailused" value="1" checked="checked" onclick="'.$onclick.'" />'.                         '<label><input type="radio" name="emailused" value="1" checked="checked" onclick="'.$onclick.'" />'.
Line 3163  sub update_user_data { Line 3208  sub update_user_data {
  $amode='localauth';   $amode='localauth';
  $genpwd=$env{'form.locarg'};   $genpwd=$env{'form.locarg'};
  $genpwd=" " if (!$genpwd);   $genpwd=" " if (!$genpwd);
       } elsif ($env{'form.login'} eq 'lti') {
           $amode='lti';
           $genpwd=" ";
     } elsif (($env{'form.login'} eq 'nochange') ||      } elsif (($env{'form.login'} eq 'nochange') ||
              ($env{'form.login'} eq ''        )) {                ($env{'form.login'} eq ''        )) { 
         # There is no need to tell the user we did not change what they          # There is no need to tell the user we did not change what they
Line 3182  sub update_user_data { Line 3230  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','portfolio','portaccess','timezone');      my @usertools = ('aboutme','blog','portfolio','portaccess','timezone');
     my @requestcourses = ('official','unofficial','community','textbook');      my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
     my @requestauthor = ('requestauthor');      my @requestauthor = ('requestauthor');
     my @authordefaults = ('webdav','editors','archive');      my @authordefaults = ('webdav','editors');
     my ($othertitle,$usertypes,$types) =       my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});          &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
     my %canmodify_status =      my %canmodify_status =
Line 3314  sub update_user_data { Line 3362  sub update_user_data {
                 if ($env{'form.customwebdav'} == 1) {                  if ($env{'form.customwebdav'} == 1) {
                     $newcustom{'webdav'} = $env{'form.authordefaults_webdav'};                      $newcustom{'webdav'} = $env{'form.authordefaults_webdav'};
                     $changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'},                      $changed{'webdav'} = &tool_admin('webdav',$newcustom{'webdav'},
                                                      \%changeHash,'authordefaults');                                                    \%changeHash,'authordefaults');
                 }  
                 if ($env{'form.customarchive'} == 1) {  
                     $newcustom{'archive'} = $env{'form.authordefaults_archive'};  
                     $changed{'archive'} = &tool_admin('archive',$newcustom{'archive'},  
                                                       \%changeHash,'authordefaults');  
   
                 }                  }
             }              }
             if ($canmodify_status{'inststatus'}) {              if ($canmodify_status{'inststatus'}) {
Line 3339  sub update_user_data { Line 3381  sub update_user_data {
                 my $chgresult =                  my $chgresult =
                      &Apache::lonnet::put('environment',\%changeHash,                       &Apache::lonnet::put('environment',\%changeHash,
                                           $env{'form.ccdomain'},$env{'form.ccuname'});                                            $env{'form.ccdomain'},$env{'form.ccuname'});
             }               }
         }          }
         $r->print('<br />'.&mt('Home Server').': '.$uhome.' '.          $r->print('<br />'.&mt('Home Server').': '.$uhome.' '.
                   &Apache::lonnet::hostname($uhome));                    &Apache::lonnet::hostname($uhome));
Line 3360  sub update_user_data { Line 3402  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 privileges to modify the authentication configuration for this user.').$end);          $r->print($error.&mt('You do not have privileges to modify the authentication configuration for this user.').$end);
  }   }
     } elsif (($env{'form.intarg'} ne '') &&      } elsif (($env{'form.intarg'} ne '') &&
              (&Apache::lonnet::queryauthenticate($env{'form.ccuname'},$env{'form.ccdomain'}) =~ /^internal:/) &&               (&Apache::lonnet::queryauthenticate($env{'form.ccuname'},$env{'form.ccdomain'}) =~ /^internal:/) &&
Line 3389  sub update_user_data { Line 3431  sub update_user_data {
              'id','permanentemail','portfolioquota','authorquota','inststatus',               'id','permanentemail','portfolioquota','authorquota','inststatus',
              'tools.aboutme','tools.blog','tools.webdav',               'tools.aboutme','tools.blog','tools.webdav',
              'tools.portfolio','tools.timezone','tools.portaccess',               'tools.portfolio','tools.timezone','tools.portaccess',
              'authormanagers','authoreditors','authorarchive','requestauthor',               'authormanagers','authoreditors','requestauthor',
              'requestcourses.official','requestcourses.unofficial',               'requestcourses.official','requestcourses.unofficial',
              'requestcourses.community','requestcourses.textbook',               'requestcourses.community','requestcourses.textbook',
                'requestcourses.placement','requestcourses.lti',
              'reqcrsotherdom.official','reqcrsotherdom.unofficial',               'reqcrsotherdom.official','reqcrsotherdom.unofficial',
              'reqcrsotherdom.community','reqcrsotherdom.textbook',               'reqcrsotherdom.community','reqcrsotherdom.textbook',
              'domcoord.author'],                'reqcrsotherdom.placement','domcoord.author'],
               $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 3429  sub update_user_data { Line 3472  sub update_user_data {
                 }                  }
             } elsif ($context eq 'author') {              } elsif ($context eq 'author') {
                 if ($rolenum eq $auname && $roledom eq $audom) {                  if ($rolenum eq $auname && $roledom eq $audom) {
                     if (!grep(/^\Q$role\E$/,@userroles)) {                       if (!grep(/^\Q$role\E$/,@userroles)) {
                         push(@userroles,$role);                          push(@userroles,$role);
                     }                      }
                 }                  }
Line 3745  sub update_user_data { Line 3788  sub update_user_data {
                         my @fromenv = keys(%changed);                          my @fromenv = keys(%changed);
                         push(@fromenv,'inststatus');                          push(@fromenv,'inststatus');
                         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') || ($key eq 'lti')) {
                                 $newenvhash{'environment.requestcourses.'.$key} =                                  $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};                                      $changeHash{'requestcourses.'.$key};
                                 if ($changeHash{'requestcourses.'.$key}) {                                  if ($changeHash{'requestcourses.'.$key}) {
Line 3803  sub update_user_data { Line 3847  sub update_user_data {
                                         $newenvhash{'environment.editors'} = 'edit,xml';                                          $newenvhash{'environment.editors'} = 'edit,xml';
                                     }                                      }
                                 }                                  }
                             } elsif ($key eq 'archive') {  
                                 $newenvhash{'environment.author.'.$key} =  
                                     $changeHash{'author.'.$key};  
                                 if ($changeHash{'author.'.$key} ne '') {  
                                     $newenvhash{'environment.canarchive'} =  
                                         $changeHash{'author.'.$key};  
                                 } else {  
                                     unless ($got_domdefs) {  
                                         %domdefaults =  
                                            &Apache::lonnet::get_domain_defaults($env{'user.domain'});  
                                         $got_domdefs = 1;  
                                     }  
                                     $newenvhash{'environment.canarchive'} =  
                                         $domdefaults{'archive'};  
                                 }  
                             } elsif ($key ne 'quota') {                              } elsif ($key ne 'quota') {
                                 $newenvhash{'environment.tools.'.$key} =                                   $newenvhash{'environment.tools.'.$key} = 
                                     $changeHash{'tools.'.$key};                                      $changeHash{'tools.'.$key};
Line 3887  sub update_user_data { Line 3916  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 4032  sub display_userinfo { Line 4061  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',
            'lti'            => 'Can Request LTI Courses',
          'requestauthor'  => 'Can Request Author Role',           'requestauthor'  => 'Can Request Author Role',
          'inststatus'     => "Affiliation",           'inststatus'     => "Affiliation",
          'prvs'           => 'Previous Value:',           'prvs'           => 'Previous Value:',
          'chto'           => 'Changed To:',           'chto'           => 'Changed To:',
          'editors'        => "Available Editors in Authoring Space",           'editors'        => "Available Editors in Authoring Space",
          'managers'       => "Co-authors who can add/revoke roles",           'managers'       => "Co-authors who can add/revoke roles",
          'archive'        => "Managers can download tar.gz file of Authoring Space",  
          'edit'           => 'Standard editor (Edit)',           'edit'           => 'Standard editor (Edit)',
          'xml'            => 'Text editor (EditXML)',           'xml'            => 'Text editor (EditXML)',
          'daxe'           => 'Daxe editor (Daxe)',           'daxe'           => 'Daxe editor (Daxe)',
Line 4072  sub display_userinfo { Line 4102  sub display_userinfo {
                     if ($entry eq 'requestauthor') {                      if ($entry eq 'requestauthor') {
                         @items = ($entry);                          @items = ($entry);
                     } elsif ($entry eq 'authordefaults') {                      } elsif ($entry eq 'authordefaults') {
                         @items = ('webdav','managers','editors','archive');                          @items = ('webdav','managers','editors');
                     } else {                      } else {
                         @items = @{$requestcourses};                          @items = @{$requestcourses};
                     }                      }
Line 4323  sub tool_changes { Line 4353  sub tool_changes {
             } elsif ($tool eq 'webdav') {              } elsif ($tool eq 'webdav') {
                 $envkey = 'tools.webdav';                  $envkey = 'tools.webdav';
                 $newval = $env{'form.'.$context.'_'.$tool};                  $newval = $env{'form.'.$context.'_'.$tool};
             } elsif ($tool eq 'archive') {  
                 $envkey = 'authorarchive';  
                 $newval = $env{'form.'.$context.'_'.$tool};  
             }              }
         } else {          } else {
             $newval = $env{'form.'.$context.'_'.$tool};              $newval = $env{'form.'.$context.'_'.$tool};
Line 4357  sub tool_changes { Line 4384  sub tool_changes {
                 } elsif ($tool eq 'editors') {                  } elsif ($tool eq 'editors') {
                     $oldaccesstext->{$tool} = &mt('can use: [_1]',                      $oldaccesstext->{$tool} = &mt('can use: [_1]',
                                                   join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey})));                                                    join(', ', map { $tooldesc{$_} } split(/,/,$userenv->{$envkey})));
                 } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {                  } elsif ($tool eq 'webdav') {
                     if ($userenv->{$envkey}) {                      if ($userenv->{$envkey}) {
                         $oldaccesstext->{$tool} = &mt("availability set to 'on'");                          $oldaccesstext->{$tool} = &mt("availability set to 'on'");
                     } else {                      } else {
Line 4403  sub tool_changes { Line 4430  sub tool_changes {
                                     $managers =~ s/,/, /g;                                      $managers =~ s/,/, /g;
                                     $newaccesstext->{$tool} = $managers;                                      $newaccesstext->{$tool} = $managers;
                                 }                                  }
                             } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {                              } elsif ($tool eq 'webdav') {
                                 if ($newval) {                                  if ($newval) {
                                     $newaccesstext->{$tool} = &mt("availability set to 'on'");                                      $newaccesstext->{$tool} = &mt("availability set to 'on'");
                                 } else {                                  } else {
Line 4443  sub tool_changes { Line 4470  sub tool_changes {
                                     $managers =~ s/,/, /g;                                      $managers =~ s/,/, /g;
                                     $newaccesstext->{$tool} = $managers;                                      $newaccesstext->{$tool} = $managers;
                                 }                                  }
                             } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {                              } elsif ($tool eq 'webdav') {
                                 if ($userenv->{$envkey}) {                                  if ($userenv->{$envkey}) {
                                     $newaccesstext->{$tool} = &mt("availability set to 'on'");                                      $newaccesstext->{$tool} = &mt("availability set to 'on'");
                                 } else {                                  } else {
                                     $newaccesstext->{$tool} = &mt("availability set to 'off'");                                      $newaccesstext->{$tool} = &mt("availability set to 'off'");
                                 }                                  }
                             }                                }
                         } else {                          } else {
                             if ($userenv->{$context.'.'.$tool}) {                              if ($userenv->{$context.'.'.$tool}) {
                                 $newaccesstext->{$tool} = &mt("availability set to 'on'");                                  $newaccesstext->{$tool} = &mt("availability set to 'on'");
Line 4492  sub tool_changes { Line 4519  sub tool_changes {
                                 $managers =~ s/,/, /g;                                  $managers =~ s/,/, /g;
                                 $newaccesstext->{$tool} = $managers;                                  $newaccesstext->{$tool} = $managers;
                             }                              }
                         } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {                          } elsif ($tool eq 'webdav') {
                             if ($newval) {                              if ($userenv->{$envkey}) {
                                 $newaccesstext->{$tool} = &mt("availability set to 'on'");                                  $newaccesstext->{$tool} = &mt("availability set to 'on'");
                             } else {                              } else {
                                 $newaccesstext->{$tool} = &mt("availability set to 'off'");                                  $newaccesstext->{$tool} = &mt("availability set to 'off'");
Line 4540  sub tool_changes { Line 4567  sub tool_changes {
                         } elsif ($tool eq 'editors') {                          } elsif ($tool eq 'editors') {
                             $newaccesstext->{$tool} = &mt('can use: [_1]',                              $newaccesstext->{$tool} = &mt('can use: [_1]',
                                                           join(', ', map { $tooldesc{$_} } split(/,/,$newval)));                                                            join(', ', map { $tooldesc{$_} } split(/,/,$newval)));
                         } elsif (($tool eq 'webdav') || ($tool eq 'archive')) {                           } elsif ($tool eq 'webdav') {
                             if ($newval) {                              if ($newval) {
                                 $newaccesstext->{$tool} = &mt("availability set to 'on'");                                  $newaccesstext->{$tool} = &mt("availability set to 'on'");
                             } else {                              } else {
Line 4569  sub update_roles { Line 4596  sub update_roles {
     my ($r,$context,$showcredits) = @_;      my ($r,$context,$showcredits) = @_;
     my $now=time;      my $now=time;
     my @rolechanges;      my @rolechanges;
     my %disallowed;      my (%disallowed,%got_role_approvals,%got_instdoms,%process_by,%instdoms,
           %pending,%reject,%notifydc,%status,%unauthorized,%currqueued);
       $got_role_approvals{$context} = '';
       $process_by{$context} = {};
       my @domroles = &Apache::lonuserutils::domain_roles();
       my @cstrroles = &Apache::lonuserutils::construction_space_roles();
       my @courseroles = &Apache::lonuserutils::roles_by_context('course',1);
     $r->print('<h3>'.&mt('Modifying Roles').'</h3>');      $r->print('<h3>'.&mt('Modifying Roles').'</h3>');
     foreach my $key (keys(%env)) {      foreach my $key (keys(%env)) {
  next if (! $env{$key});   next if (! $env{$key});
Line 4671  sub update_roles { Line 4704  sub update_roles {
     if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {      if ($key=~/^form\.ren\:([^\_]+)\_([^\_\.]+)$/) {
                 my $url = $1;                  my $url = $1;
                 my $role = $2;                  my $role = $2;
                   my $id = $url.'_'.$role;
                 my $logmsg;                  my $logmsg;
                 my $output;                  my $output;
                 if ($role eq 'st') {                  if ($role eq 'st') {
Line 4678  sub update_roles { Line 4712  sub update_roles {
                         my ($cdom,$cnum,$csec) = ($1,$2,$3);                          my ($cdom,$cnum,$csec) = ($1,$2,$3);
                         my $credits;                          my $credits;
                         if ($showcredits) {                          if ($showcredits) {
                             my $defaultcredits =                               my $defaultcredits =
                                 &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);                                  &Apache::lonuserutils::get_defaultcredits($cdom,$cnum);
                             $credits = &get_user_credits($defaultcredits,$cdom,$cnum);                              $credits = &get_user_credits($defaultcredits,$cdom,$cnum);
                         }                          }
                           unless ($udom eq $cdom) {
                               next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                            $uname,$role,$now,0,$cdom,$cnum,$csec,$credits,
                                            \%process_by,\%instdoms,\%got_role_approvals,
                                            \%got_instdoms,\%reject,\%pending,\%notifydc,
                                            \%status,\%unauthorized,\%currqueued));
                           }
                         my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);                          my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context,$credits);
                         if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {                          if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
                             if ($result eq 'refused' && $logmsg) {                              if ($result eq 'refused' && $logmsg) {
Line 4697  sub update_roles { Line 4738  sub update_roles {
                         }                          }
                     }                      }
                 } else {                  } else {
                       my ($cdom,$cnum,$csec);
                       if (grep(/^\Q$role\E$/,@cstrroles)) {
                           ($cdom,$cnum) = ($url =~ m{^/($match_domain)/($match_username)$});
                       } elsif (grep(/^\Q$role\E$/,@domroles)) {
                           ($cdom) = ($url =~ m{^/($match_domain)/$});
                       } elsif ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
                           ($cdom,$cnum,$csec) = ($1,$2,$3);
                       }
                       if ($cdom ne '') {
                           unless ($udom eq $cdom) {
                               next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                            $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
                                            \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                            \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
                           }
                       }
     my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},      my $result=&Apache::lonnet::assignrole($env{'form.ccdomain'},
                                $env{'form.ccuname'},$url,$role,0,$now,'','',                                 $env{'form.ccuname'},$url,$role,0,$now,'','',
                                $context);                                 $context);
                         $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',                      $output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
                                         &Apache::lonnet::plaintext($role),                                      &Apache::lonnet::plaintext($role),
                                         &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'<br />';                                      &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'<br />';
                     if ($result ne "ok") {                      if ($result ne "ok") {
                         $output .= &mt('Error: [_1]',$result).'<br />';                          $output .= &mt('Error: [_1]',$result).'<br />';
                     }                      }
Line 4715  sub update_roles { Line 4772  sub update_roles {
 # Re-enable custom role  # Re-enable custom role
     if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {      if ($key=~m{^form\.ren\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
                 my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);                  my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
                   my $id = $url.'_cr'."/$rdom/$rnam/$rolename";
                   my $role = "cr/$rdom/$rnam/$rolename";
                   if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
                       my ($cdom,$cnum,$csec) = ($1,$2,$3);
                       unless ($udom eq $cdom) {
                           next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                        $uname,$role,$now,0,$cdom,$cnum,$csec,'',\%process_by,
                                        \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                        \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
                       }
                   }
                 my $result = &Apache::lonnet::assigncustomrole(                  my $result = &Apache::lonnet::assigncustomrole(
                                $env{'form.ccdomain'}, $env{'form.ccuname'},                                 $env{'form.ccdomain'}, $env{'form.ccuname'},
                                $url,$rdom,$rnam,$rolename,0,$now,undef,$context);                                 $url,$rdom,$rnam,$rolename,0,$now,undef,$context);
Line 4736  sub update_roles { Line 4804  sub update_roles {
                 # Activate a custom role                  # Activate a custom role
  my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);   my ($one,$two,$three,$four,$five)=($1,$2,$3,$4,$5);
  my $url='/'.$one.'/'.$two;   my $url='/'.$one.'/'.$two;
                   my $id = $url.'_cr/'."$three/$four/$five";
                   my $role = "cr/$three/$four/$five";
  my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;   my $full=$one.'_'.$two.'_cr_cr_'.$three.'_'.$four.'_'.$five;
   
                 my $start = ( $env{'form.start_'.$full} ?                  my $start = ( $env{'form.start_'.$full} ?
Line 4744  sub update_roles { Line 4814  sub update_roles {
                 my $end   = ( $env{'form.end_'.$full} ?                  my $end   = ( $env{'form.end_'.$full} ?
                               $env{'form.end_'.$full} :                                $env{'form.end_'.$full} :
                               0 );                                0 );
                                                                                        
                 # split multiple sections                  # split multiple sections
                 my %sections = ();                  my %sections = ();
                 my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$5);                  my $num_sections = &build_roles($env{'form.sec_'.$full},\%sections,$five);
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                       unless ($udom eq $one) {
                           next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                        $uname,$role,$start,$end,$one,$two,'','',\%process_by,
                                        \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                        \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
                       }
                     $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context));                      $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$url,$three,$four,$five,$start,$end,$context));
                 } else {                  } else {
     my %curr_groups =      my %curr_groups =
  &Apache::longroup::coursegroups($one,$two);   &Apache::longroup::coursegroups($one,$two);
                       my ($restricted,$numchanges);
                     foreach my $sec (sort {$a cmp $b} keys(%sections)) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         if (($sec eq 'none') || ($sec eq 'all') ||                           if (($sec eq 'none') || ($sec eq 'all') || 
                             exists($curr_groups{$sec})) {                              exists($curr_groups{$sec})) {
Line 4760  sub update_roles { Line 4837  sub update_roles {
                             next;                              next;
                         }                          }
                         my $securl = $url.'/'.$sec;                          my $securl = $url.'/'.$sec;
                           my $secid = $securl.'_cr'."/$three/$four/$five";
                           undef($restricted);
                           unless ($udom eq $one) {
                               next if (&Apache::lonuserutils::restricted_dom($context,$secid,$udom,
                                            $uname,$role,$start,$end,$one,$two,$sec,'',\%process_by,
                                            \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                            \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
                           }
                           $numchanges ++;
         $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context));          $r->print(&Apache::loncommon::commit_customrole($udom,$uname,$securl,$three,$four,$five,$start,$end,$context));
                     }                      }
                       next unless ($numchanges);
                 }                  }
                 if (!grep(/^cr$/,@rolechanges)) {                  if (!grep(/^cr$/,@rolechanges)) {
                     push(@rolechanges,'cr');                      push(@rolechanges,'cr');
Line 4770  sub update_roles { Line 4857  sub update_roles {
  # Activate roles for sections with 3 id numbers   # Activate roles for sections with 3 id numbers
  # set start, end times, and the url for the class   # set start, end times, and the url for the class
  my ($one,$two,$three)=($1,$2,$3);   my ($one,$two,$three)=($1,$2,$3);
  my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?    my $start = ( $env{'form.start_'.$one.'_'.$two.'_'.$three} ?
       $env{'form.start_'.$one.'_'.$two.'_'.$three} :         $env{'form.start_'.$one.'_'.$two.'_'.$three} :
       $now );        $now );
  my $end   = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?    my $end   = ( $env{'form.end_'.$one.'_'.$two.'_'.$three} ?
       $env{'form.end_'.$one.'_'.$two.'_'.$three} :        $env{'form.end_'.$one.'_'.$two.'_'.$three} :
       0 );        0 );
  my $url='/'.$one.'/'.$two;   my $url='/'.$one.'/'.$two;
                 my $type = 'three';                  my $id = $url.'_'.$three;
                 # split multiple sections                  # split multiple sections
                 my %sections = ();                  my %sections = ();
                 my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);                  my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two.'_'.$three},\%sections,$three);
                 my $credits;                  my ($credits,$numchanges);
                 if ($three eq 'st') {                  if ($three eq 'st') {
                     if ($showcredits) {                       if ($showcredits) {
                         my $defaultcredits =                           my $defaultcredits = 
                             &Apache::lonuserutils::get_defaultcredits($one,$two);                              &Apache::lonuserutils::get_defaultcredits($one,$two);
                         $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};                          $credits = $env{'form.credits_'.$one.'_'.$two.'_'.$three};
Line 4794  sub update_roles { Line 4881  sub update_roles {
                     }                      }
                 }                  }
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                       unless ($udom eq $one) {
                           next if (&Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                        $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
                                        \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                        \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued));
                       }
                       $numchanges ++;
                     $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));                      $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
                 } else {                  } else {
                     my %curr_groups =                       my %curr_groups = 
  &Apache::longroup::coursegroups($one,$two);   &Apache::longroup::coursegroups($one,$two);
                     my $emptysec = 0;                      my $emptysec = 0;
                       my $restricted;
                     foreach my $sec (sort {$a cmp $b} keys(%sections)) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         $sec =~ s/\W//g;                          $sec =~ s/\W//g;
                         if ($sec ne '') {                          if ($sec ne '') {
Line 4808  sub update_roles { Line 4903  sub update_roles {
                                 next;                                  next;
                             }                              }
                             my $securl = $url.'/'.$sec;                              my $securl = $url.'/'.$sec;
                               my $secid = $securl.'_'.$three;
                               unless ($udom eq $one) {
                                   undef($restricted);
                                   $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
                                                     $uname,$three,$start,$end,$one,$two,$sec,$credits,\%process_by,
                                                     \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                                     \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                                   next if ($restricted);
                               }
                               $numchanges ++;
                             $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));                              $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$three,$start,$end,$one,$two,$sec,$context,$credits));
                         } else {                          } else {
                             $emptysec = 1;                              $emptysec = 1;
                         }                          }
                     }                      }
                     if ($emptysec) {                      if ($emptysec) {
                           unless ($udom eq $one) {
                               undef($restricted);
                               $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                                 $uname,$three,$start,$end,$one,$two,'',$credits,\%process_by,
                                                 \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                                 \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                               next if ($restricted);
                           }
                           $numchanges ++;
                         $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));                          $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$three,$start,$end,$one,$two,'',$context,$credits));
                     }                      }
                       next unless ($numchanges);
                 }                  }
                 if (!grep(/^\Q$three\E$/,@rolechanges)) {                  if (!grep(/^\Q$three\E$/,@rolechanges)) {
                     push(@rolechanges,$three);                      push(@rolechanges,$three);
Line 4823  sub update_roles { Line 4938  sub update_roles {
     } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {      } elsif ($key=~/^form\.act\_([^\_]+)\_([^\_]+)$/) {
  # Activate roles for sections with two id numbers   # Activate roles for sections with two id numbers
  # set start, end times, and the url for the class   # set start, end times, and the url for the class
  my $start = ( $env{'form.start_'.$1.'_'.$2} ?    my $start = ( $env{'form.start_'.$1.'_'.$2} ?
       $env{'form.start_'.$1.'_'.$2} :         $env{'form.start_'.$1.'_'.$2} :
       $now );        $now );
  my $end   = ( $env{'form.end_'.$1.'_'.$2} ?    my $end   = ( $env{'form.end_'.$1.'_'.$2} ?
       $env{'form.end_'.$1.'_'.$2} :        $env{'form.end_'.$1.'_'.$2} :
       0 );        0 );
                 my $one = $1;                  my $one = $1;
                 my $two = $2;                  my $two = $2;
  my $url='/'.$one.'/';   my $url='/'.$one.'/';
                   my $id = $url.'_'.$two;
                   my ($cdom,$cnum) = split(/\//,$one);
                 # split multiple sections                  # split multiple sections
                 my %sections = ();                  my %sections = ();
                   my ($restricted,$numchanges);
                 my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two);                  my $num_sections = &build_roles($env{'form.sec_'.$one.'_'.$two},\%sections,$two);
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                       unless ($udom eq $one) {
                           $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                             $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
                                             \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                             \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                           next if ($restricted);
                       }
                       $numchanges ++;
                     $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));                      $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
                 } else {                  } else {
                     my $emptysec = 0;                      my $emptysec = 0;
                     foreach my $sec (sort {$a cmp $b} keys(%sections)) {                      foreach my $sec (sort {$a cmp $b} keys(%sections)) {
                         if ($sec ne '') {                          if ($sec ne '') {
                             my $securl = $url.'/'.$sec;                              my $securl = $url.'/'.$sec;
                               my $secid = $securl.'_'.$two;
                               unless ($udom eq $one) {
                                   undef($restricted);
                                   $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
                                                     $uname,$two,$start,$end,$cdom,$cnum,$sec,'',\%process_by,
                                                     \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                                     \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                                   next if ($restricted);
                               }
                               $numchanges ++;
                             $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));                              $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$securl,$two,$start,$end,$one,undef,$sec,$context));
                         } else {                          } else {
                             $emptysec = 1;                              $emptysec = 1;
                         }                          }
                     }                      }
                     if ($emptysec) {                      if ($emptysec) {
                           unless ($udom eq $one) {
                               undef($restricted);
                               $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                                 $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
                                                 \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                                 \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                               next if ($restricted);
                           }
                           $numchanges ++;
                         $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));                          $r->print(&Apache::loncommon::commit_standardrole($udom,$uname,$url,$two,$start,$end,$one,undef,'',$context));
                     }                      }
                       next unless ($numchanges); 
                 }                  }
                 if (!grep(/^\Q$two\E$/,@rolechanges)) {                  if (!grep(/^\Q$two\E$/,@rolechanges)) {
                     push(@rolechanges,$two);                      push(@rolechanges,$two);
Line 4873  sub update_roles { Line 5019  sub update_roles {
             }              }
  }   }
     } # End of foreach (keys(%env))      } # End of foreach (keys(%env))
       if ((keys(%reject)) || (keys(%unauthorized))) {
           $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
       }
       if ((keys(%pending)) || (keys(%currqueued))) {
           $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
       }
 # Flush the course logs so reverse user roles immediately updated  # Flush the course logs so reverse user roles immediately updated
     $r->register_cleanup(\&Apache::lonnet::flushcourselogs);      $r->register_cleanup(\&Apache::lonnet::flushcourselogs);
     if (@rolechanges == 0) {      if (@rolechanges == 0) {
Line 4927  sub enroll_single_student { Line 5079  sub enroll_single_student {
             }              }
         }          }
     }      }
       my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();
       my (%got_role_approvals,%got_instdoms,%process_by,%instdoms,%pending,%reject,%notifydc,
           %status,%unauthorized,%currqueued);
       unless ($env{'form.ccdomain'} eq $env{'course.'.$env{'request.course.id'}.'.domain'}) {
           my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
           my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           my $csec = $env{'form.sections'};
           my $id = "/$cdom/$cnum";
           if ($csec ne '') {
               $id .= "/$csec";
           }
           $id .= '_st';
           if (&Apache::lonuserutils::restricted_dom($context,$id,$env{'form.ccdomain'},$env{'form.ccuname'},
                                                     'st',$startdate,$enddate,$cdom,$cnum,$csec,$credits,
                                                     \%process_by,\%instdoms,\%got_role_approvals,\%got_instdoms,
                                                     \%reject,\%pending,\%notifydc,\%status,\%unauthorized,\%currqueued)) {
               if ((keys(%reject)) || (keys(%unauthorized))) {
                   $r->print(&Apache::lonuserutils::print_roles_rejected($context,\%reject,\%unauthorized));
               }
               if ((keys(%pending)) || (keys(%currqueued))) {
                   $r->print(&Apache::lonuserutils::print_roles_queued($context,\%pending,\%notifydc,\%currqueued));
               }
               return;
           }
       }
   
     # Clean out any old student roles the user has in this class.      # Clean out any old student roles the user has in this class.
     &Apache::lonuserutils::modifystudent($env{'form.ccdomain'},      &Apache::lonuserutils::modifystudent($env{'form.ccdomain'},
          $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);           $env{'form.ccuname'},$env{'request.course.id'},undef,$uhome);
     my ($startdate,$enddate) = &Apache::lonuserutils::get_dates_from_form();  
     my $enroll_result =      my $enroll_result =
         &Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'},          &Apache::lonnet::modify_student_enrollment($env{'form.ccdomain'},
             $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},              $env{'form.ccuname'},$env{'form.cid'},$env{'form.cfirstname'},
Line 5055  sub tool_admin { Line 5231  sub tool_admin {
             $toolchanged = 1;              $toolchanged = 1;
             if ($tool eq 'requestauthor') {              if ($tool eq 'requestauthor') {
                 $changeHash->{$context} = $settool;                  $changeHash->{$context} = $settool;
             } elsif (($tool eq 'managers') || ($tool eq 'editors') || ($tool eq 'archive')) {              } elsif (($tool eq 'managers') || ($tool eq 'editors')) {
                 $changeHash->{'author'.$tool} = $settool;                  $changeHash->{'author'.$tool} = $settool;
             } elsif ($tool eq 'webdav') {              } elsif ($tool eq 'webdav') {
                 $changeHash->{'tools.'.$tool} = $settool;                  $changeHash->{'tools.'.$tool} = $settool;
Line 5301  sub set_custom_role { Line 5477  sub set_custom_role {
     );      );
 }  }
   
   sub show_role_requests {
       my ($caller,$dom) = @_;
       my $showrolereqs;
       my %domconfig = &Apache::lonnet::get_dom('configuration',['privacy'],$dom);
       if (ref($domconfig{'privacy'}) eq 'HASH') {
           if (ref($domconfig{'privacy'}{'approval'}) eq 'HASH') {
               my %approvalconf = %{$domconfig{'privacy'}{'approval'}};
               foreach my $key ('instdom','extdom') {
                   if (ref($approvalconf{$key}) eq 'HASH') {
                       if (keys(%{$approvalconf{$key}})) {
                           foreach my $context ('domain','author','course','community') {
                               if ($approvalconf{$key}{$context} eq $caller) {
                                   $showrolereqs = 1;
                                   last if ($showrolereqs);
                               }
                           }
                       }
                   }
                   last if ($showrolereqs);
               }
           }
       }
       return $showrolereqs;
   }
   
 sub display_coauthor_managers {  sub display_coauthor_managers {
     my ($permission) = @_;      my ($permission) = @_;
     my $output;      my $output;
Line 5622  sub handler { Line 5823  sub handler {
         if (! exists($env{'form.state'})) {          if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);              &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         } elsif ($env{'form.state'} eq 'got_file') {          } elsif ($env{'form.state'} eq 'got_file') {
             my $result =              my $result = 
                 &Apache::lonuserutils::print_upload_manager_form($r,$context,                  &Apache::lonuserutils::print_upload_manager_form($r,$context,
                                                                  $permission,                                                                   $permission,
                                                                  $crstype,$showcredits);                                                                   $crstype,$showcredits);
Line 5936  sub handler { Line 6137  sub handler {
                                               &Apache::lonhtmlcommon::row_closure(1));                                                &Apache::lonhtmlcommon::row_closure(1));
                                 }                                  }
                             }                              }
                             if ($pickstart) {                              if ($pickstart) { 
                                 $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');                                  $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
                             } else {                              } else {
                                 $r->print('<div>'.&mt('No information to display for this account request.').'</div>');                                  $r->print('<div>'.&mt('No information to display for this account request.').'</div>');
Line 6168  sub handler { Line 6369  sub handler {
             $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 view helpdesk access').'</span>');                        '<span class="LC_error">'.&mt('You do not have permission to view helpdesk access').'</span>');
         }          }
       } elsif ($env{'form.action'} eq 'rolerequests') {
           if ($permission->{cusr} || $permission->{view}) {
               &print_queued_roles($r,$context,$permission,$brcrum);
           }
       } elsif ($env{'form.action'} eq 'queuedroles') {
           if (($permission->{cusr}) && ($context eq 'domain')) {
               if (&show_role_requests($context,$env{'request.role.domain'})) {
                   if ($env{'form.state'} eq 'done') {
                       &process_pendingroles($r,$context,$permission,$brcrum);
                   } else {
                       &print_pendingroles($r,$context,$permission,$brcrum);
                   }
               } else {
                   $r->print(&header(undef,{'no_nav_bar' => 1}).
                             '<span class="LC_info">'.&mt('Domain coordinator approval of requests from other domains for assignment of roles to users from this domain not in use.').'</span>');
               }
           } else {
               $r->print(&header(undef,{'no_nav_bar' => 1}).
                        '<span class="LC_error">'.&mt('You do not have permission to view queued requests from other domains for assignment of roles to users from this domain.').'</span>');
           }
     } elsif ($env{'form.action'} eq 'camanagers') {      } elsif ($env{'form.action'} eq 'camanagers') {
         if (($permission->{cusr}) && ($context eq 'author')) {          if (($permission->{cusr}) && ($context eq 'author')) {
             push(@{$brcrum},              push(@{$brcrum},
Line 6495  sub print_main_menu { Line 6716  sub print_main_menu {
                             listusers  => 'Show and manage users in this community.',                              listusers  => 'Show and manage users in this community.',
                            },                             },
                 );                  );
   
   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';
Line 6616  sub print_main_menu { Line 6838  sub print_main_menu {
                                           groups => 'Community Groups',                                            groups => 'Community Groups',
                                         },                                          },
                        );                         );
           $linktext{'Placement'} = $linktext{'Course'};
   
         my %linktitle = (          my %linktitle = (
             'Course' => {              'Course' => {
Line 6630  sub print_main_menu { Line 6853  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 6753  sub print_main_menu { Line 6978  sub print_main_menu {
             },              },
         );          );
     }      }
       push(@{ $menu[2]->{items} },
           {
            linktext => 'Role Requests (other domains)',
            icon => 'edit-find.png',
            #help => 'Role_Requests',
            url => '/adm/createuser?action=rolerequests',
            permission => $permission->{'cusr'},
            linktitle => 'Role requests for users in other domains',
           },
       );
       if (&show_role_requests($context,$env{'request.role.domain'})) {
           push(@{ $menu[2]->{items} },
               {
                linktext => 'Queued Role Assignments (this domain)',
                icon => 'edit-find.png',
                #help => 'Role_Approvals',
                url => '/adm/createuser?action=queuedroles',
                permission => $permission->{'cusr'},
                linktitle => "Role requests for this domain's users",
               },
           );
       }
     return Apache::lonhtmlcommon::generate_menu(@menu);      return Apache::lonhtmlcommon::generate_menu(@menu);
 #               { text => 'View Log-in History',  #               { text => 'View Log-in History',
 #                 help => 'Course_User_Logins',  #                 help => 'Course_User_Logins',
Line 7148  ENDSCRIPT Line 7395  ENDSCRIPT
                 } elsif ($curr_types eq '') {                  } elsif ($curr_types eq '') {
                     $add_domtitle = &mt('Users in other domain:');                      $add_domtitle = &mt('Users in other domain:');
                 }                  }
                   my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$cdom);
                 $output .= &Apache::loncommon::start_data_table_row()                  $output .= &Apache::loncommon::start_data_table_row()
                            .'<td colspan="2"><span class="LC_nobreak">'.$add_domtitle.'</span><br />'                             .'<td colspan="2"><span class="LC_nobreak">'.$add_domtitle.'</span><br />'
                            .&Apache::loncommon::select_dom_form('','selfenroll_newdom',                             .&Apache::loncommon::select_dom_form('','selfenroll_newdom',
                                                                 $includeempty,$showdomdesc,'','','',$readonly)                                                                  $includeempty,$showdomdesc,'',$trusted,$untrusted,$readonly)
                            .'<input type="hidden" name="selfenroll_types_total" value="'.$num.'" />'                             .'<input type="hidden" name="selfenroll_types_total" value="'.$num.'" />'
                            .'</td>'.&Apache::loncommon::end_data_table_row()                             .'</td>'.&Apache::loncommon::end_data_table_row()
                            .&Apache::loncommon::end_data_table();                             .&Apache::loncommon::end_data_table();
Line 7422  sub get_noedit_fields { Line 7670  sub get_noedit_fields {
         }          }
     }      }
     return %noedit;      return %noedit;
 }   }
   
 sub visible_in_stdcat {  sub visible_in_stdcat {
     my ($cdom,$cnum,$domconf) = @_;      my ($cdom,$cnum,$domconf) = @_;
Line 7741  ENDSCRIPT Line 7989  ENDSCRIPT
                      chgcontext         => 'any',                       chgcontext         => 'any',
                      rolelog_start_date => $defstart,                       rolelog_start_date => $defstart,
                      rolelog_end_date   => $now,                       rolelog_end_date   => $now,
                        approvals          => 'any',
                    );                     );
     my $more_records = 0;      my $more_records = 0;
   
     # set current      # set current
     my %curr;      my %curr;
     foreach my $item ('show','page','role','chgcontext') {      foreach my $item ('show','page','role','chgcontext','approvals') {
         $curr{$item} = $env{'form.'.$item};          $curr{$item} = $env{'form.'.$item};
     }      }
     my ($startdate,$enddate) =       my ($startdate,$enddate) = 
Line 7820  ENDSCRIPT Line 8069  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);
         }          }
           if ($curr{'approvals'} eq 'none') {
               next if ($roleslog{$id}{'logentry'}{'approval'});
           } elsif ($curr{'approvals'} ne 'any') { 
               next if ($roleslog{$id}{'logentry'}{'approval'} ne $curr{'approvals'});
           }
         $count ++;          $count ++;
         next if ($count < $minshown);          next if ($count < $minshown);
         unless ($showntableheader) {          unless ($showntableheader) {
Line 7866  ENDSCRIPT Line 8120  ENDSCRIPT
         if ($chgcontext ne '' && $lt{$chgcontext} ne '') {          if ($chgcontext ne '' && $lt{$chgcontext} ne '') {
             $chgcontext = $lt{$chgcontext};              $chgcontext = $lt{$chgcontext};
         }          }
           my ($showreqby,%reqby);
           if (($roleslog{$id}{'logentry'}{'approval'}) &&
               ($roleslog{$id}{'logentry'}{'requester'})) {
               if ($reqby{$roleslog{$id}{'logentry'}{'requester'}} eq '') {
                   my ($requname,$requdom) = split(/:/,$roleslog{$id}{'logentry'}{'requester'});
                   $reqby{$roleslog{$id}{'logentry'}{'requester'}} =
                       &Apache::loncommon::plainname($requname,$requdom);
               }
               $showreqby = &mt('Requester').': <span class="LC_nobreak">'.$reqby{$roleslog{$id}{'logentry'}{'requester'}}.'</span><br />';
               if ($roleslog{$id}{'logentry'}{'approval'} eq 'domain') {
                   $showreqby .= &mt('Adjudicator').': <span class="LC_nobreak">'.
                                 $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.
                                 '</span>';
               } else {
                   $showreqby .= '<span class="LC_nobreak">'.&mt('User approved').'</span>';
               }
           } else {
               $showreqby = $whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}};
           }
         $r->print(          $r->print(
             &Apache::loncommon::start_data_table_row()              &Apache::loncommon::start_data_table_row()
            .'<td>'.$count.'</td>'             .'<td>'.$count.'</td>'
            .'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'             .'<td>'.&Apache::lonlocal::locallocaltime($roleslog{$id}{'exe_time'}).'</td>'
            .'<td>'.$whodunit{$roleslog{$id}{'exe_uname'}.':'.$roleslog{$id}{'exe_udom'}}.'</td>'             .'<td>'.$showreqby.'</td>'
            .'<td>'.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'</td>'             .'<td>'.$changed{$roleslog{$id}{'uname'}.':'.$roleslog{$id}{'udom'}}.'</td>'
            .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>');             .'<td>'.&Apache::lonnet::plaintext($roleslog{$id}{'logentry'}{'role'},$crstype).'</td>');
         if ($context eq 'course') {           if ($context eq 'course') { 
Line 8224  sub activity_display_filter { Line 8497  sub activity_display_filter {
     my $nolink = 1;      my $nolink = 1;
     my $output = '<table><tr><td valign="top">'.      my $output = '<table><tr><td valign="top">'.
                  '<span class="LC_nobreak"><b>'.&mt('Actions/page:').'</b></span><br />'.                   '<span class="LC_nobreak"><b>'.&mt('Actions/page:').'</b></span><br />'.
                  &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,                   &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef,
                                               (&mt('all'),5,10,20,50,100,1000,10000)).                                                (&mt('all'),5,10,20,50,100,1000,10000)).
                  '</td><td>&nbsp;&nbsp;</td>';                   '</td><td>&nbsp;&nbsp;</td>';
     my $startform =      my $startform =
Line 8311  sub userlogdisplay_navlinks { Line 8584  sub userlogdisplay_navlinks {
   
 sub role_display_filter {  sub role_display_filter {
     my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_;      my ($context,$formname,$cdom,$cnum,$curr,$version,$crstype) = @_;
     my $lctype;  
     if ($context eq 'course') {  
         $lctype = lc($crstype);  
     }  
     my $nolink = 1;      my $nolink = 1;
     my $output = '<table><tr><td valign="top">'.      my $output = '<table><tr><td valign="top">'.
                  '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.                   '<span class="LC_nobreak"><b>'.&mt('Changes/page:').'</b></span><br />'.
                  &Apache::lonmeta::selectbox('show',$curr->{'show'},undef,                   &Apache::lonmeta::selectbox('show',$curr->{'show'},'',undef,
                                               (&mt('all'),5,10,20,50,100,1000,10000)).                                                (&mt('all'),5,10,20,50,100,1000,10000)).
                  '</td><td>&nbsp;&nbsp;</td>';                   '</td><td>&nbsp;&nbsp;</td>';
     my $startform =      my $startform =
Line 8342  sub role_display_filter { Line 8611  sub role_display_filter {
     if ($curr->{'role'} eq 'any') {      if ($curr->{'role'} eq 'any') {
         $output .= ' selected="selected"';          $output .= ' selected="selected"';
     }      }
     $output .=  '>'.&mt('Any').'</option>'."\n";      $output .= '>'.&mt('Any').'</option>'."\n";
     my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);      my @roles = &Apache::lonuserutils::roles_by_context($context,1,$crstype);
     foreach my $role (@roles) {      foreach my $role (@roles) {
         my $plrole;          my $plrole;
Line 8363  sub role_display_filter { Line 8632  sub role_display_filter {
                &mt('Context:').'</b><br /><select name="chgcontext">';                 &mt('Context:').'</b><br /><select name="chgcontext">';
     my @posscontexts;      my @posscontexts;
     if ($context eq 'course') {      if ($context eq 'course') {
         @posscontexts = ('any','automated','updatenow','createcourse','course','domain','selfenroll','requestcourses','chgtype');          @posscontexts = ('any','automated','updatenow','createcourse','course','domain','selfenroll','requestcourses','chgtype','ltienroll');
     } elsif ($context eq 'domain') {      } elsif ($context eq 'domain') {
         @posscontexts = ('any','domain','requestauthor','domconfig','server');          @posscontexts = ('any','domain','requestauthor','domconfig','server');
     } else {      } else {
Line 8381  sub role_display_filter { Line 8650  sub role_display_filter {
         }          }
         $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";          $output .= '<option value="'.$chgtype.'"'.$selstr.'>'.$lt{$chgtype}.'</option>'."\n";
     }      }
     $output .= '</select></td>'      my @possapprovals = ('any','none','domain','user');
               .'</tr></table>';      my %apptxt = &approval_types();
       $output .= '</select></td>'.
                  '<td>&nbsp;&nbsp;</td>'.
                  '<td valign="top"><b>'.
                  &mt('Approvals:').'</b><br /><select name="approvals">';
       foreach my $approval (@possapprovals) {
           my $selstr = '';
           if ($curr->{'approvals'} eq $approval) {
               $selstr = ' selected="selected"';
           }    
           $output .= '<option value="'.$approval.'"'.$selstr.'>'.$apptxt{$approval}.'</option>';
       }
       $output .= '</select></td></tr></table>';
   
     # Update Display button      # Update Display button
     $output .= '<p>'      $output .= '<p>'
Line 8419  sub rolechg_contexts { Line 8700  sub rolechg_contexts {
                                              domain       => 'User Management in domain',                                               domain       => 'User Management in domain',
                                              selfenroll   => 'Self-enrolled',                                               selfenroll   => 'Self-enrolled',
                                              requestcourses => 'Course Request',                                               requestcourses => 'Course Request',
                                                ltienroll    => 'Enrollment via LTI',
                                          );                                           );
         if ($crstype eq 'Community') {          if ($crstype eq 'Community') {
             $lt{'createcourse'} = &mt('Community Creation');              $lt{'createcourse'} = &mt('Community Creation');
Line 8444  sub rolechg_contexts { Line 8726  sub rolechg_contexts {
     return %lt;      return %lt;
 }  }
   
   sub approval_types {
       return &Apache::lonlocal::texthash (
                                             any => 'Any',
                                             none => 'No approval needed',
                                             user => 'Role recipient approval',
                                             domain => 'Domain coordinator approval',
                                          );
   }
   
 sub print_helpdeskaccess_display {  sub print_helpdeskaccess_display {
     my ($r,$permission,$brcrum) = @_;      my ($r,$permission,$brcrum) = @_;
     my $formname = 'helpdeskaccess';      my $formname = 'helpdeskaccess';
Line 8850  ENDJS Line 9141  ENDJS
     return;      return;
 }  }
   
   sub print_queued_roles {
       my ($r,$context,$permission,$brcrum) = @_;
       push (@{$brcrum},
                {href => '/adm/createuser?action=rolerequests',
                 text => 'Role Requests (other domains)',
                 help => ''});
       my $bread_crumbs_component = 'Role Requests';
       my $args = { bread_crumbs           => $brcrum,
                    bread_crumbs_component => $bread_crumbs_component};
       # print page header
       $r->print(&header('',$args));
       my ($dom,$cnum);
       $dom = $env{'request.role.domain'};
       if ($context eq 'course') {
           if ($env{'request.course.id'}) {
               if (&Apache::loncommon::course_type() eq 'Community') {
                   $context = 'community';
               }
               $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
           }
       } elsif ($context eq 'author') {
           $cnum = $env{'user.name'};
       }
       $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomqueue',$dom,$cnum,$context));
       return;
   }
   
   sub print_pendingroles {
       my ($r,$context,$permission,$brcrum) = @_;
       push (@{$brcrum},
                {href => '/adm/createuser?action=queuedroles',
                 text => 'Queued Role Assignments (users in this domain)',
                 help => ''});
       my $bread_crumbs_component = 'Queued Role Assignments';
       my $args = { bread_crumbs           => $brcrum,
                    bread_crumbs_component => $bread_crumbs_component};
       # print page header
       $r->print(&header('',$args));
       $r->print(&Apache::loncoursequeueadmin::display_queued_requests('othdomaction',$env{'request.role.domain'},'','domain'));
       return;
   }
   
   sub process_pendingroles {
       my ($r,$context,$permission,$brcrum) = @_;
       push (@{$brcrum},
                {href => '/adm/createuser?action=queuedroles',
                 text => 'Queued Role Assignments (users in this domain)',
                 help => ''},
                {href => '/adm/createuser?action=processrolereq',
                 text => 'Process Queue',
                 help => ''});
       my $bread_crumbs_component = 'Queued Role Assignments';
       my $args = { bread_crumbs           => $brcrum,
                    bread_crumbs_component => $bread_crumbs_component};
       # print page header
       $r->print(&header('',$args));
       $r->print(&Apache::loncoursequeueadmin::update_request_queue('othdombydc',
                                                                    $env{'request.role.domain'}));
       return;
   }
   
 sub domain_adhoc_access {  sub domain_adhoc_access {
     my ($roles,$domcurrent,$accesstypes,$usertypes,$othertitle) = @_;      my ($roles,$domcurrent,$accesstypes,$usertypes,$othertitle) = @_;
     my %domusage;      my %domusage;
Line 9478  sub user_search_result { Line 9830  sub user_search_result {
             my $domd_chk = &domdirectorysrch_check($srch);              my $domd_chk = &domdirectorysrch_check($srch);
             $response .= '<span class="LC_warning">'.$instd_chk.'</span><br />';              $response .= '<span class="LC_warning">'.$instd_chk.'</span><br />';
             if ($domd_chk eq 'ok') {              if ($domd_chk eq 'ok') {
                 $response .= &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.');                  $response .= &mt('You may want to search in the LON-CAPA domain instead of in the institutional directory.');
             }              }
             $response .= '<br />';              $response .= '<br />';
         }          }
Line 9489  sub user_search_result { Line 9841  sub user_search_result {
                 my $instd_chk = &instdirectorysrch_check($srch);                  my $instd_chk = &instdirectorysrch_check($srch);
                 $response .= '<span class="LC_warning">'.$domd_chk.'</span><br />';                  $response .= '<span class="LC_warning">'.$domd_chk.'</span><br />';
                 if ($instd_chk eq 'ok') {                  if ($instd_chk eq 'ok') {
                     $response .= &mt('You may want to search in the institutional directory instead of the LON-CAPA domain.');                      $response .= &mt('You may want to search in the institutional directory instead of in the LON-CAPA domain.');
                 }                  }
                 $response .= '<br />';                  $response .= '<br />';
             }              }
Line 9590  sub user_search_result { Line 9942  sub user_search_result {
                 $response = '<span class="LC_warning">'.                  $response = '<span class="LC_warning">'.
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).                      &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.                      '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').                      &mt('You may want to search in the LON-CAPA domain instead of in the institutional directory.').
                     '<br />';                       '<br />'; 
             }              }
         }          }
Line 9663  sub user_search_result { Line 10015  sub user_search_result {
                 $response = '<span class="LC_warning">'.                  $response = '<span class="LC_warning">'.
                     &mt('Institutional directory search is not available in domain: [_1]',$showdom).                      &mt('Institutional directory search is not available in domain: [_1]',$showdom).
                     '</span><br />'.                      '</span><br />'.
                     &mt('You may want to search in the LON-CAPA domain instead of the institutional directory.').                      &mt('You may want to search in the LON-CAPA domain instead of in the institutional directory.').
                     '<br />';                      '<br />';
             }              }
         }          }

Removed from v.1.406.2.20.2.6  
changed lines
  Added in v.1.474


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