--- loncom/interface/loncreateuser.pm 2007/12/05 17:40:29 1.201
+++ loncom/interface/loncreateuser.pm 2007/12/06 04:03:35 1.203
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.201 2007/12/05 17:40:29 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.203 2007/12/06 04:03:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -627,7 +627,7 @@ sub print_user_modification_page {
}
ENDSCRIPT
} else {
- $nondc_setsection_code =
+ $nondc_setsection_code =
&Apache::lonuserutils::setsections_javascript('cu',$groupslist);
}
my $js = &user_modification_js($pjump_def,$dc_setcourse_code,
@@ -787,7 +787,7 @@ ENDCHANGEUSER
&personal_data_display($ccuname,$ccdomain,$newuser,
%inst_results));
if ($context eq 'domain') {
- $r->print(&Apache::lonuserutils::forceid_change());
+ $r->print(&Apache::lonuserutils::forceid_change($context));
}
$r->print('');
my $user_auth_text =
@@ -1198,7 +1198,7 @@ ENDBADAUTH
}
} else { # Authentication type is valid
&initialize_authen_forms($ccdomain,$currentauth);
- my $authformnop_row;
+ my $authformnop_row;
if (&Apache::lonnet::allowed('mau',$ccdomain)) {
$authformnop_row = &Apache::loncommon::start_data_table_row();
}
@@ -1591,17 +1591,23 @@ sub update_user_data {
# Check to see if we need to change user information
foreach my $item ('firstname','middlename','lastname','generation','permanentemail','id') {
# Strip leading and trailing whitespace
- $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
+ $env{'form.c'.$item} =~ s/(\s+$|^\s+)//g;
}
# Check to see if we can change the ID/student number
my $forceid = $env{'form.forceid'};
my $recurseid = $env{'form.recurseid'};
my $newuser = 0;
- my $disallowed_id = 0;
my (%alerts,%rulematch,%idinst_results,%curr_rules,%got_rules);
- if (!$forceid) {
- $env{'form.cid'} = $userenv{'id'};
- } elsif ($env{'form.cid'} ne $userenv{'id'}) {
+ my %uidhash = &Apache::lonnet::idrget($env{'form.ccdomain'},
+ $env{'form.ccuname'});
+ if (($uidhash{$env{'form.ccuname'}}) &&
+ ($uidhash{$env{'form.ccuname'}}!~/error\:/) &&
+ (!$forceid)) {
+ if ($env{'form.cid'} ne $uidhash{$env{'form.ccuname'}}) {
+ $env{'form.cid'} = $userenv{'id'};
+ }
+ }
+ if ($env{'form.cid'} ne $userenv{'id'}) {
my $checkhash;
my $checks = { 'id' => 1 };
$checkhash->{$env{'form.ccuname'}.':'.$env{'form.ccdomain'}} =
@@ -1612,7 +1618,7 @@ sub update_user_data {
\%alerts,\%rulematch,\%idinst_results,\%curr_rules,\%got_rules);
if (ref($alerts{'id'}) eq 'HASH') {
if (ref($alerts{'id'}{$env{'form.ccdomain'}}) eq 'HASH') {
- $disallowed_id = 1;
+ $env{'form.cid'} = $userenv{'id'};
}
}
}
@@ -1739,18 +1745,24 @@ END
END
$r->print(&Apache::loncommon::end_data_table_row().
&Apache::loncommon::end_data_table());
- if (($forceid) && ($recurseid) && (!$disallowed_id) &&
- (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
- my %userupdate = (
+ if ($env{'form.cid'} ne $userenv{'id'}) {
+ &Apache::lonnet::idput($env{'form.ccdomain'},
+ ($env{'form.ccuname'} => $env{'form.cid'}));
+ if (($recurseid) &&
+ (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'}))) {
+ my %userupdate = (
lastname => $env{'form.clasaname'},
middlename => $env{'form.cmiddlename'},
firstname => $env{'form.cfirstname'},
generation => $env{'fora.cgeneration'},
id => $env{'form.cid'},
);
- my $idresult = &propagate_id_change($env{'form.ccname'},
- $env{'form.ccdomain'},\%userupdate);
- $r->print('
'.$idresult.'
');
+ my $idresult =
+ &Apache::lonuserutils::propagate_id_change(
+ $env{'form.ccuname'},$env{'form.ccdomain'},
+ \%userupdate);
+ $r->print('
'.$idresult.'
');
+ }
}
if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
($env{'form.ccuname'} eq $env{'user.name'})) {
@@ -1816,10 +1828,10 @@ END
$r->print(&mt('Revoking [_1] in [_2]: [_3]',
$role,$scope,''.$result.'').'
');
if ($role eq 'st') {
- my $result =
+ my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
- $now);
+ $now);
$r->print($result);
}
}
@@ -1843,10 +1855,10 @@ END
$r->print(&mt('Deleting [_1] in [_2]: [_3]',$role,$scope,
''.$result.'').'
');
if ($role eq 'st') {
- my $result =
+ my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
- $now);
+ $now);
$r->print($result);
}
}
@@ -2393,11 +2405,13 @@ sub handler {
$context = 'domain';
}
&Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
- ['action','state']);
+ ['action','state','callingform','roletype','showrole','bulkaction']);
&Apache::lonhtmlcommon::clear_breadcrumbs();
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>"/adm/createuser",
- text=>"User Management"});
+ if ($env{'form.action'} ne 'dateselect') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>"/adm/createuser",
+ text=>"User Management"});
+ }
my ($permission,$allowed) = &get_permission($context);
if (!$allowed) {
$env{'user.error.msg'}=
@@ -2447,7 +2461,7 @@ sub handler {
if (! exists($env{'form.state'})) {
&Apache::lonuserutils::print_expire_menu($r,$context);
} elsif ($env{'form.state'} eq 'done') {
- &Apache::lonuserutils::expire_user_list($r);
+ &Apache::lonuserutils::expire_user_list($r,$context);
} else {
&Apache::lonuserutils::print_expire_menu($r,$context);
}
@@ -2512,31 +2526,46 @@ sub handler {
&custom_role_editor($r);
}
} elsif ($env{'form.action'} eq 'listusers' && $permission->{'view'}) {
- my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
- my $formname = 'studentform';
- if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
- ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
- &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
- $formname);
- my $js = &add_script($jscript).$cb_jscript;
- my $loadcode =
- &Apache::lonuserutils::course_selector_loadcode($formname);
- if ($loadcode ne '') {
- $r->print(&header($js,{'onload' => $loadcode,}));
+ if ($env{'form.phase'} eq 'bulkchange') {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'backPage(document.studentform)',
+ text=>"List Users"});
+ my $setting = $env{'form.roletype'};
+ my $choice = $env{'form.bulkaction'};
+ $r->print(&header());
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
+ 'User_Management_List'));
+ if ($permission->{'cusr'}) {
+ &Apache::lonuserutils::update_user_list($r,$context,$setting,$choice);
+ }
+ } else {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href=>'/adm/createuser?action=listusers',
+ text=>"List Users"});
+ my ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles);
+ my $formname = 'studentform';
+ if ($context eq 'domain' && $env{'form.roletype'} eq 'course') {
+ ($cb_jscript,$jscript,$totcodes,$codetitles,$idlist,$idlist_titles) =
+ &Apache::lonuserutils::courses_selector($env{'request.role.domain'},
+ $formname);
+ $jscript .= &verify_user_display();
+ my $js = &add_script($jscript).$cb_jscript;
+ my $loadcode =
+ &Apache::lonuserutils::course_selector_loadcode($formname);
+ if ($loadcode ne '') {
+ $r->print(&header($js,{'onload' => $loadcode,}));
+ } else {
+ $r->print(&header($js));
+ }
} else {
- $r->print(&header($js));
+ $r->print(&header(&add_script(&verify_user_display())));
}
- } else {
- $r->print(&header());
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
+ 'User_Management_List'));
+ &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
+ $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
+ $r->print(&Apache::loncommon::end_page());
}
- &Apache::lonhtmlcommon::add_breadcrumb
- ({href=>'/adm/createuser?action=listusers',
- text=>"List Users"});
- $r->print(&Apache::lonhtmlcommon::breadcrumbs("List Users",
- 'User_Management_List'));
- &Apache::lonuserutils::print_userlist($r,undef,$permission,$context,
- $formname,$totcodes,$codetitles,$idlist,$idlist_titles);
- $r->print(&Apache::loncommon::end_page());
} elsif ($env{'form.action'} eq 'expire' && $permission->{'cusr'}) {
$r->print(&header());
&Apache::lonhtmlcommon::add_breadcrumb
@@ -2547,26 +2576,37 @@ sub handler {
if (! exists($env{'form.state'})) {
&Apache::lonuserutils::print_expire_menu($r,$context);
} elsif ($env{'form.state'} eq 'done') {
- &Apache::lonuserutiles::expire_user_list($r);
+ &Apache::lonuserutiles::expire_user_list($r,$context);
} else {
&print_expire_menu($r,$context);
}
$r->print(&Apache::loncommon::end_page());
+ } 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::loncommon::end_page());
+ } else {
+ $r->print(&header().
+ ''.&mt('You do not have permission to modify dates or sections for users').''.
+ &Apache::loncommon::end_page());
+ }
} else {
$r->print(&header());
- $r->print(&Apache::lonhtmlcommon::breadcrumbs('User Management')); $r->print(&print_main_menu($permission));
+ $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 ($jscript,$loaditems,$args) = @_;
my $start_page;
if (ref($loaditems) eq 'HASH') {
- $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems,});
+ $start_page=&Apache::loncommon::start_page('User Management',$jscript,{'add_entries' => $loaditems});
} else {
- $start_page=&Apache::loncommon::start_page('User Management',$jscript);
+ $start_page=&Apache::loncommon::start_page('User Management',$jscript,$args);
}
return $start_page;
}
@@ -2576,6 +2616,20 @@ sub add_script {
return '';
}
+sub verify_user_display {
+ my $output = <<"END";
+
+function display_update() {
+ document.studentform.action.value = 'listusers';
+ document.studentform.phase.value = 'display';
+ document.studentform.submit();
+}
+
+END
+ return $output;
+
+}
+
###############################################################
###############################################################
# Menu Phase One
@@ -3150,9 +3204,9 @@ sub course_level_table {
'.$plrole.' | '.$area.' | '."\n"; if (%sections_count) { - my $currsec = + my $currsec = &Apache::lonuserutils::course_sections(\%sections_count, $customrole); $table.=