--- loncom/interface/loncommon.pm 2007/12/04 11:00:05 1.620 +++ loncom/interface/loncommon.pm 2007/12/21 05:19:04 1.627 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # a pile of common routines # -# $Id: loncommon.pm,v 1.620 2007/12/04 11:00:05 www Exp $ +# $Id: loncommon.pm,v 1.627 2007/12/21 05:19:04 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1942,6 +1942,11 @@ sub authform_kerberos { if (defined($in{'curr_authtype'})) { if ($in{'curr_authtype'} eq 'krb') { $krbcheck = ' checked="on"'; + if (defined($in{'mode'})) { + if ($in{'mode'} eq 'modifyuser') { + $krbcheck = ''; + } + } if (defined($in{'curr_kerb_ver'})) { if ($in{'curr_krb_ver'} eq '5') { $check5 = ' checked="on"'; @@ -2039,6 +2044,11 @@ sub authform_internal{ if ($in{'curr_authtype'} eq 'int') { if ($can_assign{'int'}) { $intcheck = 'checked="on" '; + if (defined($in{'mode'})) { + if ($in{'mode'} eq 'modifyuser') { + $intcheck = ''; + } + } if (defined($in{'curr_autharg'})) { $intarg = $in{'curr_autharg'}; } @@ -2089,6 +2099,11 @@ sub authform_local{ if ($in{'curr_authtype'} eq 'loc') { if ($can_assign{'loc'}) { $loccheck = 'checked="on" '; + if (defined($in{'mode'})) { + if ($in{'mode'} eq 'modifyuser') { + $loccheck = ''; + } + } if (defined($in{'curr_autharg'})) { $locarg = $in{'curr_autharg'}; } @@ -2138,6 +2153,11 @@ sub authform_filesystem{ if ($in{'curr_authtype'} eq 'fsys') { if ($can_assign{'fsys'}) { $fsyscheck = 'checked="on" '; + if (defined($in{'mode'})) { + if ($in{'mode'} eq 'modifyuser') { + $fsyscheck = ''; + } + } } else { $result = &mt('Currently Filesystem Authenticated.'); return $result; @@ -5039,7 +5059,6 @@ div.LC_clear_float_footer { div.LC_grade_select_mode { - float: left; font-family: $sans; } div.LC_grade_select_mode div div { @@ -6148,24 +6167,24 @@ sub default_quota { my ($udom,$inststatus) = @_; my ($defquota,$settingstatus); my %quotahash = &Apache::lonnet::get_dom('configuration', - ['quota'],$udom); - if (ref($quotahash{'quota'}) eq 'HASH') { + ['quotas'],$udom); + if (ref($quotahash{'quotas'}) eq 'HASH') { if ($inststatus ne '') { my @statuses = split(/:/,$inststatus); foreach my $item (@statuses) { - if ($quotahash{'quota'}{$item} ne '') { + if ($quotahash{'quotas'}{$item} ne '') { if ($defquota eq '') { - $defquota = $quotahash{'quota'}{$item}; + $defquota = $quotahash{'quotas'}{$item}; $settingstatus = $item; - } elsif ($quotahash{'quota'}{$item} > $defquota) { - $defquota = $quotahash{'quota'}{$item}; + } elsif ($quotahash{'quotas'}{$item} > $defquota) { + $defquota = $quotahash{'quotas'}{$item}; $settingstatus = $item; } } } } if ($defquota eq '') { - $defquota = $quotahash{'quota'}{'default'}; + $defquota = $quotahash{'quotas'}{'default'}; $settingstatus = 'default'; } } else { @@ -6217,14 +6236,14 @@ sub get_secgrprole_info { } sub user_picker { - my ($dom,$srch,$forcenewuser,$caller) = @_; + my ($dom,$srch,$forcenewuser,$caller,$cancreate,$usertype) = @_; my $currdom = $dom; my %curr_selected = ( srchin => 'dom', srchby => 'lastname', ); my $srchterm; - if (ref($srch) eq 'HASH') { + if ((ref($srch) eq 'HASH') && ($env{'form.origform'} ne 'crtusername')) { if ($srch->{'srchby'} ne '') { $curr_selected{'srchby'} = $srch->{'srchby'}; } @@ -6311,7 +6330,16 @@ sub user_picker { if ($forcenewuser) { if (ref($srch) eq 'HASH') { if ($srch->{'srchby'} eq 'uname' && $srch->{'srchtype'} eq 'exact' && $srch->{'srchin'} eq 'dom' && $srch->{'srchdomain'} eq $env{'request.role.domain'}) { - $new_user_create = '

&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" />

'; + if ($cancreate) { + $new_user_create = '

&"').'" onclick="javascript:setSearch(\'1\','.$caller.');" />

