--- loncom/interface/lonuserutils.pm 2010/01/20 20:40:43 1.97.2.10 +++ loncom/interface/lonuserutils.pm 2009/11/04 15:35:56 1.103 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.97.2.10 2010/01/20 20:40:43 raeburn Exp $ +# $Id: lonuserutils.pm,v 1.103 2009/11/04 15:35:56 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -387,7 +387,6 @@ sub javascript_validations { if ($context eq 'course') { if ($env{'request.course.sec'} eq '') { $setsection_call = 'setSections(document.'.$param{'formname'}."'$crstype'".');'; - $setsections_js = &setsections_javascript($param{'formname'},$groupslist, $mode,'',$crstype); @@ -1142,7 +1141,7 @@ sub date_setting_table { } sub make_dates_default { - my ($startdate,$enddate,$context,$crstype = @_; + my ($startdate,$enddate,$context,$crstype) = @_; my $result = ''; if ($context eq 'course') { my ($cnum,$cdom) = &get_course_identity(); @@ -1177,7 +1176,7 @@ sub default_role_selector { my %customroles; my ($options,$coursepick,$cb_jscript); if ($context ne 'author') { - %customroles = &my_custom_roles($crstype); + %customroles = &my_custom_roles(); } my %lt=&Apache::lonlocal::texthash( @@ -1351,14 +1350,10 @@ 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; } } @@ -1447,15 +1442,14 @@ sub print_userlist { ''); return; } - if (!(($context eq 'domain') && - (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')))) { + if (!(($context eq 'domain') && ($env{'form.roletype'} eq 'course'))) { $r->print(' '.&list_submit_button(&mt('Update Display')). "\n

