--- loncom/interface/loncreateuser.pm	2017/04/01 14:00:23	1.439
+++ loncom/interface/loncreateuser.pm	2018/12/08 18:30:15	1.450
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Create a user
 #
-# $Id: loncreateuser.pm,v 1.439 2017/04/01 14:00:23 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.450 2018/12/08 18:30:15 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -78,6 +78,7 @@ my $authformkrb;
 my $authformint;
 my $authformfsys;
 my $authformloc;
+my $authformlti;
 
 sub initialize_authen_forms {
     my ($dom,$formname,$curr_authtype,$mode) = @_;
@@ -88,7 +89,7 @@ sub initialize_authen_forms {
                   domain => $dom,
                 );
     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 $curr_autharg = $2;
         my %abv_auth = &auth_abbrev();
@@ -107,6 +108,7 @@ sub initialize_authen_forms {
     $authformint  = &Apache::loncommon::authform_internal(%param);
     $authformfsys = &Apache::loncommon::authform_filesystem(%param);
     $authformloc  = &Apache::loncommon::authform_local(%param);
+    $authformlti  = &Apache::loncommon::authform_lti(%param);
 }
 
 sub auth_abbrev {
@@ -116,6 +118,7 @@ sub auth_abbrev {
                      internal  => 'int',
                      localauth => 'loc',
                      unix      => 'fsys',
+                     lti       => 'lti',
                    );
     return %abv_auth;
 }
@@ -253,14 +256,15 @@ sub build_tools_display {
                    'community'  => 'Can request creation of communities',
                    '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',
     );
     if ($context eq 'requestcourses') {
         %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname,
                       'requestcourses.official','requestcourses.unofficial',
                       'requestcourses.community','requestcourses.textbook',
-                      'requestcourses.placement');
-        @usertools = ('official','unofficial','community','textbook','placement');
+                      'requestcourses.placement','requestcourses.lti');
+        @usertools = ('official','unofficial','community','textbook','placement','lti');
         @options =('norequest','approval','autolimit','validate');
         %validations = &Apache::lonnet::auto_courserequest_checks($ccdomain);
         %reqtitles = &courserequest_titles();
