--- loncom/interface/loncreateuser.pm 2009/03/08 20:26:32 1.285
+++ loncom/interface/loncreateuser.pm 2009/03/09 05:25:40 1.286
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.285 2009/03/08 20:26:32 weissno Exp $
+# $Id: loncreateuser.pm,v 1.286 2009/03/09 05:25:40 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1524,16 +1524,19 @@ sub modify_login_block {
sub personal_data_display {
my ($ccuname,$ccdomain,$newuser,$context,$inst_results,$rolesarray) = @_;
- my ($output,$showforceid,%userenv,%canmodify);
+ my ($output,$showforceid,%userenv,%canmodify,%canmodify_status);
my @userinfo = ('firstname','middlename','lastname','generation',
'permanentemail','id');
my $rowcount = 0;
my $editable = 0;
+ %canmodify_status =
+ &Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
+ ['inststatus'],$rolesarray);
if (!$newuser) {
# Get the users information
%userenv = &Apache::lonnet::get('environment',
['firstname','middlename','lastname','generation',
- 'permanentemail','id'],$ccdomain,$ccuname);
+ 'permanentemail','id','inststatus'],$ccdomain,$ccuname);
%canmodify =
&Apache::lonuserutils::can_modify_userinfo($context,$ccdomain,
\@userinfo,$rolesarray);
@@ -1549,7 +1552,8 @@ sub personal_data_display {
'generation' => "Generation",
'permanentemail' => "Permanent e-mail address",
'id' => "Student/Employee ID",
- 'lg' => "Login Data"
+ 'lg' => "Login Data",
+ 'inststatus' => "Affiliation",
);
my %textboxsize = (
firstname => '15',
@@ -1613,6 +1617,30 @@ sub personal_data_display {
$rowcount ++;
}
}
+ if (($canmodify_status{'inststatus'}) || ($context ne 'selfcreate')) {
+ my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($ccdomain);
+ if (ref($types) eq 'ARRAY') {
+ if (@{$types} > 0) {
+ my ($hiderow,$shown);
+ if ($canmodify_status{'inststatus'}) {
+ $shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
+ } else {
+ $shown .= $userenv{'inststatus'};
+ if ($userenv{'inststatus'} eq '') {
+ $hiderow = 1;
+ }
+ }
+ if (!$hiderow) {
+ my $row = &Apache::lonhtmlcommon::row_title(&mt('Affliations'),undef,'LC_oddrow_value')."\n".
+ $shown.&Apache::lonhtmlcommon::row_closure(1);
+ if ($context eq 'selfcreate') {
+ $rowcount ++;
+ }
+ $output .= $row;
+ }
+ }
+ }
+ }
$output .= &Apache::lonhtmlcommon::end_pick_box();
if (wantarray) {
if ($context eq 'selfcreate') {
@@ -1625,6 +1653,48 @@ sub personal_data_display {
}
}
+sub pick_inst_statuses {
+ my ($curr,$usertypes,$types) = @_;
+ my ($output,$rem,@currtypes);
+ if ($curr ne '') {
+ @currtypes = map { &unescape($_); } split(/:/,$curr);
+ }
+ my $numinrow = 2;
+ if (ref($types) eq 'ARRAY') {
+ $output = '
';
+ }
+ return $output;
+}
+
sub selfcreate_canmodify {
my ($context,$dom,$userinfo,$inst_results,$rolesarray) = @_;
if (ref($inst_results) eq 'HASH') {
@@ -1774,6 +1844,8 @@ sub update_user_data {
my (%alerts,%rulematch,%inst_results,%curr_rules);
my @usertools = ('aboutme','blog','portfolio');
my @requestcourses = ('official','unofficial');
+ my ($othertitle,$usertypes,$types) =
+ &Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
if ($env{'form.makeuser'}) {
$r->print(''.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -1856,6 +1928,13 @@ sub update_user_data {
$changed{$item} = &tool_admin($item,$newcustom{$item},
\%changeHash,'requestcourses');
}
+ if (exists($env{'form.inststatus'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $changeHash{'inststatus'} = join(',',@inststatuses);
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ }
+ }
if (keys(%changed)) {
$changeHash{'firstname'} = $env{'form.cfirstname'};
$changeHash{'middlename'} = $env{'form.cmiddlename'};
@@ -2024,12 +2103,13 @@ sub update_user_data {
}
}
}
- my ($quotachanged,$oldportfolioquota,$newportfolioquota,
- $inststatus,$oldisdefault,$newisdefault,$olddefquotatext,
- $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext);
+ my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
+ $inststatus,$newinststatus,$oldisdefault,$newisdefault,$olddefquotatext,
+ $newdefquotatext,%oldaccess,%oldaccesstext,%newaccess,%newaccesstext,
+ $oldinststatuses,$newinststatuses);
my ($defquota,$settingstatus) =
&Apache::loncommon::default_quota($env{'form.ccdomain'},$inststatus);
- my ($showquota,$showtools,$showrequestcourses);
+ my ($showquota,$showtools,$showrequestcourses,$showinststatus);
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
$showquota = 1;
}
@@ -2039,7 +2119,46 @@ sub update_user_data {
if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
$showrequestcourses = 1;
}
+ if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
+ $showinststatus = 1;
+ }
my (%changeHash,%changed);
+ $oldinststatus = $userenv{'inststatus'};
+ if ($oldinststatus eq '') {
+ $oldinststatuses = $othertitle;
+ } else {
+ if (ref($usertypes) eq 'HASH') {
+ $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+ } else {
+ $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+ }
+ }
+ $changeHash{'inststatus'} = $userenv{'inststatus'};
+ my %canmodify_inststatus = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},['inststatus'],\@userroles);
+ if ($canmodify_inststatus{'inststatus'}) {
+ if (exists($env{'form.inststatus'})) {
+ my @inststatuses = &Apache::loncommon::get_env_multiple('form.inststatus');
+ if (@inststatuses > 0) {
+ $newinststatus = join(':',map { &escape($_); } @inststatuses);
+ $changeHash{'inststatus'} = $newinststatus;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $newinststatus;
+ }
+ if (ref($usertypes) eq 'HASH') {
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ } else {
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ }
+ } else {
+ $newinststatus = '';
+ $changeHash{'inststatus'} = $newinststatus;
+ $newinststatuses = $othertitle;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $changeHash{'inststatus'};
+ }
+ }
+ }
+ }
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
if ($userenv{'portfolioquota'} ne '') {
$oldportfolioquota = $userenv{'portfolioquota'};
@@ -2171,6 +2290,7 @@ sub update_user_data {
'portfolio' => 'Portfolio Availability',
'official' => 'Can Request Official Courses',
'unofficial' => 'Can Request Unofficial Courses',
+ 'inststatus' => "Affiliation",
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
);
@@ -2186,6 +2306,10 @@ sub update_user_data {
$lt{'id'} |
$lt{'mail'} |
END
+ if ($showinststatus) {
+ $r->print("
+ $lt{'inststatus'} | \n");
+ }
if ($showrequestcourses) {
foreach my $item (@requestcourses) {
$r->print("
@@ -2213,6 +2337,10 @@ END
$userenv{'id'} |
$userenv{'permanentemail'} |
END
+ if ($showinststatus) {
+ $r->print("
+ $oldinststatuses | \n");
+ }
if ($showrequestcourses) {
foreach my $item (@requestcourses) {
$r->print("
@@ -2240,6 +2368,10 @@ END
$env{'form.cid'} |
$env{'form.cpermanentemail'} |
END
+ if ($showinststatus) {
+ $r->print("
+ $newinststatuses | \n");
+ }
if ($showrequestcourses) {
foreach my $item (@requestcourses) {
$r->print("
@@ -2296,6 +2428,7 @@ END
'portfolio' => "Portfolio Availability",
'official' => "Can Request Official Courses",
'unofficial' => "Can Request Unofficial Course",
+ 'inststatus' => "Affiliation",
);
$r->print(<<"END");
$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
@@ -2304,6 +2437,9 @@ END
$r->print('
['.$lt{'mail'}.': '.
$userenv{'permanentemail'}.']');
}
+ if ($showinststatus) {
+ $r->print('
['.$lt{'inststatus'}.': '.$oldinststatuses.']');
+ }
if ($showrequestcourses) {
foreach my $item (@requestcourses) {
$r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.