Diff for /loncom/interface/loncreateuser.pm between versions 1.467 and 1.469

version 1.467, 2023/03/29 16:01:13 version 1.469, 2023/08/01 15:56:32
Line 4246  sub update_roles { Line 4246  sub update_roles {
       0 );        0 );
  my $url='/'.$one.'/'.$two;   my $url='/'.$one.'/'.$two;
                 my $id = $url.'_'.$three;                  my $id = $url.'_'.$three;
                 my $type = '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);
Line 4330  sub update_roles { Line 4329  sub update_roles {
                 my $two = $2;                  my $two = $2;
  my $url='/'.$one.'/';   my $url='/'.$one.'/';
                 my $id = $url.'_'.$two;                  my $id = $url.'_'.$two;
                   my ($cdom,$cnum) = split(/\//,$one);
                 # split multiple sections                  # split multiple sections
                 my %sections = ();                  my %sections = ();
                 my ($restricted,$numchanges);                  my ($restricted,$numchanges);
Line 4337  sub update_roles { Line 4337  sub update_roles {
                 if ($num_sections == 0) {                  if ($num_sections == 0) {
                     unless ($udom eq $one) {                      unless ($udom eq $one) {
                         $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,                          $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                           $uname,$two,$start,$end,$one,$two,'','',\%process_by,                                            $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
                                           \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,                                            \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                           \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);                                            \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                         next if ($restricted);                          next if ($restricted);
Line 4353  sub update_roles { Line 4353  sub update_roles {
                             unless ($udom eq $one) {                              unless ($udom eq $one) {
                                 undef($restricted);                                  undef($restricted);
                                 $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,                                  $restricted = &Apache::lonuserutils::restricted_dom($context,$secid,$udom,
                                                   $uname,$two,$start,$end,$one,$two,$sec,'',\%process_by,                                                    $uname,$two,$start,$end,$cdom,$cnum,$sec,'',\%process_by,
                                                   \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,                                                    \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                                   \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);                                                    \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                                 next if ($restricted);                                  next if ($restricted);
Line 4368  sub update_roles { Line 4368  sub update_roles {
                         unless ($udom eq $one) {                          unless ($udom eq $one) {
                             undef($restricted);                              undef($restricted);
                             $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,                              $restricted = &Apache::lonuserutils::restricted_dom($context,$id,$udom,
                                               $uname,$two,$start,$end,$one,$two,'','',\%process_by,                                                $uname,$two,$start,$end,$cdom,$cnum,'','',\%process_by,
                                               \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,                                                \%instdoms,\%got_role_approvals,\%got_instdoms,\%reject,
                                               \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);                                                \%pending,\%notifydc,\%status,\%unauthorized,\%currqueued);
                             next if ($restricted);                              next if ($restricted);
Line 4920  sub handler { Line 4920  sub handler {
                 if (&Apache::lonnet::auto_run($cnum,$cdom) && (($permission->{'cusr'}) || ($permission->{'view'}))) {                  if (&Apache::lonnet::auto_run($cnum,$cdom) && (($permission->{'cusr'}) || ($permission->{'view'}))) {
                     push(@allhelp,'Course_Automated_Enrollment');                      push(@allhelp,'Course_Automated_Enrollment');
                 }                  }
                 if ($permission->{'selfenrolladmin'}) {                  if (($permission->{'selfenrolladmin'}) || ($permission->{'selfenrollview'})) {
                     push(@allhelp,'Course_Approve_Selfenroll');                      push(@allhelp,'Course_Approve_Selfenroll');
                 }                  }
             }              }
Line 5460  sub handler { Line 5460  sub handler {
                      '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>');                        '<span class="LC_error">'.&mt('You do not have permission to modify dates or sections for users').'</span>'); 
         }          }
     } elsif ($env{'form.action'} eq 'selfenroll') {      } elsif ($env{'form.action'} eq 'selfenroll') {
         if ($permission->{selfenrolladmin}) {          my %currsettings;
             my %currsettings = (          if ($permission->{selfenrolladmin} || $permission->{selfenrollview}) {
               %currsettings = (
                 selfenroll_types              => $env{'course.'.$cid.'.internal.selfenroll_types'},                  selfenroll_types              => $env{'course.'.$cid.'.internal.selfenroll_types'},
                 selfenroll_registered         => $env{'course.'.$cid.'.internal.selfenroll_registered'},                  selfenroll_registered         => $env{'course.'.$cid.'.internal.selfenroll_registered'},
                 selfenroll_section            => $env{'course.'.$cid.'.internal.selfenroll_section'},                  selfenroll_section            => $env{'course.'.$cid.'.internal.selfenroll_section'},
Line 5477  sub handler { Line 5478  sub handler {
                 default_enrollment_end_date   => $env{'course.'.$cid.'.default_enrollment_end_date'},                  default_enrollment_end_date   => $env{'course.'.$cid.'.default_enrollment_end_date'},
                 uniquecode                    => $env{'course.'.$cid.'.internal.uniquecode'},                  uniquecode                    => $env{'course.'.$cid.'.internal.uniquecode'},
             );              );
           }
           if ($permission->{selfenrolladmin}) {
             push(@{$brcrum},              push(@{$brcrum},
                     {href => '/adm/createuser?action=selfenroll',                      {href => '/adm/createuser?action=selfenroll',
                      text => "Configure Self-enrollment",                       text => "Configure Self-enrollment",
Line 5497  sub handler { Line 5500  sub handler {
                 $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n");                  $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n");
                 &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings);                  &update_selfenroll_config($r,$cid,$cdom,$cnum,$context,$crstype,\%currsettings);
             }              }
           } elsif ($permission->{selfenrollview}) {
               push(@{$brcrum},
                       {href => '/adm/createuser?action=selfenroll',
                        text => "View Self-enrollment configuration",
                        help => 'Course_Self_Enrollment'});
               $args = { bread_crumbs           => $brcrum,
                         bread_crumbs_component => 'Self-enrollment Settings'};
               $r->print(&header(undef,$args));
               $r->print('<h3>'.&mt('Self-enrollment with a student role').'</h3>'."\n");
               &print_selfenroll_menu($r,'course',$cid,$cdom,$cnum,\%currsettings,'',1);
         } else {          } else {
             $r->print(&header(undef,{'no_nav_bar' => 1}).              $r->print(&header(undef,{'no_nav_bar' => 1}).
                      '<span class="LC_error">'.&mt('You do not have permission to configure self-enrollment').'</span>');                       '<span class="LC_error">'.&mt('You do not have permission to configure self-enrollment').'</span>');
Line 6028  sub print_main_menu { Line 6041  sub print_main_menu {
                      icon => 'selfenrl-queue.png',                       icon => 'selfenrl-queue.png',
                      #help => 'Course_Approve_Selfenroll',                       #help => 'Course_Approve_Selfenroll',
                      url => '/adm/createuser?action=selfenrollqueue',                       url => '/adm/createuser?action=selfenrollqueue',
                      permission => $permission->{'selfenrolladmin'},                       permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'},
                      linktitle =>'Approve or reject enrollment requests.',                       linktitle =>'Approve or reject enrollment requests.',
                     },                      },
             );              );
Line 6055  sub print_main_menu { Line 6068  sub print_main_menu {
                  icon => 'self_enroll.png',                   icon => 'self_enroll.png',
                  #help => 'Course_Self_Enrollment',                   #help => 'Course_Self_Enrollment',
                  url => '/adm/createuser?action=selfenroll',                   url => '/adm/createuser?action=selfenroll',
                  permission => $permission->{'selfenrolladmin'},                   permission => $permission->{'selfenrolladmin'} || $permission->{'selfenrollview'},
                  linktitle => 'Configure user self-enrollment.',                   linktitle => 'Configure user self-enrollment.',
                 },                  },
             );              );
Line 6326  ENDSCRIPT Line 6339  ENDSCRIPT
                  '// ]]>'."\n".                   '// ]]>'."\n".
                  '</script>'."\n".                   '</script>'."\n".
                  '<h3>'.$lt->{'selfenroll'}.'</h3>'."\n";                   '<h3>'.$lt->{'selfenroll'}.'</h3>'."\n";
        my $visactions = &cat_visibility($cdom);
     my $visactions = &cat_visibility();  
     my ($cathash,%cattype);      my ($cathash,%cattype);
     my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);      my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
     if (ref($domconfig{'coursecategories'}) eq 'HASH') {      if (ref($domconfig{'coursecategories'}) eq 'HASH') {
Line 6873  sub visible_in_stdcat { Line 6885  sub visible_in_stdcat {
 }  }
   
 sub cat_visibility {  sub cat_visibility {
       my ($cdom) = @_;
     my %visactions = &Apache::lonlocal::texthash(      my %visactions = &Apache::lonlocal::texthash(
                    vis => 'This course/community currently appears in the Course/Community Catalog for this domain.',                     vis => 'This course/community currently appears in the Course/Community Catalog for this domain.',
                    gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',                     gen => 'Courses can be both self-cataloging, based on an institutional code (e.g., fs08phy231), or can be assigned categories from a hierarchy defined for the domain.',
Line 6885  sub cat_visibility { Line 6898  sub cat_visibility {
                    dc_chgconf => 'Ask a domain coordinator to change the Catalog type for this domain.',                     dc_chgconf => 'Ask a domain coordinator to change the Catalog type for this domain.',
                    dc_setcode => 'Ask a domain coordinator to assign a six character code to the course',                     dc_setcode => 'Ask a domain coordinator to assign a six character code to the course',
                    dc_unhide  => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',                     dc_unhide  => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.',
                    dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',                     dc_addinst => 'Ask a domain coordinator to enable catalog display of "Official courses (with institutional codes)".',
                    dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',                     dc_instcode => 'Ask a domain coordinator to assign an institutional code (if this is an official course).',
                    dc_catalog  => 'Ask a domain coordinator to enable or create at least one course category in the domain.',                     dc_catalog  => 'Ask a domain coordinator to enable or create at least one course category in the domain.',
                    dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',                     dc_categories => 'Ask a domain coordinator to create a hierarchy of categories and sub categories for courses in the domain.',
                    dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',                     dc_chgcat => 'Ask a domain coordinator to change the category assigned to the course, as the one currently assigned is no longer used in the domain',
                    dc_addcat => 'Ask a domain coordinator to assign a category to the course.',                     dc_addcat => 'Ask a domain coordinator to assign a category to the course.',
     );      );
       if ($env{'request.role'} eq "dc./$cdom/") {
           $visactions{'dc_chgconf'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the Catalog type for this domain.','&raquo;');
           $visactions{'dc_setcode'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to assign a six character code to the course.','&raquo;');
           $visactions{'dc_unhide'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to change the "Exclude from course catalog" setting.','&raquo;');
           $visactions{'dc_addinst'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable catalog display of "Official courses (with institutional codes)".','&raquo;');
           $visactions{'dc_instcode'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify course owner, institutional code ... " to assign an institutional code (if this is an official course).','&raquo;');
           $visactions{'dc_catalog'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to enable or create at least one course category in the domain.','&raquo;');
           $visactions{'dc_categories'} = &mt('Use: "Main menu" [_1] "Set domain configuration" [_1] "Cataloging of courses/communities" to create a hierarchy of categories and sub categories for courses in the domain.','&raquo;');
           $visactions{'dc_chgcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','&raquo;');
           $visactions{'dc_addcat'} = &mt('Use: "Main menu" [_1] "View or modify a course or community" [_1] "View/Modify catalog settings for course" to assign a category to the course.','&raquo;');
       }
     $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');      $visactions{'unhide'} = &mt('Use [_1]Categorize course[_2] to change the "Exclude from course catalog" setting.','<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
     $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');      $visactions{'chgcat'} = &mt('Use [_1]Categorize course[_2] to change the category assigned to the course, as the one currently assigned is no longer used in the domain.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
     $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');      $visactions{'addcat'} = &mt('Use [_1]Categorize course[_2] to assign a category to the course.','"<a href="/adm/courseprefs?phase=display&actions=courseinfo">','</a>"');
Line 7070  ENDSCRIPT Line 7094  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 7149  ENDSCRIPT Line 7174  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 7195  ENDSCRIPT Line 7225  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 7688  sub role_display_filter { Line 7737  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 7706  sub role_display_filter { Line 7755  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 7744  sub rolechg_contexts { Line 7805  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 7768  sub rolechg_contexts { Line 7830  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 9904  sub update_selfenroll_config { Line 9975  sub update_selfenroll_config {
     } else {      } else {
         $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));          $r->print(&mt('No changes were made to the existing self-enrollment settings in this course.'));
     }      }
     my $visactions = &cat_visibility();      my $visactions = &cat_visibility($cdom);
     my ($cathash,%cattype);      my ($cathash,%cattype);
     my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);      my %domconfig = &Apache::lonnet::get_dom('configuration',['coursecategories'],$cdom);
     if (ref($domconfig{'coursecategories'}) eq 'HASH') {      if (ref($domconfig{'coursecategories'}) eq 'HASH') {

Removed from v.1.467  
changed lines
  Added in v.1.469


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