@@ -543,6 +547,7 @@ sub courserequest_titles {
                                    community  => 'Communities',
                                    textbook   => 'Textbook',
                                    placement  => 'Placement Tests',
+                                   lti        => 'LTI Provider',
                                    norequest  => 'Not allowed',
                                    approval   => 'Approval by Dom. Coord.',
                                    validate   => 'With validation',
@@ -886,7 +891,15 @@ ENDBLOCK
         (!(($env{'form.action'} eq 'singleuser') && ($context eq 'domain') &&
         (!&Apache::lonnet::allowed('mau',$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(
                   'enro' => 'Enroll one student',
                   'enrm' => 'Enroll one member',
@@ -1471,15 +1484,21 @@ ENDAUTH
                                          $inst_results{$ccuname.':'.$ccdomain}));
         if ((&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) ||
             (&Apache::lonnet::allowed('udp',$env{'request.role.domain'}))) {
-            $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'.
-                      &Apache::loncommon::start_data_table());
-            if ($env{'request.role.domain'} eq $ccdomain) {
-                $r->print(&build_tools_display($ccuname,$ccdomain,'requestcourses'));
+            $r->print('<br /><h3>'.&mt('User Can Request Creation of Courses/Communities in this Domain?').'</h3>'."\n");
+            if (($env{'request.role.domain'} eq $ccdomain) ||
+                (&Apache::lonnet::will_trust('reqcrs',$ccdomain,$env{'request.role.domain'}))) {
+                $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 {
-                $r->print(&coursereq_externaluser($ccuname,$ccdomain,
-                                                  $env{'request.role.domain'}));
+                $r->print(&mt('Domain configuration for this domain prohibits course creation by users from domain: "[_1]"',
+                              &Apache::lonnet::domain($ccdomain,'description')));
             }
-            $r->print(&Apache::loncommon::end_data_table());
         }
         $r->print('</div>');
         my @order = ('auth','quota','tools','requestauthor');
@@ -2135,11 +2154,20 @@ sub new_domain_roles {
     '<th>'.&mt('Start').'</th><th>'.&mt('End').'</th>'.
     &Apache::loncommon::end_data_table_header_row();
     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 $role (@allroles) {
             next if ($role eq 'ad');
             next if (($role eq 'au') && ($ccdomain ne $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 %lt=&Apache::lonlocal::texthash(
                     'ssd'  => "Set Start Date",
@@ -2181,7 +2209,7 @@ sub user_authentication {
                    'ld'    => "Login Data"
     );
     # Check for a bad authentication type
-    if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth):/) {
+    if ($currentauth !~ /^(krb4|krb5|unix|internal|localauth|lti):/) {
         # bad authentication scheme
         if (&Apache::lonnet::allowed('mau',$ccdomain)) {
             &initialize_authen_forms($ccdomain,$formname);
@@ -2260,6 +2288,8 @@ ENDBADAUTH
                     $result = &mt('Currently using local (institutional) authentication.');
                 } elsif ($currentauth =~ /^unix:/) {
                     $result = &mt('Currently Filesystem Authenticated.');
+                } elsif ($currentauth =~ /^lti:/) {
+                    $result = &mt('Currently LTi authenticated.');
                 }
                 $outcome = '<h3>'.$lt{'ld'}.'</h3>'.
                            &Apache::loncommon::start_data_table().
@@ -2298,6 +2328,9 @@ sub modify_login_block {
         if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);
         }
+        if ($can_assign{'lti'}) {
+            push(@authform_others,$authformlti);
+        }
         if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) {
             $show_override_msg = 1;
         }
@@ -2309,6 +2342,9 @@ sub modify_login_block {
         if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);
         }
+        if ($can_assign{'lti'}) {
+            push(@authform_others,$authformlti);
+        }
         if ($can_assign{'int'}) {
             $show_override_msg = 1;
         }
@@ -2323,6 +2359,9 @@ sub modify_login_block {
         if ($can_assign{'loc'}) {
             push(@authform_others,$authformloc);
         }
+        if ($can_assign{'lti'}) {
+            push(@authform_others,$authformlti);
+        }
         if ($can_assign{'fsys'}) {
             $show_override_msg = 1;
         }
@@ -2334,9 +2373,23 @@ sub modify_login_block {
         if ($can_assign{'int'}) {
             push(@authform_others,$authformint);
         }
+        if ($can_assign{'lti'}) {
+            push(@authform_others,$authformlti);
+        }
         if ($can_assign{'loc'}) {
             $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) {
         $authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent.
@@ -2352,7 +2405,7 @@ sub modify_login_block {
 
 sub personal_data_display {
     my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray,
-        $now,$captchaform,$emailusername,$usertype) = @_;
+        $now,$captchaform,$emailusername,$usertype,$usernameset,$condition,$excluded) = @_;
     my ($output,%userenv,%canmodify,%canmodify_status);
     my @userinfo = ('firstname','middlename','lastname','generation',
                     'permanentemail','id');
@@ -2379,6 +2432,7 @@ sub personal_data_display {
                 'inststatus'     => "Affiliation",
                 'email'          => 'E-mail address',
                 'valid'          => 'Validation',
+                'username'       => 'Username',
     );
 
     %canmodify_status =
@@ -2397,7 +2451,7 @@ sub personal_data_display {
             if (ref($emailusername) eq 'HASH') {
                 if (ref($emailusername->{$usertype}) eq 'HASH') {
                     my ($infofields,$infotitles) = &Apache::loncommon::emailusername_info();
-                    @userinfo = ();          
+                    @userinfo = ();
                     if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
                         foreach my $field (@{$infofields}) { 
                             if ($emailusername->{$usertype}->{$field}) {
@@ -2427,9 +2481,38 @@ sub personal_data_display {
     $output = '<h3>'.$lt{'pd'}.'</h3>'.
               &Apache::lonhtmlcommon::start_pick_box();
     if (($context eq 'selfcreate') && ($newuser eq 'email')) {
+        my $size = 25;
+        if ($condition) {
+            if ($condition =~ /^\@[^\@]+$/) {
+                $size = 10;
+            } else {
+                undef($condition);
+            }
+        } 
+        if ($excluded) {
+            unless ($excluded =~ /^\@[^\@]+$/) {
+                undef($condition);
+            }
+        }
         $output .= &Apache::lonhtmlcommon::row_title($lt{'email'}.'<b>*</b>',undef,
                                                      'LC_oddrow_value')."\n".
-                   '<input type="text" name="uname" size="25" value="" autocomplete="off" />';
+                   '<input type="text" name="uname" size="'.$size.'" value="" autocomplete="off" />';
+        if ($condition) {
+            $output .= $condition;
+        } elsif ($excluded) {
+            $output .= '<br /><span style="font-size: smaller">'.&mt('You must use an e-mail address that does not end with [_1]',
+                                                                     $excluded).'</span>';
+        }
+        if ($usernameset eq 'first') {
+            $output .= '<br /><span style="font-size: smaller">';
+            if ($condition) {
+                $output .= &mt('Your username in LON-CAPA will be the part of your e-mail address before [_1]',
+                                      $condition);
+            } else {
+                $output .= &mt('Your username in LON-CAPA will be the part of your e-mail address before the @');
+            }
+            $output .= '</span>';
+        }
         $rowcount ++;
         $output .= &Apache::lonhtmlcommon::row_closure(1);
         my $upassone = '<input type="password" name="upass'.$now.'" size="20" autocomplete="off" />';
@@ -2444,6 +2527,19 @@ sub personal_data_display {
                                                      'LC_oddrow_value')."\n".
                    $upasstwo.
                    &Apache::lonhtmlcommon::row_closure()."\n";
+        if ($usernameset eq 'free') {
+            my $onclick = "toggleUsernameDisp(this,'selfcreateusername');"; 
+            $output .= &Apache::lonhtmlcommon::row_title($lt{'username'},undef,'LC_oddrow_value')."\n".
+                       &mt('Use e-mail address: ').
+                       '<label><input type="radio" name="emailused" value="1" checked="checked" onclick="'.$onclick.'" />'.&mt('Yes').'</label>'."\n".
+                       ('&nbsp;'x2).
+                       '<label><input type="radio" name="emailused" value="0" onclick="'.$onclick.'" />'.&mt('No').'</label>'."\n".
+                       '<div id="selfcreateusername" style="display: none; font-size: smaller">'.
+                       '<br /><span class="LC_nobreak">'.&mt('Preferred username').
+                       '&nbsp;<input type="text" name="username" value="" size="20" autocomplete="off"/>'.
+                       '</span></div>'."\n".&Apache::lonhtmlcommon::row_closure(1);
+            $rowcount ++;
+        }
     }
     foreach my $item (@userinfo) {
         my $rowtitle = $lt{$item};
@@ -2752,6 +2848,9 @@ sub update_user_data {
 	$amode='localauth';
 	$genpwd=$env{'form.locarg'};
 	$genpwd=" " if (!$genpwd);
+    } elsif ($env{'form.login'} eq 'lti') {
+        $amode='lti';
+        $genpwd=" ";
     } elsif (($env{'form.login'} eq 'nochange') ||
              ($env{'form.login'} eq ''        )) { 
         # There is no need to tell the user we did not change what they
@@ -2771,7 +2870,7 @@ sub update_user_data {
     my (%alerts,%rulematch,%inst_results,%curr_rules);
     my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
     my @usertools = ('aboutme','blog','webdav','portfolio');
-    my @requestcourses = ('official','unofficial','community','textbook','placement');
+    my @requestcourses = ('official','unofficial','community','textbook','placement','lti');
     my @requestauthor = ('requestauthor');
     my ($othertitle,$usertypes,$types) = 
         &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
@@ -3237,7 +3336,7 @@ sub update_user_data {
                         foreach my $key (keys(%changed)) {
                             if (($key eq 'official') || ($key eq 'unofficial') ||
                                 ($key eq 'community') || ($key eq 'textbook') ||
-                                ($key eq 'placement')) {
+                                ($key eq 'placement') || ($key eq 'lti')) {
                                 $newenvhash{'environment.requestcourses.'.$key} =
                                     $changeHash{'requestcourses.'.$key};
                                 if ($changeHash{'requestcourses.'.$key}) {
@@ -3447,6 +3546,7 @@ sub display_userinfo {
          'community'      => 'Can Request Communities',
          'textbook'       => 'Can Request Textbook Courses',
          'placement'      => 'Can Request Placement Tests',
+         'lti'            => 'Can Request LTI Courses',
          'requestauthor'  => 'Can Request Author Role',
          'inststatus'     => "Affiliation",
          'prvs'           => 'Previous Value:',
@@ -4636,10 +4736,6 @@ sub handler {
                     help=>$allhelpitems}
                   ];
     }
-    #SD Following files not added to help, because the corresponding .tex-files seem to
-    #be missing: Course_Approve_Selfenroll,Course_User_Logs,
-    my ($permission,$allowed) = 
-        &Apache::lonuserutils::get_permission($context,$crstype);
     if (!$allowed) {
         if ($context eq 'course') {
             $r->internal_redirect('/adm/viewclasslist');
@@ -4692,16 +4788,41 @@ sub handler {
         if (! exists($env{'form.state'})) {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         } elsif ($env{'form.state'} eq 'got_file') {
-            &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
-                                                             $crstype,$showcredits);
+            my $result = 
+                &Apache::lonuserutils::print_upload_manager_form($r,$context,
+                                                                 $permission,
+                                                                 $crstype,$showcredits);
+            if ($result eq 'missingdata') {
+                delete($env{'form.state'});
+                &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+            }
         } elsif ($env{'form.state'} eq 'enrolling') {
             if ($env{'form.datatoken'}) {
-                &Apache::lonuserutils::upfile_drop_add($r,$context,$permission,
-                                                       $showcredits);
+                my $result = &Apache::lonuserutils::upfile_drop_add($r,$context,
+                                                                    $permission,
+                                                                    $showcredits);
+                if ($result eq 'missingdata') {
+                    delete($env{'form.state'});
+                    &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+                } elsif ($result eq 'invalidhome') {
+                    $env{'form.state'} = 'got_file';
+                    delete($env{'form.lcserver'});
+                    my $result =
+                        &Apache::lonuserutils::print_upload_manager_form($r,$context,$permission,
+                                                                         $crstype,$showcredits);
+                    if ($result eq 'missingdata') {
+                        delete($env{'form.state'});
+                        &Apache::lonuserutils::print_first_users_upload_form($r,$context);
+                    }
+                }
+            } else {
+                delete($env{'form.state'});
+                &Apache::lonuserutils::print_first_users_upload_form($r,$context);
             }
         } else {
             &Apache::lonuserutils::print_first_users_upload_form($r,$context);
         }
+        $r->print('</form>');
     } elsif (((($env{'form.action'} eq 'singleuser') || ($env{'form.action'}
               eq 'singlestudent')) && ($permission->{'cusr'})) ||
              (($env{'form.action'} eq 'singleuser') && ($permission->{'view'})) ||
@@ -4923,47 +5044,77 @@ sub handler {
                             unless ($usertype) {
                                 $usertype = 'default';
                             }
+                            my ($showstatus,$showemail,$pickstart);
+                            my $numextras = 0;
+                            my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom);
+                            if ((ref($types) eq 'ARRAY') && (@{$types} > 0)) {
+                                if (ref($usertypes) eq 'HASH') {
+                                    if ($usertypes->{$usertype}) {
+                                        $showstatus = $usertypes->{$usertype};
+                                    } else {
+                                        $showstatus = $othertitle;
+                                    }
+                                    if ($showstatus) {
+                                        $numextras ++;
+                                    }
+                                }
+                            }
+                            if (($info{$uname}{'email'} ne '') && ($info{$uname}{'email'} ne $uname)) {
+                                $showemail = $info{$uname}{'email'};
+                                $numextras ++;
+                            }
                             if (ref($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}) eq 'HASH') {
                                 if ((ref($infofields) eq 'ARRAY') && (ref($infotitles) eq 'HASH')) {
+                                    $pickstart = 1;
                                     $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box());
-                                    my ($num,$count,$showstatus);
+                                    my ($num,$count);
                                     $count = scalar(keys(%{$domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}}));
-                                    unless ($usertype eq 'default') {
-                                        my ($othertitle,$usertypes,$types) = 
-                                            &Apache::loncommon::sorted_inst_types($dom);
-                                        if (ref($usertypes) eq 'HASH') {
-                                            if ($usertypes->{$usertype}) {
-                                                $showstatus = $usertypes->{$usertype};
-                                                $count ++;
-                                            }
-                                        }
-                                    }
+                                    $count += $numextras;
                                     foreach my $field (@{$infofields}) {
                                         next unless ($domconfig{'usercreation'}{'cancreate'}{'emailusername'}{$usertype}{$field});
                                         next unless ($infotitles->{$field});
                                         $r->print(&Apache::lonhtmlcommon::row_title($infotitles->{$field}).
                                                   $info{$uname}{$field});
                                         $num ++;
-                                        if ($count == $num) {
-                                            $r->print(&Apache::lonhtmlcommon::row_closure(1));
-                                        } else {
+                                        unless ($count == $num) {
                                             $r->print(&Apache::lonhtmlcommon::row_closure());
                                         }
                                     }
-                                    if ($showstatus) {
-                                        $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type (self-reported)')).
-                                                  $showstatus.
-                                                  &Apache::lonhtmlcommon::row_closure(1));
+                                }
+                            }
+                            if ($numextras) {
+                                unless ($pickstart) {
+                                    $r->print('<div>'.&Apache::lonhtmlcommon::start_pick_box());
+                                    $pickstart = 1;
+                                }
+                                if ($showemail) {
+                                    my $closure = '';
+                                    unless ($showstatus) {
+                                        $closure = 1;
                                     }
-                                    $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
+                                    $r->print(&Apache::lonhtmlcommon::row_title(&mt('E-mail address')).
+                                              $showemail.
+                                              &Apache::lonhtmlcommon::row_closure($closure));
+                                }
+                                if ($showstatus) {
+                                    $r->print(&Apache::lonhtmlcommon::row_title(&mt('Status type[_1](self-reported)','<br />')).
+                                              $showstatus.
+                                              &Apache::lonhtmlcommon::row_closure(1));
                                 }
                             }
+                            if ($pickstart) { 
+                                $r->print(&Apache::lonhtmlcommon::end_pick_box().'</div>');
+                            } else {
+                                $r->print('<div>'.&mt('No information to display for this account request.').'</div>');
+                            }
+                        } else {
+                            $r->print('<div>'.&mt('No information available for this account request.').'</div>');
                         }
                     }
                 }
             }
-            $r->print(&close_popup_form());
         }
+        $r->print(&close_popup_form());
     } elsif (($env{'form.action'} eq 'listusers') && 
              ($permission->{'view'} || $permission->{'cusr'})) {
         my $helpitem = 'Course_View_Class_List';
@@ -5833,12 +5984,13 @@ function validate_types(form) {
 }
 
 function check_types(num,countfail,needaction) {
-    var typeidx = getIndexByName('selfenroll_types_'+num);
+    var boxname = 'selfenroll_types_'+num;
+    var typeidx = getIndexByName(boxname);
     var count = 0;
     if (typeidx != -1) {
-        if (document.$formname.elements[typeidx].length) {
-            for (var k=0; k<document.$formname.elements[typeidx].length; k++) {
-                if (document.$formname.elements[typeidx][k].checked) {
+        if (document.$formname.elements[boxname].length) {
+            for (var k=0; k<document.$formname.elements[boxname].length; k++) {
+                if (document.$formname.elements[boxname][k].checked) {
                     count ++;
                 }
             }
@@ -6059,10 +6211,11 @@ ENDSCRIPT
                 } elsif ($curr_types eq '') {
                     $add_domtitle = &mt('Users in other domain:');
                 }
+                my ($trusted,$untrusted) = &Apache::lonnet::trusted_domains('enroll',$cdom);
                 $output .= &Apache::loncommon::start_data_table_row()
                            .'<td colspan="2"><span class="LC_nobreak">'.$add_domtitle.'</span><br />'
                            .&Apache::loncommon::select_dom_form('','selfenroll_newdom',
-                                                                $includeempty,$showdomdesc,'','','',$readonly)
+                                                                $includeempty,$showdomdesc,'',$trusted,$untrusted,$readonly)
                            .'<input type="hidden" name="selfenroll_types_total" value="'.$num.'" />'
                            .'</td>'.&Apache::loncommon::end_data_table_row()
                            .&Apache::loncommon::end_data_table();