version 1.131, 2010/11/14 20:29:34
|
version 1.137, 2012/04/25 21:05:30
|
Line 589 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 708 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 1391 sub curr_role_permissions {
|
Line 1422 sub curr_role_permissions {
|
sub my_custom_roles { |
sub my_custom_roles { |
my ($crstype) = @_; |
my ($crstype) = @_; |
my %returnhash=(); |
my %returnhash=(); |
my %rolehash=&Apache::lonnet::dump('roles'); |
my $extra = &Apache::lonnet::freeze_escape({'skipcheck' => 1}); |
|
my %rolehash=&Apache::lonnet::dump('roles',undef,undef,'.',undef,$extra); |
foreach my $key (keys(%rolehash)) { |
foreach my $key (keys(%rolehash)) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
if ($key=~/^rolesdef\_(\w+)$/) { |
if ($crstype eq 'Community') { |
if ($crstype eq 'Community') { |
Line 2698 END
|
Line 2730 END
|
$in{'clicker'} = $clickers; |
$in{'clicker'} = $clickers; |
my $role = $in{'role'}; |
my $role = $in{'role'}; |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
$in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
unless ($mode eq 'excel') { |
$in{'start'} = &mt('none'); |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
} else { |
$in{'start'} = &mt('none'); |
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
} else { |
} |
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
if (! defined($in{'end'}) || $in{'end'} == 0) { |
} |
$in{'end'} = &mt('none'); |
if (! defined($in{'end'}) || $in{'end'} == 0) { |
} else { |
$in{'end'} = &mt('none'); |
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
} else { |
|
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
|
} |
} |
} |
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
if ($mode eq 'view' || $mode eq 'html' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { |
$r->print(&Apache::loncommon::start_data_table_row()); |
$r->print(&Apache::loncommon::start_data_table_row()); |
Line 2808 END
|
Line 2842 END
|
} elsif ($mode eq 'csv') { |
} elsif ($mode eq 'csv') { |
next if (! defined($CSVfile)); |
next if (! defined($CSVfile)); |
# no need to bother with $linkto |
# no need to bother with $linkto |
if (! defined($in{'start'}) || $in{'start'} == 0) { |
|
$in{'start'} = &mt('none'); |
|
} else { |
|
$in{'start'} = &Apache::lonlocal::locallocaltime($in{'start'}); |
|
} |
|
if (! defined($in{'end'}) || $in{'end'} == 0) { |
|
$in{'end'} = &mt('none'); |
|
} else { |
|
$in{'end'} = &Apache::lonlocal::locallocaltime($in{'end'}); |
|
} |
|
my @line = (); |
my @line = (); |
foreach my $item (@cols) { |
foreach my $item (@cols) { |
push @line,&Apache::loncommon::csv_translate($in{$item}); |
push @line,&Apache::loncommon::csv_translate($in{$item}); |
Line 2827 END
|
Line 2851 END
|
my $col = 0; |
my $col = 0; |
foreach my $item (@cols) { |
foreach my $item (@cols) { |
if ($item eq 'start' || $item eq 'end') { |
if ($item eq 'start' || $item eq 'end') { |
if (defined($item) && $item != 0) { |
if ((defined($in{$item})) && ($in{$item} != 0)) { |
$excel_sheet->write($row,$col++, |
$excel_sheet->write($row,$col++, |
&Apache::lonstathelpers::calc_serial($in{item}), |
&Apache::lonstathelpers::calc_serial($in{$item}), |
$format->{'date'}); |
$format->{'date'}); |
} else { |
} else { |
$excel_sheet->write($row,$col++,'none'); |
$excel_sheet->write($row,$col++,'none'); |
Line 3969 sub upfile_drop_add {
|
Line 3993 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; |
Line 4124 sub upfile_drop_add {
|
Line 4149 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 4159 sub upfile_drop_add {
|
Line 4192 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 5240 sub can_modify_userinfo {
|
Line 5273 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; |
|
} |
} |
} |
} |
} |
} |
} |