version 1.202, 2007/12/05 21:23:14
|
version 1.209, 2007/12/14 00:20:53
|
Line 76 my $authformfsys;
|
Line 76 my $authformfsys;
|
my $authformloc; |
my $authformloc; |
|
|
sub initialize_authen_forms { |
sub initialize_authen_forms { |
my ($dom,$curr_authtype) = @_; |
my ($dom,$curr_authtype,$mode) = @_; |
my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); |
my ($krbdefdom)=( $ENV{'SERVER_NAME'}=~/(\w+\.\w+)$/); |
$krbdefdom= uc($krbdefdom); |
$krbdefdom= uc($krbdefdom); |
my %param = ( formname => 'document.cu', |
my %param = ( formname => 'document.cu', |
Line 91 sub initialize_authen_forms {
|
Line 91 sub initialize_authen_forms {
|
if ($long_auth =~ /^krb(4|5)$/) { |
if ($long_auth =~ /^krb(4|5)$/) { |
$param{'curr_kerb_ver'} = $1; |
$param{'curr_kerb_ver'} = $1; |
} |
} |
|
if ($mode eq 'modifyuser') { |
|
$param{'mode'} = $mode; |
|
} |
} |
} |
# no longer static due to configurable kerberos defaults |
# no longer static due to configurable kerberos defaults |
# $loginscript = &Apache::loncommon::authform_header(%param); |
# $loginscript = &Apache::loncommon::authform_header(%param); |
Line 112 sub auth_abbrev {
|
Line 115 sub auth_abbrev {
|
return %abv_auth; |
return %abv_auth; |
} |
} |
|
|
# ==================================================== Figure out author access |
|
|
|
sub authorpriv { |
|
my ($auname,$audom)=@_; |
|
unless ((&Apache::lonnet::allowed('cca',$audom.'/'.$auname)) |
|
|| (&Apache::lonnet::allowed('caa',$audom.'/'.$auname))) { return ''; } |
|
return 1; |
|
} |
|
|
|
# ==================================================== |
# ==================================================== |
|
|
sub portfolio_quota { |
sub portfolio_quota { |
Line 206 END_SCRIPT
|
Line 200 END_SCRIPT
|
# =================================================================== Phase one |
# =================================================================== Phase one |
|
|
sub print_username_entry_form { |
sub print_username_entry_form { |
my ($r,$response,$srch,$forcenewuser) = @_; |
my ($r,$context,$response,$srch,$forcenewuser) = @_; |
my $defdom=$env{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
my $formtoset = 'crtuser'; |
my $formtoset = 'crtuser'; |
if (exists($env{'form.startrolename'})) { |
if (exists($env{'form.startrolename'})) { |
$formtoset = 'docustom'; |
$formtoset = 'docustom'; |
$env{'form.rolename'} = $env{'form.startrolename'}; |
$env{'form.rolename'} = $env{'form.startrolename'}; |
|
} elsif ($env{'form.origform'} eq 'crtusername') { |
|
$formtoset = $env{'form.origform'}; |
} |
} |
|
|
my ($jsback,$elements) = &crumb_utilities(); |
my ($jsback,$elements) = &crumb_utilities(); |
Line 249 sub print_username_entry_form {
|
Line 245 sub print_username_entry_form {
|
'ecrp' => "Edit Custom Role Privileges", |
'ecrp' => "Edit Custom Role Privileges", |
'nr' => "Name of Role", |
'nr' => "Name of Role", |
'cre' => "Custom Role Editor", |
'cre' => "Custom Role Editor", |
'mod' => "to add/modify roles", |
'mod' => "to edit user information or add/modify roles", |
); |
); |
my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface'); |
my $help = &Apache::loncommon::help_open_menu(undef,undef,282,'Instructor Interface'); |
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); |
my $helpsiur=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); |
Line 263 sub print_username_entry_form {
|
Line 259 sub print_username_entry_form {
|
$r->print(" |
$r->print(" |
<h3>$lt{'srch'} $sellink $lt{'mod'}$helpsiur</h3> |
<h3>$lt{'srch'} $sellink $lt{'mod'}$helpsiur</h3> |
$response"); |
$response"); |
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
$r->print(&entry_form($defdom,$srch,$forcenewuser,$context)); |
} elsif ($env{'form.action'} eq 'custom') { |
} elsif ($env{'form.action'} eq 'custom') { |
if (&Apache::lonnet::allowed('mcr','/')) { |
if (&Apache::lonnet::allowed('mcr','/')) { |
$r->print(<<ENDCUSTOM); |
$r->print(<<ENDCUSTOM); |
Line 281 ENDCUSTOM
|
Line 277 ENDCUSTOM
|
} |
} |
|
|
sub entry_form { |
sub entry_form { |
my ($dom,$srch,$forcenewuser) = @_; |
my ($dom,$srch,$forcenewuser,$context) = @_; |
|
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
|
my $cancreate = &Apache::lonuserutils::can_create_user($dom,$context); |
|
if (!$cancreate) { |
|
$forcenewuser = ''; |
|
} |
my $userpicker = |
my $userpicker = |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
'document.crtuser'); |
'document.crtuser'); |
my $srchbutton = &mt('Search'); |
my $srchbutton = &mt('Search'); |
my $output = <<"ENDDOCUMENT"; |
my $output = <<"ENDBLOCK"; |
<form action="/adm/createuser" method="post" name="crtuser"> |
<form action="/adm/createuser" method="post" name="crtuser"> |
<input type="hidden" name="action" value="$env{'form.action'}" /> |
<input type="hidden" name="action" value="$env{'form.action'}" /> |
<input type="hidden" name="phase" value="get_user_info" /> |
<input type="hidden" name="phase" value="get_user_info" /> |
$userpicker |
$userpicker |
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" /> |
<input name="userrole" type="button" value="$srchbutton" onclick="javascript:validateEntry(document.crtuser)" /> |
</form> |
</form> |
|
ENDBLOCK |
|
if ($cancreate) { |
|
my $defdom=$env{'request.role.domain'}; |
|
my $domform = &Apache::loncommon::select_dom_form($defdom,'srchdomain'); |
|
my $helpcrt=&Apache::loncommon::help_open_topic('Course_Change_Privileges'); |
|
my %lt=&Apache::lonlocal::texthash( |
|
'crnu' => 'Create a new user', |
|
'usr' => 'Username', |
|
'dom' => 'in domain', |
|
'cra' => 'Create user', |
|
); |
|
$output .= <<"ENDDOCUMENT"; |
|
<form action="/adm/createuser" method="post" name="crtusername"> |
|
<input type="hidden" name="action" value="$env{'form.action'}" /> |
|
<input type="hidden" name="phase" value="createnewuser" /> |
|
<input type="hidden" name="srchtype" value="exact" /> |
|
<input type="hidden" name="srchby" value="username" /> |
|
<input type="hidden" name="srchin" value="dom" /> |
|
<input type="hidden" name="forcenewuser" value="1" /> |
|
<input type="hidden" name="origform" value="crtusername" /> |
|
<h3>$lt{crnu}$helpcrt</h3> |
|
<table> |
|
<tr> |
|
<td>$lt{'usr'}:</td> |
|
<td><input type="text" size="15" name="srchterm" /></td> |
|
<td> $lt{'dom'}:</td><td>$domform</td> |
|
<td> <input name="userrole" type="submit" value="$lt{'cra'}" /></td> |
|
</tr> |
|
</table> |
|
</form> |
ENDDOCUMENT |
ENDDOCUMENT |
|
} |
return $output; |
return $output; |
} |
} |
|
|
Line 326 END
|
Line 358 END
|
|
|
# =================================================================== Phase two |
# =================================================================== Phase two |
sub print_user_selection_page { |
sub print_user_selection_page { |
my ($r,$response,$srch,$srch_results,$operation,$srcharray) = @_; |
my ($r,$response,$srch,$srch_results,$operation,$srcharray,$context) = @_; |
my @fields = ('username','domain','lastname','firstname','permanentemail'); |
my @fields = ('username','domain','lastname','firstname','permanentemail'); |
my $sortby = $env{'form.sortby'}; |
my $sortby = $env{'form.sortby'}; |
|
|
Line 371 ENDSCRIPT
|
Line 403 ENDSCRIPT
|
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print("<b>$lt{'usrch'}</b><br />"); |
$r->print("<b>$lt{'usrch'}</b><br />"); |
$r->print(&entry_form($srch->{'srchdomain'},$srch)); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print('<h3>'.$lt{'usel'}.'</h3>'); |
$r->print('<h3>'.$lt{'usel'}.'</h3>'); |
} else { |
} else { |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
Line 443 sub print_user_modification_page {
|
Line 475 sub print_user_modification_page {
|
my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_; |
my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_; |
if (($ccuname eq '') || ($ccdomain eq '')) { |
if (($ccuname eq '') || ($ccdomain eq '')) { |
my $usermsg = &mt('No username and/or domain provided.'); |
my $usermsg = &mt('No username and/or domain provided.'); |
&print_username_entry_form($r,$usermsg); |
&print_username_entry_form($r,$context,$usermsg); |
return; |
return; |
} |
} |
my %abv_auth = &auth_abbrev(); |
my %abv_auth = &auth_abbrev(); |
Line 471 sub print_user_modification_page {
|
Line 503 sub print_user_modification_page {
|
$domdesc,$curr_rules{$ccdomain}{'username'}, |
$domdesc,$curr_rules{$ccdomain}{'username'}, |
'username'); |
'username'); |
} |
} |
&print_username_entry_form($r,$userchkmsg); |
&print_username_entry_form($r,$context,$userchkmsg); |
return; |
return; |
} |
} |
} |
} |
Line 704 $loginscript
|
Line 736 $loginscript
|
<input type='hidden' name='makeuser' value='1' /> |
<input type='hidden' name='makeuser' value='1' /> |
<h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2> |
<h2>$lt{'cnu'} "$ccuname" $lt{'ind'} $ccdomain</h2> |
ENDTITLE |
ENDTITLE |
$r->print('<div class="LC_left_float">'. |
$r->print('<div class="LC_left_float">'); |
&personal_data_display($ccuname,$ccdomain,$newuser, |
my $personal_table = |
%inst_results)); |
&personal_data_display($ccuname,$ccdomain,$newuser, |
|
$context,%inst_results); |
|
$r->print($personal_table); |
my ($home_server_pick,$numlib) = |
my ($home_server_pick,$numlib) = |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
&Apache::loncommon::home_server_form_item($ccdomain,'hserver', |
'default','hide'); |
'default','hide'); |
Line 783 $crumbs
|
Line 817 $crumbs
|
$forminfo |
$forminfo |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
ENDCHANGEUSER |
ENDCHANGEUSER |
$r->print('<div class="LC_left_float">'. |
$r->print('<div class="LC_left_float">'); |
&personal_data_display($ccuname,$ccdomain,$newuser, |
my ($personal_table,$showforceid) = |
%inst_results)); |
&personal_data_display($ccuname,$ccdomain,$newuser, |
if ($context eq 'domain') { |
$context,%inst_results); |
$r->print(&Apache::lonuserutils::forceid_change()); |
$r->print($personal_table); |
|
if ($showforceid) { |
|
$r->print(&Apache::lonuserutils::forceid_change($context)); |
} |
} |
$r->print('</div>'); |
$r->print('</div>'); |
my $user_auth_text = |
my $user_auth_text = |
Line 925 ENDNOPORTPRIV
|
Line 961 ENDNOPORTPRIV
|
} |
} |
if (($role_code eq 'ca') || ($role_code eq 'aa')) { |
if (($role_code eq 'ca') || ($role_code eq 'aa')) { |
$area=~m{/($match_domain)/($match_username)}; |
$area=~m{/($match_domain)/($match_username)}; |
if (&authorpriv($2,$1)) { |
if (&Apache::lonuserutils::authorpriv($2,$1)) { |
$allowed=1; |
$allowed=1; |
} else { |
} else { |
$allowed=0; |
$allowed=0; |
Line 1018 ENDNOPORTPRIV
|
Line 1054 ENDNOPORTPRIV
|
# |
# |
# Co-Author |
# Co-Author |
# |
# |
if (&authorpriv($env{'user.name'},$env{'request.role.domain'}) && |
if (&Apache::lonuserutils::authorpriv($env{'user.name'}, |
|
$env{'request.role.domain'}) && |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
($env{'user.name'} ne $ccuname || $env{'user.domain'} ne $ccdomain)) { |
# No sense in assigning co-author role to yourself |
# No sense in assigning co-author role to yourself |
$addrolesdisplay = 1; |
$addrolesdisplay = 1; |
Line 1069 ENDNOPORTPRIV
|
Line 1106 ENDNOPORTPRIV
|
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table_row()."\n". |
&Apache::loncommon::end_data_table()); |
&Apache::loncommon::end_data_table()); |
} elsif ($env{'request.role'} =~ /^au\./) { |
} elsif ($env{'request.role'} =~ /^au\./) { |
if (!(&authorpriv($env{'user.name'},$env{'request.role.domain'}))) { |
if (!(&Apache::lonuserutils::authorpriv($env{'user.name'}, |
|
$env{'request.role.domain'}))) { |
$r->print('<span class="LC_error">'. |
$r->print('<span class="LC_error">'. |
&mt('You do not have privileges to assign co-author roles.'). |
&mt('You do not have privileges to assign co-author roles.'). |
'</span>'); |
'</span>'); |
Line 1197 $lt{'uuas'} ($currentauth). $lt{'adcs'}.
|
Line 1235 $lt{'uuas'} ($currentauth). $lt{'adcs'}.
|
ENDBADAUTH |
ENDBADAUTH |
} |
} |
} else { # Authentication type is valid |
} else { # Authentication type is valid |
&initialize_authen_forms($ccdomain,$currentauth); |
&initialize_authen_forms($ccdomain,$currentauth,'modifyuser'); |
my $authformnop_row; |
my ($authformcurrent,$can_modify,@authform_others) = |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$authformnop_row = &Apache::loncommon::start_data_table_row(); |
|
} |
|
my ($authformcurrent,$authform_other,$can_modify) = |
|
&modify_login_block($ccdomain,$currentauth); |
&modify_login_block($ccdomain,$currentauth); |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
# Current user has login modification privileges |
# Current user has login modification privileges |
Line 1217 ENDBADAUTH
|
Line 1251 ENDBADAUTH
|
'</script>'."\n". |
'</script>'."\n". |
'<h3>'.$lt{'ld'}.'</h3>'. |
'<h3>'.$lt{'ld'}.'</h3>'. |
&Apache::loncommon::start_data_table(). |
&Apache::loncommon::start_data_table(). |
$authformnop_row. |
&Apache::loncommon::start_data_table_row(). |
'<td>'.$authformnop; |
'<td>'.$authformnop; |
if ($can_modify) { |
if ($can_modify) { |
$outcome .= '</td>'."\n". |
$outcome .= '</td>'."\n". |
Line 1229 ENDBADAUTH
|
Line 1263 ENDBADAUTH
|
$outcome .= ' ('.$authformcurrent.')</td>'. |
$outcome .= ' ('.$authformcurrent.')</td>'. |
&Apache::loncommon::end_data_table_row()."\n"; |
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
if ($authform_other ne '') { |
foreach my $item (@authform_others) { |
$outcome .= $authform_other; |
$outcome .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$item.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
} |
} |
$outcome .= &Apache::loncommon::end_data_table_row(). |
$outcome .= &Apache::loncommon::end_data_table(); |
&Apache::loncommon::end_data_table(); |
|
} else { |
} else { |
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('mau',$env{'request.role.domain'})) { |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
Line 1256 sub modify_login_block {
|
Line 1291 sub modify_login_block {
|
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my ($authnum,%can_assign) = |
my ($authnum,%can_assign) = |
&Apache::loncommon::get_assignable_auth($dom); |
&Apache::loncommon::get_assignable_auth($dom); |
my ($authformcurrent,$authform_other,$show_override_msg); |
my ($authformcurrent,@authform_others,$show_override_msg); |
if ($currentauth=~/^krb(4|5):/) { |
if ($currentauth=~/^krb(4|5):/) { |
$authformcurrent=$authformkrb; |
$authformcurrent=$authformkrb; |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other = &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformint); |
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformloc); |
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1275 sub modify_login_block {
|
Line 1306 sub modify_login_block {
|
} elsif ($currentauth=~/^internal:/) { |
} elsif ($currentauth=~/^internal:/) { |
$authformcurrent=$authformint; |
$authformcurrent=$authformint; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformkrb); |
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformloc); |
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1290 sub modify_login_block {
|
Line 1317 sub modify_login_block {
|
} elsif ($currentauth=~/^unix:/) { |
} elsif ($currentauth=~/^unix:/) { |
$authformcurrent=$authformfsys; |
$authformcurrent=$authformfsys; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformkrb); |
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformint); |
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformloc); |
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if ($can_assign{'fsys'}) { |
if ($can_assign{'fsys'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
Line 1310 sub modify_login_block {
|
Line 1331 sub modify_login_block {
|
} elsif ($currentauth=~/^localauth:/) { |
} elsif ($currentauth=~/^localauth:/) { |
$authformcurrent=$authformloc; |
$authformcurrent=$authformloc; |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
$authform_other = &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformkrb); |
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
} |
if ($can_assign{'int'}) { |
if ($can_assign{'int'}) { |
$authform_other .= &Apache::loncommon::start_data_table_row(). |
push(@authform_others,$authformint); |
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
} |
if ($can_assign{'loc'}) { |
if ($can_assign{'loc'}) { |
$show_override_msg = 1; |
$show_override_msg = 1; |
} |
} |
} |
} |
if ($show_override_msg) { |
if ($show_override_msg) { |
$authformcurrent.= ' <span class="LC_cusr_emph">'. |
$authformcurrent = '<table><tr><td colspan="3">'.$authformcurrent. |
|
'</td></tr>'."\n". |
|
'<tr><td> </td>'. |
|
'<td><b>'.&mt('Currently in use').'</b></td>'. |
|
'<td align="right"><span class="LC_cusr_emph">'. |
&mt('will override current values'). |
&mt('will override current values'). |
'</span><br />'; |
'</span></td></tr></table>'; |
} |
} |
return ($authformcurrent,$authform_other,$show_override_msg); |
return ($authformcurrent,$show_override_msg,@authform_others); |
} |
} |
|
|
sub personal_data_display { |
sub personal_data_display { |
my ($ccuname,$ccdomain,$newuser,%inst_results) = @_; |
my ($ccuname,$ccdomain,$newuser,$context,%inst_results) = @_; |
my ($output,%userenv); |
my ($output,$showforceid,%userenv,%domconfig); |
if (!$newuser) { |
if (!$newuser) { |
# Get the users information |
# Get the users information |
%userenv = &Apache::lonnet::get('environment', |
%userenv = &Apache::lonnet::get('environment', |
['firstname','middlename','lastname','generation', |
['firstname','middlename','lastname','generation', |
'permanentemail','id'],$ccdomain,$ccuname); |
'permanentemail','id'],$ccdomain,$ccuname); |
|
%domconfig = |
|
&Apache::lonnet::get_dom('configuration',['usermodification'], |
|
$ccdomain); |
} |
} |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'pd' => "Personal Data", |
'pd' => "Personal Data", |
Line 1376 sub personal_data_display {
|
Line 1400 sub personal_data_display {
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
} |
} |
} else { |
} else { |
|
my $canmodify = 0; |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
|
$canmodify = 1; |
|
} else { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $key (keys(%{$domconfig{'usermodification'}{$context}})) { |
|
if (ref($domconfig{'usermodification'}{$context}{$key}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$key}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
$canmodify = 1; |
|
} |
|
} |
|
if ($canmodify) { |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />'; |
} else { |
} else { |
$output .= $userenv{$item}; |
$output .= $userenv{$item}; |
} |
} |
|
if ($item eq 'id') { |
|
$showforceid = $canmodify; |
|
} |
} |
} |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
$output .= &Apache::lonhtmlcommon::row_closure(1); |
} |
} |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
$output .= &Apache::lonhtmlcommon::end_pick_box(); |
return $output; |
if (wantarray) { |
|
return ($output,$showforceid); |
|
} else { |
|
return $output; |
|
} |
} |
} |
|
|
# ================================================================= Phase Three |
# ================================================================= Phase Three |
sub update_user_data { |
sub update_user_data { |
my ($r) = @_; |
my ($r,$context) = @_; |
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, |
my $uhome=&Apache::lonnet::homeserver($env{'form.ccuname'}, |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
# Error messages |
# Error messages |
Line 1588 sub update_user_data {
|
Line 1638 sub update_user_data {
|
if ($tmp =~ /^(con_lost|error)/i) { |
if ($tmp =~ /^(con_lost|error)/i) { |
%userenv = (); |
%userenv = (); |
} |
} |
# Check to see if we need to change user information |
my $no_forceid_alert; |
|
# Check to see if user information can be changed |
|
my %domconfig = |
|
&Apache::lonnet::get_dom('configuration',['usermodification'], |
|
$env{'form.ccdomain'}); |
|
my @roletypes = ('active','future'); |
|
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@roletypes,undef,$env{'request.role.domain'}); |
|
my @userroles; |
|
my ($cnum,$cdom,$auname,$audom); |
|
if ($context eq 'course') { |
|
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
if ($cnum eq '' || $cdom eq '') { |
|
my $cid = $env{'request.course.id'}; |
|
my %coursehash = |
|
&Apache::lonnet::coursedescription($cid,{'one_time' => 1}); |
|
$cdom = $coursehash{'domain'}; |
|
$cnum = $coursehash{'num'}; |
|
} |
|
} elsif ($context eq 'author') { |
|
$auname = $env{'user.name'}; |
|
$audom = $env{'user.domain'}; |
|
} |
|
foreach my $item (keys(%roles)) { |
|
my ($rolenum,$roledom,$role) = split(/:/,$item); |
|
if ($context eq 'course') { |
|
if ($cnum ne '' && $cdom ne '') { |
|
if ($rolenum eq $cnum && $roledom eq $cdom) { |
|
if (!grep(/^\Q$role\E$/,@userroles)) { |
|
push(@userroles,$role); |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'author') { |
|
if ($rolenum eq $auname && $roledom eq $audom) { |
|
if (!grep(/^\Q$role\E$/,@userroles)) { |
|
push(@userroles,$role); |
|
} |
|
} |
|
} |
|
} |
|
# Check for course or co-author roles being activated or re-enabled |
|
if ($context eq 'author' || $context eq 'course') { |
|
foreach my $key (keys(%env)) { |
|
if ($context eq 'author') { |
|
if ($key=~/^form\.act_\Q$audom\E_\Q$auname\E_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} elsif ($key =~/^form\.ren\:\Q$audom\E\/\Q$auname\E_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
if ($key=~/^form\.act_\Q$cdom\E_\Q$cnum\E_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} elsif ($key =~/^form\.ren\:\Q$cdom\E\/\Q$cnum\E(\/?\w*)_([^_]+)/) { |
|
if (!grep(/^\Q$1\E$/,@userroles)) { |
|
push(@userroles,$1); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
#Check to see if we can change personal data for the user |
|
my (@mod_disallowed,@longroles); |
|
foreach my $role (@userroles) { |
|
if ($role eq 'cr') { |
|
push(@longroles,'Custom'); |
|
} else { |
|
push(@longroles,&Apache::lonnet::plaintext($role)); |
|
} |
|
} |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { |
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') { |
|
my $canmodify = 0; |
|
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) { |
|
$canmodify = 1; |
|
} else { |
|
if ($context eq 'course' || $context eq 'author') { |
|
if (ref($domconfig{'usermodification'}) eq 'HASH') { |
|
if (ref($domconfig{'usermodification'}{$context}) eq 'HASH') { |
|
foreach my $role (@userroles) { |
|
if (ref($domconfig{'usermodification'}{$context}{$role}) eq 'HASH') { |
|
if ($domconfig{'usermodification'}{$context}{$role}{$item}) { |
|
$canmodify = 1; |
|
last; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'course') { |
|
if (grep(/^st$/,@userroles)) { |
|
$canmodify = 1; |
|
} |
|
} |
|
} |
# Strip leading and trailing whitespace |
# Strip leading and trailing whitespace |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
$env{'form.c'.$item} =~ s/(\s+$|^\s+)//g; |
|
if (!$canmodify) { |
|
if (defined($env{'form.c'.$item})) { |
|
if ($env{'form.c'.$item} ne $userenv{$item}) { |
|
push(@mod_disallowed,$item); |
|
} |
|
} |
|
$env{'form.c'.$item} = $userenv{$item}; |
|
} |
} |
} |
# Check to see if we can change the ID/student number |
# Check to see if we can change the ID/student number |
my $forceid = $env{'form.forceid'}; |
my $forceid = $env{'form.forceid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $recurseid = $env{'form.recurseid'}; |
my $newuser = 0; |
my $newuser = 0; |
my $disallowed_id = 0; |
|
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules); |
if (!$forceid) { |
my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'}, |
$env{'form.cid'} = $userenv{'id'}; |
$env{'form.ccuname'}); |
} elsif ($env{'form.cid'} ne $userenv{'id'}) { |
if (($uidhash{$env{'form.ccuname'}}) && |
|
($uidhash{$env{'form.ccuname'}}!~/error\:/) && |
|
(!$forceid)) { |
|
if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) { |
|
$env{'form.cid'} = $userenv{'id'}; |
|
$no_forceid_alert = &mt('New student/employeeID does not match existing ID for this user.').'<br />'.&mt('Change is not permitted without checking the \'Force ID change\' checkbox on the previous page.').'<br />'."\n"; |
|
} |
|
} |
|
if ($env{'form.cid'} ne $userenv{'id'}) { |
my $checkhash; |
my $checkhash; |
my $checks = { 'id' => 1 }; |
my $checks = { 'id' => 1 }; |
$checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = |
$checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} = |
Line 1612 sub update_user_data {
|
Line 1775 sub update_user_data {
|
\%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules); |
\%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules); |
if (ref($alerts{'id'}) eq 'HASH') { |
if (ref($alerts{'id'}) eq 'HASH') { |
if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { |
if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') { |
$disallowed_id = 1; |
$env{'form.cid'} = $userenv{'id'}; |
} |
} |
} |
} |
} |
} |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
$inststatus,$isdefault,$defquotatext); |
$inststatus,$oldisdefault,$newisdefault,$olddefquotatext, |
|
$newdefquotatext); |
my ($defquota,$settingstatus) = |
my ($defquota,$settingstatus) = |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus); |
my %changeHash; |
my %changeHash; |
|
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'}; |
if ($userenv{'portfolioquota'} ne '') { |
if ($userenv{'portfolioquota'} ne '') { |
$oldportfolioquota = $userenv{'portfolioquota'}; |
$oldportfolioquota = $userenv{'portfolioquota'}; |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.customquota'} == 1) { |
Line 1630 sub update_user_data {
|
Line 1795 sub update_user_data {
|
$newportfolioquota = $env{'form.portfolioquota'}; |
$newportfolioquota = $env{'form.portfolioquota'}; |
$newportfolioquota =~ s/[^\d\.]//g; |
$newportfolioquota =~ s/[^\d\.]//g; |
} |
} |
if ($newportfolioquota != $userenv{'portfolioquota'}) { |
if ($newportfolioquota != $oldportfolioquota) { |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
} |
} |
} else { |
} else { |
$quotachanged = "a_admin('',\%changeHash); |
$quotachanged = "a_admin('',\%changeHash); |
$newportfolioquota = $defquota; |
$newportfolioquota = $defquota; |
$isdefault = 1; |
$newisdefault = 1; |
} |
} |
} else { |
} else { |
|
$oldisdefault = 1; |
$oldportfolioquota = $defquota; |
$oldportfolioquota = $defquota; |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.customquota'} == 1) { |
if ($env{'form.portfolioquota'} eq '') { |
if ($env{'form.portfolioquota'} eq '') { |
Line 1650 sub update_user_data {
|
Line 1816 sub update_user_data {
|
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
$quotachanged = "a_admin($newportfolioquota,\%changeHash); |
} else { |
} else { |
$newportfolioquota = $defquota; |
$newportfolioquota = $defquota; |
$isdefault = 1; |
$newisdefault = 1; |
} |
} |
} |
} |
if ($isdefault) { |
if ($oldisdefault) { |
if ($settingstatus eq '') { |
$olddefquotatext = &get_defaultquota_text($settingstatus); |
$defquotatext = &mt('(default)'); |
|
} else { |
|
my ($usertypes,$order) = |
|
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); |
|
if ($usertypes->{$settingstatus} eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
$defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); |
|
} |
|
} |
|
} |
} |
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}) && |
if ($newisdefault) { |
($env{'form.cfirstname'} ne $userenv{'firstname'} || |
$newdefquotatext = &get_defaultquota_text($settingstatus); |
$env{'form.cmiddlename'} ne $userenv{'middlename'} || |
} |
$env{'form.clastname'} ne $userenv{'lastname'} || |
if ($env{'form.cfirstname'} ne $userenv{'firstname'} || |
$env{'form.cgeneration'} ne $userenv{'generation'} || |
$env{'form.cmiddlename'} ne $userenv{'middlename'} || |
$env{'form.cid'} ne $userenv{'id'} || |
$env{'form.clastname'} ne $userenv{'lastname'} || |
$env{'form.cpermanentemail'} ne $userenv{'permanentemail'} )) { |
$env{'form.cgeneration'} ne $userenv{'generation'} || |
|
$env{'form.cid'} ne $userenv{'id'} || |
|
$env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) { |
$namechanged = 1; |
$namechanged = 1; |
} |
} |
if ($namechanged) { |
if ($namechanged || $quotachanged) { |
# Make the change |
|
$changeHash{'firstname'} = $env{'form.cfirstname'}; |
$changeHash{'firstname'} = $env{'form.cfirstname'}; |
$changeHash{'middlename'} = $env{'form.cmiddlename'}; |
$changeHash{'middlename'} = $env{'form.cmiddlename'}; |
$changeHash{'lastname'} = $env{'form.clastname'}; |
$changeHash{'lastname'} = $env{'form.clastname'}; |
$changeHash{'generation'} = $env{'form.cgeneration'}; |
$changeHash{'generation'} = $env{'form.cgeneration'}; |
$changeHash{'id'} = $env{'form.cid'}; |
$changeHash{'id'} = $env{'form.cid'}; |
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; |
$changeHash{'permanentemail'} = $env{'form.cpermanentemail'}; |
my $putresult = &Apache::lonnet::put |
my ($quotachgresult,$namechgresult); |
('environment',\%changeHash, |
if ($quotachanged) { |
$env{'form.ccdomain'},$env{'form.ccuname'}); |
$quotachgresult = |
if ($putresult eq 'ok') { |
&Apache::lonnet::put('environment',\%changeHash, |
|
$env{'form.ccdomain'},$env{'form.ccuname'}); |
|
} |
|
if ($namechanged) { |
|
# Make the change |
|
$namechgresult = |
|
&Apache::lonnet::modifyuser($env{'form.ccdomain'}, |
|
$env{'form.ccuname'},$changeHash{'id'},undef,undef, |
|
$changeHash{'firstname'},$changeHash{'middlename'}, |
|
$changeHash{'lastname'},$changeHash{'generation'}, |
|
$changeHash{'id'},undef,$changeHash{'permanentemail'}); |
|
} |
|
if (($namechanged && $namechgresult eq 'ok') || |
|
($quotachanged && $quotachgresult eq 'ok')) { |
# Tell the user we changed the name |
# Tell the user we changed the name |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'uic' => "User Information Changed", |
'uic' => "User Information Changed", |
Line 1723 END
|
Line 1893 END
|
<td>$userenv{'generation'} </td> |
<td>$userenv{'generation'} </td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'id'}</td> |
<td>$userenv{'permanentemail'} </td> |
<td>$userenv{'permanentemail'} </td> |
<td>$oldportfolioquota Mb</td> |
<td>$oldportfolioquota Mb $olddefquotatext </td> |
END |
END |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::start_data_table_row()); |
&Apache::loncommon::start_data_table_row()); |
Line 1735 END
|
Line 1905 END
|
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cgeneration'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cid'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$env{'form.cpermanentemail'} </td> |
<td>$newportfolioquota Mb $defquotatext </td> |
<td>$newportfolioquota Mb $newdefquotatext </td> |
END |
END |
$r->print(&Apache::loncommon::end_data_table_row(). |
$r->print(&Apache::loncommon::end_data_table_row(). |
&Apache::loncommon::end_data_table()); |
&Apache::loncommon::end_data_table().'<br />'); |
if (($forceid) && ($recurseid) && (!$disallowed_id) && |
if ($env{'form.cid'} ne $userenv{'id'}) { |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
&Apache::lonnet::idput($env{'form.ccdomain'}, |
my %userupdate = ( |
($env{'form.ccuname'} => $env{'form.cid'})); |
|
if (($recurseid) && |
|
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
|
my %userupdate = ( |
lastname => $env{'form.clasaname'}, |
lastname => $env{'form.clasaname'}, |
middlename => $env{'form.cmiddlename'}, |
middlename => $env{'form.cmiddlename'}, |
firstname => $env{'form.cfirstname'}, |
firstname => $env{'form.cfirstname'}, |
generation => $env{'fora.cgeneration'}, |
generation => $env{'fora.cgeneration'}, |
id => $env{'form.cid'}, |
id => $env{'form.cid'}, |
); |
); |
my $idresult = &propagate_id_change($env{'form.ccname'}, |
my $idresult = |
$env{'form.ccdomain'},\%userupdate); |
&Apache::lonuserutils::propagate_id_change( |
$r->print('<br />'.$idresult.'<br />'); |
$env{'form.ccuname'},$env{'form.ccdomain'}, |
|
\%userupdate); |
|
$r->print('<br />'.$idresult.'<br />'); |
|
} |
} |
} |
if (($env{'form.ccdomain'} eq $env{'user.domain'}) && |
if (($env{'form.ccdomain'} eq $env{'user.domain'}) && |
($env{'form.ccuname'} eq $env{'user.name'})) { |
($env{'form.ccuname'} eq $env{'user.name'})) { |
Line 1763 END
|
Line 1939 END
|
} else { # error occurred |
} else { # error occurred |
$r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '. |
$r->print('<span class="LC_error">'.&mt('Unable to successfully change environment for').' '. |
$env{'form.ccuname'}.' '.&mt('in domain').' '. |
$env{'form.ccuname'}.' '.&mt('in domain').' '. |
$env{'form.ccdomain'}.'</span>'); |
$env{'form.ccdomain'}.'</span><br />'); |
} |
} |
} else { # End of if ($env ... ) logic |
} else { # End of if ($env ... ) logic |
my $putresult; |
# They did not want to change the users name or quota but we can |
if ($quotachanged) { |
# still tell them what the name and quota are |
$putresult = &Apache::lonnet::put |
|
('environment',\%changeHash, |
|
$env{'form.ccdomain'},$env{'form.ccuname'}); |
|
} |
|
# They did not want to change the users name but we can |
|
# still tell them what the name is |
|
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'id' => "ID/Student number", |
'id' => "ID/Student number", |
'mail' => "Permanent e-mail", |
'mail' => "Permanent e-mail", |
Line 1782 END
|
Line 1952 END
|
$r->print(<<"END"); |
$r->print(<<"END"); |
<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'} |
<h4>$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'} |
END |
END |
if ($userenv{'permanentemail'} eq '') { |
if ($userenv{'permanentemail'} ne '') { |
$r->print('</h4>'); |
$r->print('<br />['.$lt{'mail'}.': '. |
|
$userenv{'permanentemail'}.']'); |
|
} |
|
$r->print('<br />['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '. |
|
$olddefquotatext.']</h4>'); |
|
} |
|
if (@mod_disallowed) { |
|
my ($rolestr,$contextname); |
|
if (@longroles > 0) { |
|
$rolestr = join(', ',@longroles); |
} else { |
} else { |
$r->print(' ('.$lt{'mail'}.': '. |
$rolestr = &mt('No roles'); |
$userenv{'permanentemail'}.')</h4>'); |
|
} |
} |
if ($putresult eq 'ok') { |
if ($context eq 'course') { |
if ($oldportfolioquota != $newportfolioquota) { |
$contextname = &mt('course'); |
$r->print('<h4>'.$lt{'disk'}.': '.$newportfolioquota.' Mb '. |
} elsif ($context eq 'author') { |
$defquotatext.'</h4>'); |
$contextname = &mt('co-author'); |
&Apache::lonnet::appenv('environment.portfolioquota' => $changeHash{'portfolioquota'}); |
} |
} |
$r->print(&mt('The following fields were not updated: ').'<ul>'); |
|
my %fieldtitles = &Apache::loncommon::personal_data_fieldtitles(); |
|
foreach my $field (@mod_disallowed) { |
|
$r->print('<li>'.$fieldtitles{$field}.'</li>'."\n"); |
|
} |
|
$r->print('</ul>'); |
|
if (@mod_disallowed == 1) { |
|
$r->print(&mt("You do not have the authority to change this field given the user's current set of active/future [_1] roles:",$contextname)); |
|
} else { |
|
$r->print(&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles:",$contextname)); |
} |
} |
|
$r->print('<span class="LC_cusr_emph">'.$rolestr.'</span><br />'. |
|
&mt('Contact your <a href="[_1]">helpdesk</a> for more information.',"javascript:helpMenu('display')").'<br />'); |
} |
} |
|
$r->print($no_forceid_alert. |
|
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
} |
} |
## |
## |
my $now=time; |
my $now=time; |
Line 2023 END
|
Line 2214 END
|
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
|
sub get_defaultquota_text { |
|
my ($settingstatus) = @_; |
|
my $defquotatext; |
|
if ($settingstatus eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
my ($usertypes,$order) = |
|
&Apache::lonnet::retrieve_inst_usertypes($env{'form.ccdomain'}); |
|
if ($usertypes->{$settingstatus} eq '') { |
|
$defquotatext = &mt('(default)'); |
|
} else { |
|
$defquotatext = &mt('(default for [_1])',$usertypes->{$settingstatus}); |
|
} |
|
} |
|
return $defquotatext; |
|
} |
|
|
sub update_result_form { |
sub update_result_form { |
my ($uhome) = @_; |
my ($uhome) = @_; |
my $outcome = |
my $outcome = |
Line 2030 sub update_result_form {
|
Line 2238 sub update_result_form {
|
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
foreach my $item ('srchby','srchin','srchtype','srchterm','srchdomain','ccuname','ccdomain') { |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
} |
} |
|
if ($env{'form.origname'} ne '') { |
|
$outcome .= '<input type="hidden" name="origname" value="'.$env{'form.origname'}.'" />'."\n"; |
|
} |
foreach my $item ('sortby','seluname','seludom') { |
foreach my $item ('sortby','seluname','seludom') { |
if (exists($env{'form.'.$item})) { |
if (exists($env{'form.'.$item})) { |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
$outcome .= '<input type="hidden" name="'.$item.'" value="'.$env{'form.'.$item}.'" />'."\n"; |
Line 2388 sub handler {
|
Line 2599 sub handler {
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
$context = 'course'; |
$context = 'course'; |
} elsif ($env{'request.role'} =~ /^au\./) { |
} elsif ($env{'request.role'} =~ /^au\./) { |
$context = 'construction_space'; |
$context = 'author'; |
} else { |
} else { |
$context = 'domain'; |
$context = 'domain'; |
} |
} |
Line 2400 sub handler {
|
Line 2611 sub handler {
|
({href=>"/adm/createuser", |
({href=>"/adm/createuser", |
text=>"User Management"}); |
text=>"User Management"}); |
} |
} |
my ($permission,$allowed) = &get_permission($context); |
my ($permission,$allowed) = |
|
&Apache::lonuserutils::get_permission($context); |
if (!$allowed) { |
if (!$allowed) { |
$env{'user.error.msg'}= |
$env{'user.error.msg'}= |
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
Line 2415 sub handler {
|
Line 2627 sub handler {
|
if (! exists($env{'form.action'})) { |
if (! exists($env{'form.action'})) { |
$r->print(&header()); |
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&print_main_menu($permission)); |
$r->print(&print_main_menu($permission,$context)); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) { |
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) { |
$r->print(&header()); |
$r->print(&header()); |
Line 2463 sub handler {
|
Line 2675 sub handler {
|
$srch->{$item} = $env{'form.'.$item}; |
$srch->{$item} = $env{'form.'.$item}; |
} |
} |
|
|
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
if (($phase eq 'get_user_info') || ($phase eq 'userpicked') || |
if ($env{'form.phase'} eq 'get_user_info') { |
($phase eq 'createnewuser')) { |
|
if ($env{'form.phase'} eq 'createnewuser') { |
|
my $response; |
|
if ($env{'form.srchterm'} !~ /^$match_username$/) { |
|
my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); |
|
&print_username_entry_form($r,$context,$response,$srch); |
|
} else { |
|
my $ccuname =&LONCAPA::clean_username($srch->{'srchterm'}); |
|
my $ccdomain=&LONCAPA::clean_domain($srch->{'srchdomain'}); |
|
&print_user_modification_page($r,$ccuname,$ccdomain, |
|
$srch,$response,$context); |
|
} |
|
} elsif ($env{'form.phase'} eq 'get_user_info') { |
my ($currstate,$response,$forcenewuser,$results) = |
my ($currstate,$response,$forcenewuser,$results) = |
&user_search_result($srch); |
&user_search_result($srch); |
if ($env{'form.currstate'} eq 'modify') { |
if ($env{'form.currstate'} eq 'modify') { |
Line 2472 sub handler {
|
Line 2696 sub handler {
|
} |
} |
if ($currstate eq 'select') { |
if ($currstate eq 'select') { |
&print_user_selection_page($r,$response,$srch,$results, |
&print_user_selection_page($r,$response,$srch,$results, |
'createuser',\@search); |
'createuser',\@search,$context); |
} elsif ($currstate eq 'modify') { |
} elsif ($currstate eq 'modify') { |
my ($ccuname,$ccdomain); |
my ($ccuname,$ccdomain); |
if (($srch->{'srchby'} eq 'uname') && |
if (($srch->{'srchby'} eq 'uname') && |
Line 2493 sub handler {
|
Line 2717 sub handler {
|
} elsif ($currstate eq 'query') { |
} elsif ($currstate eq 'query') { |
&print_user_query_page($r,'createuser'); |
&print_user_query_page($r,'createuser'); |
} else { |
} else { |
&print_username_entry_form($r,$response,$srch, |
&print_username_entry_form($r,$context,$response,$srch, |
$forcenewuser); |
$forcenewuser); |
} |
} |
} elsif ($env{'form.phase'} eq 'userpicked') { |
} elsif ($env{'form.phase'} eq 'userpicked') { |
Line 2503 sub handler {
|
Line 2727 sub handler {
|
$context); |
$context); |
} |
} |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
&update_user_data($r); |
&update_user_data($r,$context); |
} else { |
} else { |
&print_username_entry_form($r,undef,$srch); |
&print_username_entry_form($r,$context,undef,$srch); |
} |
} |
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
if ($env{'form.phase'} eq 'set_custom_roles') { |
if ($env{'form.phase'} eq 'set_custom_roles') { |
Line 2513 sub handler {
|
Line 2737 sub handler {
|
} else { |
} else { |
&custom_role_editor($r); |
&custom_role_editor($r); |
} |
} |
} elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) { |
} elsif (($env{'form.action'} eq 'listusers') && |
|
($permission->{'view'} || $permission->{'cusr'})) { |
if ($env{'form.phase'} eq 'bulkchange') { |
if ($env{'form.phase'} eq 'bulkchange') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'backPage(document.studentform)', |
({href=>'backPage(document.studentform)', |
Line 2582 sub handler {
|
Line 2807 sub handler {
|
} else { |
} else { |
$r->print(&header()); |
$r->print(&header()); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print(&print_main_menu($permission)); |
$r->print(&print_main_menu($permission,$context)); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
return OK; |
return OK; |
Line 2622 END
|
Line 2847 END
|
############################################################### |
############################################################### |
# Menu Phase One |
# Menu Phase One |
sub print_main_menu { |
sub print_main_menu { |
my ($permission) = @_; |
my ($permission,$context) = @_; |
|
my %links = ( |
|
domain => { |
|
upload => 'Upload a File of Users', |
|
singleuser => 'Add/Manage a Single User', |
|
listusers => 'Manage Multiple Users', |
|
}, |
|
author => { |
|
upload => 'Upload a File of Co-authors', |
|
singleuser => 'Add/Manage a Single Co-author', |
|
listusers => 'Display Co-authors and Manage Multiple Users', |
|
}, |
|
course => { |
|
upload => 'Upload a File of Course Users', |
|
singleuser => 'Add/Manage a Single Course User', |
|
listusers => 'Display Class Lists and Manage Multiple Users', |
|
}, |
|
); |
my @menu = |
my @menu = |
( |
( |
{ text => 'Upload a File of Users to Modify/Create Users and/or Add roles', |
{ text => $links{$context}{'upload'}, |
help => 'User_Management_Upload', |
help => 'User_Management_Upload', |
action => 'upload', |
action => 'upload', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
}, |
}, |
{ text => 'Create User/Set User Roles for a single user', |
{ text => $links{$context}{'singleuser'}, |
help => 'User_Management_Single_User', |
help => 'User_Management_Single_User', |
action => 'singleuser', |
action => 'singleuser', |
permission => $permission->{'cusr'}, |
permission => $permission->{'cusr'}, |
}, |
}, |
{ text => 'Display Lists of Users', |
{ text => $links{$context}{'listusers'}, |
help => 'User_Management_List', |
help => 'User_Management_List', |
action => 'listusers', |
action => 'listusers', |
permission => $permission->{'view'}, |
permission => ($permission->{'view'} || $permission->{'cusr'}), |
}, |
|
# { text => 'Expire User Roles', |
|
# help => 'User_Management_Drops', |
|
# action => 'expire', |
|
# permission => $permission->{'cusr'}, |
|
# }, |
|
{ text => 'Edit Custom Roles', |
|
help => 'Custom_Role_Edit', |
|
action => 'custom', |
|
permission => $permission->{'custom'}, |
|
}, |
}, |
); |
); |
|
if ($context eq 'domain' || $context eq 'course') { |
|
my $customlink = { text => 'Edit Custom Roles', |
|
help => 'Custom_Role_Edit', |
|
action => 'custom', |
|
permission => $permission->{'custom'}, |
|
}; |
|
push(@menu,$customlink); |
|
} |
|
if ($context eq 'course') { |
|
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
|
my @courselinks = |
|
( |
|
{ text => 'Automated Enrollment Manager', |
|
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
|
&& $permission->{'cusr'}), |
|
url => '/adm/populate', |
|
}, |
|
{ text => 'Manage Course Groups', |
|
help => 'Course_Manage_Group', |
|
permission => $permission->{'grp_manage'}, |
|
url => '/adm/coursegroups?refpage=cusr', |
|
}, |
|
); |
|
push(@menu,@courselinks); |
|
} |
my $menu_html = ''; |
my $menu_html = ''; |
foreach my $menu_item (@menu) { |
foreach my $menu_item (@menu) { |
next if (! $menu_item->{'permission'}); |
next if (! $menu_item->{'permission'}); |
Line 2672 sub print_main_menu {
|
Line 2930 sub print_main_menu {
|
return $menu_html; |
return $menu_html; |
} |
} |
|
|
sub get_permission { |
|
my ($context) = @_; |
|
my %permission; |
|
if ($context eq 'course') { |
|
if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cin',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cep',$env{'request.course.id'})) || |
|
(&Apache::lonnet::allowed('cst',$env{'request.course.id'}))) { |
|
$permission{'cusr'} = 1; |
|
$permission{'view'} = |
|
&Apache::lonnet::allowed('vcl',$env{'request.course.id'}); |
|
|
|
} |
|
if (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) { |
|
$permission{'custom'} = 1; |
|
} |
|
if (&Apache::lonnet::allowed('vcl',$env{'request.course.id'})) { |
|
$permission{'view'} = 1; |
|
if (!$permission{'view'}) { |
|
my $scope = $env{'request.course.id'}.'/'.$env{'request.course.sec'}; |
|
$permission{'view'} = &Apache::lonnet::allowed('vcl',$scope); |
|
if ($permission{'view'}) { |
|
$permission{'view_section'} = $env{'request.course.sec'}; |
|
} |
|
} |
|
} |
|
} elsif ($context eq 'construction_space') { |
|
$permission{'cusr'} = &authorpriv($env{'user.name'},$env{'request.role.domain'}); |
|
$permission{'view'} = $permission{'cusr'}; |
|
} else { |
|
if ((&Apache::lonnet::allowed('cad',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cli',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cau',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('csc',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('cdg',$env{'request.role.domain'})) || |
|
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
|
$permission{'cusr'} = 1; |
|
} |
|
if (&Apache::lonnet::allowed('ccr',$env{'request.role.domain'})) { |
|
$permission{'custom'} = 1; |
|
} |
|
$permission{'view'} = $permission{'cusr'}; |
|
} |
|
my $allowed = 0; |
|
foreach my $perm (values(%permission)) { |
|
if ($perm) { $allowed=1; last; } |
|
} |
|
return (\%permission,$allowed); |
|
} |
|
|
|
sub restore_prev_selections { |
sub restore_prev_selections { |
my %saveable_parameters = ('srchby' => 'scalar', |
my %saveable_parameters = ('srchby' => 'scalar', |
'srchin' => 'scalar', |
'srchin' => 'scalar', |
Line 3125 sub crumb_utilities {
|
Line 3332 sub crumb_utilities {
|
srchtype => 'selectbox', |
srchtype => 'selectbox', |
srchdomain => 'selectbox', |
srchdomain => 'selectbox', |
}, |
}, |
|
crtusername => { |
|
srchterm => 'text', |
|
srchdomain => 'selectbox', |
|
}, |
docustom => { |
docustom => { |
rolename => 'selectbox', |
rolename => 'selectbox', |
newrolename => 'textbox', |
newrolename => 'textbox', |