\n"); } my ($indexhash,$keylist) = &make_keylist_array(); - my (%userlist,%userinfo,$clearcoursepick); + my (%userlist,%userinfo); if (($context eq 'domain') && - ($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')) { my ($crstype,$numcodes,$title,$warning); if ($env{'form.roletype'} eq 'course') { @@ -1478,15 +1472,9 @@ 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"); - $clearcoursepick = 0; - if (($env{'form.origroletype'} ne '') && - ($env{'form.origroletype'} ne $env{'form.roletype'})) { - $clearcoursepick = 1; - } - if (($env{'form.coursepick'}) && (!$clearcoursepick)) { + if ($env{'form.coursepick'}) { $r->print('
'.&mt('Searching').' ...
 
'); } } else { @@ -1559,8 +1547,9 @@ sub print_userlist { } } } - } elsif ($env{'form.roletype'} eq 'course') { - if (($env{'form.coursepick'}) && (!$clearcoursepick)) { + } elsif (($env{'form.roletype'} eq 'course') || + ($env{'form.roletype'} eq 'community')) { + if ($env{'form.coursepick'}) { my %courses = &process_coursepick(); my %allusers; my $hidepriv = 1; @@ -1963,17 +1952,13 @@ 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,$crssrch); + undef,undef,'Course'); } elsif ($coursefilter eq 'category') { my $instcode = &instcode_from_coursefilter(); %courses = &Apache::lonnet::courseiddump($cdom,'.','.',$instcode,'.','.', - undef,undef,$crssrch); + undef,undef,'Course'); } elsif ($coursefilter eq 'specific') { if ($env{'form.coursetotal'} > 1) { my @course_ids = split(/&&/,$env{'form.courselist'}); @@ -2158,7 +2143,7 @@ END } elsif ($context eq 'domain') { if ($setting eq 'community') { $crstype = 'Community'; - } elsif ($setting eq 'course') { + } elsif ($crstype eq 'course') { $crstype = 'Course'; } } @@ -2271,7 +2256,7 @@ END push(@cols,'section'); } if (!($context eq 'domain' && ($env{'form.roletype'} eq 'course') - && ($env{'form.roletype'} eq 'community'))) { + && ($env{'form.roletype'} eq 'community'))) { push(@cols,('start','end')); } if ($env{'form.showrole'} eq 'Any' || $env{'form.showrole'} eq 'cr') { @@ -2282,7 +2267,7 @@ END $env{'form.roletype'} eq 'community')) { push (@cols,'extent'); } - if (($statusmode eq 'Any') && + if (($statusmode eq 'Any') && (!($context eq 'domain' && (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community'))))) { push(@cols,'status'); @@ -2297,24 +2282,19 @@ END if ($env{'form.showrole'} eq 'cr') { $rolefilter = &mt('custom'); } elsif ($env{'form.showrole'} ne 'Any') { - $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'}); + $rolefilter = &Apache::lonnet::plaintext($env{'form.showrole'},$crstype); } my $results_description; if ($mode ne 'autoenroll') { $results_description = &results_header_row($rolefilter,$statusmode, $context,$permission,$mode,$crstype); - $r->print(''.$results_description.'

'); } my ($output,$actionselect,%canchange,%canchangesec); if ($mode eq 'html' || $mode eq 'view' || $mode eq 'autoenroll' || $mode eq 'pickauthor') { if ($mode ne 'autoenroll' && $mode ne 'pickauthor') { if ($permission->{'cusr'}) { - unless (($context eq 'domain') && - (($setting eq 'course') || ($setting eq 'community'))) { - $actionselect = - &select_actions($context,$setting,$statusmode,$formname); - } + $actionselect = &select_actions($context,$setting,$statusmode,$formname); } $r->print(< @@ -2325,7 +2305,7 @@ END END if ($actionselect) { $output .= <<"END"; -
$lt{'ac'} +
$lt{'ac'} $actionselect

 
@@ -2370,7 +2350,7 @@ END } } } - $output .= '
'.$lt{'link'}.''. + $output .= '
'.$lt{'link'}.''. ''; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { @@ -2381,6 +2361,7 @@ END $env{'request.course.sec'})) { push(@linkdests,'track'); } + $output .= ' "; } else { - $output .= "\n".''."\n"; + if ($mode eq 'pickauthor') { + $output .= "\n".''."\n"; + } else { + $output .= "\n".''."\n"; + } if ($actionselect) { $output .= ''."\n"; } @@ -2462,13 +2447,9 @@ 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.') - .' '.&mt('This error has been logged.') - .' '.&mt('Please alert your LON-CAPA administrator.') - .'

' - ); + $r->print(&mt('Problems occurred in writing the CSV file. ' + .'This error has been logged. ' + .'Please alert your LON-CAPA administrator.')); $CSVfile = undef; } # @@ -2650,7 +2631,7 @@ END if ($clickers!~/\w/) { $clickers='-'; } $in{'clicker'} = $clickers; my $role = $in{'role'}; - $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); + $in{'role'}=&Apache::lonnet::plaintext($sdata->[$index{'role'}],$crstype); if (! defined($in{'start'}) || $in{'start'} == 0) { $in{'start'} = &mt('none'); } else { @@ -2949,7 +2930,6 @@ sub role_type_names { 'author' => 'Co-Author Roles', 'course' => 'Course Roles', 'community' => 'Community Roles', - ); return %lt; } @@ -3404,7 +3384,6 @@ sub results_header_row { } } elsif (($env{'form.roletype'} eq 'course') || ($env{'form.roletype'} eq 'community')) { - my $coursefilter = $env{'form.coursepick'}; if ($env{'form.roletype'} eq 'course') { if ($coursefilter eq 'category') { @@ -3657,20 +3636,27 @@ sub print_first_users_upload_form { $str .= ''; $str .= ''; - $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')) - .&Apache::loncommon::upfile_select_html() + .&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_closure() .&Apache::lonhtmlcommon::row_title( '
'; my $usernamelink = $env{'form.usernamelink'}; if ($usernamelink eq '') { @@ -2407,7 +2388,11 @@ END $lt{'type'}  '.&mt('Count').''.&mt('Select').'