--- loncom/interface/lonuserutils.pm 2009/04/22 16:44:36 1.87 +++ loncom/interface/lonuserutils.pm 2009/08/14 10:37:22 1.97 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Utility functions for managing LON-CAPA user accounts # -# $Id: lonuserutils.pm,v 1.87 2009/04/22 16:44:36 bisitz Exp $ +# $Id: lonuserutils.pm,v 1.97 2009/08/14 10:37:22 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -328,9 +328,11 @@ sub print_upload_manager_header { &javascript_validations('upload',$krbdefdom,$password_choice,undef, $env{'request.role.domain'},$context, $groupslist); - my $checked=(($env{'form.noFirstLine'})?' checked="checked" ':''); - $r->print(&mt('Total number of records found in file: [_1]','<b>'.$distotal.'</b>'). - "<br />\n"); + my $checked=(($env{'form.noFirstLine'})?' checked="checked"':''); + $r->print('<p>' + .&mt('Total number of records found in file: [_1]' + ,'<b>'.$distotal.'</b>') + ."</p>\n"); $r->print('<div class="LC_left_float"><h3>'. &mt('Identify fields in uploaded list')."</h3>\n"); $r->print(&mt('Enter as many fields as you can.<br /> The system will inform you and bring you back to this page, <br /> if the data selected are insufficient to add users.')."<br />\n"); @@ -345,10 +347,13 @@ sub print_upload_manager_header { &mt('Ignore First Line').'</label><br />'); $r->print('<br /><input type="button" value="'.&mt('Reverse Association').'" '. 'name="Reverse Association" '. - 'onClick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'); + 'onclick="javascript:this.form.associate.value=\'Reverse Association\';submit(this.form);" />'); $r->print("<br /><br />\n". '<script type="text/javascript" language="Javascript">'."\n". - $javascript."\n".$javascript_validations.'</script>'); + '// <![CDATA['."\n". + $javascript."\n".$javascript_validations."\n". + '// ]]>'."\n". + '</script>'); } ############################################################### @@ -401,7 +406,7 @@ sub javascript_validations { krb => 'You need to specify the Kerberos domain.', ipass => 'You need to specify the initial password.', name => 'The optional name field was not specified.', - snum => 'The optional ID number field was not specified.', + snum => 'The optional student/employee ID field was not specified.', section => 'The optional section field was not specified.', email => 'The optional e-mail address field was not specified.', role => 'The optional role field was not specified.', @@ -757,78 +762,134 @@ sub print_upload_manager_footer { my $locform = &Apache::loncommon::authform_local(%param); my $date_table = &date_setting_table(undef,undef,$context,undef, $formname,$permission); + my $Str = "\n".'<div class="LC_left_float">'; $Str .= &hidden_input('nfields',$i); $Str .= &hidden_input('keyfields',$keyfields); - $Str .= "<h3>".&mt('Login Type')."</h3>\n"; + + $Str .= '<h3>'.&mt('Options').'</h3>' + .&Apache::lonhtmlcommon::start_pick_box(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Login Type')); if ($context eq 'domain') { - $Str .= '<p>'.&mt('Change authentication for existing users in domain "[_1]" to these settings?',$defdom).' <span class="LC_nobreak"><label><input type="radio" name="changeauth" value="No" checked="checked" />'.&mt('No').'</label> <label><input type="radio" name="changeauth" value="Yes" />'.&mt('Yes').'</label></span></p>'; + $Str .= '<p>' + .&mt('Change authentication for existing users in domain "[_1]" to these settings?' + ,$defdom) + .' <span class="LC_nobreak"><label>' + .'<input type="radio" name="changeauth" value="No" checked="checked" />' + .&mt('No').'</label>' + .' <label>' + .'<input type="radio" name="changeauth" value="Yes" />' + .&mt('Yes').'</label>' + .'</span></p>'; } else { - $Str .= "<p>\n". - &mt('Note: This will not take effect if the user already exists.'). + $Str .= '<p class="LC_info">'."\n". + &mt('This will not take effect if the user already exists.'). &Apache::loncommon::help_open_topic('Auth_Options'). "</p>\n"; } $Str .= &set_login($defdom,$krbform,$intform,$locform); + my ($home_server_pick,$numlib) = &Apache::loncommon::home_server_form_item($defdom,'lcserver', 'default','hide'); if ($numlib > 1) { - $Str .= '<h3>'.&mt('LON-CAPA Home Server for New Users')."</h3>\n". - &mt('LON-CAPA domain: [_1] with home server: [_2]',$defdom, - $home_server_pick).'<br />'; - } else { - $Str .= $home_server_pick; - } - $Str .= '<h3>'.&mt('Default domain').'</h3>'."\n". - &Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1); - $Str .= '<h3>'.&mt('Starting and Ending Dates'). - "</h3>\n"; - $Str .= "<p>\n".$date_table."</p>\n"; + $Str .= &Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( + &mt('LON-CAPA Home Server for New Users')) + .&mt('LON-CAPA domain: [_1] with home server:','"'.$defdom.'"') + .$home_server_pick + .&Apache::lonhtmlcommon::row_closure(); + } else { + $Str .= $home_server_pick. + &Apache::lonhtmlcommon::row_closure(); + } + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Default domain')) + .&Apache::loncommon::select_dom_form($defdom,'defaultdomain',undef,1) + .&Apache::lonhtmlcommon::row_closure(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Starting and Ending Dates')) + ."<p>\n".$date_table."</p>\n" + .&Apache::lonhtmlcommon::row_closure(); + if ($context eq 'domain') { - $Str .= '<h3>'.&mt('Settings for assigning roles:').'</h3>'."\n". - &mt('Pick the action to take on roles for these users:').'<br /><span class="LC_nobreak"><label><input type="radio" name="roleaction" value="norole" checked="checked" /> '.&mt('No role changes').'</label> <label><input type="radio" name="roleaction" value="domain" /> '.&mt('Add a domain role').'</label> <label><input type="radio" name="roleaction" value="course" /> '.&mt('Add a course role').'</label></span>'; - } - if ($context eq 'author') { - $Str .= '<h3>'.&mt('Default role')."</h3>\n". - &mt('Choose the role to assign to users without a value specified in the uploaded file'); + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Settings for assigning roles')) + .&mt('Pick the action to take on roles for these users:').'<br />' + .'<span class="LC_nobreak"><label>' + .'<input type="radio" name="roleaction" value="norole" checked="checked" />' + .' '.&mt('No role changes').'</label>' + .' <label>' + .'<input type="radio" name="roleaction" value="domain" />' + .' '.&mt('Add a domain role').'</label>' + .' <label>' + .'<input type="radio" name="roleaction" value="course" />' + .' '.&mt('Add a course role').'</label>' + .'</span>'; + } elsif ($context eq 'author') { + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role')) + .&mt('Choose the role to assign to users without a value specified in the uploaded file.') } elsif ($context eq 'course') { - $Str .= '<h3>'.&mt('Default role and section')."</h3>\n". - &mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file'); - } else { - $Str .= '<br /><br /><b>'.&mt('Default role and/or section(s)')."</b><br />\n". - &mt('Role and/or section(s) for users without values specified in the uploaded file.'); + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role and section')) + .&mt('Choose the role and/or section(s) to assign to users without values specified in the uploaded file.'); + } else { + $Str .= &Apache::lonhtmlcommon::row_title( + &mt('Default role and/or section(s)')) + .&mt('Role and/or section(s) for users without values specified in the uploaded file.'); } - $Str .= '<br />'; if (($context eq 'domain') || ($context eq 'author')) { + $Str .= '<br />'; my ($options,$cb_script,$coursepick) = &default_role_selector($context,1); if ($context eq 'domain') { - $Str .= '<span class="LC_role_level">'.&mt('Domain Level').'</span><br />'.$options.'<br /><br /><span class="LC_role_level">'.&mt('Course Level').'</span><br />'.$cb_script.$coursepick; + $Str .= '<p>' + .'<b>'.&mt('Domain Level').'</b><br />' + .$options + .'</p><p>' + .'<b>'.&mt('Course Level').'</b>' + .'</p>' + .$cb_script.$coursepick + .&Apache::lonhtmlcommon::row_closure(); } elsif ($context eq 'author') { - $Str .= $options; + $Str .= $options + .&Apache::lonhtmlcommon::row_closure(1); # last row in pick_box } } else { my ($cnum,$cdom) = &get_course_identity(); my $rowtitle = &mt('section'); my $secbox = §ion_picker($cdom,$cnum,'Any',$rowtitle, $permission,$context,'upload'); - $Str .= $secbox."<h3>".&mt('Full Update')."</h3>\n". - '<p><label><input type="checkbox" name="fullup" value="yes" />'. - ' '.&mt('Display students with current/future access who are not in the uploaded file.').'</label><br />'.&mt('Students selected from this list can be dropped.').'</p>'."\n"; + $Str .= $secbox + .&Apache::lonhtmlcommon::row_closure(); + + $Str .= &Apache::lonhtmlcommon::row_title(&mt('Full Update')) + .'<label><input type="checkbox" name="fullup" value="yes" />'. + ' '.&mt('Display students with current/future access who are not in the uploaded file.') + .'</label><br />' + .&mt('Students selected from this list can be dropped.') + .&Apache::lonhtmlcommon::row_closure(); } if ($context eq 'course' || $context eq 'domain') { $Str .= &forceid_change($context); } + + $Str .= &Apache::lonhtmlcommon::end_pick_box(); $Str .= '</div>'; - $Str .= '<div class="LC_clear_float_footer">'; + + # Footer + $Str .= '<div class="LC_clear_float_footer">' + .'<hr />'; if ($context eq 'course') { - $Str .= '<div class="LC_info">' + $Str .= '<p class="LC_info">' .&mt('Note: For large courses, this operation may be time consuming.') - .'</div>'; + .'</p>'; } - $Str .= '<input type="button"' - .'onClick="javascript:verify(this.form,this.form.csec)" ' - .'value="'.&mt('Update Users').'" />'."\n" + $Str .= '<p><input type="button"' + .' onclick="javascript:verify(this.form,this.form.csec)"' + .' value="'.&mt('Update Users').'" />' + .'</p>'."\n" .'</div>'; $r->print($Str); return; @@ -837,18 +898,18 @@ sub print_upload_manager_footer { sub forceid_change { my ($context) = @_; my $output = - "<h3>".&mt('Student/Employee ID')."</h3>\n". - "<p>\n".'<label><input type="checkbox" name="forceid" value="yes" />'. - &mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs'). - '</label><br />'."\n". - &mt('(only do if you know what you are doing.)')."\n"; + &Apache::lonhtmlcommon::row_title(&mt('Student/Employee ID')) + .'<label><input type="checkbox" name="forceid" value="yes" />' + .&mt('Disable Student/Employee ID Safeguard and force change of conflicting IDs') + .'</label><br />'."\n" + .&mt('(only do if you know what you are doing.)')."\n"; if ($context eq 'domain') { $output .= '<br /><label><input type="checkbox" name="recurseid"'. ' value="yes" />'. - &mt('Update Student/Employee ID in courses in which user is active/future student,[_1](if forcing change).','<br />'). + &mt('Update student/employee ID in courses in which user is active/future student,[_1](if forcing change).','<br />'). '</label>'."\n"; } - $output .= '</p>'; + $output .= &Apache::lonhtmlcommon::row_closure(1); # last row in pick_box return $output; } @@ -1122,7 +1183,7 @@ sub default_role_selector { '<th>'.$lt{'grs'}.'</th>'. &Apache::loncommon::end_data_table_header_row(). &Apache::loncommon::start_data_table_row()."\n". - '<td><input type="text" name="coursedesc" value="" onFocus="this.blur();opencrsbrowser('."'studentform','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". + '<td><input type="text" name="coursedesc" value="" onfocus="this.blur();opencrsbrowser('."'studentform','dccourse','dcdomain','coursedesc',''".')" /></td>'."\n". '<td><select name="courserole">'."\n". &default_course_roles($context,$checkpriv,%customroles)."\n". '</select></td><td>'. @@ -1315,9 +1376,9 @@ sub print_userlist { 'html' => 'HTML'); my $output_selector = '<select size="1" name="output" >'; foreach my $outputformat ('html','csv','excel') { - my $option = '<option value="'.$outputformat.'" '; + my $option = '<option value="'.$outputformat.'"'; if ($outputformat eq $env{'form.output'}) { - $option .= 'selected '; + $option .= ' selected="selected"'; } $option .='>'.$lt{$outputformat}.'</option>'; $output_selector .= "\n".$option; @@ -1332,7 +1393,7 @@ sub print_userlist { .'</span></label>'.(' 'x3)."\n"); my $roleselected = ''; if ($env{'form.showrole'} eq 'Any') { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my ($cnum,$cdom); $r->print(&role_filter($context)); @@ -1526,7 +1587,7 @@ sub role_filter { my $output; my $roleselected = ''; if ($env{'form.showrole'} eq 'Any') { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my ($role_select); if ($context eq 'domain') { @@ -1542,7 +1603,7 @@ sub role_filter { foreach my $role (@poss_roles) { $roleselected = ''; if ($role eq $env{'form.showrole'}) { - $roleselected = ' selected="selected" '; + $roleselected = ' selected="selected"'; } my $plrole; if ($role eq 'cr') { @@ -1599,7 +1660,7 @@ sub section_group_filter { foreach my $option ('all','none',@options) { $currsel = ''; if ($env{'form.'.$name{$item}} eq $option) { - $currsel = ' selected="selected" '; + $currsel = ' selected="selected"'; } $markup .= ' <option value="'.$option.'"'.$currsel.'>'; if (($option eq 'all') || ($option eq 'none')) { @@ -1998,6 +2059,7 @@ sub show_users_list { if ($env{'course.'.$cid.'.internal.showphoto'}) { $r->print(' <script type="text/javascript"> +// <![CDATA[ function photowindow(photolink) { var title = "Photo_Viewer"; var options = "scrollbars=1,resizable=1,menubar=0"; @@ -2005,6 +2067,7 @@ function photowindow(photolink) { stdeditbrowser = open(photolink,title,options,"1"); stdeditbrowser.focus(); } +// ]]> </script> '); } @@ -2021,6 +2084,7 @@ END $r->print(<<END); <script type="text/javascript" language="Javascript"> +// <![CDATA[ $check_uncheck_js $verify_action_js @@ -2059,6 +2123,7 @@ function username_display_launch(usernam } } } +// ]]> </script> $date_sec_selector <input type="hidden" name="state" value="$env{'form.state'}" /> @@ -2153,7 +2218,7 @@ END END if ($actionselect) { $output .= <<"END"; -<div class="LC_left_float"><fieldset><legend><b>$lt{'ac'}</b></legend> +<div class="LC_left_float"><fieldset><legend>$lt{'ac'}</legend> $actionselect <br/><br /><input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.$formname.actionlist)" /> <input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.$formname.actionlist)" /><br /><input type="button" value="$lt{'pr'}" onclick="javascript:verify_action('actionlist')" /></fieldset></div> @@ -2198,7 +2263,7 @@ END } } } - $output .= '<div class="LC_left_float"><fieldset><legend><b>'.$lt{'link'}.'</b></legend>'. + $output .= '<div class="LC_left_float"><fieldset><legend>'.$lt{'link'}.'</legend>'. '<table><tr>'; my @linkdests = ('aboutme'); if ($permission->{'cusr'}) { @@ -2572,7 +2637,7 @@ END } if ($env{'course.'.$env{'request.course.id'}.'.internal.showphoto'}) { if ($displayphotos eq 'on' && $role eq 'st' && $in{'photo'} ne '') { - $r->print(' <td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1"></a></td>'); + $r->print(' <td align="right"><a href="javascript:photowindow('."'".$in{'photo'}."'".')"><img src="'.$in{'thumbnail'}.'" border="1" alt="" /></a></td>'); } else { $r->print(' <td> </td> '); } @@ -2859,8 +2924,8 @@ sub select_actions { } } if ($choices{'sections'}) { - $output .= '<input type="hidden" name="retainsec" value= "" />'."\n". - '<input type="hidden" name="newsecs" value= "" />'."\n"; + $output .= '<input type="hidden" name="retainsec" value="" />'."\n". + '<input type="hidden" name="newsecs" value="" />'."\n"; } } return $output; @@ -2874,9 +2939,9 @@ sub date_section_javascript { delete => "Check the boxes for any users for whom roles are to be deleted, and click 'Proceed'", none => "Choose an action to take for selected users", ); - my $output = ' -<script type="text/javascript">'."\n"; - $output .= <<"ENDONE"; + my $output = <<"ENDONE"; +<script type="text/javascript"> +// <![CDATA[ function opendatebrowser(callingform,formname,calledby) { var bulkaction = callingform.bulkaction.options[callingform.bulkaction.selectedIndex].value; var url = '/adm/createuser?'; @@ -2899,6 +2964,7 @@ ENDONE stdeditbrowser = open(url,title,options,'1'); stdeditbrowser.focus(); } +// ]]> </script> ENDTWO return $output; @@ -2912,6 +2978,7 @@ sub date_section_selector { my $sec_js = &setsections_javascript($formname,$groupslist); my $output = <<"END"; <script type="text/javascript"> +// <![CDATA[ $sec_js @@ -2980,6 +3047,7 @@ END $verify_action_js +// ]]> </script> ENDJS my %lt = &Apache::lonlocal::texthash ( @@ -3256,7 +3324,9 @@ sub show_drop_list { <input type="hidden" name="action" value="$action" /> <input type="hidden" name="state" value="done" /> <script type="text/javascript" language="Javascript"> +// <![CDATA[ $check_uncheck_js +// ]]> </script> <p> <input type="hidden" name="phase" value="four" /> @@ -3396,10 +3466,14 @@ END 'ua' => "uncheck all", ); $r->print(<<"END"); -</p><p> +</p> +<p> <input type="button" value="$lt{'ca'}" onclick="javascript:checkAll(document.studentform.droplist)" /> <input type="button" value="$lt{'ua'}" onclick="javascript:uncheckAll(document.studentform.droplist)" /> -<p><input type=submit value="$lt{'dp'}" /></p> +</p> +<p> +<input type="submit" value="$lt{'dp'}" /> +</p> END return; } @@ -3413,24 +3487,39 @@ sub print_first_users_upload_form { $str = '<input type="hidden" name="phase" value="two" />'; $str .= '<input type="hidden" name="action" value="upload" />'; $str .= '<input type="hidden" name="state" value="got_file" />'; + $str .= '<h2>'.&mt('Upload a file containing information about users').'</h2>'."\n"; - $str .= '<p class="LC_info">' - .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.') - .'</p>'."\n"; - $str .= &Apache::loncommon::upfile_select_html(); - $str .= '<p>'; - $str .= &Apache::loncommon::help_open_topic("Course_Create_Class_List", - &mt("How do I create a users list from a spreadsheet")). - "<br />\n"; - $str .= &Apache::loncommon::help_open_topic("Course_Convert_To_CSV", - &mt("How do I create a CSV file from a spreadsheet")); - $str .= "</p>\n"; - $str .= "<p>\n"; - $str .= '<label><input type="checkbox" name="noFirstLine" /> '. - &mt('Ignore First Line')."</label></p>\n"; - $str .= '<input type="submit" name="fileupload" value="'. - &mt('Next').'" />'."<br />\n"; + + # Excel and CSV Help + $str .= '<p>' + .&Apache::loncommon::help_open_topic("Course_Create_Class_List", + &mt("How do I create a users list from a spreadsheet")) + ."<br />\n" + .&Apache::loncommon::help_open_topic("Course_Convert_To_CSV", + &mt("How do I create a CSV file from a spreadsheet")) + ."</p>\n"; + + $str .= &Apache::lonhtmlcommon::start_pick_box() + .&Apache::lonhtmlcommon::row_title(&mt('File')) + .'<p class="LC_info">'."\n" + .&mt('Please upload an UTF8 encoded file to ensure a correct character encoding in your classlist.')."\n" + .'</p>'."\n" + .&Apache::loncommon::upfile_select_html() + .&Apache::lonhtmlcommon::row_closure() + .&Apache::lonhtmlcommon::row_title( + '<label for="noFirstLine">' + .&mt('Ignore First Line') + .'</label>') + .'<input type="checkbox" name="noFirstLine" id="noFirstLine" />' + .&Apache::lonhtmlcommon::row_closure(1) + .&Apache::lonhtmlcommon::end_pick_box(); + + $str .= '<p>' + .'<input type="submit" name="fileupload" value="'.&mt('Next').'" />' + .'</p>'; + $str .= &Apache::loncommon::end_page(); + $r->print($str); return; } @@ -4439,7 +4528,7 @@ sub course_sections { my $output = ''; my @sections = (sort {$a <=> $b} keys %{$sections_count}); my $numsec = scalar(@sections); - my $is_selected = ' selected="selected" '; + my $is_selected = ' selected="selected"'; if ($numsec <= 1) { $output = '<select name="currsec_'.$role.'" >'."\n". ' <option value="">'.&mt('Select').'</option>'."\n";