--- loncom/interface/lonuserutils.pm 2011/01/05 18:42:53 1.134 +++ loncom/interface/lonuserutils.pm 2011/01/18 23:37:47 1.135 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.134 2011/01/05 18:42:53 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.135 2011/01/18 23:37:47 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -4000,7 +4000,8 @@ sub upfile_drop_add { official => 'Institutional', unofficial => 'Non-institutional', ); - map { $cancreate{$_} = &can_create_user($domain,$context,$_); } keys(%longtypes); + my $newuserdom = $env{'request.role.domain'}; + map { $cancreate{$_} = &can_create_user($newuserdom,$context,$_); } keys(%longtypes); # Get new users list foreach my $line (@userdata) { my @secs; @@ -4155,25 +4156,33 @@ sub upfile_drop_add { my (%rulematch,%inst_results,%idinst_results); my $uhome=&Apache::lonnet::homeserver($username,$userdomain); if ($uhome eq 'no_host') { - if ($userdomain ne $domain) { - $r->print('
'. - &mt('[_1]: The domain specified ([_2]) is different to that of the course.', - ''.$username.'',$userdomain).'
'. - &mt('The user does not already exist, and you may not create a new user in a different domain.')); + if ($userdomain ne $newuserdom) { + if ($context eq 'course') { + $r->print('
'. + &mt('[_1]: The domain specified ([_2]) is different to that of the course.', + ''.$username.'',$userdomain).'
'); + } elsif ($context eq 'author') { + $r->print(&mt('[_1]: The domain specified ([_2]) is different to that of the author.', + ''.$username.'',$userdomain).'
'); + } else { + $r->print(&mt('[_1]: The domain specified ([_2]) is different to that of your current role.', + ''.$username.'',$userdomain).'
'); + } + $r->print(&mt('The user does not already exist, and you may not create a new user in a different domain.')); next; } $checkid = 1; $newuser = 1; - my $user = $username.':'.$domain; + my $user = $username.':'.$newuserdom; my $checkhash; my $checks = { 'username' => 1 }; - $checkhash->{$username.':'.$domain} = { 'newuser' => 1, }; + $checkhash->{$username.':'.$newuserdom} = { 'newuser' => 1, }; &Apache::loncommon::user_rule_check($checkhash,$checks, \%alerts,\%rulematch,\%inst_results,\%curr_rules, \%got_rules); if (ref($alerts{'username'}) eq 'HASH') { - if (ref($alerts{'username'}{$domain}) eq 'HASH') { - if ($alerts{'username'}{$domain}{$username}) { + if (ref($alerts{'username'}{$newuserdom}) eq 'HASH') { + if ($alerts{'username'}{$newuserdom}{$username}) { $r->print('
'. &mt('[_1]: matches the username format at your institution, but is not known to your directory service.',''.$username.'').'
'. &mt('Consequently, the user was not created.'));