'; + } else { + my $helplink = ' href="javascript:helpMenu('."'display'".')"'; + my %usertypetext = ( + official => 'institutional', + unofficial => 'non-institutional', + ); + $new_user_create = '
'.&mt("You are not authorized to create new $usertypetext{$usertype} users in this domain.").' '.&mt('Contact the helpdesk for assistance.',$helplink).'

'; + } } } @@ -6579,6 +6607,19 @@ sub instrule_disallow_msg { return $response; } +sub personal_data_fieldtitles { + my %fieldtitles = &Apache::lonlocal::texthash ( + id => 'Student/Employee ID', + permanentemail => 'E-mail address', + lastname => 'Last Name', + firstname => 'First Name', + middlename => 'Middle Name', + generation => 'Generation', + gen => 'Generation', + ); + return %fieldtitles; +} + =pod =back @@ -7733,8 +7774,8 @@ sub commit_standardrole { my $result = &commit_studentrole(\$logmsg,$udom,$uname,$url,$three,$start,$end, $one,$two,$sec,$context); if (($result =~ /^error/) || ($result eq 'not_in_class') || - ($result eq 'unknown_course')) { - $output = "Error: $result\n"; + ($result eq 'unknown_course') || ($result eq 'refused')) { + $output = $logmsg.' '.&mt('Error: ').$result."\n"; } else { $output = $logmsg.$linefeed.&mt('Assigning').' '.$three.' in '.$url. ($start?', '.&mt('starting').' '.localtime($start):''). @@ -7763,7 +7804,7 @@ sub commit_standardrole { sub commit_studentrole { my ($logmsg,$udom,$uname,$url,$three,$start,$end,$one,$two,$sec,$context) = @_; - my ($result,$linefeed); + my ($result,$linefeed,$oldsecurl,$newsecurl); if ($context eq 'auto') { $linefeed = "\n"; } else { @@ -7783,6 +7824,7 @@ sub commit_studentrole { if ($oldsec) { $uurl.='/'.$oldsec; } + $oldsecurl = $uurl; $expire_role_result = &Apache::lonnet::assignrole($udom,$uname,$uurl,'st',time); $result = $expire_role_result; } @@ -7791,21 +7833,35 @@ sub commit_studentrole { $modify_section_result = &Apache::lonnet::modify_student_enrollment($udom,$uname,undef,undef,undef,undef,undef,$sec,$end,$start,'','',$cid); if ($modify_section_result =~ /^ok/) { if ($secchange == 1) { - $$logmsg .= "Section for $uname switched from old section: $oldsec to new section: $sec".$linefeed; + $$logmsg .= &mt('Section for [_1] switched from old section: [_2] to new section: [_3].',$uname,$oldsec,$sec).$linefeed; } elsif ($oldsec eq '-1') { - $$logmsg .= "New student role for $uname in section $sec in course $cid".$linefeed; + $$logmsg .= &mt('New student role for [_1] in section [_2] in course [_3].',$uname,$sec,$cid).$linefeed; } else { - $$logmsg .= "Student $uname assigned to unchanged section $sec in course $cid".$linefeed; + $$logmsg .= &mt('Student [_1] assigned to unchanged section [_2] in course [_3].',$uname,$sec,$cid).$linefeed; } } else { - $$logmsg .= "Error when attempting section change for $uname from old section $oldsec to new section: $sec in course $cid -error: $modify_section_result".$linefeed; + $$logmsg .= &mt('Error when attempting section change for [_1] from old section [_2] to new section: [_3] in course [_4] -error:',$uname,$oldsec,$sec,$cid).' '.$modify_section_result.$linefeed; } $result = $modify_section_result; } elsif ($secchange == 1) { - $$logmsg .= "Error when attempting to expire role for $uname in old section $oldsec in course $cid -error: $expire_role_result".$linefeed; + $$logmsg .= &mt('Error when attempting to expire role for [_1] in old section [_2] in course [_3] -error: ',$uname,$oldsec,$cid).' '.$expire_role_result.$linefeed; + if ($expire_role_result eq 'refused') { + my $newsecurl = '/'.$cid; + $newsecurl =~ s/\_/\//g; + if ($sec ne '') { + $newsecurl.='/'.$sec; + } + if (&Apache::lonnet::allowed('cst',$newsecurl) && !(&Apache::lonnet::allowed('cst',$oldsecurl))) { + if ($sec eq '') { + $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments unaffiliated with any section.',$sec).$linefeed; + } else { + $$logmsg .= &mt('Although your current role has privileges to add students to section "[_1]", you do not have privileges to modify existing enrollments in other sections.',$sec).$linefeed; + } + } + } } } else { - $$logmsg .= "Incomplete course id defined. Addition of user $uname from domain $udom to course $one\_$two, section $sec not completed.$linefeed"; + $$logmsg .= &mt('Incomplete course id defined.').$linefeed.&mt('Addition of user [_1] from domain [_2] to course [_3], section [_4] not completed.',$uname,$udom,$one.'_'.$two,$sec).$linefeed; $result = "error: incomplete course id\n"; } return $result;