[LON-CAPA-cvs] cvs: loncom(version_2_7_X) /interface loncreateuser.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 13 Jul 2008 09:57:30 -0000
raeburn Sun Jul 13 05:57:30 2008 EDT
Modified files: (Branch: version_2_7_X)
/loncom/interface loncreateuser.pm
Log:
- backport 1.251, 1.252, 1.253, 1.254
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.249.2.1 loncom/interface/loncreateuser.pm:1.249.2.2
--- loncom/interface/loncreateuser.pm:1.249.2.1 Tue Jul 8 00:27:51 2008
+++ loncom/interface/loncreateuser.pm Sun Jul 13 05:57:29 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.249.2.1 2008/07/08 04:27:51 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.249.2.2 2008/07/13 09:57:29 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1396,18 +1396,31 @@
}
sub personal_data_display {
- my ($ccuname,$ccdomain,$newuser,$context,$inst_results) = @_;
- my ($output,$showforceid,%userenv,%canmodify);
+ my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_;
+ my ($output,$showforceid,%userenv,%canmodify,@inststatuses);
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
+ my $rowcount = 0;
+ my $editable = 0;
+ if ($context eq 'selfcreate') {
+ if (ref($inst_results) eq 'HASH') {
+ @inststatuses = &get_inststatuses($inst_results);
+ if (@inststatuses == 0) {
+ @inststatuses = ('default');
+ }
+ $rolesarray = \@inststatuses;
+ }
+ }
if (!$newuser) {
# Get the users information
%userenv = &Apache::lonnet::get('environment',
['firstname','middlename','lastname','generation',
'permanentemail','id'],$ccdomain,$ccuname);
+ }
+ if ((!$newuser) || ($context eq 'selfcreate')) {
%canmodify =
&Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
- \@userinfo);
+ \@userinfo,$rolesarray);
}
my %lt=&Apache::lonlocal::texthash(
'pd' => "Personal Data",
@@ -1432,40 +1445,78 @@
&Apache::lonhtmlcommon::start_pick_box();
foreach my $item (@userinfo) {
my $rowtitle = $lt{$item};
+ my $hiderow = 0;
if ($item eq 'generation') {
$rowtitle = $genhelp.$rowtitle;
}
- $output .= &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
+ my $row = &Apache::lonhtmlcommon::row_title($rowtitle,undef,'LC_oddrow_value')."\n";
if ($newuser) {
if (ref($inst_results) eq 'HASH') {
if ($inst_results->{$item} ne '') {
- $output .= '<input type="hidden" name="c'.$item.'" value="'.$inst_results->{$item}.'" />'.$inst_results->{$item};
+ $row .= '<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="" />';
+ if ($context eq 'selfcreate') {
+ if ($canmodify{$item}) {
+ $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
+ $editable ++;
+ } else {
+ $hiderow = 1;
+ }
+ } else {
+ $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
+ }
}
} else {
- $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
+ if ($context eq 'selfcreate') {
+ if ($canmodify{$item}) {
+ $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
+ $editable ++;
+ } else {
+ $hiderow = 1;
+ }
+ } else {
+ $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="" />';
+ }
}
} else {
if ($canmodify{$item}) {
- $output .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';
+ $row .= '<input type="text" name="c'.$item.'" size="'.$textboxsize{$item}.'" value="'.$userenv{$item}.'" />';
} else {
- $output .= $userenv{$item};
+ $row .= $userenv{$item};
}
if ($item eq 'id') {
$showforceid = $canmodify{$item};
}
}
- $output .= &Apache::lonhtmlcommon::row_closure(1);
+ $row .= &Apache::lonhtmlcommon::row_closure(1);
+ if (!$hiderow) {
+ $output .= $row;
+ $rowcount ++;
+ }
}
$output .= &Apache::lonhtmlcommon::end_pick_box();
if (wantarray) {
- return ($output,$showforceid);
+ if ($context eq 'selfcreate') {
+ return($output,$rowcount,$editable);
+ } else {
+ return ($output,$showforceid);
+ }
} else {
return $output;
}
}
+sub get_inststatuses {
+ my ($insthashref) = @_;
+ my @inststatuses = ();
+ if (ref($insthashref) eq 'HASH') {
+ if (ref($insthashref->{'inststatus'}) eq 'ARRAY') {
+ @inststatuses = @{$insthashref->{'inststatus'}};
+ }
+ }
+ return @inststatuses;
+}
+
# ================================================================= Phase Three
sub update_user_data {
my ($r,$context) = @_;
@@ -3538,7 +3589,7 @@
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($currdom);
my $othervalue = 'any';
if ((ref($types) eq 'ARRAY') && (ref($usertypes) eq 'HASH')) {
- if (@{$types} > 0) {
+ if (keys(%{$usertypes}) > 0) {
$othervalue = 'other';
}
$output .= '<table><tr>';