[LON-CAPA-cvs] cvs: loncom /interface loncreateuser.pm
raeburn
lon-capa-cvs-allow@mail.lon-capa.org
Sun, 13 Jul 2008 00:15:15 -0000
raeburn Sat Jul 12 20:15:15 2008 EDT
Modified files:
/loncom/interface loncreateuser.pm
Log:
- Changes in data entry table generated by &personal_data_display()
- Extra arg in subroutine call - $rolesarray (optional ref to array of roles to check for allowed modification of user information).
- In context "selfcreate" get array of institutional status types for user [set to ('default')] if none.
- Pass arrayref to &Apache::lonuserutils::can_modify_userinfo().
- In context selfcreate, array of three args returned to caller:
- output, number of rows in datatable, number of rows with editable fields.
Index: loncom/interface/loncreateuser.pm
diff -u loncom/interface/loncreateuser.pm:1.251 loncom/interface/loncreateuser.pm:1.252
--- loncom/interface/loncreateuser.pm:1.251 Thu Jul 10 18:07:18 2008
+++ loncom/interface/loncreateuser.pm Sat Jul 12 20:15:14 2008
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.251 2008/07/10 22:07:18 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.252 2008/07/13 00:15:14 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1396,18 +1396,29 @@
}
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');
- if (!$newuser) {
+ 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 || $context eq 'selfcreate') {
# Get the users information
%userenv = &Apache::lonnet::get('environment',
['firstname','middlename','lastname','generation',
'permanentemail','id'],$ccdomain,$ccuname);
%canmodify =
&Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
- \@userinfo);
+ \@userinfo,$rolesarray);
}
my %lt=&Apache::lonlocal::texthash(
'pd' => "Personal Data",
@@ -1432,40 +1443,74 @@
&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 {
- $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 {
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) = @_;