--- loncom/interface/lonuserutils.pm 2009/11/04 15:35:56 1.103
+++ loncom/interface/lonuserutils.pm 2010/01/05 22:08:48 1.109.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Utility functions for managing LON-CAPA user accounts
#
-# $Id: lonuserutils.pm,v 1.103 2009/11/04 15:35:56 raeburn Exp $
+# $Id: lonuserutils.pm,v 1.109.2.2 2010/01/05 22:08:48 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -386,7 +386,7 @@ 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'}."'$crstype'".');';
+ $setsection_call = 'setSections(document.'.$param{'formname'}.",'$crstype'".');';
$setsections_js =
&setsections_javascript($param{'formname'},$groupslist,
$mode,'',$crstype);
@@ -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(
@@ -1185,8 +1185,10 @@ sub default_role_selector {
'exs' => "Existing sections",
'new' => "New section",
);
- $options = ''."\n".
- ' '.&mt('Please select').' '."\n";
+ $options = ''."\n";
+ unless (($context eq 'course') && (&Apache::loncommon::needs_gci_custom())) {
+ $options .= ' '.&mt('Please select').' '."\n";
+ }
if ($context eq 'course') {
$options .= &default_course_roles($context,$checkpriv,$crstype,%customroles);
} elsif ($context eq 'author') {
@@ -1350,10 +1352,14 @@ sub curr_role_permissions {
# ======================================================= Existing Custom Roles
sub my_custom_roles {
+ my ($crstype) = @_;
my %returnhash=();
my %rolehash=&Apache::lonnet::dump('roles');
- foreach my $key (keys %rolehash) {
+ foreach my $key (keys(%rolehash)) {
if ($key=~/^rolesdef\_(\w+)$/) {
+ if ($crstype eq 'Community') {
+ next if ($rolehash{$key} =~ /bre\&S/);
+ }
$returnhash{$1}=$1;
}
}
@@ -1442,12 +1448,13 @@ sub print_userlist {
' ');
return;
}
- if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) {
+ if (!(($context eq 'domain') &&
+ (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) {
$r->print(' '.&list_submit_button(&mt('Update Display')).
"\n
\n");
}
my ($indexhash,$keylist) = &make_keylist_array();
- my (%userlist,%userinfo);
+ my (%userlist,%userinfo,$clearcoursepick);
if (($context eq 'domain') &&
($env{'form.roletype'} eq 'course') ||
($env{'form.roletype'} eq 'community')) {
@@ -1472,9 +1479,15 @@ sub print_userlist {
$courseform."\n".
&Apache::lonhtmlcommon::row_closure(1).
&Apache::lonhtmlcommon::end_pick_box().''.
- ''.&list_submit_button(&mt('Update Display')).
+ '
'.
+ &list_submit_button(&mt('Update Display')).
"\n".'
'.$warning.' '."\n");
- if ($env{'form.coursepick'}) {
+ $clearcoursepick = 0;
+ if (($env{'form.origroletype'} ne '') &&
+ ($env{'form.origroletype'} ne $env{'form.roletype'})) {
+ $clearcoursepick = 1;
+ }
+ if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
$r->print(' '.&mt('Searching').' ... ');
}
} else {
@@ -1549,7 +1562,7 @@ sub print_userlist {
}
} elsif (($env{'form.roletype'} eq 'course') ||
($env{'form.roletype'} eq 'community')) {
- if ($env{'form.coursepick'}) {
+ if (($env{'form.coursepick'}) && (!$clearcoursepick)) {
my %courses = &process_coursepick();
my %allusers;
my $hidepriv = 1;
@@ -1952,13 +1965,17 @@ sub process_coursepick {
my $coursefilter = $env{'form.coursepick'};
my $cdom = $env{'request.role.domain'};
my %courses;
+ my $crssrch = 'Course';
+ if ($env{'form.roletype'} eq 'community') {
+ $crssrch = 'Community';
+ }
if ($coursefilter eq 'all') {
%courses = &Apache::lonnet::courseiddump($cdom,'.','.','.','.','.',
- undef,undef,'Course');
+ undef,undef,$crssrch);
} elsif ($coursefilter eq 'category') {
my $instcode = &instcode_from_coursefilter();
%courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.',
- undef,undef,'Course');
+ undef,undef,$crssrch);
} elsif ($coursefilter eq 'specific') {
if ($env{'form.coursetotal'} > 1) {
my @course_ids = split(/&&/,$env{'form.courselist'});
@@ -2143,7 +2160,7 @@ END
} elsif ($context eq 'domain') {
if ($setting eq 'community') {
$crstype = 'Community';
- } elsif ($crstype eq 'course') {
+ } elsif ($setting eq 'course') {
$crstype = 'Course';
}
}
@@ -2294,7 +2311,11 @@ END
if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') {
if ($mode ne 'autoenroll' && $mode ne 'pickauthor') {
if ($permission->{'cusr'}) {
- $actionselect = &select_actions($context,$setting,$statusmode,$formname);
+ unless (($context eq 'domain') &&
+ (($setting eq 'course') || ($setting eq 'community'))) {
+ $actionselect =
+ &select_actions($context,$setting,$statusmode,$formname);
+ }
}
$r->print(<
@@ -2388,11 +2409,7 @@ END
$lt{'type'}
";
} else {
- if ($mode eq 'pickauthor') {
- $output .= "\n".' '."\n";
- } else {
- $output .= "\n".''.&mt('Count').' '."\n";
- }
+ $output .= "\n".' '."\n";
if ($actionselect) {
$output .= ''.&mt('Select').' '."\n";
}
@@ -2447,9 +2464,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;
}
#
@@ -3636,27 +3657,19 @@ sub print_first_users_upload_form {
$str .= ' ';
$str .= ' ';
- $str .= ''.&mt('Upload a file containing information about users').' '."\n";
+ $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";
-
+ .'
'."\n";
$str .= &Apache::lonhtmlcommon::start_pick_box()
- .&Apache::lonhtmlcommon::row_title(&mt('File'));
- if (&Apache::lonlocal::current_language() ne 'en') {
- if ($context eq 'course') {
- $str .= ''."\n"
- .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n"
- .'
'."\n";
- }
- }
- $str .= &Apache::loncommon::upfile_select_html()
+ .&Apache::lonhtmlcommon::row_title(&mt('File'))
+ .&Apache::loncommon::upfile_select_html()
.&Apache::lonhtmlcommon::row_closure()
.&Apache::lonhtmlcommon::row_title(
''
@@ -3670,8 +3683,6 @@ sub print_first_users_upload_form {
.' '
.'';
- $str .= &Apache::loncommon::end_page();
-
$r->print($str);
return;
}
@@ -3900,7 +3911,7 @@ sub upfile_drop_add {
}
}
my (%curr_rules,%got_rules,%alerts);
- my %customroles = &my_custom_roles();
+ my %customroles = &my_custom_roles($crstype);
my @permitted_roles =
&roles_on_upload($context,$setting,$crstype,%customroles);
# Get new users list
@@ -5014,14 +5025,22 @@ sub roles_by_context {
if ($env{'request.role'} =~ m{^dc\./}) {
push(@allroles,'ad');
}
- push(@allroles,('ta','ep','in'));
- if ($crstype eq 'Community') {
- push(@allroles,'co');
+ if (&Apache::loncommon::needs_gci_custom()) {
+ if ($crstype eq 'Community') {
+ push(@allroles,'co');
+ } else {
+ push(@allroles,'cc');
+ }
} else {
- push(@allroles,'cc');
- }
- if ($custom) {
- push(@allroles,'cr');
+ push(@allroles,('ta','ep','in'));
+ if ($crstype eq 'Community') {
+ push(@allroles,'co');
+ } else {
+ push(@allroles,'cc');
+ }
+ if ($custom) {
+ push(@allroles,'cr');
+ }
}
} elsif ($context eq 'author') {
@allroles = ('ca','aa');