--- loncom/interface/loncreateuser.pm 2007/12/21 18:16:39 1.220 +++ loncom/interface/loncreateuser.pm 2007/12/21 21:02:10 1.222 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.220 2007/12/21 18:16:39 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.222 2007/12/21 21:02:10 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -2730,10 +2730,11 @@ sub handler { 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); + &Apache::lonuserutils::print_upload_manager_form($r,$context, + $permission); } elsif ($env{'form.state'} eq 'enrolling') { if ($env{'form.datatoken'}) { - &Apache::lonuserutils::upfile_drop_add($r,$context); + &Apache::lonuserutils::upfile_drop_add($r,$context,$permission); } } else { &Apache::lonuserutils::print_first_users_upload_form($r,$context); @@ -2755,16 +2756,18 @@ sub handler { my $response; if ($env{'form.srchterm'} !~ /^$match_username$/) { my $response = &mt('You must specify a valid username. Only the following are allowed: letters numbers - . @'); + $env{'form.phase'} = ''; &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); + $srch,$response,$context, + $permission); } } elsif ($env{'form.phase'} eq 'get_user_info') { my ($currstate,$response,$forcenewuser,$results) = - &user_search_result($srch); + &user_search_result($context,$srch); if ($env{'form.currstate'} eq 'modify') { $currstate = $env{'form.currstate'}; } @@ -2793,7 +2796,8 @@ sub handler { $response = ''; } &print_user_modification_page($r,$ccuname,$ccdomain, - $srch,$response,$context); + $srch,$response,$context, + $permission); } elsif ($currstate eq 'query') { &print_user_query_page($r,'createuser'); } else { @@ -2804,7 +2808,7 @@ sub handler { my $ccuname = &LONCAPA::clean_username($env{'form.seluname'}); my $ccdomain = &LONCAPA::clean_domain($env{'form.seludom'}); &print_user_modification_page($r,$ccuname,$ccdomain,$srch,'', - $context); + $context,$permission); } } elsif ($env{'form.phase'} eq 'update_user_data') { &update_user_data($r,$context); @@ -2821,15 +2825,22 @@ sub handler { ($permission->{'view'} || $permission->{'cusr'})) { if ($env{'form.phase'} eq 'bulkchange') { &Apache::lonhtmlcommon::add_breadcrumb - ({href=>'backPage(document.studentform)', - text=>"List Users"}); + ({href=>'/adm/createuser?action=listusers', + text=>"List Users"}, + {href=>"/adm/createuser", + text=>"Result"}); my $setting = $env{'form.roletype'}; my $choice = $env{'form.bulkaction'}; $r->print(&header()); - $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users", + $r->print(&Apache::lonhtmlcommon::breadcrumbs("Update Users", 'User_Management_List')); if ($permission->{'cusr'}) { &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice); + $r->print('
'.&mt('Display User Lists').'');
+ $r->print(&Apache::loncommon::end_page());
+ } else {
+ $r->print(&mt('You are not authorized to make bulk changes to user roles'));
+ $r->print(&Apache::loncommon::end_page());
}
} else {
&Apache::lonhtmlcommon::add_breadcrumb
@@ -2882,7 +2893,8 @@ sub handler {
} elsif ($env{'form.action'} eq 'dateselect') {
if ($permission->{'cusr'}) {
$r->print(&header(undef,undef,{'no_nav_bar' => 1}).
- &Apache::lonuserutils::date_section_selector($context).
+ &Apache::lonuserutils::date_section_selector($context,
+ $permission).
&Apache::loncommon::end_page());
} else {
$r->print(&header().
@@ -2936,17 +2948,17 @@ sub print_main_menu {
my %links = (
domain => {
upload => 'Upload a File of Users',
- singleuser => 'Add/Manage a Single User',
+ singleuser => 'Add/Modify a Single User',
listusers => 'Manage Multiple Users',
},
author => {
upload => 'Upload a File of Co-authors',
- singleuser => 'Add/Manage a Single Co-author',
+ singleuser => 'Add/Modify 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',
+ singleuser => 'Add/Modify a Single Course User',
listusers => 'Display Class Lists and Manage Multiple Users',
},
);
@@ -3040,7 +3052,7 @@ sub restore_prev_selections {
#-------------------------------------------------- functions for &phase_two
sub user_search_result {
- my ($srch) = @_;
+ my ($context,$srch) = @_;
my %allhomes;
my %inst_matches;
my %srch_results;
@@ -3109,14 +3121,14 @@ sub user_search_result {
my $uhome=&Apache::lonnet::homeserver($srch->{'srchterm'},$srch->{'srchdomain'});
if ($uhome eq 'no_host') {
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
} else {
$currstate = 'modify';
}
} else {
%srch_results = &Apache::lonnet::usersearch($srch);
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
}
} else {
my $courseusers = &get_courseusers();
@@ -3125,7 +3137,7 @@ sub user_search_result {
$currstate = 'modify';
} else {
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
}
} else {
foreach my $user (keys(%$courseusers)) {
@@ -3152,7 +3164,7 @@ sub user_search_result {
}
}
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
}
}
}
@@ -3162,7 +3174,7 @@ sub user_search_result {
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
if ($dirsrchres eq 'ok') {
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
} else {
my $showdom = &display_domain_info($srch->{'srchdomain'});
$response = ''.
@@ -3176,7 +3188,7 @@ sub user_search_result {
if ($srch->{'srchin'} eq 'dom') {
%srch_results = &Apache::lonnet::usersearch($srch);
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
} elsif ($srch->{'srchin'} eq 'crs') {
my $courseusers = &get_courseusers();
foreach my $user (keys(%$courseusers)) {
@@ -3228,14 +3240,14 @@ sub user_search_result {
}
}
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
} elsif ($srch->{'srchin'} eq 'alc') {
$currstate = 'query';
} elsif ($srch->{'srchin'} eq 'instd') {
($dirsrchres,%srch_results) = &Apache::lonnet::inst_directory_query($srch);
if ($dirsrchres eq 'ok') {
($currstate,$response,$forcenewuser) =
- &build_search_response($srch,%srch_results);
+ &build_search_response($context,$srch,%srch_results);
} else {
my $showdom = &display_domain_info($srch->{'srchdomain'}); $response = ''.
&mt('Institutional directory search is not available in domain: [_1]',$showdom).
@@ -3341,7 +3353,7 @@ sub get_courseusers {
}
sub build_search_response {
- my ($srch,%srch_results) = @_;
+ my ($context,$srch,%srch_results) = @_;
my ($currstate,$response,$forcenewuser);
my %names = (
'uname' => 'username',
@@ -3400,8 +3412,15 @@ sub build_search_response {
}
}
if (!($srch->{'srchby'} eq 'uname' && $srch->{'srchin'} eq 'dom' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchdomain'} eq $env{'request.role.domain'})) {
- my $showdom = &display_domain_info($env{'request.role.domain'});
+ my $cancreate =
+ &Apache::lonuserutils::can_create_user($env{'request.role.domain'},$context);
+ if ($cancreate) {
+ my $showdom = &display_domain_info($env{'request.role.domain'});
$response .= '
'.&mt("To add a new user (you can only create new users in your current role's domain - [_1]):",$env{'request.role.domain'}).'
';
+ } else {
+ my $helplink = ' href="javascript:helpMenu('."'display'".')"';
+ $response .= '
'.&mt("You are not authorized to create new users in your current role's domain - [_1].",$env{'request.role.domain'}).'
'.&mt('Contact the helpdesk if you need to create a new user.',$helplink).'
';
+ }
}
}
}
@@ -3503,83 +3522,24 @@ sub course_level_table {
}
my @roles = &Apache::lonuserutils::roles_by_context('course');
foreach my $role (@roles) {
+ my $plrole=&Apache::lonnet::plaintext($role);
if (&Apache::lonnet::allowed('c'.$role,$thiscourse)) {
- my $plrole=&Apache::lonnet::plaintext($role);
- $table .= &Apache::loncommon::start_data_table_row().
-'
'.$lt{'exs'}.' '. - $currsec.' | '.
- ''. - ' | '.$lt{'new'}.' '. - ''. - ' | '.
- '
'.
- $lt{'exs'}.' '.$currsec.' | '.
- ''. - ' | '.$lt{'new'}.' '. - ' | '.
- ''.
- '
'.$lt->{'exs'}.' '. + $currsec.' | '."\n".
+ ' '."\n". + ' | '.$lt->{'new'}.' '. + ''. + ' | '."\n".
+ '