[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm lonuserutils.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 06 Dec 2007 04:03:36 -0000
raeburn Wed Dec 5 23:03:36 2007 EDT
Modified files:
/loncom/interface loncreateuser.pm lonuserutils.pm
Log:
- Pass updated userinformation along when propagating changes
- Use same logic as lonnet::modifyuser() when determining if ID should be updated
- Blank IDs can now be made non-blank without requiring forceID checkbox to have been checked.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.202 loncom/interface/loncreateuser.pm:1.203
--- loncom/interface/loncreateuser.pm:1.202 Wed Dec 5 16:23:14 2007
+++ loncom/interface/loncreateuser.pm Wed Dec 5 23:03:35 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.202 2007/12/05 21:23:14 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.203 2007/12/06 04:03:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -787,7 +787,7 @@
&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('</div>');
my $user_auth_text =
@@ -1591,17 +1591,23 @@
# 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 @@
\%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
$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('<br />'.$idresult.'<br />');
+ my $idresult =
+ &Apache::lonuserutils::propagate_id_change(
+ $env{'form.ccuname'},$env{'form.ccdomain'},
+ \%userupdate);
+ $r->print('<br />'.$idresult.'<br />');
+ }
}
if (($env{'form.ccdomain'} eq $env{'user.domain'}) &&
($env{'form.ccuname'} eq $env{'user.name'})) {
Index: loncom/interface/lonuserutils.pm
diff -u loncom/interface/lonuserutils.pm:1.11 loncom/interface/lonuserutils.pm:1.12
--- loncom/interface/lonuserutils.pm:1.11 Wed Dec 5 16:23:14 2007
+++ loncom/interface/lonuserutils.pm Wed Dec 5 23:03:36 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.11 2007/12/05 21:23:14 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.12 2007/12/06 04:03:36 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -136,22 +136,30 @@
sub propagate_id_change {
my ($uname,$udom,$user) = @_;
- my (@types,@roles,@cdoms);
+ my (@types,@roles);
@types = ('active','future');
@roles = ('st');
my $idresult;
my %roleshash = &Apache::lonnet::get_my_roles($uname,
- $udom,'userroles',\@types,\@roles,\@cdoms);
+ $udom,'userroles',\@types,\@roles);
+ my %args = (
+ one_time => 1,
+ );
foreach my $item (keys(%roleshash)) {
my ($cnum,$cdom,$role) = split(/:/,$item);
my ($start,$end) = split(/:/,$roleshash{$item});
if (&Apache::lonnet::is_course($cdom,$cnum)) {
- my %userupdate;
- my $result = &update_classlist($cdom,$cnum,$udom,$uname,\%userupdate);
+ my $result = &update_classlist($cdom,$cnum,$udom,$uname,$user);
+ my %coursehash =
+ &Apache::lonnet::coursedescription($cdom.'_'.$cnum,\%args);
+ my $cdesc = $coursehash{'description'};
+ if ($cdesc eq '') {
+ $cdesc = $cdom.'_'.$cnum;
+ }
if ($result eq 'ok') {
- $idresult .= "Classlist change: $uname:$udom - class -> $cnum:$cdom\n";
+ $idresult .= &mt('Classlist update for "[_1]" in "[_2]".',$uname.':'.$udom,$cdesc).'<br />'."\n";
} else {
- $idresult .= "Error - $result -during classlist update for $uname:$udom in $cnum:$cdom\n";
+ $idresult .= &mt('Error: "[_1]" during classlist update for "[_2]" in "[_3]".',$result,$uname.':'.$udom,$cdesc).'<br />'."\n";
}
}
}