--- loncom/interface/loncreateuser.pm 2010/04/23 17:51:42 1.295.2.33
+++ loncom/interface/loncreateuser.pm 2009/10/30 04:44:56 1.319
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.295.2.33 2010/04/23 17:51:42 raeburn Exp $
+# $Id: loncreateuser.pm,v 1.319 2009/10/30 04:44:56 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -51,14 +51,13 @@ In LON-CAPA, roles are actually collecti
Assistant", "Course Coordinator", and other such roles are really just
collection of privileges that are useful in many circumstances.
-Custom roles can be defined by a Domain Coordinator, Course Coordinator
-or Community Coordinator via the Manage User functionality.
-The custom role editor screen will show all privileges which can be
-assigned to users. For a complete list of privileges, please see
-C.
+Creating custom roles can be done by the Domain Coordinator through
+the Create User functionality. That screen will show all privileges
+that can be assigned to users. For a complete list of privileges,
+please see C.
-Custom role definitions are stored in the C '
@@ -1038,24 +963,10 @@ sub print_user_modification_page {
ENDFORMINFO
- my (%inccourses,$roledom);
- if ($context eq 'course') {
- $inccourses{$env{'request.course.id'}}=1;
- $roledom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- } elsif ($context eq 'author') {
- $roledom = $env{'request.role.domain'};
- } elsif ($context eq 'domain') {
- foreach my $key (keys(%env)) {
- $roledom = $env{'request.role.domain'};
- if ($key=~/^user\.priv\.cm\.\/($roledom)\/($match_username)/) {
- $inccourses{$1.'_'.$2}=1;
- }
- }
- } else {
- foreach my $key (keys(%env)) {
- if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
- $inccourses{$1.'_'.$2}=1;
- }
+ my %inccourses;
+ foreach my $key (keys(%env)) {
+ if ($key=~/^user\.priv\.cm\.\/($match_domain)\/($match_username)/) {
+ $inccourses{$1.'_'.$2}=1;
}
}
if ($newuser) {
@@ -1292,10 +1203,10 @@ ENDNOTOOLSPRIV
}
$r->print('$lt{'ecrp'}
+$choice $lt{'nr'}:
+
+
+ENDCUSTOM
}
} else {
my $actiontext = $lt{'srad'};
@@ -585,7 +547,8 @@ sub print_username_entry_form {
$actiontext = $lt{'srst'};
}
}
- $r->print("$actiontext
");
+ $r->print("
+$actiontext
");
if ($env{'form.origform'} ne 'crtusername') {
$r->print("\n".$response);
}
@@ -594,44 +557,6 @@ sub print_username_entry_form {
$r->print(&Apache::loncommon::end_page());
}
-sub customrole_javascript {
- my $js = <<"END";
-
-END
- return $js;
-}
-
sub entry_form {
my ($dom,$srch,$forcenewuser,$context,$responsemsg,$crstype) = @_;
my %domconf = &Apache::lonnet::get_dom('configuration',['usercreation'],$dom);
@@ -685,7 +610,7 @@ ENDBLOCK
);
my $sellink=&Apache::loncommon::selectstudent_link('crtusername','srchterm','srchdomain');
my ($title,$buttontext,$showresponse);
- if ($env{'form.action'} eq 'singlestudent') {
+ if ($env{'form.action'} eq 'singlestudent') {
if ($crstype eq 'Community') {
$title = $lt{'enrm'};
} else {
@@ -945,7 +870,7 @@ sub print_user_modification_page {
);
my $response;
if ($env{'form.origform'} eq 'crtusername') {
- $response = ''.&mt('No match found for the username [_1] in LON-CAPA domain: [_2]',''.$ccuname.'',$ccdomain).
+ $response = ''.&mt('No match was found for the username ([_1]) in LON-CAPA domain: [_2]',$ccuname,$ccdomain).
'
';
}
$response .= '
'.&mt('Domain').': '.$coursedom.(' 'x8).
+ my ($croleudom,$croleuname,$croletitle)=
+ ($role_code=~m{^cr/($match_domain)/($match_username)/(\w+)$});
+ my $allowed=0;
+ my $delallowed=0;
+ my $sortkey=$role_code;
+ my $class='Unknown';
+ if ($area =~ m{^/($match_domain)/($match_courseid)} ) {
+ $class='Course';
+ my ($coursedom,$coursedir) = ($1,$2);
+ $sortkey.="\0$coursedom";
+ # $1.'_'.$2 is the course id (eg. 103_12345abcef103l3).
+ my %coursedata=
+ &Apache::lonnet::coursedescription($1.'_'.$2);
+ my $carea;
+ if (defined($coursedata{'description'})) {
+ $carea=$coursedata{'description'}.
+ '
'.&mt('Domain').': '.$coursedom.(' 'x8).
&Apache::loncommon::syllabuswrapper(&mt('Syllabus'),$coursedir,$coursedom);
- $sortkey.="\0".$coursedata{'description'};
- } else {
- if ($class eq 'Community') {
- $carea=&mt('Unavailable community').': '.$area;
- $sortkey.="\0".&mt('Unavailable community').': '.$area;
+ $sortkey.="\0".$coursedata{'description'};
+ $class=$coursedata{'type'};
} else {
$carea=&mt('Unavailable course').': '.$area;
$sortkey.="\0".&mt('Unavailable course').': '.$area;
}
- }
- $sortkey.="\0$coursedir";
- $inccourses->{$cid}=1;
- if ((&Apache::lonnet::allowed('c'.$role_code,$coursedom.'/'.$coursedir)) ||
- (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
- $allowed=1;
- }
- unless ($allowed) {
- my $isowner = &is_courseowner($cid,$coursedata{'internal.courseowner'});
- if ($isowner) {
- if (($role_code eq 'co') && ($class eq 'Community')) {
- $allowed = 1;
- } elsif (($role_code eq 'cc') && ($class eq 'Course')) {
- $allowed = 1;
- }
- }
- }
- if ((&Apache::lonnet::allowed('dro',$coursedom)) ||
- (&Apache::lonnet::allowed('dro',$ccdomain))) {
- $delallowed=1;
- }
-# - custom role. Needs more info, too
- if ($croletitle) {
- if (&Apache::lonnet::allowed('ccr',$coursedom.'/'.$coursedir)) {
- $allowed=1;
- $thisrole.='.'.$role_code;
- }
- }
- if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.='
Section: '.$3;
- $sortkey.="\0$3";
- if (!$allowed) {
- if ($env{'request.course.sec'} eq $3) {
- if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
- $allowed = 1;
- }
- }
- }
- }
- $area=$carea;
- } else {
- $sortkey.="\0".$area;
- # Determine if current user is able to revoke privileges
- if ($area=~m{^/($match_domain)/}) {
- if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
+ $sortkey.="\0$coursedir";
+ $inccourses->{$1.'_'.$2}=1;
+ if ((&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2)) ||
(&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
$allowed=1;
}
- if (((&Apache::lonnet::allowed('dro',$1)) ||
- (&Apache::lonnet::allowed('dro',$ccdomain))) &&
- ($role_code ne 'dc')) {
+ if ((&Apache::lonnet::allowed('dro',$1)) ||
+ (&Apache::lonnet::allowed('dro',$ccdomain))) {
$delallowed=1;
}
+# - custom role. Needs more info, too
+ if ($croletitle) {
+ if (&Apache::lonnet::allowed('ccr',$1.'/'.$2)) {
+ $allowed=1;
+ $thisrole.='.'.$role_code;
+ }
+ }
+ # Compute the background color based on $area
+ if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
+ $carea.='
Section: '.$3;
+ $sortkey.="\0$3";
+ if (!$allowed) {
+ if ($env{'request.course.sec'} eq $3) {
+ if (&Apache::lonnet::allowed('c'.$role_code,$1.'/'.$2.'/'.$3)) {
+ $allowed = 1;
+ }
+ }
+ }
+ }
+ $area=$carea;
} else {
- if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
+ $sortkey.="\0".$area;
+ # Determine if current user is able to revoke privileges
+ if ($area=~m{^/($match_domain)/}) {
+ if ((&Apache::lonnet::allowed('c'.$role_code,$1)) ||
+ (&Apache::lonnet::allowed('c'.$role_code,$ccdomain))) {
+ $allowed=1;
+ }
+ if (((&Apache::lonnet::allowed('dro',$1)) ||
+ (&Apache::lonnet::allowed('dro',$ccdomain))) &&
+ ($role_code ne 'dc')) {
+ $delallowed=1;
+ }
+ } else {
+ if (&Apache::lonnet::allowed('c'.$role_code,'/')) {
+ $allowed=1;
+ }
+ }
+ if ($role_code eq 'ca' || $role_code eq 'au') {
+ $class='Construction Space';
+ } elsif ($role_code eq 'su') {
+ $class='System';
+ } else {
+ $class='Domain';
+ }
+ }
+ if (($role_code eq 'ca') || ($role_code eq 'aa')) {
+ $area=~m{/($match_domain)/($match_username)};
+ if (&Apache::lonuserutils::authorpriv($2,$1)) {
$allowed=1;
+ } else {
+ $allowed=0;
}
}
- if ($role_code eq 'ca' || $role_code eq 'au') {
- $class='Construction Space';
- } elsif ($role_code eq 'su') {
- $class='System';
+ my $row = '';
+ $row.= '';
+ my $active=1;
+ $active=0 if (($role_end_time) && ($now>$role_end_time));
+ if (($active) && ($allowed)) {
+ $row.= '';
} else {
- $class='Domain';
+ if ($active) {
+ $row.=' ';
+ } else {
+ $row.=&mt('expired or revoked');
+ }
}
- }
- if (($role_code eq 'ca') || ($role_code eq 'aa')) {
- $area=~m{/($match_domain)/($match_username)};
- if (&Apache::lonuserutils::authorpriv($2,$1)) {
- $allowed=1;
+ $row.=' ';
+ if ($allowed && !$active) {
+ $row.= '';
} else {
- $allowed=0;
+ $row.=' ';
}
- }
- my $row = '';
- $row.= ' ';
- my $active=1;
- $active=0 if (($role_end_time) && ($now>$role_end_time));
- if (($active) && ($allowed)) {
- $row.= '';
- } else {
- if ($active) {
- $row.=' ';
+ $row.=' ';
+ if ($delallowed) {
+ $row.= '';
} else {
- $row.=&mt('expired or revoked');
+ $row.=' ';
}
- }
- $row.=' ';
- if ($allowed && !$active) {
- $row.= '';
- } else {
- $row.=' ';
- }
- $row.=' ';
- if ($delallowed) {
- $row.= '';
- } else {
- $row.=' ';
- }
- my $plaintext='';
- if (!$croletitle) {
- $plaintext=&Apache::lonnet::plaintext($role_code,$class)
- } else {
- $plaintext=
+ my $plaintext='';
+ if (!$croletitle) {
+ $plaintext=&Apache::lonnet::plaintext($role_code,$class)
+ } else {
+ $plaintext=
"Customrole '$croletitle'
defined by $croleuname\@$croleudom";
- }
- $row.= ''.$plaintext.
- ' '.$area.
- ' '.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
- : ' ' ).
- ' '.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
- : ' ' )
- ." ";
- $sortrole{$sortkey}=$envkey;
- $roletext{$envkey}=$row;
- $roleclass{$envkey}=$class;
- $rolepriv{$envkey}=$allowed;
- } # end of foreach (table building loop)
-
- my $rolesdisplay = 0;
- my %output = ();
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
- $output{$type} = '';
- foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
- if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
- $output{$type}.=
- &Apache::loncommon::start_data_table_row().
- $roletext{$sortrole{$which}}.
- &Apache::loncommon::end_data_table_row();
- }
- }
- unless($output{$type} eq '') {
- $output{$type} = ''.
- " ".
- $output{$type};
- $rolesdisplay = 1;
- }
- }
- if ($rolesdisplay == 1) {
- my $contextrole='';
- if ($env{'request.course.id'}) {
- if (&Apache::loncommon::course_type() eq 'Community') {
- $contextrole = &mt('Existing Roles in this Community');
+ }
+ $row.= '".&mt($type)." '.$plaintext.
+ ' '.$area.
+ ' '.($role_start_time?&Apache::lonlocal::locallocaltime($role_start_time)
+ : ' ' ).
+ ' '.($role_end_time ?&Apache::lonlocal::locallocaltime($role_end_time)
+ : ' ' )
+ ." ";
+ $sortrole{$sortkey}=$envkey;
+ $roletext{$envkey}=$row;
+ $roleclass{$envkey}=$class;
+ $rolepriv{$envkey}=$allowed;
+ #$r->print($row);
+ } # end of foreach (table building loop)
+ my $rolesdisplay = 0;
+ my %output = ();
+ foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ $output{$type} = '';
+ foreach my $which (sort {uc($a) cmp uc($b)} (keys(%sortrole))) {
+ if ( ($roleclass{$sortrole{$which}} =~ /^\Q$type\E/ ) && ($rolepriv{$sortrole{$which}}) ) {
+ $output{$type}.=
+ &Apache::loncommon::start_data_table_row().
+ $roletext{$sortrole{$which}}.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ unless($output{$type} eq '') {
+ $output{$type} = ''.
+ " ".
+ $output{$type};
+ $rolesdisplay = 1;
+ }
+ }
+ if ($rolesdisplay == 1) {
+ my $contextrole='';
+ if ($env{'request.course.id'}) {
+ my $crstype = &Apache::loncommon::course_type();
+ $contextrole = "Existing Roles in this $crstype";
+ } elsif ($env{'request.role'} =~ /^au\./) {
+ $contextrole = 'Existing Co-Author Roles in your Construction Space';
} else {
- $contextrole = &mt('Existing Roles in this Course');
+ $contextrole = 'Existing Roles in this Domain';
}
- } elsif ($env{'request.role'} =~ /^au\./) {
- $contextrole = &mt('Existing Co-Author Roles in your Construction Space');
- } else {
- $contextrole = &mt('Existing Roles in this Domain');
- }
- $r->print('
+ $r->print('
".&mt($type)." '.$lt{'rer'}.'
'.
-''.$lt{'rev'}.' '.$lt{'ren'}.' '.$lt{'del'}.
' '.$lt{'rol'}.' '.$lt{'ext'}.
' '.$lt{'sta'}.' '.$lt{'end'}.' '.
&Apache::loncommon::end_data_table_header_row());
- foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
- if ($output{$type}) {
- $r->print($output{$type}."\n");
+ foreach my $type ('Construction Space','Course','Community','Domain','System','Unknown') {
+ if ($output{$type}) {
+ $r->print($output{$type}."\n");
+ }
}
+ $r->print(&Apache::loncommon::end_data_table());
}
- $r->print(&Apache::loncommon::end_data_table());
- }
+ } # End of check for keys in rolesdump
return;
}
@@ -2065,22 +1921,9 @@ sub personal_data_display {
if ($canmodify_status{'inststatus'}) {
$shown = &pick_inst_statuses($userenv{'inststatus'},$usertypes,$types);
} else {
+ $shown .= $userenv{'inststatus'};
if ($userenv{'inststatus'} eq '') {
$hiderow = 1;
- } else {
- my @showitems;
- foreach my $item ( map { &unescape($_); } split(':',$userenv{'inststatus'})) {
- if (exists($usertypes->{$item})) {
- push(@showitems,$usertypes->{$item});
- } else {
- push(@showitems,$item);
- }
- }
- if (@showitems) {
- $shown = join(', ',@showitems);
- } else {
- $hiderow = 1;
- }
}
}
if (!$hiderow) {
@@ -2298,14 +2141,10 @@ sub update_user_data {
$r->print(''.&mt('User [_1] in domain [_2]',
$env{'form.ccuname'}, $env{'form.ccdomain'}).'
');
my (%alerts,%rulematch,%inst_results,%curr_rules);
- my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my @usertools = ('aboutme','blog','portfolio');
my @requestcourses = ('official','unofficial','community');
my ($othertitle,$usertypes,$types) =
&Apache::loncommon::sorted_inst_types($env{'form.ccdomain'});
- my %canmodify_status =
- &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},
- ['inststatus']);
if ($env{'form.makeuser'}) {
$r->print(''.&mt('Creating new account.').'
');
# Check for the authentication mode and password
@@ -2365,52 +2204,49 @@ sub update_user_data {
$r->print(&mt('Generating user').': '.$result);
$uhome = &Apache::lonnet::homeserver($env{'form.ccuname'},
$env{'form.ccdomain'});
- my (%changeHash,%newcustom,%changed,%changedinfo);
+ my (%changeHash,%newcustom,%changed);
if ($uhome ne 'no_host') {
- if ($context eq 'domain') {
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newcustom{'quota'} = 0;
- } else {
- $newcustom{'quota'} = $env{'form.portfolioquota'};
- $newcustom{'quota'} =~ s/[^\d\.]//g;
- }
- $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newcustom{'quota'} = 0;
+ } else {
+ $newcustom{'quota'} = $env{'form.portfolioquota'};
+ $newcustom{'quota'} =~ s/[^\d\.]//g;
}
- foreach my $item (@usertools) {
- if ($env{'form.custom'.$item} == 1) {
- $newcustom{$item} = $env{'form.tools_'.$item};
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'tools');
- }
+ $changed{'quota'} = "a_admin($newcustom{'quota'},\%changeHash);
+ }
+ foreach my $item (@usertools) {
+ if ($env{'form.custom'.$item} == 1) {
+ $newcustom{$item} = $env{'form.tools_'.$item};
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'tools');
}
- foreach my $item (@requestcourses) {
- if ($env{'form.custom'.$item} == 1) {
- $newcustom{$item} = $env{'form.crsreq_'.$item};
- if ($env{'form.crsreq_'.$item} eq 'autolimit') {
- $newcustom{$item} .= '=';
- unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
- $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
- }
- }
- $changed{$item} = &tool_admin($item,$newcustom{$item},
- \%changeHash,'requestcourses');
+ }
+ foreach my $item (@requestcourses) {
+ $newcustom{$item} = $env{'form.crsreq_'.$item};
+ if ($env{'form.crsreq_'.$item} eq 'autolimit') {
+ $newcustom{$item} .= '=';
+ unless ($env{'form.crsreq_'.$item.'_limit'} =~ /\D/) {
+ $newcustom{$item} .= $env{'form.crsreq_'.$item.'_limit'};
}
}
+ $changed{$item} = &tool_admin($item,$newcustom{$item},
+ \%changeHash,'requestcourses');
}
- if ($canmodify_status{'inststatus'}) {
- 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 (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)) {
- foreach my $item (@userinfo) {
- $changeHash{$item} = $env{'form.c'.$item};
- }
+ $changeHash{'firstname'} = $env{'form.cfirstname'};
+ $changeHash{'middlename'} = $env{'form.cmiddlename'};
+ $changeHash{'lastname'} = $env{'form.clastname'};
+ $changeHash{'generation'} = $env{'form.cgeneration'};
+ $changeHash{'id'} = $env{'form.cid'};
+ $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my $chgresult =
&Apache::lonnet::put('environment',\%changeHash,
$env{'form.ccdomain'},$env{'form.ccuname'});
@@ -2439,7 +2275,7 @@ sub update_user_data {
}
}
##
- my (@userroles,%userupdate,$cnum,$cdom,$crstype,%namechanged);
+ my (@userroles,%userupdate,$cnum,$cdom,$crstype,$namechanged);
if ($context eq 'course') {
($cnum,$cdom) = &Apache::lonuserutils::get_course_identity();
$crstype = &Apache::loncommon::course_type($cdom.'_'.$cnum);
@@ -2529,6 +2365,7 @@ sub update_user_data {
push(@longroles,&Apache::lonnet::plaintext($role,$crstype));
}
}
+ my @userinfo = ('firstname','middlename','lastname','generation','permanentemail','id');
my %canmodify = &Apache::lonuserutils::can_modify_userinfo($context,$env{'form.ccdomain'},\@userinfo,\@userroles);
foreach my $item (@userinfo) {
# Strip leading and trailing whitespace
@@ -2575,48 +2412,40 @@ sub update_user_data {
}
}
my ($quotachanged,$oldportfolioquota,$newportfolioquota,$oldinststatus,
- $newinststatus,$oldisdefault,$newisdefault,%oldsettings,
- %oldsettingstext,%newsettings,%newsettingstext,@disporder,
- $olddefquota,$oldsettingstatus,$newdefquota,$newsettingstatus);
- @disporder = ('inststatus');
- if ($env{'request.role.domain'} eq $env{'form.ccdomain'}) {
- push(@disporder,'requestcourses');
- } else {
- push(@disporder,'reqcrsotherdom');
- }
- push(@disporder,('quota','tools'));
- $oldinststatus = $userenv{'inststatus'};
- ($olddefquota,$oldsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$oldinststatus);
- ($newdefquota,$newsettingstatus) = ($olddefquota,$oldsettingstatus);
- my %canshow;
+ $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,$showinststatus,$showreqotherdom);
if (&Apache::lonnet::allowed('mpq',$env{'form.ccdomain'})) {
- $canshow{'quota'} = 1;
+ $showquota = 1;
}
if (&Apache::lonnet::allowed('mut',$env{'form.ccdomain'})) {
- $canshow{'tools'} = 1;
+ $showtools = 1;
}
if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) {
- $canshow{'requestcourses'} = 1;
+ $showrequestcourses = 1;
} elsif (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) {
- $canshow{'reqcrsotherdom'} = 1;
+ $showreqotherdom = 1;
}
if (&Apache::lonnet::allowed('mau',$env{'form.ccdomain'})) {
- $canshow{'inststatus'} = 1;
+ $showinststatus = 1;
}
my (%changeHash,%changed);
+ $oldinststatus = $userenv{'inststatus'};
if ($oldinststatus eq '') {
- $oldsettings{'inststatus'} = $othertitle;
+ $oldinststatuses = $othertitle;
} else {
if (ref($usertypes) eq 'HASH') {
- $oldsettings{'inststatus'} = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
+ $oldinststatuses = join(', ',map{ $usertypes->{ &unescape($_) }; } (split(/:/,$userenv{'inststatus'})));
} else {
- $oldsettings{'inststatus'} = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
+ $oldinststatuses = join(', ',map{ &unescape($_); } (split(/:/,$userenv{'inststatus'})));
}
}
$changeHash{'inststatus'} = $userenv{'inststatus'};
- if ($canmodify_status{'inststatus'}) {
- $canshow{'inststatus'} = 1;
+ 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) {
@@ -2624,88 +2453,86 @@ sub update_user_data {
$changeHash{'inststatus'} = $newinststatus;
if ($newinststatus ne $oldinststatus) {
$changed{'inststatus'} = $newinststatus;
- ($newdefquota,$newsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
}
if (ref($usertypes) eq 'HASH') {
- $newsettings{'inststatus'} = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
} else {
- $newsettings{'inststatus'} = join(', ',@inststatuses);
+ $newinststatuses = join(', ',map{ $usertypes->{$_}; } (@inststatuses));
+ }
+ } else {
+ $newinststatus = '';
+ $changeHash{'inststatus'} = $newinststatus;
+ $newinststatuses = $othertitle;
+ if ($newinststatus ne $oldinststatus) {
+ $changed{'inststatus'} = $changeHash{'inststatus'};
}
- }
- } else {
- $newinststatus = '';
- $changeHash{'inststatus'} = $newinststatus;
- $newsettings{'inststatus'} = $othertitle;
- if ($newinststatus ne $oldinststatus) {
- $changed{'inststatus'} = $changeHash{'inststatus'};
- ($newdefquota,$newsettingstatus) =
- &Apache::loncommon::default_quota($env{'form.ccdomain'},$newinststatus);
}
}
- } elsif ($context ne 'selfcreate') {
- $canshow{'inststatus'} = 1;
- $newsettings{'inststatus'} = $oldsettings{'inststatus'};
}
$changeHash{'portfolioquota'} = $userenv{'portfolioquota'};
- if ($context eq 'domain') {
- if ($userenv{'portfolioquota'} ne '') {
- $oldportfolioquota = $userenv{'portfolioquota'};
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
- if ($newportfolioquota != $oldportfolioquota) {
- $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- }
+ if ($userenv{'portfolioquota'} ne '') {
+ $oldportfolioquota = $userenv{'portfolioquota'};
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newportfolioquota = 0;
} else {
- $changed{'quota'} = "a_admin('',\%changeHash);
- $newportfolioquota = $newdefquota;
- $newisdefault = 1;
+ $newportfolioquota = $env{'form.portfolioquota'};
+ $newportfolioquota =~ s/[^\d\.]//g;
}
- } else {
- $oldisdefault = 1;
- $oldportfolioquota = $olddefquota;
- if ($env{'form.customquota'} == 1) {
- if ($env{'form.portfolioquota'} eq '') {
- $newportfolioquota = 0;
- } else {
- $newportfolioquota = $env{'form.portfolioquota'};
- $newportfolioquota =~ s/[^\d\.]//g;
- }
+ if ($newportfolioquota != $oldportfolioquota) {
$changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
- } else {
- $newportfolioquota = $newdefquota;
- $newisdefault = 1;
}
- }
- if ($oldisdefault) {
- $oldsettingstext{'quota'} = &get_defaultquota_text($oldsettingstatus);
- }
- if ($newisdefault) {
- $newsettingstext{'quota'} = &get_defaultquota_text($newsettingstatus);
- }
- &tool_changes('tools',\@usertools,\%oldsettings,\%oldsettingstext,\%userenv,
- \%changeHash,\%changed,\%newsettings,\%newsettingstext);
- if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
- &tool_changes('requestcourses',\@requestcourses,\%oldsettings,\%oldsettingstext,
- \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
} else {
- &tool_changes('reqcrsotherdom',\@requestcourses,\%oldsettings,\%oldsettingstext,
- \%userenv,\%changeHash,\%changed,\%newsettings,\%newsettingstext);
+ $changed{'quota'} = "a_admin('',\%changeHash);
+ $newportfolioquota = $defquota;
+ $newisdefault = 1;
}
- }
- foreach my $item (@userinfo) {
- if ($env{'form.c'.$item} ne $userenv{$item}) {
- $namechanged{$item} = 1;
+ } else {
+ $oldisdefault = 1;
+ $oldportfolioquota = $defquota;
+ if ($env{'form.customquota'} == 1) {
+ if ($env{'form.portfolioquota'} eq '') {
+ $newportfolioquota = 0;
+ } else {
+ $newportfolioquota = $env{'form.portfolioquota'};
+ $newportfolioquota =~ s/[^\d\.]//g;
+ }
+ $changed{'quota'} = "a_admin($newportfolioquota,\%changeHash);
+ } else {
+ $newportfolioquota = $defquota;
+ $newisdefault = 1;
}
}
- $oldsettings{'quota'} = $oldportfolioquota.' Mb';
- $newsettings{'quota'} = $newportfolioquota.' Mb';
- if ((keys(%namechanged) > 0) || (keys(%changed) > 0)) {
+ if ($oldisdefault) {
+ $olddefquotatext = &get_defaultquota_text($settingstatus);
+ }
+ if ($newisdefault) {
+ $newdefquotatext = &get_defaultquota_text($settingstatus);
+ }
+ &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv,
+ \%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ if ($env{'form.ccdomain'} eq $env{'request.role.domain'}) {
+ &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext,
+ \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ } else {
+ &tool_changes('reqcrsotherdom',\@requestcourses,\%oldaccess,\%oldaccesstext,
+ \%userenv,\%changeHash,\%changed,\%newaccess,\%newaccesstext);
+ }
+ if ($env{'form.cfirstname'} ne $userenv{'firstname'} ||
+ $env{'form.cmiddlename'} ne $userenv{'middlename'} ||
+ $env{'form.clastname'} ne $userenv{'lastname'} ||
+ $env{'form.cgeneration'} ne $userenv{'generation'} ||
+ $env{'form.cid'} ne $userenv{'id'} ||
+ $env{'form.cpermanentemail'} ne $userenv{'permanentemail'} ) {
+ $namechanged = 1;
+ }
+ if (($namechanged) || (keys(%changed) > 0)) {
+ $changeHash{'firstname'} = $env{'form.cfirstname'};
+ $changeHash{'middlename'} = $env{'form.cmiddlename'};
+ $changeHash{'lastname'} = $env{'form.clastname'};
+ $changeHash{'generation'} = $env{'form.cgeneration'};
+ $changeHash{'id'} = $env{'form.cid'};
+ $changeHash{'permanentemail'} = $env{'form.cpermanentemail'};
my ($chgresult,$namechgresult);
if (keys(%changed) > 0) {
$chgresult =
@@ -2721,7 +2548,8 @@ sub update_user_data {
$newenvhash{'environment.requestcourses.'.$key} =
$changeHash{'requestcourses.'.$key};
if ($changeHash{'requestcourses.'.$key} ne '') {
- $newenvhash{'environment.canrequest.'.$key} = 1;
+ $newenvhash{'environment.canrequest.'.$key} =
+ $changeHash{'requestcourses.'.$key};
} else {
$newenvhash{'environment.canrequest.'.$key} =
&Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'},
@@ -2745,17 +2573,14 @@ sub update_user_data {
}
}
}
- if (keys(%namechanged) > 0) {
- foreach my $field (@userinfo) {
- $changeHash{$field} = $env{'form.c'.$field};
- }
-# Make the change
+ if ($namechanged) {
+ # Make the change
$namechgresult =
&Apache::lonnet::modifyuser($env{'form.ccdomain'},
$env{'form.ccuname'},$changeHash{'id'},undef,undef,
$changeHash{'firstname'},$changeHash{'middlename'},
$changeHash{'lastname'},$changeHash{'generation'},
- $changeHash{'id'},undef,$changeHash{'permanentemail'},undef,\@userinfo);
+ $changeHash{'id'},undef,$changeHash{'permanentemail'});
%userupdate = (
lastname => $env{'form.clastname'},
middlename => $env{'form.cmiddlename'},
@@ -2764,14 +2589,139 @@ sub update_user_data {
id => $env{'form.cid'},
);
}
- if (((keys(%namechanged) > 0) && $namechgresult eq 'ok') ||
+ if (($namechanged && $namechgresult eq 'ok') ||
((keys(%changed) > 0) && $chgresult eq 'ok')) {
# Tell the user we changed the name
- &display_userinfo($r,1,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,
- \%oldsettings, \%oldsettingstext,\%newsettings,
- \%newsettingstext);
-
+ my %lt=&Apache::lonlocal::texthash(
+ 'uic' => 'User Information Changed',
+ 'frst' => 'First Name',
+ 'mddl' => 'Middle Name',
+ 'lst' => 'Last Name',
+ 'gen' => 'Generation',
+ 'id' => 'Student/Employee ID',
+ 'mail' => 'Permanent e-mail address',
+ 'disk' => 'Disk space allocated to portfolio files',
+ 'blog' => 'Blog Availability',
+ 'aboutme' => 'Personal Information Page Availability',
+ 'portfolio' => 'Portfolio Availability',
+ 'official' => 'Can Request Official Courses',
+ 'unofficial' => 'Can Request Unofficial Courses',
+ 'community' => 'Can Request Communities',
+ 'inststatus' => "Affiliation",
+ 'prvs' => 'Previous Value:',
+ 'chto' => 'Changed To:'
+ );
+ $r->print(''.$lt{'uic'}.'
'.
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row());
+ $r->print(<<"END");
+
+ $lt{'frst'}
+ $lt{'mddl'}
+ $lt{'lst'}
+ $lt{'gen'}
+ $lt{'id'}
+ $lt{'mail'}
+END
+ if ($showinststatus) {
+ $r->print("
+ $lt{'inststatus'} \n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $lt{$item} \n");
+ }
+ } elsif ($showreqotherdom) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $lt{$item} \n");
+ }
+ }
+ if ($showquota) {
+ $r->print("
+ $lt{'disk'} \n");
+ }
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print("
+ $lt{$item} \n");
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table_header_row().
+ &Apache::loncommon::start_data_table_row());
+ $r->print(<<"END");
+ $lt{'prvs'}
+ $userenv{'firstname'}
+ $userenv{'middlename'}
+ $userenv{'lastname'}
+ $userenv{'generation'}
+ $userenv{'id'}
+ $userenv{'permanentemail'}
+END
+ if ($showinststatus) {
+ $r->print("
+ $oldinststatuses \n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $oldaccess{$item} $oldaccesstext{$item} \n");
+ }
+ } elsif ($showreqotherdom) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $oldaccess{$item} $oldaccesstext{$item} \n");
+ }
+ }
+ if ($showquota) {
+ $r->print("
+ $oldportfolioquota Mb $olddefquotatext \n");
+ }
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print("
+ $oldaccess{$item} $oldaccesstext{$item} \n");
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::start_data_table_row());
+ $r->print(<<"END");
+ $lt{'chto'}
+ $env{'form.cfirstname'}
+ $env{'form.cmiddlename'}
+ $env{'form.clastname'}
+ $env{'form.cgeneration'}
+ $env{'form.cid'}
+ $env{'form.cpermanentemail'}
+END
+ if ($showinststatus) {
+ $r->print("
+ $newinststatuses \n");
+ }
+ if ($showrequestcourses) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $newaccess{$item} $newaccesstext{$item} \n");
+ }
+ } elsif ($showreqotherdom) {
+ foreach my $item (@requestcourses) {
+ $r->print("
+ $newaccess{$item} $newaccesstext{$item} \n");
+ }
+ }
+ if ($showquota) {
+ $r->print("
+ $newportfolioquota Mb $newdefquotatext \n");
+ }
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print("
+ $newaccess{$item} $newaccesstext{$item} \n");
+ }
+ }
+ $r->print(&Apache::loncommon::end_data_table_row().
+ &Apache::loncommon::end_data_table().'
');
if ($env{'form.cid'} ne $userenv{'id'}) {
&Apache::lonnet::idput($env{'form.ccdomain'},
($env{'form.ccuname'} => $env{'form.cid'}));
@@ -2797,13 +2747,54 @@ sub update_user_data {
$env{'form.ccuname'}.' '.&mt('in domain').' '.
$env{'form.ccdomain'}.'
');
}
- } else { # End of if ($env ... ) logic
+ } else { # End of if ($env ... ) logic
# They did not want to change the users name, quota, tool availability,
# or ability to request creation of courses,
# but we can still tell them what the name and quota and availabilities are
- &display_userinfo($r,undef,\@disporder,\%canshow,\@requestcourses,
- \@usertools,\%userenv,\%changed,\%namechanged,\%oldsettings,
- \%oldsettingstext,\%newsettings,\%newsettingstext);
+ my %lt=&Apache::lonlocal::texthash(
+ 'id' => "Student/Employee ID",
+ 'mail' => "Permanent e-mail address",
+ 'disk' => "Disk space allocated to user's portfolio files",
+ 'blog' => "Blog Availability",
+ 'aboutme' => "Personal Information Page Availability",
+ 'portfolio' => "Portfolio Availability",
+ 'official' => "Can Request Official Courses",
+ 'unofficial' => "Can Request Unofficial Courses",
+ 'community' => "Can Request Communities",
+ 'inststatus' => "Affiliation",
+ );
+ $r->print(<<"END");
+$userenv{'firstname'} $userenv{'middlename'} $userenv{'lastname'} $userenv{'generation'}
+END
+ if ($userenv{'permanentemail'} ne '') {
+ $r->print('
');
}
if (@mod_disallowed) {
my ($rolestr,$contextname);
@@ -2850,7 +2841,7 @@ sub update_user_data {
$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}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ } elsif ($showreqotherdom) {
+ foreach my $item (@requestcourses) {
+ $r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ }
+ if ($showtools) {
+ foreach my $item (@usertools) {
+ $r->print('
['.$lt{$item}.': '.$newaccess{$item}.' '.
+ $newaccesstext{$item}.']'."\n");
+ }
+ }
+ if ($showquota) {
+ $r->print('
['.$lt{'disk'}.': '.$oldportfolioquota.' Mb '.
+ $olddefquotatext.']');
+ }
+ $r->print('
'; - if (exists($menu_item->{'help'})) { - $menu_html.= - &Apache::loncommon::help_open_topic($menu_item->{'help'}); - } - $menu_html.=''; - if (exists($menu_item->{'url'})) { - $menu_html.=qq{}; - } else { - $menu_html.= - qq{}; } - $menu_html.= &mt($menu_item->{'text'}).''; - $menu_html.='
'; - } - return $menu_html; } sub restore_prev_selections { @@ -4469,7 +4351,6 @@ sub restore_prev_selections { sub print_selfenroll_menu { my ($r,$context,$permission) = @_; - my $crstype = &Apache::loncommon::course_type(); my $formname = 'enrollstudent'; my $nolink = 1; my ($row,$lt) = &get_selfenroll_titles(); @@ -4682,9 +4563,7 @@ ENDSCRIPT if (ref($lt) eq 'HASH') { $title = $lt->{$item}; } - $output .= - &Apache::lonhtmlcommon::row_title($title, - 'LC_selfenroll_pick_box_title','LC_oddrow_value')."\n"; + $output .= &Apache::lonhtmlcommon::row_title($title); if ($item eq 'types') { my $curr_types = $env{'course.'.$env{'request.course.id'}.'.internal.selfenroll_types'}; my $showdomdesc = 1; @@ -4833,12 +4712,8 @@ ENDSCRIPT &mt('No').''; my %advhash = &Apache::lonnet::get_course_adv_roles($cid,1); my (@ccs,%notified); - my $ccrole = 'cc'; - if ($crstype eq 'Community') { - $ccrole = 'co'; - } - if ($advhash{$ccrole}) { - @ccs = split(/,/,$advhash{$ccrole}); + if ($advhash{'cc'}) { + @ccs = split(/,/,$advhash{'cc'}); } if ($currnotified) { foreach my $current (split(/,/,$currnotified)) { @@ -5183,13 +5058,6 @@ sub print_userchangelogs_display { my (%whodunit,%changed,$version); ($version) = ($r->dir_config('lonVersion') =~ /^([\d\.]+)\-/); $r->print(&role_display_filter($formname,$cdom,$cnum,\%curr,$version,$crstype)); - my $showntablehdr = 0; - my $tablehdr = &Apache::loncommon::start_data_table(). - &Apache::loncommon::start_data_table_header_row(). - '' + .&mt('There are no records to display.') + .'
' + ); + $r->print($form_footer); + return; } - if ($showntablehdr) { - $r->print(&Apache::loncommon::end_data_table().''.&mt('Previous [_1] changes',$curr{'show'}).' | '); - } - if ($more_records) { - $r->print(''.&mt('Next [_1] changes',$curr{'show'}).' | '); - } - $r->print('
'. - &mt('There are no records to display'). - '
'); - } - $r->print(''. - ''); + # Navigation Buttons + my $nav_links; + $nav_links = ''; + if (($curr{'page'} > 1) || ($more_records)) { + if ($curr{'page'} > 1) { + $nav_links .= ' '; + } + if ($more_records) { + $nav_links .= ''; + } + } + $nav_links .= '
'; + + # Table Header + my $tableheader = + &Apache::loncommon::start_data_table_header_row() + .''.&mt('After:'). - ' | '.$startform.' |
'.&mt('Before:').' | '. - $endform.' |
'.&mt('After:'). + ' | '.$startform.' |
'.&mt('Before:').' | '. + ''.$endform.' |