version 1.206, 2007/12/11 02:27:24
|
version 1.216, 2007/12/21 15:22:01
|
Line 115 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 209 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 230 sub print_username_entry_form {
|
Line 223 sub print_username_entry_form {
|
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('User Management', |
&Apache::loncommon::start_page('User Management', |
$jscript,{'add_entries' => \%loaditems,}); |
$jscript,{'add_entries' => \%loaditems,}); |
if ($env{'form.action'} eq 'singleuser') { |
if ($env{'form.action'} eq 'custom') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.crtuser)", |
({href=>"javascript:backPage(document.crtuser)", |
text=>"Single user search", |
text=>"Pick custom role",}); |
faq=>282,bug=>'Instructor Interface',}); |
} else { |
} elsif ($env{'form.action'} eq 'custom') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.crtuser)", |
({href=>"javascript:backPage(document.crtuser)", |
text=>"Pick custom role",}); |
text=>"Single user search", |
|
faq=>282,bug=>'Instructor Interface',}); |
} |
} |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my %existingroles=&Apache::lonuserutils::my_custom_roles(); |
my %existingroles=&Apache::lonuserutils::my_custom_roles(); |
Line 252 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 modify user information or add/modify roles", |
|
'enrl' => "to enroll one student", |
); |
); |
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'); |
|
my $helpsist=&Apache::loncommon::help_open_topic('Course_Add_Student'); |
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles'); |
my $helpecpr=&Apache::loncommon::help_open_topic('Course_Editing_Custom_Roles'); |
my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain'); |
my $sellink=&Apache::loncommon::selectstudent_link('crtuser','srchterm','srchdomain'); |
if ($sellink) { |
if ($sellink) { |
$sellink = "$lt{'or'} ".$sellink; |
$sellink = "$lt{'or'} ".$sellink; |
} |
} |
$r->print($start_page."\n".$crumbs); |
$r->print($start_page."\n".$crumbs); |
if ($env{'form.action'} eq 'singleuser') { |
if ($env{'form.action'} eq 'custom') { |
$r->print(" |
|
<h3>$lt{'srch'} $sellink $lt{'mod'}$helpsiur</h3> |
|
$response"); |
|
$r->print(&entry_form($defdom,$srch,$forcenewuser)); |
|
} elsif ($env{'form.action'} eq 'custom') { |
|
if (&Apache::lonnet::allowed('mcr','/')) { |
if (&Apache::lonnet::allowed('mcr','/')) { |
$r->print(<<ENDCUSTOM); |
$r->print(<<ENDCUSTOM); |
<form action="/adm/createuser" method="post" name="docustom"> |
<form action="/adm/createuser" method="post" name="docustom"> |
Line 279 $lt{'nr'}: $choice <input type="text" si
|
Line 269 $lt{'nr'}: $choice <input type="text" si
|
</form> |
</form> |
ENDCUSTOM |
ENDCUSTOM |
} |
} |
|
} else { |
|
my $actiontext = $lt{'mod'}.$helpsiur; |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$actiontext = $lt{'enrl'}.$helpsist; |
|
} |
|
$r->print(" |
|
<h3>$lt{'srch'} $sellink $actiontext</h3>"); |
|
if ($env{'form.origform'} ne 'crtusername') { |
|
$r->print("\n".$response); |
|
} |
|
$r->print(&entry_form($defdom,$srch,$forcenewuser,$context,$response)); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
|
|
sub entry_form { |
sub entry_form { |
my ($dom,$srch,$forcenewuser) = @_; |
my ($dom,$srch,$forcenewuser,$context,$responsemsg) = @_; |
|
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom); |
|
my $usertype; |
|
if (ref($srch) eq 'HASH') { |
|
if (($srch->{'srchin'} eq 'dom') && |
|
($srch->{'srchby'} eq 'uname') && |
|
($srch->{'srchtype'} eq 'exact') && |
|
($srch->{'srchdomain'} ne '') && |
|
($srch->{'srchterm'} ne '')) { |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($srch->{'srchdomain'},'username'); |
|
$usertype = &Apache::lonuserutils::check_usertype($srch->{'srchdomain'},$srch->{'srchterm'},$rules); |
|
} |
|
} |
|
my $cancreate = |
|
&Apache::lonuserutils::can_create_user($dom,$context,$usertype); |
my $userpicker = |
my $userpicker = |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
&Apache::loncommon::user_picker($dom,$srch,$forcenewuser, |
'document.crtuser'); |
'document.crtuser',$cancreate,$usertype); |
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 && $env{'form.phase'} eq '') { |
|
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> |
|
$responsemsg |
|
<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 329 END
|
Line 377 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 363 ENDSCRIPT
|
Line 411 ENDSCRIPT
|
'firstname' => "first name", |
'firstname' => "first name", |
'permanentemail' => "permanent e-mail", |
'permanentemail' => "permanent e-mail", |
); |
); |
|
$r->print(&Apache::loncommon::start_page('User Management',$jscript)); |
if ($operation eq 'createuser') { |
if ($operation eq 'createuser') { |
$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=>"Create/modify user", |
text=>"Create/modify user", |
Line 374 ENDSCRIPT
|
Line 422 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 { |
} elsif ($operation eq 'enrollstudent') { |
|
&Apache::lonhtmlcommon::add_breadcrumb |
|
({href=>"javascript:backPage(document.usersrchform,'','')", |
|
text=>"Create/modify student", |
|
faq=>282,bug=>'Instructor Interface',}, |
|
{href=>"javascript:backPage(document.usersrchform,'get_user_info','select')", |
|
text=>"Select Student", |
|
faq=>282,bug=>'Instructor Interface',}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
$r->print($jscript."<b>$lt{'stusrch'}</b><br />"); |
$r->print(&Apache::londropadd::single_user_entry_form($srch->{'srchdomain'},$srch)); |
$r->print(&entry_form($srch->{'srchdomain'},$srch,undef,$context)); |
$r->print('</form><h3>'.$lt{'stusel'}.'</h3>'); |
$r->print('</form><h3>'.$lt{'stusel'}.'</h3>'); |
} |
} |
$r->print('<form name="usersrchform" method="post">'. |
$r->print('<form name="usersrchform" method="post">'. |
Line 424 ENDSCRIPT
|
Line 480 ENDSCRIPT
|
' <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"); |
' <input type="hidden" name="action" value="'.$env{'form.action'}.'" />'."\n"); |
$r->print($response); |
$r->print($response.'</form>'.&Apache::loncommon::end_page()); |
if ($operation eq 'createuser') { |
|
$r->print('</form>'.&Apache::loncommon::end_page()); |
|
} else { |
|
$r->print('<input type="hidden" name="action" value="enrollstudent" />'."\n". |
|
'<input type="hidden" name="state" value="gotusername" />'."\n"); |
|
} |
|
} |
} |
|
|
sub print_user_query_page { |
sub print_user_query_page { |
Line 443 sub print_user_query_page {
|
Line 493 sub print_user_query_page {
|
} |
} |
|
|
sub print_user_modification_page { |
sub print_user_modification_page { |
my ($r,$ccuname,$ccdomain,$srch,$response,$context) = @_; |
my ($r,$ccuname,$ccdomain,$srch,$response,$context,$permission) = @_; |
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); |
$env{'form.phase'} = ''; |
|
&print_username_entry_form($r,$context,$usermsg); |
return; |
return; |
} |
} |
|
my ($form,$formname); |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$form = 'document.enrollstudent'; |
|
$formname = 'enrollstudent'; |
|
} else { |
|
$form = 'document.cu'; |
|
$formname = 'cu'; |
|
} |
my %abv_auth = &auth_abbrev(); |
my %abv_auth = &auth_abbrev(); |
my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, |
my ($curr_authtype,%rulematch,%inst_results,$curr_kerb_ver,$newuser, |
%alerts,%curr_rules,%got_rules); |
%alerts,%curr_rules,%got_rules); |
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
my $uhome=&Apache::lonnet::homeserver($ccuname,$ccdomain); |
if ($uhome eq 'no_host') { |
if ($uhome eq 'no_host') { |
|
my $usertype; |
|
my ($rules,$ruleorder) = |
|
&Apache::lonnet::inst_userrules($ccdomain,'username'); |
|
$usertype = |
|
&Apache::lonuserutils::check_usertype($ccdomain,$ccuname,$rules); |
|
my $cancreate = |
|
&Apache::lonuserutils::can_create_user($ccdomain,$context, |
|
$usertype); |
|
if (!$cancreate) { |
|
my $helplink = ' href="javascript:helpMenu('."'display'".')"'; |
|
my %usertypetext = ( |
|
official => 'institutional', |
|
unofficial => 'non-institutional', |
|
); |
|
my $response; |
|
if ($env{'form.origform'} eq 'crtusername') { |
|
$response = '<span class="LC_warning">'.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain). |
|
'</span><br />'; |
|
} |
|
$response .= '<span class="LC_warning">'.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the <a[_1]>helpdesk</a> for assistance.',$helplink).'</span><br /><br />'; |
|
$env{'form.phase'} = ''; |
|
&print_username_entry_form($r,$context,$response); |
|
return; |
|
} |
$newuser = 1; |
$newuser = 1; |
my $checkhash; |
my $checkhash; |
my $checks = { 'username' => 1 }; |
my $checks = { 'username' => 1 }; |
Line 474 sub print_user_modification_page {
|
Line 557 sub print_user_modification_page {
|
$domdesc,$curr_rules{$ccdomain}{'username'}, |
$domdesc,$curr_rules{$ccdomain}{'username'}, |
'username'); |
'username'); |
} |
} |
&print_username_entry_form($r,$userchkmsg); |
$env{'form.phase'} = ''; |
|
&print_username_entry_form($r,$context,$userchkmsg); |
return; |
return; |
} |
} |
} |
} |
} |
} |
} else { |
} else { |
Line 491 sub print_user_modification_page {
|
Line 575 sub print_user_modification_page {
|
} |
} |
} |
} |
if ($response) { |
if ($response) { |
$response = '<br />'.$response |
$response = '<br />'.$response; |
} |
} |
my $defdom=$env{'request.role.domain'}; |
my $defdom=$env{'request.role.domain'}; |
|
|
Line 511 sub print_user_modification_page {
|
Line 595 sub print_user_modification_page {
|
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition(); |
my $dc_setcourse_code = ''; |
my $dc_setcourse_code = ''; |
my $nondc_setsection_code = ''; |
my $nondc_setsection_code = ''; |
|
|
my %loaditem; |
my %loaditem; |
|
|
my $groupslist; |
my $groupslist = &Apache::lonuserutils::get_groupslist(); |
my %curr_groups = &Apache::longroup::coursegroups(); |
|
if (%curr_groups) { |
|
$groupslist = join('","',sort(keys(%curr_groups))); |
|
$groupslist = '"'.$groupslist.'"'; |
|
} |
|
|
|
if ($env{'request.role'} =~ m-^dc\./($match_domain)/$-) { |
|
my $dcdom = $1; |
|
$loaditem{'onload'} = "document.cu.coursedesc.value='';"; |
|
my @rolevals = ('st','ta','ep','in','cc'); |
|
my (@crsroles,@grproles); |
|
for (my $i=0; $i<@rolevals; $i++) { |
|
$crsroles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Course'); |
|
$grproles[$i]=&Apache::lonnet::plaintext($rolevals[$i],'Group'); |
|
} |
|
my $rolevalslist = join('","',@rolevals); |
|
my $crsrolenameslist = join('","',@crsroles); |
|
my $grprolenameslist = join('","',@grproles); |
|
my $pickcrsfirst = '<--'.&mt('Pick course first'); |
|
my $pickgrpfirst = '<--'.&mt('Pick group first'); |
|
$dc_setcourse_code = <<"ENDSCRIPT"; |
|
function setCourse() { |
|
var course = document.cu.dccourse.value; |
|
if (course != "") { |
|
if (document.cu.dcdomain.value != document.cu.origdom.value) { |
|
alert("You must select a course in the current domain"); |
|
return; |
|
} |
|
var userrole = document.cu.role.options[document.cu.role.selectedIndex].value |
|
var section=""; |
|
var numsections = 0; |
|
var newsecs = new Array(); |
|
for (var i=0; i<document.cu.currsec.length; i++) { |
|
if (document.cu.currsec.options[i].selected == true ) { |
|
if (document.cu.currsec.options[i].value != "" && document.cu.currsec.options[i].value != null) { |
|
if (numsections == 0) { |
|
section = document.cu.currsec.options[i].value |
|
numsections = 1; |
|
} |
|
else { |
|
section = section + "," + document.cu.currsec.options[i].value |
|
numsections ++; |
|
} |
|
} |
|
} |
|
} |
|
if (document.cu.newsec.value != "" && document.cu.newsec.value != null) { |
|
if (numsections == 0) { |
|
section = document.cu.newsec.value |
|
} |
|
else { |
|
section = section + "," + document.cu.newsec.value |
|
} |
|
newsecs = document.cu.newsec.value.split(/,/g); |
|
numsections = numsections + newsecs.length; |
|
} |
|
if ((userrole == 'st') && (numsections > 1)) { |
|
alert("In each course, each user may only have one student role at a time. You had selected "+numsections+" sections.\\nPlease modify your selections so they include no more than one section.") |
|
return; |
|
} |
|
for (var j=0; j<newsecs.length; j++) { |
|
if ((newsecs[j] == 'all') || (newsecs[j] == 'none')) { |
|
alert("'"+newsecs[j]+"' may not be used as the name for a section, as it is a reserved word.\\nPlease choose a different section name."); |
|
return; |
|
} |
|
if (document.cu.groups.value != '') { |
|
var groups = document.cu.groups.value.split(/,/g); |
|
for (var k=0; k<groups.length; k++) { |
|
if (newsecs[j] == groups[k]) { |
|
alert("'"+newsecs[j]+"' may not be used as the name for a section, as it is the name of a course group.\\nSection names and group names must be distinct. Please choose a different section name."); |
|
return; |
|
} |
|
} |
|
} |
|
} |
|
if ((userrole == 'cc') && (numsections > 0)) { |
|
alert("Section designations do not apply to Course Coordinator roles.\\nA course coordinator role will be added with access to all sections."); |
|
section = ""; |
|
} |
|
var coursename = "_$dcdom"+"_"+course+"_"+userrole |
|
var numcourse = getIndex(document.cu.dccourse); |
|
if (numcourse == "-1") { |
|
alert("There was a problem with your course selection"); |
|
return |
|
} |
|
else { |
|
document.cu.elements[numcourse].name = "act"+coursename; |
|
var numnewsec = getIndex(document.cu.newsec); |
|
if (numnewsec != "-1") { |
|
document.cu.elements[numnewsec].name = "sec"+coursename; |
|
document.cu.elements[numnewsec].value = section; |
|
} |
|
var numstart = getIndex(document.cu.start); |
|
if (numstart != "-1") { |
|
document.cu.elements[numstart].name = "start"+coursename; |
|
} |
|
var numend = getIndex(document.cu.end); |
|
if (numend != "-1") { |
|
document.cu.elements[numend].name = "end"+coursename |
|
} |
|
} |
|
} |
|
document.cu.submit(); |
|
} |
|
|
|
function getIndex(caller) { |
my $js = &validation_javascript($context,$ccdomain,$pjump_def, |
for (var i=0;i<document.cu.elements.length;i++) { |
$groupslist,$newuser,$formname,\%loaditem); |
if (document.cu.elements[i] == caller) { |
|
return i; |
|
} |
|
} |
|
return -1; |
|
} |
|
ENDSCRIPT |
|
} else { |
|
$nondc_setsection_code = |
|
&Apache::lonuserutils::setsections_javascript('cu',$groupslist); |
|
} |
|
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
|
$nondc_setsection_code,$groupslist); |
|
|
|
my ($jsback,$elements) = &crumb_utilities(); |
|
my $javascript_validations; |
|
if ((&Apache::lonnet::allowed('mau',$ccdomain)) || ($uhome eq 'no_host')) { |
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
|
$javascript_validations = |
|
&Apache::lonuserutils::javascript_validations('auth',$krbdefdom,undef, |
|
undef,$ccdomain); |
|
} |
|
$js .= "\n". |
|
'<script type="text/javascript">'."\n".$jsback."\n". |
|
$javascript_validations.'</script>'; |
|
my $start_page = |
my $start_page = |
&Apache::loncommon::start_page('User Management', |
&Apache::loncommon::start_page('User Management', |
$js,{'add_entries' => \%loaditem,}); |
$js,{'add_entries' => \%loaditem,}); |
|
my %breadcrumb_text = &singleuser_breadcrumb(); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.cu)", |
({href=>"javascript:backPage($form)", |
text=>"Create/modify user", |
text=>$breadcrumb_text{'search'}, |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
|
|
if ($env{'form.phase'} eq 'userpicked') { |
if ($env{'form.phase'} eq 'userpicked') { |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.cu,'get_user_info','select')", |
({href=>"javascript:backPage($form,'get_user_info','select')", |
text=>"Select a user", |
text=>$breadcrumb_text{'userpicked'}, |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>"javascript:backPage(document.cu,'$env{'form.phase'}','modify')", |
({href=>"javascript:backPage($form,'$env{'form.phase'}','modify')", |
text=>"Set user role", |
text=>$breadcrumb_text{'modify'}, |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
my $crumbs = &Apache::lonhtmlcommon::breadcrumbs('User Management'); |
|
|
my $forminfo =<<"ENDFORMINFO"; |
my $forminfo =<<"ENDFORMINFO"; |
<form action="/adm/createuser" method="post" name="cu"> |
<form action="/adm/createuser" method="post" name="$formname"> |
<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" /> |
Line 683 ENDFORMINFO
|
Line 637 ENDFORMINFO
|
$inccourses{$1.'_'.$2}=1; |
$inccourses{$1.'_'.$2}=1; |
} |
} |
} |
} |
if ($uhome eq 'no_host') { |
if ($newuser) { |
my $portfolioform; |
my $portfolioform; |
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
if (&Apache::lonnet::allowed('mpq',$env{'request.role.domain'})) { |
# Current user has quota modification privileges |
# Current user has quota modification privileges |
Line 692 ENDFORMINFO
|
Line 646 ENDFORMINFO
|
&initialize_authen_forms($ccdomain); |
&initialize_authen_forms($ccdomain); |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cnu' => 'Create New User', |
'cnu' => 'Create New User', |
|
'ast' => 'as a student', |
'ind' => 'in domain', |
'ind' => 'in domain', |
'lg' => 'Login Data', |
'lg' => 'Login Data', |
'hs' => "Home Server", |
'hs' => "Home Server", |
Line 705 $forminfo
|
Line 660 $forminfo
|
$loginscript |
$loginscript |
</script> |
</script> |
<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 |
ENDTITLE |
ENDTITLE |
$r->print('<div class="LC_left_float">'); |
if ($env{'form.action'} eq 'singlestudent') { |
|
$r->print(' ('.$lt{'ast'}.')'); |
|
} |
|
$r->print('</h2>'."\n".'<div class="LC_left_float">'); |
my $personal_table = |
my $personal_table = |
&personal_data_display($ccuname,$ccdomain,$newuser, |
&personal_data_display($ccuname,$ccdomain,$newuser,$context, |
$context,%inst_results); |
$inst_results{$ccuname.':'.$ccdomain}); |
$r->print($personal_table); |
$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', |
Line 773 ENDAUTH
|
Line 731 ENDAUTH
|
} else { |
} else { |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
$r->print(&Apache::lonuserutils::set_login($ccdomain,$authformkrb,$authformint,$authformloc)); |
} |
} |
$r->print(<<ENDPORT); |
$r->print($portfolioform); |
$portfolioform |
if ($env{'form.action'} eq 'singlestudent') { |
</div><div class="LC_clear_float_footer"></div> |
$r->print(&date_sections_select($context,$newuser,$formname, |
ENDPORT |
$permission)); |
|
} |
|
$r->print('</div><div class="LC_clear_float_footer"></div>'); |
} else { # user already exists |
} else { # user already exists |
my %lt=&Apache::lonlocal::texthash( |
my %lt=&Apache::lonlocal::texthash( |
'cup' => "Modify existing user: ", |
'cup' => "Modify existing user: ", |
|
'ens' => "Enroll one student: ", |
'id' => "in domain", |
'id' => "in domain", |
); |
); |
$r->print(<<ENDCHANGEUSER); |
$r->print(<<ENDCHANGEUSER); |
$start_page |
$start_page |
$crumbs |
$crumbs |
$forminfo |
$forminfo |
<h2>$lt{'cup'} "$ccuname" $lt{'id'} "$ccdomain"</h2> |
<h2> |
ENDCHANGEUSER |
ENDCHANGEUSER |
$r->print('<div class="LC_left_float">'); |
if ($env{'form.action'} eq 'singlestudent') { |
|
$r->print($lt{'ens'}); |
|
} else { |
|
$r->print($lt{'cup'}); |
|
} |
|
$r->print(' "'.$ccuname.'" '.$lt{'id'}.' "'.$ccdomain.'"</h2>'. |
|
"\n".'<div class="LC_left_float">'); |
my ($personal_table,$showforceid) = |
my ($personal_table,$showforceid) = |
&personal_data_display($ccuname,$ccdomain,$newuser, |
&personal_data_display($ccuname,$ccdomain,$newuser,$context, |
$context,%inst_results); |
$inst_results{$ccuname.':'.$ccdomain}); |
$r->print($personal_table); |
$r->print($personal_table); |
if ($showforceid) { |
if ($showforceid) { |
$r->print(&Apache::lonuserutils::forceid_change($context)); |
$r->print(&Apache::lonuserutils::forceid_change($context)); |
Line 823 ENDNOPORTPRIV
|
Line 790 ENDNOPORTPRIV
|
if ($user_quota_text ne '') { |
if ($user_quota_text ne '') { |
$r->print($user_quota_text); |
$r->print($user_quota_text); |
} |
} |
$r->print('</div>'); |
if ($env{'form.action'} eq 'singlestudent') { |
|
$r->print(&date_sections_select($context,$newuser,$formname)); |
|
} |
} elsif ($user_quota_text ne '') { |
} elsif ($user_quota_text ne '') { |
$r->print('<div class="LC_left_float">'.$user_quota_text.'</div>'); |
$r->print('<div class="LC_left_float">'.$user_quota_text); |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$r->print(&date_sections_select($context,$newuser,$formname)); |
|
} |
|
} else { |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$r->print('<div class="LC_left_float">'. |
|
&date_sections_select($context,$newuser,$formname)); |
|
} |
} |
} |
$r->print('<div class="LC_clear_float_footer"></div>'); |
$r->print('</div><div class="LC_clear_float_footer"></div>'); |
my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); |
my %rolesdump=&Apache::lonnet::dump('roles',$ccdomain,$ccuname); |
# Build up table of user roles to allow revocation of a role. |
# Build up table of user roles to allow revocation of a role. |
my ($tmp) = keys(%rolesdump); |
my ($tmp) = keys(%rolesdump); |
Line 932 ENDNOPORTPRIV
|
Line 908 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 1025 ENDNOPORTPRIV
|
Line 1001 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 1076 ENDNOPORTPRIV
|
Line 1053 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 1155 ENDNOPORTPRIV
|
Line 1133 ENDNOPORTPRIV
|
$r->print("</form>".&Apache::loncommon::end_page()); |
$r->print("</form>".&Apache::loncommon::end_page()); |
} |
} |
|
|
|
sub singleuser_breadcrumb { |
|
my %breadcrumb_text; |
|
if ($env{'form.action'} eq 'singlestudent') { |
|
$breadcrumb_text{'search'} = 'Enroll a student'; |
|
$breadcrumb_text{'userpicked'} = 'Select a user', |
|
$breadcrumb_text{'modify'} = 'Set section/dates', |
|
} else { |
|
$breadcrumb_text{'search'} = 'Create/modify user'; |
|
$breadcrumb_text{'userpicked'} = 'Select a user', |
|
$breadcrumb_text{'modify'} = 'Set user role', |
|
} |
|
return %breadcrumb_text; |
|
} |
|
|
|
sub date_sections_select { |
|
my ($context,$newuser,$formname,$permission) = @_; |
|
my $cid = $env{'request.course.id'}; |
|
my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid); |
|
my $date_table = '<h3>'.&mt('Starting and Ending Dates').'</h3>'."\n". |
|
&Apache::lonuserutils::date_setting_table(undef,undef,$context, |
|
undef,$formname,$permission); |
|
my $rowtitle = 'Section'; |
|
my $secbox = '<h3>'.&mt('Section').'</h3>'."\n". |
|
&Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle, |
|
$permission); |
|
my $output = $date_table.$secbox; |
|
return $output; |
|
} |
|
|
|
sub validation_javascript { |
|
my ($context,$ccdomain,$pjump_def,$groupslist,$newuser,$formname, |
|
$loaditem) = @_; |
|
my $dc_setcourse_code = ''; |
|
my $nondc_setsection_code = ''; |
|
if ($context eq 'domain') { |
|
my $dcdom = $env{'request.role.domain'}; |
|
$loaditem->{'onload'} = "document.cu.coursedesc.value='';"; |
|
$dc_setcourse_code = &Apache::lonuserutils::dc_setcourse_js('cu','singleuser'); |
|
} else { |
|
$nondc_setsection_code = |
|
&Apache::lonuserutils::setsections_javascript($formname,$groupslist); |
|
} |
|
my $js = &user_modification_js($pjump_def,$dc_setcourse_code, |
|
$nondc_setsection_code,$groupslist); |
|
|
|
my ($jsback,$elements) = &crumb_utilities(); |
|
my $javascript_validations; |
|
if ((&Apache::lonnet::allowed('mau',$ccdomain)) || ($newuser)) { |
|
my ($krbdef,$krbdefdom) = |
|
&Apache::loncommon::get_kerberos_defaults($ccdomain); |
|
$javascript_validations = |
|
&Apache::lonuserutils::javascript_validations('createuser',$krbdefdom,undef, |
|
undef,$ccdomain); |
|
} |
|
$js .= "\n". |
|
'<script type="text/javascript">'."\n".$jsback."\n". |
|
$javascript_validations.'</script>'; |
|
return $js; |
|
} |
|
|
sub user_authentication { |
sub user_authentication { |
my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; |
my ($ccuname,$ccdomain,$krbdefdom,$abv_auth) = @_; |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
my $currentauth=&Apache::lonnet::queryauthenticate($ccuname,$ccdomain); |
Line 1322 sub modify_login_block {
|
Line 1360 sub modify_login_block {
|
} |
} |
|
|
sub personal_data_display { |
sub personal_data_display { |
my ($ccuname,$ccdomain,$newuser,$context,%inst_results) = @_; |
my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_; |
my ($output,$showforceid,%userenv,%domconfig); |
my ($output,$showforceid,%userenv,%domconfig); |
if (!$newuser) { |
if (!$newuser) { |
# Get the users information |
# Get the users information |
Line 1363 sub personal_data_display {
|
Line 1401 sub personal_data_display {
|
} |
} |
$output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"; |
$output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n"; |
if ($newuser) { |
if ($newuser) { |
if ($inst_results{$item} ne '') { |
if (ref($inst_results) eq 'HASH') { |
$output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results{$item}.'" />'.$inst_results{$item}; |
if ($inst_results->{$item} ne '') { |
|
$output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item}; |
|
} else { |
|
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
|
} |
} else { |
} else { |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
$output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />'; |
} |
} |
Line 1424 sub update_user_data {
|
Line 1466 sub update_user_data {
|
} else { |
} else { |
$title='Modify User Privileges'; |
$title='Modify User Privileges'; |
} |
} |
|
my $newuser = 0; |
my ($jsback,$elements) = &crumb_utilities(); |
my ($jsback,$elements) = &crumb_utilities(); |
my $jscript = '<script type="text/javascript">'."\n". |
my $jscript = '<script type="text/javascript">'."\n". |
$jsback."\n".'</script>'."\n"; |
$jsback."\n".'</script>'."\n"; |
|
my %breadcrumb_text = &singleuser_breadcrumb(); |
$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=>"Create/modify user", |
text=>$breadcrumb_text{'search'}, |
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 |
({href=>"javascript:backPage(document.userupdate,'get_user_info','select')", |
({href=>"javascript:backPage(document.userupdate,'get_user_info','select')", |
text=>"Select a user", |
text=>$breadcrumb_text{'userpicked'}, |
faq=>282,bug=>'Instructor Interface',}); |
faq=>282,bug=>'Instructor Interface',}); |
} |
} |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
Line 1597 sub update_user_data {
|
Line 1639 sub update_user_data {
|
} |
} |
} |
} |
## |
## |
|
my (@userroles,%userupdate,$cnum,$cdom,$namechanged); |
|
if ($context eq 'course') { |
|
($cnum,$cdom) = &Apache::lonuserutils::get_course_identity(); |
|
} |
if (! $env{'form.makeuser'} ) { |
if (! $env{'form.makeuser'} ) { |
# Check for need to change |
# Check for need to change |
my %userenv = &Apache::lonnet::get |
my %userenv = &Apache::lonnet::get |
Line 1612 sub update_user_data {
|
Line 1658 sub update_user_data {
|
my %domconfig = |
my %domconfig = |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
&Apache::lonnet::get_dom('configuration',['usermodification'], |
$env{'form.ccdomain'}); |
$env{'form.ccdomain'}); |
my @roletypes = ('active','future'); |
my @statuses = ('active','future'); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@roletypes,undef,$env{'request.role.domain'}); |
my %roles = &Apache::lonnet::get_my_roles($env{'form.ccuname'},$env{'form.ccdomain'},'userroles',\@statuses,undef,$env{'request.role.domain'}); |
my @userroles; |
my ($auname,$audom); |
my ($cnum,$cdom,$auname,$audom); |
|
if ($context eq 'course') { |
if ($context eq 'course') { |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
$cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
Line 1710 sub update_user_data {
|
Line 1755 sub update_user_data {
|
# 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 (!$canmodify) { |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
if (defined($env{'form.c'.$item})) { |
push(@mod_disallowed,$item); |
if ($env{'form.c'.$item} ne $userenv{$item}) { |
|
push(@mod_disallowed,$item); |
|
} |
} |
} |
$env{'form.c'.$item} = $userenv{$item}; |
$env{'form.c'.$item} = $userenv{$item}; |
} |
} |
Line 1746 sub update_user_data {
|
Line 1793 sub update_user_data {
|
} |
} |
} |
} |
} |
} |
my ($quotachanged,$namechanged,$oldportfolioquota,$newportfolioquota, |
my ($quotachanged,$oldportfolioquota,$newportfolioquota, |
$inststatus,$oldisdefault,$newisdefault,$olddefquotatext, |
$inststatus,$oldisdefault,$newisdefault,$olddefquotatext, |
$newdefquotatext); |
$newdefquotatext); |
my ($defquota,$settingstatus) = |
my ($defquota,$settingstatus) = |
Line 1881 END
|
Line 1928 END
|
($env{'form.ccuname'} => $env{'form.cid'})); |
($env{'form.ccuname'} => $env{'form.cid'})); |
if (($recurseid) && |
if (($recurseid) && |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
(&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) { |
my %userupdate = ( |
%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'}, |
Line 1943 END
|
Line 1990 END
|
foreach my $field (@mod_disallowed) { |
foreach my $field (@mod_disallowed) { |
$r->print('<li>'.$fieldtitles{$field}.'</li>'."\n"); |
$r->print('<li>'.$fieldtitles{$field}.'</li>'."\n"); |
} |
} |
$r->print('</ul>'.&mt("You do not have the authority to change these fields given the user's current set of active/future [_1] roles: <span class=\"LC_cusr_emph\">[_2]</span>.",$contextname,$rolestr).'<br />'.&mt('Contact your <a href="[_1]">helpdesk</a> for more information.',"javascript:helpMenu('display')").'<br />'); |
$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. |
$r->print($no_forceid_alert. |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
&Apache::lonuserutils::print_namespacing_alerts($env{'form.ccdomain'},\%alerts, \%curr_rules)); |
Line 2198 sub update_result_form {
|
Line 2252 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 2568 sub handler {
|
Line 2625 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 2583 sub handler {
|
Line 2641 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 2607 sub handler {
|
Line 2665 sub handler {
|
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
&Apache::lonuserutils::print_first_users_upload_form($r,$context); |
} |
} |
$r->print('</form>'.&Apache::loncommon::end_page()); |
$r->print('</form>'.&Apache::loncommon::end_page()); |
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
} elsif ((($env{'form.action'} eq 'singleuser') || ($env{'form.action'} |
$r->print(&header()); |
eq 'singlestudent')) && ($permission->{'cusr'})) { |
&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,$context); |
|
} 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 $phase = $env{'form.phase'}; |
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
my @search = ('srchterm','srchby','srchin','srchtype','srchdomain'); |
&Apache::loncreateuser::restore_prev_selections(); |
&Apache::loncreateuser::restore_prev_selections(); |
Line 2631 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') { |
$currstate = $env{'form.currstate'}; |
$currstate = $env{'form.currstate'}; |
} |
} |
if ($currstate eq 'select') { |
if ($currstate eq 'select') { |
|
my $operation; |
|
if ($env{'form.action'} eq 'singleuser') { |
|
$operation = 'createuser'; |
|
} elsif ($env{'form.action'} eq 'singlestudent') { |
|
$operation = 'enrollstudent'; |
|
} |
&print_user_selection_page($r,$response,$srch,$results, |
&print_user_selection_page($r,$response,$srch,$results, |
'createuser',\@search); |
$operation,\@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 2661 sub handler {
|
Line 2723 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 2673 sub handler {
|
Line 2735 sub handler {
|
} elsif ($env{'form.phase'} eq 'update_user_data') { |
} elsif ($env{'form.phase'} eq 'update_user_data') { |
&update_user_data($r,$context); |
&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 2681 sub handler {
|
Line 2743 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 2722 sub handler {
|
Line 2785 sub handler {
|
$formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
$formname,$totcodes,$codetitles,$idlist,$idlist_titles); |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} |
} |
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) { |
} elsif ($env{'form.action'} eq 'drop' && $permission->{'cusr'}) { |
$r->print(&header()); |
$r->print(&header()); |
&Apache::lonhtmlcommon::add_breadcrumb |
&Apache::lonhtmlcommon::add_breadcrumb |
({href=>'/adm/createuser?action=drop', |
({href=>'/adm/createuser?action=drop', |
text=>"Expire Users"}); |
text=>"Drop Students"}); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Expire User Roles', |
if (!exists($env{'form.state'})) { |
'User_Management_Drops')); |
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students', |
if (! exists($env{'form.state'})) { |
'Course_Drop_Student')); |
&Apache::lonuserutils::print_expire_menu($r,$context); |
|
|
&Apache::lonuserutils::print_drop_menu($r,$context,$permission); |
} elsif ($env{'form.state'} eq 'done') { |
} elsif ($env{'form.state'} eq 'done') { |
&Apache::lonuserutiles::expire_user_list($r,$context); |
&Apache::lonhtmlcommon::add_breadcrumb |
} else { |
({href=>'/adm/createuser?action=drop', |
&print_expire_menu($r,$context); |
text=>"Result"}); |
|
$r->print(&Apache::lonhtmlcommon::breadcrumbs('Drop Students', |
|
'Course_Drop_Student')); |
|
&Apache::lonuserutils::update_user_list($r,$context,undef, |
|
$env{'form.action'}); |
} |
} |
$r->print(&Apache::loncommon::end_page()); |
$r->print(&Apache::loncommon::end_page()); |
} elsif ($env{'form.action'} eq 'dateselect') { |
} elsif ($env{'form.action'} eq 'dateselect') { |
Line 2750 sub handler {
|
Line 2818 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 2790 END
|
Line 2858 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,$cdom) = &Apache::lonuserutils::get_course_identity(); |
|
my @courselinks = |
|
( |
|
{ text => 'Enroll a Single Student', |
|
help => 'Course_Single_Student', |
|
action => 'singlestudent', |
|
permission => $permission->{'cusr'}, |
|
}, |
|
{ text => 'Drop Students', |
|
help => 'Course_Drop_Student', |
|
action => 'drop', |
|
permission => $permission->{'cusr'}, |
|
}); |
|
if (!exists($permission->{'cusr_section'})) { |
|
push(@courselinks, |
|
{ text => 'Automated Student Enrollment Manager', |
|
permission => (&Apache::lonnet::auto_run($cnum,$cdom) |
|
&& $permission->{'cusr'}), |
|
url => '/adm/populate', |
|
}); |
|
} |
|
push(@courselinks, |
|
{ 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 2840 sub print_main_menu {
|
Line 2953 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 'author') { |
|
$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 3293 sub crumb_utilities {
|
Line 3355 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', |
Line 3308 sub crumb_utilities {
|
Line 3374 sub crumb_utilities {
|
|
|
my $jsback .= qq| |
my $jsback .= qq| |
function backPage(formname,prevphase,prevstate) { |
function backPage(formname,prevphase,prevstate) { |
formname.phase.value = prevphase; |
if (typeof prevphase == 'undefined') { |
formname.currstate.value = prevstate; |
formname.phase.value = ''; |
|
} |
|
else { |
|
formname.phase.value = prevphase; |
|
} |
|
if (typeof prevstate == 'undefined') { |
|
formname.currstate.value = ''; |
|
} |
|
else { |
|
formname.currstate.value = prevstate; |
|
} |
formname.submit(); |
formname.submit(); |
} |
} |
|; |
|; |
Line 3351 sub course_level_table {
|
Line 3427 sub course_level_table {
|
&Apache::loncommon::get_sections($domain,$cnum); |
&Apache::loncommon::get_sections($domain,$cnum); |
} |
} |
} |
} |
foreach my $role ('st','ta','ep','in','cc') { |
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
|
foreach my $role (@roles) { |
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) { |
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) { |
my $plrole=&Apache::lonnet::plaintext($role); |
my $plrole=&Apache::lonnet::plaintext($role); |
$table .= &Apache::loncommon::start_data_table_row(). |
$table .= &Apache::loncommon::start_data_table_row(). |
Line 3451 $table.
|
Line 3528 $table.
|
sub course_level_dc { |
sub course_level_dc { |
my ($dcdom) = @_; |
my ($dcdom) = @_; |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
my %customroles=&Apache::lonuserutils::my_custom_roles(); |
|
my @roles = &Apache::lonuserutils::roles_by_context('course'); |
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="" />'; |
Line 3475 sub course_level_dc {
|
Line 3553 sub course_level_dc {
|
my $otheritems = &Apache::loncommon::start_data_table_row()."\n". |
my $otheritems = &Apache::loncommon::start_data_table_row()."\n". |
'<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". |
'<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'cu','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". |
'<td><select name="role">'."\n"; |
'<td><select name="role">'."\n"; |
foreach my $role ('st','ta','ep','in','cc') { |
foreach my $role (@roles) { |
my $plrole=&Apache::lonnet::plaintext($role); |
my $plrole=&Apache::lonnet::plaintext($role); |
$otheritems .= ' <option value="'.$role.'">'.$plrole; |
$otheritems .= ' <option value="'.$role.'">'.$plrole; |
} |
} |