version 1.125, 2010/09/20 00:21:08
|
version 1.135, 2011/01/18 23:37:47
|
Line 47 sub modifystudent {
|
Line 47 sub modifystudent {
|
# this one. If $csec is defined, drop them from all other sections of |
# this one. If $csec is defined, drop them from all other sections of |
# this course and add them to section $csec |
# this course and add them to section $csec |
my ($cnum,$cdom) = &get_course_identity($courseid); |
my ($cnum,$cdom) = &get_course_identity($courseid); |
my %roles = &Apache::lonnet::dump('roles',$udom,$unam); |
my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); |
|
my %roles = &Apache::lonnet::dump('roles',$udom,$unam,'.',undef,$extra); |
my ($tmp) = keys(%roles); |
my ($tmp) = keys(%roles); |
# Bail out if we were unable to get the students roles |
# Bail out if we were unable to get the students roles |
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); |
return "$1" if ($tmp =~ /^(con_lost|error|no_such_host)/i); |
Line 533 END
|
Line 534 END
|
if (message!='') { |
if (message!='') { |
message+='\\n'; |
message+='\\n'; |
} |
} |
|
message+='$alert{'section'}'; |
} |
} |
if (foundemail==0) { |
if (foundemail==0) { |
if (message!='') { |
if (message!='') { |
Line 587 END
|
Line 589 END
|
############################################################### |
############################################################### |
sub upload_manager_javascript_forward_associate { |
sub upload_manager_javascript_forward_associate { |
my ($can_assign) = @_; |
my ($can_assign) = @_; |
my $auth_update; |
my ($auth_update,$numbuttons,$argreset); |
if (ref($can_assign) eq 'HASH') { |
if (ref($can_assign) eq 'HASH') { |
if (keys(%{$can_assign}) > 1) { |
if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) { |
|
$argreset .= " vf.krbarg.value='';\n"; |
|
$numbuttons ++ ; |
|
} |
|
if ($can_assign->{'int'}) { |
|
$argreset .= " vf.intarg.value='';\n"; |
|
$numbuttons ++; |
|
} |
|
if ($can_assign->{'loc'}) { |
|
$argreset .= " vf.locarg.value='';\n"; |
|
$numbuttons ++; |
|
} |
|
if (!$can_assign->{'int'}) { |
|
my $warning = &mt('You may not specify an initial password for each user, as this is only available when new users use LON-CAPA internal authentication.\n'). |
|
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
$auth_update = <<"END"; |
|
// Currently the initial password field is only supported for internal auth |
|
// (see bug 6368). |
|
if (nw==9) { |
|
eval('vf.f'+tf+'.selectedIndex=0;') |
|
alert('$warning'); |
|
} |
|
END |
|
} elsif ($numbuttons > 1) { |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// If we set the password, make the password form below correspond to |
// If we set the password, make the password form below correspond to |
// the new value. |
// the new value. |
if (nw==9) { |
if (nw==9) { |
changed_radio('int',document.studentform); |
changed_radio('int',document.studentform); |
set_auth_radio_buttons('int',document.studentform); |
set_auth_radio_buttons('int',document.studentform); |
|
$argreset |
|
} |
|
|
END |
END |
} |
} |
if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) { |
|
$auth_update .= " vf.krbarg.value='';\n"; |
|
} |
|
if ($can_assign->{'int'}) { |
|
$auth_update .= " vf.intarg.value='';\n"; |
|
} |
|
if ($can_assign->{'loc'}) { |
|
$auth_update .= " vf.locarg.value='';\n"; |
|
} |
|
$auth_update .= " |
|
}\n"; |
|
} |
} |
|
|
return(<<ENDPICK); |
return(<<ENDPICK); |
Line 706 ENDPICK
|
Line 723 ENDPICK
|
############################################################### |
############################################################### |
sub upload_manager_javascript_reverse_associate { |
sub upload_manager_javascript_reverse_associate { |
my ($can_assign) = @_; |
my ($can_assign) = @_; |
my $auth_update; |
my ($auth_update,$numbuttons,$argreset); |
if (ref($can_assign) eq 'HASH') { |
if (ref($can_assign) eq 'HASH') { |
if (keys(%{$can_assign}) > 1) { |
if ($can_assign->{'krb4'} || $can_assign->{'krb5'}) { |
|
$argreset .= " vf.krbarg.value='';\n"; |
|
$numbuttons ++ ; |
|
} |
|
if ($can_assign->{'int'}) { |
|
$argreset .= " vf.intarg.value='';\n"; |
|
$numbuttons ++; |
|
} |
|
if ($can_assign->{'loc'}) { |
|
$argreset .= " vf.locarg.value='';\n"; |
|
$numbuttons ++; |
|
} |
|
if (!$can_assign->{'int'}) { |
|
my $warning = &mt('You may not specify an initial password, as this is only available when new users use LON-CAPA internal authentication.\n'). |
|
&mt('Your current role does not have rights to create users with that authentication type.'); |
|
$auth_update = <<"END"; |
|
// Currently the initial password field is only supported for internal auth |
|
// (see bug 6368). |
|
if (tf==8 && nw!=0) { |
|
eval('vf.f'+tf+'.selectedIndex=0;') |
|
alert('$warning'); |
|
} |
|
END |
|
} elsif ($numbuttons > 1) { |
$auth_update = <<"END"; |
$auth_update = <<"END"; |
// initial password specified, pick internal authentication |
// initial password specified, pick internal authentication |
if (tf==8 && nw!=0) { |
if (tf==8 && nw!=0) { |
changed_radio('int',document.studentform); |
changed_radio('int',document.studentform); |
set_auth_radio_buttons('int',document.studentform); |
set_auth_radio_buttons('int',document.studentform); |
|
$argreset |
|
} |
|
|
END |
END |
} |
} |
if ($can_assign->{'krb'}) { |
|
$auth_update .= " vf.krbarg.value='';\n"; |
|
} |
|
if ($can_assign->{'int'}) { |
|
$auth_update .= " vf.intarg.value='';\n"; |
|
} |
|
if ($can_assign->{'loc'}) { |
|
$auth_update .= " vf.locarg.value='';\n"; |
|
} |
|
$auth_update .= " |
|
}\n"; |
|
} |
} |
|
|
return(<<ENDPICK); |
return(<<ENDPICK); |
function verify(vf,sec_caller) { |
function verify(vf,sec_caller) { |
var founduname=0; |
var founduname=0; |
Line 735 function verify(vf,sec_caller) {
|
Line 768 function verify(vf,sec_caller) {
|
var foundname=0; |
var foundname=0; |
var foundid=0; |
var foundid=0; |
var foundsec=0; |
var foundsec=0; |
|
var foundemail=0; |
var foundrole=0; |
var foundrole=0; |
var founddomain=0; |
var founddomain=0; |
var foundinststatus=0; |
var foundinststatus=0; |
Line 746 function verify(vf,sec_caller) {
|
Line 780 function verify(vf,sec_caller) {
|
if (i==6 && tw!=0) { foundid=1; } |
if (i==6 && tw!=0) { foundid=1; } |
if (i==7 && tw!=0) { foundsec=1; } |
if (i==7 && tw!=0) { foundsec=1; } |
if (i==8 && tw!=0) { foundpwd=1; } |
if (i==8 && tw!=0) { foundpwd=1; } |
if (i==9 && tw!=0) { foundrole=1; } |
if (i==9 && tw!=0) { foundemail=1; } |
if (i==10 && tw!=0) { founddomain=1; } |
if (i==10 && tw!=0) { foundrole=1; } |
if (i==13 && tw!=0) { foundinstatus=1; } |
if (i==11 && tw!=0) { founddomain=1; } |
|
if (i==12 && tw!=0) { foundinstatus=1; } |
} |
} |
verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundrole,founddomain,foundinststatus); |
verify_message(vf,founduname,foundpwd,foundname,foundid,foundsec,foundemail,foundrole,founddomain,foundinststatus); |
} |
} |
|
|
function flip(vf,tf) { |
function flip(vf,tf) { |
Line 3965 sub upfile_drop_add {
|
Line 4000 sub upfile_drop_add {
|
official => 'Institutional', |
official => 'Institutional', |
unofficial => 'Non-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 |
# Get new users list |
foreach my $line (@userdata) { |
foreach my $line (@userdata) { |
my @secs; |
my @secs; |
my %entries=&Apache::loncommon::record_sep($line); |
my %entries=&Apache::loncommon::record_sep($line); |
# Determine user name |
# Determine user name |
|
$entries{$fields{'username'}} =~ s/^\s+|\s+$//g; |
unless (($entries{$fields{'username'}} eq '') || |
unless (($entries{$fields{'username'}} eq '') || |
(!defined($entries{$fields{'username'}}))) { |
(!defined($entries{$fields{'username'}}))) { |
my ($fname, $mname, $lname,$gen) = ('','','',''); |
my ($fname, $mname, $lname,$gen) = ('','','',''); |
Line 3991 sub upfile_drop_add {
|
Line 4028 sub upfile_drop_add {
|
$gen=$entries{$fields{'gen'}}; |
$gen=$entries{$fields{'gen'}}; |
} |
} |
} |
} |
|
|
if ($entries{$fields{'username'}} |
if ($entries{$fields{'username'}} |
ne &LONCAPA::clean_username($entries{$fields{'username'}})) { |
ne &LONCAPA::clean_username($entries{$fields{'username'}})) { |
|
my $nowhitespace; |
|
if ($entries{$fields{'username'}} =~ /\s/) { |
|
$nowhitespace = ' - '.&mt('usernames may not contain spaces.'); |
|
} |
$r->print('<br />'. |
$r->print('<br />'. |
&mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]', |
&mt('[_1]: Unacceptable username for user [_2] [_3] [_4] [_5]', |
'<b>'.$entries{$fields{'username'}}.'</b>',$fname,$mname,$lname,$gen)); |
'<b>'.$entries{$fields{'username'}}.'</b>',$fname,$mname,$lname,$gen). |
|
$nowhitespace); |
next; |
next; |
} else { |
} else { |
|
$entries{$fields{'domain'}} =~ s/^\s+|\s+$//g; |
if ($entries{$fields{'domain'}} |
if ($entries{$fields{'domain'}} |
ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) { |
ne &LONCAPA::clean_domain($entries{$fields{'domain'}})) { |
$r->print('<br />'. '<b>'.$entries{$fields{'domain'}}. |
$r->print('<br />'. '<b>'.$entries{$fields{'domain'}}. |
Line 4056 sub upfile_drop_add {
|
Line 4100 sub upfile_drop_add {
|
# determine email address |
# determine email address |
my $email=''; |
my $email=''; |
if (defined($fields{'email'})) { |
if (defined($fields{'email'})) { |
|
$entries{$fields{'email'}} =~ s/^\s+|\s+$//g; |
if (defined($entries{$fields{'email'}})) { |
if (defined($entries{$fields{'email'}})) { |
$email=$entries{$fields{'email'}}; |
$email=$entries{$fields{'email'}}; |
unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } |
unless ($email=~/^[^\@]+\@[^\@]+$/) { $email=''; } |
Line 4102 sub upfile_drop_add {
|
Line 4147 sub upfile_drop_add {
|
$role = $defaultrole; |
$role = $defaultrole; |
} |
} |
# Clean up whitespace |
# Clean up whitespace |
foreach (\$id,\$fname,\$mname,\$lname,\$gen) { |
foreach (\$id,\$fname,\$mname,\$lname,\$gen,\$inststatus) { |
$$_ =~ s/(\s+$|^\s+)//g; |
$$_ =~ s/(\s+$|^\s+)//g; |
} |
} |
# check against rules |
# check against rules |
Line 4111 sub upfile_drop_add {
|
Line 4156 sub upfile_drop_add {
|
my (%rulematch,%inst_results,%idinst_results); |
my (%rulematch,%inst_results,%idinst_results); |
my $uhome=&Apache::lonnet::homeserver($username,$userdomain); |
my $uhome=&Apache::lonnet::homeserver($username,$userdomain); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
if ($userdomain ne $domain) { |
if ($userdomain ne $newuserdom) { |
$r->print('<br />'. |
if ($context eq 'course') { |
&mt('[_1]: The domain specified ([_2]) is different to that of the course.', |
$r->print('<br />'. |
'<b>'.$username.'</b>',$userdomain).'<br />'. |
&mt('[_1]: The domain specified ([_2]) is different to that of the course.', |
&mt('The user does not already exist, and you may not create a new user in a different domain.')); |
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} elsif ($context eq 'author') { |
|
$r->print(&mt('[_1]: The domain specified ([_2]) is different to that of the author.', |
|
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} else { |
|
$r->print(&mt('[_1]: The domain specified ([_2]) is different to that of your current role.', |
|
'<b>'.$username.'</b>',$userdomain).'<br />'); |
|
} |
|
$r->print(&mt('The user does not already exist, and you may not create a new user in a different domain.')); |
next; |
next; |
} |
} |
$checkid = 1; |
$checkid = 1; |
$newuser = 1; |
$newuser = 1; |
my $user = $username.':'.$domain; |
my $user = $username.':'.$newuserdom; |
my $checkhash; |
my $checkhash; |
my $checks = { 'username' => 1 }; |
my $checks = { 'username' => 1 }; |
$checkhash->{$username.':'.$domain} = { 'newuser' => 1, }; |
$checkhash->{$username.':'.$newuserdom} = { 'newuser' => 1, }; |
&Apache::loncommon::user_rule_check($checkhash,$checks, |
&Apache::loncommon::user_rule_check($checkhash,$checks, |
\%alerts,\%rulematch,\%inst_results,\%curr_rules, |
\%alerts,\%rulematch,\%inst_results,\%curr_rules, |
\%got_rules); |
\%got_rules); |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}) eq 'HASH') { |
if (ref($alerts{'username'}{$domain}) eq 'HASH') { |
if (ref($alerts{'username'}{$newuserdom}) eq 'HASH') { |
if ($alerts{'username'}{$domain}{$username}) { |
if ($alerts{'username'}{$newuserdom}{$username}) { |
$r->print('<br />'. |
$r->print('<br />'. |
&mt('[_1]: matches the username format at your institution, but is not known to your directory service.','<b>'.$username.'</b>').'<br />'. |
&mt('[_1]: matches the username format at your institution, but is not known to your directory service.','<b>'.$username.'</b>').'<br />'. |
&mt('Consequently, the user was not created.')); |
&mt('Consequently, the user was not created.')); |
Line 4146 sub upfile_drop_add {
|
Line 4199 sub upfile_drop_add {
|
unless ($cancreate{$usertype}) { |
unless ($cancreate{$usertype}) { |
my $showtype = $longtypes{$usertype}; |
my $showtype = $longtypes{$usertype}; |
$r->print('<br />'. |
$r->print('<br />'. |
&mt("[_1]: The user does not exist, and you are not permitted to create users of type: $showtype.",'<b>'.$username.'</b>')); |
&mt('[_1]: The user does not exist, and you are not permitted to create users of type: [_2].','<b>'.$username.'</b>',$showtype)); |
next; |
next; |
} |
} |
} else { |
} else { |
Line 4299 sub upfile_drop_add {
|
Line 4352 sub upfile_drop_add {
|
} |
} |
} # end of foreach (@userdata) |
} # end of foreach (@userdata) |
# 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); |
$r->print("</p>\n<p>\n".&mt('Processed [quant,_1,user].',$counts{'user'}). |
$r->print("</p>\n<p>\n".&mt('Processed [quant,_1,user].',$counts{'user'}). |
"</p>\n"); |
"</p>\n"); |
if ($counts{'role'} > 0) { |
if ($counts{'role'} > 0) { |
Line 4791 sub update_user_list {
|
Line 4844 sub update_user_list {
|
$r->print('<p>'.&mt('Re-enabling will re-activate data for the role.').'</p>'); |
$r->print('<p>'.&mt('Re-enabling will re-activate data for the role.').'</p>'); |
} |
} |
# Flush the course logs so reverse user roles immediately updated |
# Flush the course logs so reverse user roles immediately updated |
&Apache::lonnet::flushcourselogs(); |
$r->register_cleanup(\&Apache::lonnet::flushcourselogs); |
} |
} |
if ($env{'form.makedatesdefault'}) { |
if ($env{'form.makedatesdefault'}) { |
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { |
if ($choice eq 'chgdates' || $choice eq 'reenable' || $choice eq 'activate') { |
Line 5227 sub can_modify_userinfo {
|
Line 5280 sub can_modify_userinfo {
|
} |
} |
|
|
sub check_usertype { |
sub check_usertype { |
my ($dom,$uname,$rules) = @_; |
my ($dom,$uname,$rules,$curr_rules,$got_rules) = @_; |
my $usertype; |
my $usertype; |
if (ref($rules) eq 'HASH') { |
if ((ref($got_rules) eq 'HASH') && (ref($curr_rules) eq 'HASH')) { |
my @user_rules = keys(%{$rules}); |
if (!$got_rules->{$dom}) { |
if (@user_rules > 0) { |
my %domconfig = &Apache::lonnet::get_dom('configuration', |
my %rule_check = &Apache::lonnet::inst_rulecheck($dom,$uname,undef,'username',\@user_rules); |
['usercreation'],$dom); |
if (keys(%rule_check) > 0) { |
if (ref($domconfig{'usercreation'}) eq 'HASH') { |
$usertype = 'unofficial'; |
foreach my $item ('username','id') { |
foreach my $item (keys(%rule_check)) { |
if (ref($domconfig{'usercreation'}{$item.'_rule'}) eq 'ARRAY') { |
if ($rule_check{$item}) { |
$curr_rules->{$dom}{$item} = |
$usertype = 'official'; |
$domconfig{'usercreation'}{$item.'_rule'}; |
last; |
} |
|
} |
|
} |
|
$got_rules->{$dom} = 1; |
|
} |
|
if (ref($rules) eq 'HASH') { |
|
my @user_rules; |
|
if (ref($curr_rules->{$dom}{'username'}) eq 'ARRAY') { |
|
foreach my $rule (keys(%{$rules})) { |
|
if (grep(/^\Q$rule\E/,@{$curr_rules->{$dom}{'username'}})) { |
|
push(@user_rules,$rule); |
|
} |
|
} |
|
} |
|
if (@user_rules > 0) { |
|
my %rule_check = &Apache::lonnet::inst_rulecheck($dom,$uname,undef,'username',\@user_rules); |
|
if (keys(%rule_check) > 0) { |
|
$usertype = 'unofficial'; |
|
foreach my $item (keys(%rule_check)) { |
|
if ($rule_check{$item}) { |
|
$usertype = 'official'; |
|
last; |
|
} |
} |
} |
} |
} |
} |
} |