version 1.189, 2007/10/11 02:16:25
|
version 1.190, 2007/10/22 22:16:38
|
Line 65 use Apache::lonnet;
|
Line 65 use Apache::lonnet;
|
use Apache::loncommon; |
use Apache::loncommon; |
use Apache::lonlocal; |
use Apache::lonlocal; |
use Apache::longroup; |
use Apache::longroup; |
|
use Apache::lonuserutils; |
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
|
|
my $loginscript; # piece of javascript used in two separate instances |
my $loginscript; # piece of javascript used in two separate instances |
Line 111 sub auth_abbrev {
|
Line 112 sub auth_abbrev {
|
return %abv_auth; |
return %abv_auth; |
} |
} |
|
|
# ======================================================= Existing Custom Roles |
|
|
|
sub my_custom_roles { |
|
my %returnhash=(); |
|
my %rolehash=&Apache::lonnet::dump('roles'); |
|
foreach my $key (keys %rolehash) { |
|
if ($key=~/^rolesdef\_(\w+)$/) { |
|
$returnhash{$1}=$1; |
|
} |
|
} |
|
return %returnhash; |
|
} |
|
|
|
# ==================================================== Figure out author access |
# ==================================================== Figure out author access |
|
|
sub authorpriv { |
sub authorpriv { |
Line 237 sub print_username_entry_form {
|
Line 225 sub print_username_entry_form {
|
'onload' => "javascript:setFormElements(document.$formtoset)", |
'onload' => "javascript:setFormElements(document.$formtoset)", |
); |
); |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
&Apache::loncommon::start_page('User Management', |
$jscript,{'add_entries' => \%loaditems,}); |
$jscript,{'add_entries' => \%loaditems,}); |
&Apache::lonhtmlcommon::add_breadcrumb |
if ($env{'form.action'} eq 'singleuser') { |
({href=>"javascript:backPage(document.crtuser)", |
&Apache::lonhtmlcommon::add_breadcrumb |
text=>"User modify/custom role edit", |
({href=>"javascript:backPage(document.crtuser)", |
faq=>282,bug=>'Instructor Interface',}); |
text=>"Single user search", |
|
faq=>282,bug=>'Instructor Interface',}); |
|
} elsif ($env{'form.action'} eq 'custom') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.crtuser)", |
|
text=>"Pick custom role",}); |
|
} |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my %existingroles=&my_custom_roles(); |
my %existingroles=&Apache::lonuserutils::my_custom_roles(); |
my $choice=&Apache::loncommon::select_form('make new role','rolename', |
my $choice=&Apache::loncommon::select_form('make new role','rolename', |
('make new role' => 'Generate new role ...',%existingroles)); |
('make new role' => 'Generate new role ...',%existingroles)); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'srch' => "User Search", |
'srch' => "User Search", |
or => "or", |
or => "or", |
'siur' => "Set Individual User Roles", |
|
'usr' => "Username", |
'usr' => "Username", |
'dom' => "Domain", |
'dom' => "Domain", |
'ecrp' => "Edit Custom Role Privileges", |
'ecrp' => "Edit Custom Role Privileges", |
Line 266 sub print_username_entry_form {
|
Line 258 sub print_username_entry_form {
|
if ($sellink) { |
if ($sellink) { |
$sellink = "$lt{'or'} ".$sellink; |
$sellink = "$lt{'or'} ".$sellink; |
} |
} |
$r->print(" |
$r->print($start_page."\n".$crumbs); |
$start_page |
if ($env{'form.action'} eq 'singleuser') { |
$crumbs |
$r->print(" |
<h2>$lt{siur}$helpsiur</h2> |
<h3>$lt{'srch'} $sellink $lt{'mod'}$helpsiur</h3> |
<h3>$lt{'srch'} $sellink $lt{'mod'}</h3> |
|
$response"); |
$response"); |
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
if (&Apache::lonnet::allowed('mcr','/')) { |
} elsif ($env{'form.action'} eq 'custom') { |
$r->print(<<ENDCUSTOM); |
if (&Apache::lonnet::allowed('mcr','/')) { |
|
$r->print(<<ENDCUSTOM); |
<form action="/adm/createuser" method="post" name="docustom"> |
<form action="/adm/createuser" method="post" name="docustom"> |
|
<input type="hidden" name="action" value="$env{'form.action'}" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<input type="hidden" name="phase" value="selected_custom_edit" /> |
<h2>$lt{'ecrp'}$helpecpr</h2> |
<h3>$lt{'ecrp'}$helpecpr</h3> |
$lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br /> |
$lt{'nr'}: $choice <input type="text" size="15" name="newrolename" /><br /> |
<input name="customeditor" type="submit" value="$lt{'cre'}" /> |
<input name="customeditor" type="submit" value="$lt{'cre'}" /> |
</form> |
</form> |
ENDCUSTOM |
ENDCUSTOM |
|
} |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 294 sub entry_form {
|
Line 288 sub entry_form {
|
my $srchbutton = &mt('Search'); |
my $srchbutton = &mt('Search'); |
my $output = <<"ENDDOCUMENT"; |
my $output = <<"ENDDOCUMENT"; |
<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="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)" /> |
Line 331 END
|
Line 326 END
|
|
|
# =================================================================== Phase two |
# =================================================================== Phase two |
sub print_user_selection_page { |
sub print_user_selection_page { |
my ($r,$response,$srch,$srch_results,$context,$srcharray) = @_; |
my ($r,$response,$srch,$srch_results,$operation,$srcharray) = @_; |
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 365 ENDSCRIPT
|
Line 360 ENDSCRIPT
|
'firstname' => "first name", |
'firstname' => "first name", |
'permanentemail' => "permanent e-mail", |
'permanentemail' => "permanent e-mail", |
); |
); |
if ($context eq 'createuser') { |
if ($operation eq 'createuser') { |
$r->print(&Apache::loncommon::start_page('Create Users, Change User Privileges',$jscript)); |
$r->print(&Apache::loncommon::start_page('User Management',$jscript)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.usersrchform,'','')", |
({href=>"javascript:backPage(document.usersrchform,'','')", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
text=>"Select User", |
text=>"Select User", |
Line 425 ENDSCRIPT
|
Line 420 ENDSCRIPT
|
' <input type="hidden" name="seluname" value="" />'."\n". |
' <input type="hidden" name="seluname" value="" />'."\n". |
' <input type="hidden" name="seludom" value="" />'."\n". |
' <input type="hidden" name="seludom" value="" />'."\n". |
' <input type="hidden" name="currstate" value="select" />'."\n". |
' <input type="hidden" name="currstate" value="select" />'."\n". |
' <input type="hidden" name="phase" value="get_user_info" />'."\n"); |
' <input type="hidden" name="phase" value="get_user_info" />'."\n". |
|
' <input type="hidden" name="action" value="singleuser" />'."\n"); |
$r->print($response); |
$r->print($response); |
if ($context eq 'createuser') { |
if ($operation eq 'createuser') { |
$r->print('</form>'.&Apache::loncommon::end_page()); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} else { |
} else { |
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
Line 707 ENDSECCODE
|
Line 703 ENDSECCODE
|
my ($krbdef,$krbdefdom) = |
my ($krbdef,$krbdefdom) = |
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
$javascript_validations = |
$javascript_validations = |
&Apache::londropadd::javascript_validations('auth',$krbdefdom,undef, |
&Apache::lonuserutils::javascript_validations('auth',$krbdefdom,undef, |
undef,$ccdomain); |
undef,$ccdomain); |
} |
} |
$js .= "\n". |
$js .= "\n". |
'<script type="text/javascript">'."\n".$jsback."\n". |
'<script type="text/javascript">'."\n".$jsback."\n". |
$javascript_validations.'</script>'; |
$javascript_validations.'</script>'; |
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('Create Users, Change User Privileges', |
&Apache::loncommon::start_page('User Management', |
$js,{'add_entries' => \%loaditem,}); |
$js,{'add_entries' => \%loaditem,}); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.cu)", |
({href=>"javascript:backPage(document.cu)", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
|
|
if ($env{'form.phase'} eq 'userpicked') { |
if ($env{'form.phase'} eq 'userpicked') { |
Line 735 ENDSECCODE
|
Line 731 ENDSECCODE
|
|
|
my $forminfo =<<"ENDFORMINFO"; |
my $forminfo =<<"ENDFORMINFO"; |
<form action="/adm/createuser" method="post" name="cu"> |
<form action="/adm/createuser" method="post" name="cu"> |
<input type="hidden" name="phase" value="update_user_data" /> |
<input type="hidden" name="phase" value="update_user_data" /> |
<input type="hidden" name="ccuname" value="$ccuname" /> |
<input type="hidden" name="ccuname" value="$ccuname" /> |
<input type="hidden" name="ccdomain" value="$ccdomain" /> |
<input type="hidden" name="ccdomain" value="$ccdomain" /> |
<input type="hidden" name="pres_value" value="" /> |
<input type="hidden" name="pres_value" value="" /> |
Line 759 ENDFORMINFO
|
Line 755 ENDFORMINFO
|
'cnu' => 'Create New User', |
'cnu' => 'Create New User', |
'ind' => 'in domain', |
'ind' => 'in domain', |
'lg' => 'Login Data', |
'lg' => 'Login Data', |
|
'hs' => "Home Server", |
); |
); |
$r->print(<<ENDTITLE); |
$r->print(<<ENDTITLE); |
$start_page |
$start_page |
Line 793 $lt{'hs'}: $home_server_pick
|
Line 790 $lt{'hs'}: $home_server_pick
|
if (ref($rules->{$rulematch}) eq 'HASH') { |
if (ref($rules->{$rulematch}) eq 'HASH') { |
my $authtype = $rules->{$rulematch}{'authtype'}; |
my $authtype = $rules->{$rulematch}{'authtype'}; |
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
if ($authtype !~ /^(krb4|krb5|int|fsys|loc)$/) { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} else { |
} else { |
my $authparm = $rules->{$rulematch}{'authparm'}; |
my $authparm = $rules->{$rulematch}{'authparm'}; |
if ($authtype =~ /^krb(4|5)$/) { |
if ($authtype =~ /^krb(4|5)$/) { |
Line 819 KERB
|
Line 816 KERB
|
} |
} |
} |
} |
} else { |
} else { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} |
} |
} |
} |
if ($authmsg) { |
if ($authmsg) { |
Line 830 $varauth
|
Line 827 $varauth
|
ENDAUTH |
ENDAUTH |
} |
} |
} else { |
} else { |
$r->print(&set_login($ccdomain)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} |
} |
$r->print(<<ENDPORT); |
$r->print(<<ENDPORT); |
$portfolioform |
$portfolioform |
Line 1129 ENDNOPORTPRIV
|
Line 1126 ENDNOPORTPRIV
|
"javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
"javascript:pjump('."'date_end','End Date Assistant Co-Author',document.cu.end_$cudom\_$cuname\_aa.value,'end_$cudom\_$cuname\_aa','cu.pres','dateset'".')">'.$lt{'sed'}.'</a></td>'."\n". |
&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 (!(&authorpriv($env{'user.name'},$env{'request.role.domain'}))) { |
} elsif ($env{'request.role'} =~ /^au\./) { |
$r->print('<span class="LC_error">'. |
if (!(&authorpriv($env{'user.name'},$env{'request.role.domain'}))) { |
&mt('You do not have privileges to assign co-author roles.'). |
$r->print('<span class="LC_error">'. |
'</span>'); |
&mt('You do not have privileges to assign co-author roles.'). |
} elsif (($env{'user.name'} eq $ccuname) && |
'</span>'); |
|
} elsif (($env{'user.name'} eq $ccuname) && |
($env{'user.domain'} eq $ccdomain)) { |
($env{'user.domain'} eq $ccdomain)) { |
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); |
$r->print(&mt('Assigning yourself a co-author or assistant co-author role in your own author area in Construction Space is not permitted')); |
|
} |
} |
} |
# |
# |
# Domain level |
# Domain level |
Line 1236 sub user_authentication {
|
Line 1235 sub user_authentication {
|
); |
); |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
if (&Apache::lonnet::allowed('mau',$ccdomain)) { |
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms($ccdomain); |
my $choices = &set_login($ccdomain); |
my $choices = &Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc); |
$outcome = <<ENDBADAUTH; |
$outcome = <<ENDBADAUTH; |
<script type="text/javascript" language="Javascript"> |
<script type="text/javascript" language="Javascript"> |
$loginscript |
$loginscript |
Line 1307 ENDNOPRIV
|
Line 1306 ENDNOPRIV
|
return $outcome; |
return $outcome; |
} |
} |
|
|
sub set_login { |
|
my ($dom) = @_; |
|
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
|
my $response; |
|
my ($authnum,%can_assign) = |
|
&Apache::loncommon::get_assignable_auth($dom); |
|
if ($authnum) { |
|
$response = &Apache::loncommon::start_data_table(); |
|
if (($can_assign{'krb4'}) || ($can_assign{'krb5'})) { |
|
$response .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformkrb.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
if ($can_assign{'int'}) { |
|
$response .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformint.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n" |
|
} |
|
if ($can_assign{'loc'}) { |
|
$response .= &Apache::loncommon::start_data_table_row(). |
|
'<td>'.$authformloc.'</td>'. |
|
&Apache::loncommon::end_data_table_row()."\n"; |
|
} |
|
$response .= &Apache::loncommon::end_data_table(); |
|
} |
|
return $response; |
|
} |
|
|
|
sub modify_login_block { |
sub modify_login_block { |
my ($dom,$currentauth) = @_; |
my ($dom,$currentauth) = @_; |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
my %domconfig = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
Line 1432 sub personal_data_display {
|
Line 1403 sub personal_data_display {
|
'generation' => "Generation", |
'generation' => "Generation", |
'permanentemail' => "Permanent e-mail address", |
'permanentemail' => "Permanent e-mail address", |
'id' => "ID/Student Number", |
'id' => "ID/Student Number", |
'hs' => "Home Server", |
|
'lg' => "Login Data" |
'lg' => "Login Data" |
); |
); |
my @userinfo = ('firstname','middlename','lastname','generation', |
my @userinfo = ('firstname','middlename','lastname','generation', |
Line 1498 sub update_user_data {
|
Line 1468 sub update_user_data {
|
$r->print(&Apache::loncommon::start_page($title,$jscript)); |
$r->print(&Apache::loncommon::start_page($title,$jscript)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.userupdate)", |
({href=>"javascript:backPage(document.userupdate)", |
text=>"User modify/custom role edit", |
text=>"Create/modify user", |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
if ($env{'form.prevphase'} eq 'userpicked') { |
if ($env{'form.prevphase'} eq 'userpicked') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 1799 END
|
Line 1769 END
|
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
$r->print('<h3>'.&mt('Modifying Roles').'</h3>'); |
foreach my $key (keys (%env)) { |
foreach my $key (keys (%env)) { |
next if (! $env{$key}); |
next if (! $env{$key}); |
|
next if ($key eq 'form.action'); |
# Revoke roles |
# Revoke roles |
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
if ($key=~/^form\.rev\:([^\_]+)\_([^\_\.]+)$/) { |
Line 1990 END
|
Line 1961 END
|
} |
} |
} |
} |
} else { |
} else { |
$r->print('<p>'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></p><br />'); |
$r->print('<p><span class="LC_error">'.&mt('ERROR').': '.&mt('Unknown command').' <tt>'.$key.'</tt></span></p><br />'); |
} |
} |
foreach my $key (sort(keys(%disallowed))) { |
foreach my $key (sort(keys(%disallowed))) { |
if (($key eq 'none') || ($key eq 'all')) { |
if (($key eq 'none') || ($key eq 'all')) { |
Line 2024 sub update_result_form {
|
Line 1995 sub update_result_form {
|
} |
} |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
$outcome .= '<input type="hidden" name="phase" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
'<input type ="hidden" name="currstate" value="" />'."\n". |
|
'<input type ="hidden" name="action" value="singleuser" />'."\n". |
'</form>'; |
'</form>'; |
return $outcome; |
return $outcome; |
} |
} |
Line 2108 sub custom_role_editor {
|
Line 2080 sub custom_role_editor {
|
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
if (!$rolename) { |
if (!$rolename || $env{'form.phase'} eq 'pickrole') { |
&print_username_entry_form($r); |
&print_username_entry_form($r); |
return; |
return; |
} |
} |
Line 2177 sub custom_role_editor {
|
Line 2149 sub custom_role_editor {
|
$head_script .= "\n".$jsback."\n".'</script>'."\n"; |
$head_script .= "\n".$jsback."\n".'</script>'."\n"; |
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
$r->print(&Apache::loncommon::start_page('Custom Role Editor',$head_script)); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.form1,'','')", |
({href=>"javascript:backPage(document.form1,'pickrole','')", |
text=>"User modify/custom role edit", |
text=>"Pick custom role", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.form1,'','')", |
{href=>"javascript:backPage(document.form1,'','')", |
text=>"Edit custom role", |
text=>"Edit custom role", |
Line 2221 ENDCCF
|
Line 2193 ENDCCF
|
&Apache::loncommon::end_data_table_row()); |
&Apache::loncommon::end_data_table_row()); |
} |
} |
$r->print(&Apache::loncommon::end_data_table(). |
$r->print(&Apache::loncommon::end_data_table(). |
|
'<input type="hidden" name="action" value="'.$env{'form.action'}.'" />'. |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'<input type="hidden" name="startrolename" value="'.$env{'form.rolename'}. |
'" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n". |
'" />'."\n".'<input type="hidden" name="currstate" value="" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
'<input type="reset" value="'.&mt("Reset").'" />'."\n". |
Line 2302 sub make_button_code {
|
Line 2275 sub make_button_code {
|
# ---------------------------------------------------------- Call to definerole |
# ---------------------------------------------------------- Call to definerole |
sub set_custom_role { |
sub set_custom_role { |
my ($r) = @_; |
my ($r) = @_; |
|
|
my $rolename=$env{'form.rolename'}; |
my $rolename=$env{'form.rolename'}; |
|
|
$rolename=~s/[^A-Za-z0-9]//gs; |
$rolename=~s/[^A-Za-z0-9]//gs; |
|
|
if (!$rolename) { |
if (!$rolename) { |
&print_username_entry_form($r); |
&custom_role_editor($r); |
return; |
return; |
} |
} |
|
|
my ($jsback,$elements) = &crumb_utilities(); |
my ($jsback,$elements) = &crumb_utilities(); |
my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>'; |
my $jscript = '<script type="text/javascript">'.$jsback."\n".'</script>'; |
|
|
$r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript); |
$r->print(&Apache::loncommon::start_page('Save Custom Role'),$jscript); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.customresult,'','')", |
({href=>"javascript:backPage(document.customresult,'pickrole','')", |
text=>"User modify/custom role edit", |
text=>"Pick custom role", |
faq=>282,bug=>'Instructor Interface',}, |
faq=>282,bug=>'Instructor Interface',}, |
{href=>"javascript:backPage(document.customresult,'selected_custom_edit','')", |
{href=>"javascript:backPage(document.customresult,'selected_custom_edit','')", |
text=>"Edit custom role", |
text=>"Edit custom role", |
Line 2381 sub set_custom_role {
|
Line 2350 sub set_custom_role {
|
$env{'user.name'}, |
$env{'user.name'}, |
$rolename)); |
$rolename)); |
} |
} |
$r->print('<p><a href="/adm/createuser">Create another role, or Create/Modify a user.</a></p><form name="customresult" method="post">'); |
$r->print('<p><a href="javascript:backPage(document.customresult,'."'pickrole'".')">'.&mt('Create or edit another custom role').'</a></p><form name="customresult" method="post">'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
$r->print(&Apache::lonhtmlcommon::echo_form_input([]).'</form>'); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
Line 2389 sub set_custom_role {
|
Line 2358 sub set_custom_role {
|
# ================================================================ Main Handler |
# ================================================================ Main Handler |
sub handler { |
sub handler { |
my $r = shift; |
my $r = shift; |
|
|
if ($r->header_only) { |
if ($r->header_only) { |
&Apache::loncommon::content_type($r,'text/html'); |
&Apache::loncommon::content_type($r,'text/html'); |
$r->send_http_header; |
$r->send_http_header; |
return OK; |
return OK; |
} |
} |
|
my $context; |
|
if ($env{'request.course.id'}) { |
|
$context = 'course'; |
|
} elsif ($env{'request.role'} =~ /^au\./) { |
|
$context = 'construction_space'; |
|
} else { |
|
$context = 'domain'; |
|
} |
|
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, |
|
['action','state']); |
|
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"/adm/createuser", |
|
text=>"User Management"}); |
|
my ($permission,$allowed) = &get_permission($context); |
|
if (!$allowed) { |
|
$env{'user.error.msg'}= |
|
"/adm/createuser:cst:0:0:Cannot create/modify user data ". |
|
"or view user status."; |
|
return HTTP_NOT_ACCEPTABLE; |
|
} |
|
|
|
&Apache::loncommon::content_type($r,'text/html'); |
|
$r->send_http_header; |
|
|
|
# Main switch on form.action and form.state, as appropriate |
|
if (! exists($env{'form.action'})) { |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
|
$r->print(&print_main_menu($permission)); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'upload' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=upload&state=', |
|
text=>"Upload Users List"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Upload Users List', |
|
'User_Management_Upload')); |
|
$r->print('<form name="studentform" method="post" '. |
|
'enctype="multipart/form-data" '. |
|
' action="/adm/createuser">'."\n"); |
|
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); |
|
} elsif ($env{'form.state'} eq 'enrolling') { |
|
if ($env{'form.datatoken'}) { |
|
&Apache::lonuserutils::upfile_drop_add($r,$context); |
|
} |
|
} else { |
|
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
|
} |
|
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=expire', |
|
text=>"Expire User Roles"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Expire User Roles', |
|
'User_Management_Drops')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} elsif ($env{'form.state'} eq 'done') { |
|
&Apache::lonuserutils::expire_user_list($r); |
|
} else { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'singleuser' && $permission->{'cusr'}) { |
|
my $phase = $env{'form.phase'}; |
|
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
|
|
|
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
|
my $srch; |
|
foreach my $item (@search) { |
|
$srch->{$item} = $env{'form.'.$item}; |
|
} |
|
if ($env{'form.phase'} eq 'get_user_info') { |
|
my ($currstate,$response,$forcenewuser,$results) = |
|
&user_search_result($srch); |
|
if ($env{'form.currstate'} eq 'modify') { |
|
$currstate = $env{'form.currstate'}; |
|
} |
|
if ($currstate eq 'select') { |
|
&print_user_selection_page($r,$response,$srch,$results, |
|
'createuser',\@search); |
|
} elsif ($currstate eq 'modify') { |
|
my ($ccuname,$ccdomain); |
|
if (($srch->{'srchby'} eq 'uname') && |
|
($srch->{'srchtype'} eq 'exact')) { |
|
$ccuname = $srch->{'srchterm'}; |
|
$ccdomain= $srch->{'srchdomain'}; |
|
} else { |
|
my @matchedunames = keys(%{$results}); |
|
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
|
} |
|
$ccuname =&LONCAPA::clean_username($ccuname); |
|
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
|
if ($env{'form.forcenewuser'}) { |
|
$response = ''; |
|
} |
|
&print_user_modification_page($r,$ccuname,$ccdomain, |
|
$srch,$response); |
|
} elsif ($currstate eq 'query') { |
|
&print_user_query_page($r,'createuser'); |
|
} else { |
|
&print_username_entry_form($r,$response,$srch, |
|
$forcenewuser); |
|
} |
|
} elsif ($env{'form.phase'} eq 'userpicked') { |
|
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
|
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
|
&print_user_modification_page($r,$ccuname,$ccdomain,$srch); |
|
} |
|
} elsif ($env{'form.phase'} eq 'update_user_data') { |
|
&update_user_data($r); |
|
} else { |
|
&print_username_entry_form($r); |
|
} |
|
} elsif ($env{'form.action'} eq 'custom' && $permission->{'custom'}) { |
|
if ($env{'form.phase'} eq 'set_custom_roles') { |
|
&set_custom_role($r); |
|
} else { |
|
&custom_role_editor($r); |
|
} |
|
} elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=listusers', |
|
text=>"List Users' Roles"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users' Roles", |
|
'User_Management_List')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_html_classlist($r,undef,$permission); |
|
} elsif ($env{'form.state'} eq 'csv') { |
|
&Apache::lonuserutils::print_html_classlist($r,'csv',$permission); |
|
} elsif ($env{'form.state'} eq 'excel') { |
|
&Apache::lonuserutils::print_html_classlist($r,'excel',$permission); |
|
} else { |
|
&Apache::lonuserutils::print_html_classlist($r,undef,$permission); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
|
$r->print(&header()); |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>'/adm/createuser?action=drop', |
|
text=>"Expire Users"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Expire User Roles', |
|
'User_Management_Drops')); |
|
if (! exists($env{'form.state'})) { |
|
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
} elsif ($env{'form.state'} eq 'done') { |
|
&Apache::lonuserutiles::expire_user_list($r); |
|
} else { |
|
&print_expire_menu($r,$context); |
|
} |
|
$r->print(&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print(&header()); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); $r->print(&print_main_menu($permission)); |
|
$r->print(&Apache::loncommon::end_page()); |
|
} |
|
return OK; |
|
} |
|
|
|
sub header { |
|
my ($jscript,$loaditems) = @_; |
|
my $start_page; |
|
if (ref($loaditems) eq 'HASH') { |
|
$start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems,}); |
|
} else { |
|
$start_page=&Apache::loncommon::start_page('User Management',$jscript); |
|
} |
|
return $start_page; |
|
} |
|
|
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'})) || |
# Menu Phase One |
(&Apache::lonnet::allowed('cep',$env{'request.course.id'})) || |
sub print_main_menu { |
(&authorpriv($env{'user.name'},$env{'request.role.domain'})) || |
my ($permission) = @_; |
(&Apache::lonnet::allowed('mau',$env{'request.role.domain'}))) { |
my @menu = |
&Apache::loncommon::content_type($r,'text/html'); |
( |
$r->send_http_header; |
{ text => 'Upload a File of Users to Set Roles', |
&Apache::lonhtmlcommon::clear_breadcrumbs(); |
help => 'User_Management_Upload', |
|
action => 'upload', |
my $phase = $env{'form.phase'}; |
permission => $permission->{'cusr'}, |
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
}, |
|
{ text => 'Set User Roles for an Individual User', |
&Apache::loncreateuser::restore_prev_selections(); |
help => 'User_Management_Single_User', |
my $srch; |
action => 'singleuser', |
foreach my $item (@search) { |
permission => $permission->{'cusr'}, |
$srch->{$item} = $env{'form.'.$item}; |
}, |
} |
# { text => 'Display User Roles for Multiple Users', |
|
# help => 'User_Management_List', |
if (($phase eq 'get_user_info') || ($phase eq 'userpicked')) { |
# action => 'listusers', |
|
# permission => $permission->{'view'}, |
if ($env{'form.phase'} eq 'get_user_info') { |
# }, |
my ($currstate,$response,$forcenewuser,$results) = |
# { text => 'Expire User Roles ', |
&user_search_result($srch); |
# help => 'User_Management_Drops', |
if ($env{'form.currstate'} eq 'modify') { |
# action => 'expire', |
$currstate = $env{'form.currstate'}; |
# permission => $permission->{'cusr'}, |
} |
# }, |
if ($currstate eq 'select') { |
{ text => 'Edit Custom Roles', |
&print_user_selection_page($r,$response,$srch,$results,'createuser',\@search); |
help => 'Custom_Role_Edit', |
} elsif ($currstate eq 'modify') { |
action => 'custom', |
my ($ccuname,$ccdomain); |
permission => $permission->{'custom'}, |
if (($srch->{'srchby'} eq 'uname') && |
}, |
($srch->{'srchtype'} eq 'exact')) { |
); |
$ccuname = $srch->{'srchterm'}; |
my $menu_html = ''; |
$ccdomain= $srch->{'srchdomain'}; |
foreach my $menu_item (@menu) { |
} else { |
next if (! $menu_item->{'permission'}); |
my @matchedunames = keys(%{$results}); |
$menu_html.='<p>'; |
($ccuname,$ccdomain) = split(/:/,$matchedunames[0]); |
$menu_html.='<font size="+1">'; |
} |
if (exists($menu_item->{'url'})) { |
$ccuname =&LONCAPA::clean_username($ccuname); |
$menu_html.=qq{<a href="$menu_item->{'url'}">}; |
$ccdomain=&LONCAPA::clean_domain($ccdomain); |
} else { |
if ($env{'form.forcenewuser'}) { |
$menu_html.= |
$response = ''; |
qq{<a href="/adm/createuser?action=$menu_item->{'action'}">}; |
} |
} |
&print_user_modification_page($r,$ccuname,$ccdomain,$srch, |
$menu_html.= &mt($menu_item->{'text'}).'</a></font>'; |
$response); |
if (exists($menu_item->{'help'})) { |
} elsif ($currstate eq 'query') { |
$menu_html.= |
&print_user_query_page($r,'createuser'); |
&Apache::loncommon::help_open_topic($menu_item->{'help'}); |
} else { |
} |
&print_username_entry_form($r,$response,$srch,$forcenewuser); |
$menu_html.='</p>'; |
} |
} |
} elsif ($env{'form.phase'} eq 'userpicked') { |
return $menu_html; |
my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); |
} |
my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); |
|
&print_user_modification_page($r,$ccuname,$ccdomain,$srch); |
sub get_permission { |
} |
my ($context) = @_; |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
my %permission; |
&update_user_data($r); |
if ($context eq 'course') { |
} elsif ($env{'form.phase'} eq 'selected_custom_edit') { |
if ((&Apache::lonnet::allowed('cta',$env{'request.course.id'})) || |
&custom_role_editor($r); |
(&Apache::lonnet::allowed('cin',$env{'request.course.id'})) || |
} elsif ($env{'form.phase'} eq 'set_custom_roles') { |
(&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) || |
&set_custom_role($r); |
(&Apache::lonnet::allowed('cep',$env{'request.course.id'})) || |
} else { |
(&Apache::lonnet::allowed('cst',$env{'request.course.id'}))) { |
&print_username_entry_form($r,undef,$srch); |
$permission{'cusr'} = 1; |
} |
$permission{'view'} = |
} else { |
&Apache::lonnet::allowed('vcl',$env{'request.course.id'}); |
$env{'user.error.msg'}= |
|
"/adm/createuser:mau:0:0:Cannot modify user data"; |
} |
return HTTP_NOT_ACCEPTABLE; |
if (&Apache::lonnet::allowed('ccr',$env{'request.course.id'})) { |
} |
$permission{'custom'} = 1; |
return OK; |
} |
|
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 { |
Line 2898 sub course_level_table {
|
Line 3073 sub course_level_table {
|
my $table = ''; |
my $table = ''; |
# Custom Roles? |
# Custom Roles? |
|
|
my %customroles=&my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'exs' => "Existing sections", |
'exs' => "Existing sections", |
'new' => "Define new section", |
'new' => "Define new section", |
Line 3045 sub course_sections {
|
Line 3220 sub course_sections {
|
|
|
sub course_level_dc { |
sub course_level_dc { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my %customroles=&my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'. |
my $hiddenitems = '<input type="hidden" name="dcdomain" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom" value="'.$dcdom.'" />'. |
'<input type="hidden" name="origdom" value="'.$dcdom.'" />'. |
'<input type="hidden" name="dccourse" value="" />'; |
'<input type="hidden" name="dccourse" value="" />'; |