--- loncom/interface/loncreateuser.pm 2012/11/30 15:09:17 1.367
+++ loncom/interface/loncreateuser.pm 2013/02/19 17:30:35 1.374
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Create a user
#
-# $Id: loncreateuser.pm,v 1.367 2012/11/30 15:09:17 goltermann Exp $
+# $Id: loncreateuser.pm,v 1.374 2013/02/19 17:30:35 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -111,11 +111,11 @@ sub initialize_authen_forms {
sub auth_abbrev {
my %abv_auth = (
- krb5 => 'krb',
- krb4 => 'krb',
- internal => 'int',
- localuth => 'loc',
- unix => 'fsys',
+ krb5 => 'krb',
+ krb4 => 'krb',
+ internal => 'int',
+ localauth => 'loc',
+ unix => 'fsys',
);
return %abv_auth;
}
@@ -1319,7 +1319,7 @@ ENDAUTH
$r->print($portfolioform.$domroleform);
if ($env{'form.action'} eq 'singlestudent') {
$r->print(&date_sections_select($context,$newuser,$formname,
- $permission));
+ $permission,$crstype));
}
$r->print('
');
} else { # user already exists
@@ -1421,8 +1421,9 @@ ENDNOTOOLSPRIV
unless ($gotdiv) {
$r->print('');
}
- $r->print(&date_sections_select($context,$newuser,$formname));
- }
+ $r->print(&date_sections_select($context,$newuser,$formname,
+ $permission,$crstype));
+ }
if ($gotdiv) {
$r->print('
');
}
@@ -1495,7 +1496,7 @@ sub singleuser_breadcrumb {
}
sub date_sections_select {
- my ($context,$newuser,$formname,$permission) = @_;
+ my ($context,$newuser,$formname,$permission,$crstype) = @_;
my $cid = $env{'request.course.id'};
my ($cnum,$cdom) = &Apache::lonuserutils::get_course_identity($cid);
my $date_table = ''.&mt('Starting and Ending Dates').'
'."\n".
@@ -1504,7 +1505,7 @@ sub date_sections_select {
my $rowtitle = 'Section';
my $secbox = ''.&mt('Section').'
'."\n".
&Apache::lonuserutils::section_picker($cdom,$cnum,'st',$rowtitle,
- $permission);
+ $permission,$context,'',$crstype);
my $output = $date_table.$secbox;
return $output;
}
@@ -1672,7 +1673,7 @@ sub display_existing_roles {
}
}
if ($area=~m{^/($match_domain)/($match_courseid)/(\w+)}) {
- $carea.='
Section: '.$3;
+ $carea.='
'.&mt('Section: [_1]',$3);
$sortkey.="\0$3";
if (!$allowed) {
if ($env{'request.course.sec'} eq $3) {
@@ -3062,7 +3063,7 @@ sub display_userinfo {
ref($newsetting) eq 'HASH' &&
ref($newsettingtext) eq 'HASH');
my %lt=&Apache::lonlocal::texthash(
- 'ui' => 'User Information (unchanged)',
+ 'ui' => 'User Information',
'uic' => 'User Information Changed',
'firstname' => 'First Name',
'middlename' => 'Middle Name',
@@ -3083,10 +3084,8 @@ sub display_userinfo {
'prvs' => 'Previous Value:',
'chto' => 'Changed To:'
);
- my $title = $lt{'ui'};
if ($changed) {
- $title = $lt{'uic'};
- $r->print(''.$title.'
'.
+ $r->print(''.$lt{'uic'}.'
'.
&Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row());
$r->print(" | \n");
@@ -3145,6 +3144,9 @@ sub display_userinfo {
}
}
$r->print(&Apache::loncommon::end_data_table().'
');
+ } else {
+ $r->print(''.$lt{'ui'}.'
'.
+ ''.&mt('No changes made to user information').'
');
}
return;
}
@@ -3343,8 +3345,13 @@ sub update_roles {
$env{'form.ccuname'},
$scope,$role,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
- &mt('Revoking [_1] in [_2]', &Apache::lonnet::plaintext($role), '"'.&cid_to_cname($scope).'"
'),
- $result ne "ok"));
+ &mt('Revoking [_1] in [_2]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
@@ -3358,10 +3365,15 @@ sub update_roles {
}
if ($key=~m{^form\.rev\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}s) {
# Revoke custom role
+ my $result = &Apache::lonnet::revokecustomrole(
+ $env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
- &mt('Revoking custom role [_1] by [_2]:[_3] in [_4]',$4,$3,$2,'"'.&cid_to_cname($1).'"
'),
- &Apache::lonnet::revokecustomrole($env{'form.ccdomain'},$env{'form.ccuname'},$1,$2,$3,$4,'','',$context) ne 'ok'));
-
+ &mt('Revoking custom role [_1] by [_2] in [_3]',
+ $4,$3.':'.$2,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3377,14 +3389,19 @@ sub update_roles {
$context);
$r->print(&Apache::lonhtmlcommon::confirm_success(
&mt('Deleting [_1] in [_2]',
- &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($scope).'"
'),$result ne 'ok'));
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($scope,$context,$role)),
+ $result ne 'ok').'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if ($role eq 'st') {
my $result =
&Apache::lonuserutils::classlist_drop($scope,
$env{'form.ccuname'},$env{'form.ccdomain'},
$now);
- $r->print($result);
+ $r->print(&Apache::lonhtmlcommon::confirm_success($result));
}
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3393,11 +3410,16 @@ sub update_roles {
if ($key=~m{^form\.del\:([^_]+)_cr\.cr/($match_domain)/($match_username)/(\w+)$}) {
my ($url,$rdom,$rnam,$rolename) = ($1,$2,$3,$4);
# Delete custom role
- $r->print(&confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'));
- &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
- $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
- 0,1,$context);
+ my $result =
+ &Apache::lonnet::assigncustomrole($env{'form.ccdomain'},
+ $env{'form.ccuname'},$url,$rdom,$rnam,$rolename,$now,
+ 0,1,$context);
+ $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Deleting custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
@@ -3414,16 +3436,19 @@ sub update_roles {
my $output;
if ($role eq 'st') {
if ($url =~ m-^/($match_domain)/($match_courseid)/?(\w*)$-) {
- my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$1,$2,$3);
+ my ($cdom,$cnum,$csec) = ($1,$2,$3);
+ my $result = &Apache::loncommon::commit_studentrole(\$logmsg,$udom,$uname,$url,$role,$now,0,$cdom,$cnum,$csec,$context);
if (($result =~ /^error/) || ($result eq 'not_in_class') || ($result eq 'unknown_course') || ($result eq 'refused')) {
if ($result eq 'refused' && $logmsg) {
$output = $logmsg;
} else {
- $output = "Error: $result\n";
+ $output = &mt('Error: [_1]',$result)."\n";
}
} else {
- $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',&Apache::lonnet::plaintext($role),
- '"'.&cid_to_cname($url).'"',&Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
+ $output = &Apache::lonhtmlcommon::confirm_success(&mt('Assigning [_1] in [_2] starting [_3]',
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,'st'),
+ &Apache::lonlocal::locallocaltime($now))).'
'.$logmsg.'
';
}
}
} else {
@@ -3431,8 +3456,12 @@ sub update_roles {
$env{'form.ccuname'},$url,$role,0,$now,'','',
$context);
$output = &Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling [_1] in [_2]',
- &Apache::lonnet::plaintext($role),'"'.&cid_to_cname($url).'"').'
',$result ne "ok");
- }
+ &Apache::lonnet::plaintext($role),
+ &Apache::loncommon::show_role_extent($url,$context,$role)),$result ne "ok").'
';
+ if ($result ne "ok") {
+ $output .= &mt('Error: [_1]',$result).'
';
+ }
+ }
$r->print($output);
if (!grep(/^\Q$role\E$/,@rolechanges)) {
push(@rolechanges,$role);
@@ -3444,8 +3473,13 @@ sub update_roles {
my $result = &Apache::lonnet::assigncustomrole(
$env{'form.ccdomain'}, $env{'form.ccuname'},
$url,$rdom,$rnam,$rolename,0,$now,undef,$context);
- $r->print(&Apache::lonhtmlcommon::confirm_success(&mt('Re-enabling custom role [_1] by [_2] in [_3]',
- $rolename,$rnam.':'.$rdom,'"'.&cid_to_cname($1).'"').'
'),$result ne "ok");
+ $r->print(&Apache::lonhtmlcommon::confirm_success(
+ &mt('Re-enabling custom role [_1] by [_2] in [_3]',
+ $rolename,$rnam.':'.$rdom,&Apache::loncommon::show_role_extent($1,$context,'cr')),
+ $result ne "ok").'
');
+ if ($result ne "ok") {
+ $r->print(&mt('Error: [_1]',$result).'
');
+ }
if (!grep(/^cr$/,@rolechanges)) {
push(@rolechanges,'cr');
}
@@ -3585,7 +3619,7 @@ sub update_roles {
# Flush the course logs so reverse user roles immediately updated
$r->register_cleanup(\&Apache::lonnet::flushcourselogs);
if (@rolechanges == 0) {
- $r->print(&mt('No roles to modify'));
+ $r->print(''.&mt('No roles to modify').'
');
}
return @rolechanges;
}
@@ -4526,6 +4560,11 @@ sub add_script {
sub verify_user_display {
my ($context) = @_;
+ my %lt = &Apache::lonlocal::texthash (
+ course => 'course(s): description, section(s), status',
+ community => 'community(s): description, section(s), status',
+ author => 'author',
+ );
my $photos;
if (($context eq 'course') && $env{'request.course.id'}) {
$photos = $env{'course.'.$env{'request.course.id'}.'.internal.showphoto'};
@@ -4549,16 +4588,25 @@ function updateCols(caller) {
var context = '$context';
var photos = '$photos';
if (caller == 'Status') {
- if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
- document.getElementById('showcolstatus').checked = true;
- document.getElementById('showcolstatus').disabled = '';
- document.getElementById('showcolstart').checked = true;
- document.getElementById('showcolend').checked = true;
- } else {
+ if ((context == 'domain') &&
+ ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community'))) {
document.getElementById('showcolstatus').checked = false;
document.getElementById('showcolstatus').disabled = 'disabled';
document.getElementById('showcolstart').checked = false;
document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ } else {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ }
}
}
if (caller == 'output') {
@@ -4576,13 +4624,53 @@ function updateCols(caller) {
}
}
if (caller == 'showrole') {
- if (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') {
+ if ((document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'Any') ||
+ (document.studentform.showrole.options[document.studentform.showrole.selectedIndex].value == 'cr')) {
document.getElementById('showcolrole').checked = true;
document.getElementById('showcolrole').disabled = '';
} else {
document.getElementById('showcolrole').checked = false;
document.getElementById('showcolrole').disabled = 'disabled';
}
+ if (context == 'domain') {
+ if ((document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'course') ||
+ (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community')) {
+ document.getElementById('showcolstatus').checked = false;
+ document.getElementById('showcolstatus').disabled = 'disabled';
+ document.getElementById('showcolstart').checked = false;
+ document.getElementById('showcolend').checked = false;
+ } else {
+ if (document.studentform.Status.options[document.studentform.Status.selectedIndex].value == 'Any') {
+ document.getElementById('showcolstatus').checked = true;
+ document.getElementById('showcolstatus').disabled = '';
+ document.getElementById('showcolstart').checked = true;
+ document.getElementById('showcolend').checked = true;
+ }
+ }
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'domain') {
+ document.getElementById('showcolextent').disabled = 'disabled';
+ document.getElementById('showcolextent').checked = 'false';
+ document.getElementById('showextent').style.display='none';
+ document.getElementById('showcoltextextent').innerHTML = '';
+ } else {
+ document.getElementById('showextent').style.display='block';
+ document.getElementById('showextent').style.textAlign='left';
+ document.getElementById('showextent').style.textFace='normal';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'author') {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ document.getElementById('showcoltextextent').innerHTML="$lt{'author'}";
+ } else {
+ document.getElementById('showcolextent').disabled = '';
+ document.getElementById('showcolextent').checked = 'true';
+ if (document.studentform.roletype.options[document.studentform.roletype.selectedIndex].value == 'community') {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'community'}";
+ } else {
+ document.getElementById('showcoltextextent').innerHTML="$lt{'course'}";
+ }
+ }
+ }
+ }
}
return;
}
@@ -4826,6 +4914,7 @@ sub print_main_menu {
);
}
} elsif ($context eq 'author') {
+ push(@{ $menu[2]->{items} }, #Category: Administration
{
linktext => 'Change Log',
icon => 'document-properties.png',
@@ -4834,6 +4923,7 @@ sub print_main_menu {
permission => $permission->{'cusr'},
linktitle => 'View change log.',
},
+ );
}
return Apache::lonhtmlcommon::generate_menu(@menu);
# { text => 'View Log-in History',
@@ -6945,12 +7035,7 @@ sub get_selfenroll_titles {
#--------------------------------- functions for &phase_two and &phase_three
#--------------------------end of functions for &phase_two and &phase_three
-sub cid_to_cname(){
- my $courseid = shift;
- $courseid =~ s/^\///;
- $courseid =~ s/\//_/;
- return $env{'course.'.$courseid.'.description'};
-}
+
1;
__END__