--- loncom/interface/lonuserutils.pm 2009/10/31 14:27:48 1.102
+++ loncom/interface/lonuserutils.pm 2010/01/20 16:46:23 1.114
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.102 2009/10/31 14:27:48 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.114 2010/01/20 16:46:23 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -91,7 +91,7 @@ sub modifyuserrole {
if ($setting eq 'course' || $context eq 'course') {
$scope = '/'.$cid;
$scope =~ s/\_/\//g;
- if ($role ne 'cc' && $sec ne '') {
+ if (($role ne 'cc') && ($role ne 'co') && ($sec ne '')) {
$scope .='/'.$sec;
}
} elsif ($context eq 'domain') {
@@ -295,7 +295,7 @@ sub hidden_input {
}
sub print_upload_manager_header {
- my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission)=@_;
+ my ($r,$datatoken,$distotal,$krbdefdom,$context,$permission,$crstype)=@_;
my $javascript;
#
if (! exists($env{'form.upfile_associate'})) {
@@ -332,7 +332,7 @@ sub print_upload_manager_header {
my $javascript_validations =
&javascript_validations('upload',$krbdefdom,$password_choice,undef,
$env{'request.role.domain'},$context,
- $groupslist);
+ $groupslist,$crstype);
my $checked=(($env{'form.noFirstLine'})?' checked="checked"':'');
$r->print('
'
.&mt('Total number of records found in file: [_1]'
@@ -365,7 +365,7 @@ sub print_upload_manager_header {
###############################################################
sub javascript_validations {
my ($mode,$krbdefdom,$curr_authtype,$curr_authfield,$domain,
- $context,$groupslist)=@_;
+ $context,$groupslist,$crstype)=@_;
my %param = (
kerb_def_dom => $krbdefdom,
curr_authtype => $curr_authtype,
@@ -386,10 +386,10 @@ sub javascript_validations {
if (($context eq 'course') || ($context eq 'domain')) {
if ($context eq 'course') {
if ($env{'request.course.sec'} eq '') {
- $setsection_call = 'setSections(document.'.$param{'formname'}.');';
+ $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
$setsections_js =
&setsections_javascript($param{'formname'},$groupslist,
- $mode);
+ $mode,'',$crstype);
} else {
$setsection_call = "'ok'";
}
@@ -830,7 +830,7 @@ sub print_upload_manager_footer {
.' '.&mt('Add a domain role').''
.' '
+ .' '.&mt('Add a course/community role').''
.'';
} elsif ($context eq 'author') {
$Str .= &Apache::lonhtmlcommon::row_title(
@@ -899,7 +899,7 @@ sub print_upload_manager_footer {
.'
';
if ($context eq 'course') {
$Str .= '
'
- .&mt('Note: For large courses, this operation may be time consuming.')
+ .&mt('Note: This operation may be time consuming when adding several users.')
.'
';
}
$Str .= '
=0) {
@@ -1176,7 +1176,7 @@ sub default_role_selector {
my %customroles;
my ($options,$coursepick,$cb_jscript);
if ($context ne 'author') {
- %customroles = &my_custom_roles();
+ %customroles = &my_custom_roles($crstype);
}
my %lt=&Apache::lonlocal::texthash(
@@ -1202,16 +1202,16 @@ sub default_role_selector {
$options .= ' ';
}
my $courseform = &Apache::loncommon::selectcourse_link
- ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course');
+ ('studentform','dccourse','dcdomain','coursedesc',"$env{'request.role.domain'}",undef,'Course/Community');
$cb_jscript =
- &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform');
+ &Apache::loncommon::coursebrowser_javascript($env{'request.role.domain'},'currsec','studentform','courserole','Course/Community');
$coursepick = &Apache::loncommon::start_data_table().
&Apache::loncommon::start_data_table_header_row().
'
'."\n";
}
@@ -2446,9 +2468,13 @@ END
time.'_'.rand(1000000000).'.csv';
unless ($CSVfile = Apache::File->new('>/home/httpd'.$CSVfilename)) {
$r->log_error("Couldn't open $CSVfilename for output $!");
- $r->print(&mt('Problems occurred in writing the CSV file. '
- .'This error has been logged. '
- .'Please alert your LON-CAPA administrator.'));
+ $r->print(
+ '
'
+ .&mt('Problems occurred in writing the CSV file.')
+ .' '.&mt('This error has been logged.')
+ .' '.&mt('Please alert your LON-CAPA administrator.')
+ .'
'
+ );
$CSVfile = undef;
}
#
@@ -2917,7 +2943,7 @@ sub print_username_link {
$output = $in->{'username'};
} else {
$output = '{'username'}','$in->{'domain'}'".')" />'.
+ "'$in->{'username'}','$in->{'domain'}'".')">'.
$in->{'username'}.'';
}
return $output;
@@ -3090,7 +3116,7 @@ END
} else {
opener.document.$callingform.retainsec.value = formname.retainsec.value;
}
- setSections(formname);
+ setSections(formname,'$crstype');
if (seccheck == 'ok') {
opener.document.$callingform.newsecs.value = formname.sections.value;
}
@@ -3150,7 +3176,7 @@ ENDJS
fors => 'For student roles changing the section, will result in a section switch as students may only be in one section of a course at a time.',
forn => 'For a role in a course that is not a student role, a user may have roles in more than one section of a course at a time.',
reta => "Retain each user's current section affiliations?",
- dnap => '(Does not apply to student roles).',
+ dnap => '(Does not apply to student roles).',
);
my ($date_items,$headertext);
if ($env{'form.bulkaction'} eq 'chgsec') {
@@ -3171,7 +3197,11 @@ ENDJS
$date_items;
if ($context eq 'course' && $env{'form.bulkaction'} eq 'chgsec') {
my ($cnum,$cdom) = &get_course_identity();
- my $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
+ $lt{'fors'} = &mt('For member roles changing the section, will result in a section switch as members may only be in one section of a community at a time.');
+ $lt{'forn'} = &mt('For a role in a community that is not a member role, a user may have roles in more than one section of a community at a time.');
+ $lt{'dnap'} = &mt('(Does not apply to member roles).');
+ }
my $info;
if ($env{'form.showrole'} eq 'st') {
$output .= '
'.$lt{'fors'}.'
';
@@ -3288,7 +3318,7 @@ sub results_header_row {
if ($viewablesec ne '') {
if ($env{'form.showrole'} eq 'st') {
$constraint = &mt('only users in section "[_1]"',$viewablesec);
- } elsif ($env{'form.showrole'} ne 'cc') {
+ } elsif (($env{'form.showrole'} ne 'cc') && ($env{'form.showrole'} ne 'co')) {
$constraint = &mt('only users affiliated with no section or section "[_1]"',$viewablesec);
}
if (($env{'form.grpfilter'} ne 'all') && ($env{'form.grpfilter'} ne '')) {
@@ -3633,20 +3663,23 @@ sub print_first_users_upload_form {
$str .= '
'.&mt('Upload a file containing information about users').'
'."\n";
# Excel and CSV Help
- $str .= '
'
+ $str .= '
'
.&Apache::loncommon::help_open_topic("Course_Create_Class_List",
&mt("How do I create a users list from a spreadsheet"))
- ." \n"
+ .'
'."\n"
.&Apache::loncommon::help_open_topic("Course_Convert_To_CSV",
&mt("How do I create a CSV file from a spreadsheet"))
- ."\n";
-
+ .'