--- loncom/interface/loncreateuser.pm 2009/02/05 17:15:04 1.278 +++ loncom/interface/loncreateuser.pm 2009/02/18 19:34:08 1.282 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Create a user # -# $Id: loncreateuser.pm,v 1.278 2009/02/05 17:15:04 raeburn Exp $ +# $Id: loncreateuser.pm,v 1.282 2009/02/18 19:34:08 schafran Exp $ # # Copyright Michigan State University Board of Trustees # @@ -227,9 +227,9 @@ sub build_tools_display { 'official' => 'Can request creation of official courses', 'unofficial' => 'Can request creation of unofficial courses', ); - if ($context eq 'requestcourse') { + if ($context eq 'requestcourses') { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, - 'requestcourse.official','requestcourse.unofficial'); + 'requestcourses.official','requestcourses.unofficial'); @usertools = ('official','unofficial'); } else { %userenv = &Apache::lonnet::userenvironment($ccdomain,$ccuname, @@ -337,7 +337,7 @@ sub print_username_entry_form { 'dom' => "Domain", 'ecrp' => "Edit Custom Role Privileges", 'nr' => "Name of Role", - 'cre' => "Custom Role Editor", + 'cre' => "Next", ); $r->print($start_page."\n".$crumbs); if ($env{'form.action'} eq 'custom') { @@ -347,7 +347,7 @@ sub print_username_entry_form {

$lt{'ecrp'}

-$lt{'nr'}: $choice
+$choice $lt{'nr'}:
ENDCUSTOM @@ -870,7 +870,7 @@ ENDCHANGEUSER if (&Apache::lonnet::allowed('ccc',$env{'request.role.domain'})) { $r->print('

'.&mt('User Can Request Creation of Courses?').'

'. &Apache::loncommon::start_data_table(). - &build_tools_display($ccuname,$ccdomain,'requestcourse'). + &build_tools_display($ccuname,$ccdomain,'requestcourses'). &Apache::loncommon::end_data_table()); } $r->print(''); @@ -1713,8 +1713,8 @@ sub update_user_data { } if ( $env{'form.ccuname'} ne &LONCAPA::clean_username($env{'form.ccuname'}) ) { - $r->print($error.&mt('Invalid login name').'. '. - &mt('Only letters, numbers, periods, dashes, @, and underscores are valid').'.'. + $r->print($error.&mt('Invalid login name.').' '. + &mt('Only letters, numbers, periods, dashes, @, and underscores are valid.'). $end.$rtnlink); return; } @@ -1724,8 +1724,8 @@ sub update_user_data { } if ( $env{'form.ccdomain'} ne &LONCAPA::clean_domain($env{'form.ccdomain'}) ) { - $r->print($error.&mt ('Invalid domain name').'. '. - &mt('Only letters, numbers, periods, dashes, and underscores are valid').'.'. + $r->print($error.&mt('Invalid domain name.').' '. + &mt('Only letters, numbers, periods, dashes, and underscores are valid.'). $end.$rtnlink); return; } @@ -1851,12 +1851,10 @@ sub update_user_data { \%changeHash,'tools'); } } - if (&Apache::lonnet::allowed('ccc',$env{'request.domain'})) { - foreach my $item (@requestcourses) { - $newcustom{$item} = $env{'form.requestcourse_'.$item}; - $changed{$item} = &tool_admin($item,$newcustom{$item}, - \%changeHash,'requestcourse'); - } + foreach my $item (@requestcourses) { + $newcustom{$item} = $env{'form.requestcourses_'.$item}; + $changed{$item} = &tool_admin($item,$newcustom{$item}, + \%changeHash,'requestcourses'); } if (keys(%changed)) { $changeHash{'firstname'} = $env{'form.cfirstname'}; @@ -1902,8 +1900,8 @@ sub update_user_data { my %userenv = &Apache::lonnet::get ('environment',['firstname','middlename','lastname','generation', 'id','permanentemail','portfolioquota','inststatus','tools.aboutme', - 'tools.blog','tools.portfolio','requestcourse.official', - 'requestcourse.unofficial'], + 'tools.blog','tools.portfolio','requestcourses.official', + 'requestcourses.unofficial'], $env{'form.ccdomain'},$env{'form.ccuname'}); my ($tmp) = keys(%userenv); if ($tmp =~ /^(con_lost|error)/i) { @@ -2084,7 +2082,7 @@ sub update_user_data { } &tool_changes('tools',\@usertools,\%oldaccess,\%oldaccesstext,\%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext); - &tool_changes('requestcourse',\@requestcourses,\%oldaccess,\%oldaccesstext, + &tool_changes('requestcourses',\@requestcourses,\%oldaccess,\%oldaccesstext, \%userenv, \%changeHash,\%changed,\%newaccess,\%newaccesstext); if ($env{'form.cfirstname'} ne $userenv{'firstname'} || $env{'form.cmiddlename'} ne $userenv{'middlename'} || @@ -2112,16 +2110,26 @@ sub update_user_data { my %newenvhash; foreach my $key (keys(%changed)) { if (($key eq 'official') || ($key eq 'unofficial')) { - $newenvhash{'environment.canrequest.'.$key} = - $changeHash{'requestcourse.'.$key}; - $newenvhash{'environment.canrequest.'.$key} = - $changeHash{'requestcourse.'.$key}; - + $newenvhash{'environment.requestcourses.'.$key} = + $changeHash{'requestcourses.'.$key}; + if ($changeHash{'requestcourses.'.$key} ne '') { + $newenvhash{'environment.canrequest.'.$key} = + $changeHash{'requestcourses.'.$key}; + } else { + $newenvhash{'environment.canrequest.'.$key} = + &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, + $key,'reload','requestcourses'); + } } elsif ($key ne 'quota') { $newenvhash{'environment.tools.'.$key} = $changeHash{'tools.'.$key}; - $newenvhash{'environment.availabletools.'.$key} = - $changeHash{'tools.'.$key}; + if ($changeHash{'tools.'.$key} ne '') { + $newenvhash{'environment.availabletools.'.$key} = + $changeHash{'tools.'.$key}; + } else { + $newenvhash{'environment.availabletools.'.$key} = + &Apache::lonnet::usertools_access($env{'user.name'},$env{'user.domain'}, $key,'reload','tools'); + } } } if (keys(%newenvhash)) { @@ -2397,9 +2405,9 @@ sub tool_changes { } else { $oldaccesstext->{$tool} = &mt("availability set to 'off'"); } - $changeHash->{$context.'.'.$tool} = $userenv->{'tools.'.$tool}; + $changeHash->{$context.'.'.$tool} = $userenv->{$context.'.'.$tool}; if ($env{'form.custom'.$tool} == 1) { - if ($env{'form.'.$context.'_'.$tool} ne $userenv->{'tools.'.$tool}) { + if ($env{'form.'.$context.'_'.$tool} ne $userenv->{$context.'.'.$tool}) { $changed->{$tool} = &tool_admin($tool,$env{'form.'.$context.'_'.$tool}, $changeHash,$context); if ($changed->{$tool}) { @@ -2823,7 +2831,7 @@ sub quota_admin { sub tool_admin { my ($tool,$settool,$changeHash,$context) = @_; my $canchange = 0; - if ($context eq 'requestcourse') { + if ($context eq 'requestcourses') { if (&Apache::lonnet::allowed('ccc',$env{'form.ccdomain'})) { $canchange = 1; } @@ -3009,7 +3017,7 @@ ENDCCF ''."\n".''."\n". ''."\n". - ''. + ''. &Apache::loncommon::end_page()); } # -------------------------------------------------------- @@ -4081,7 +4089,7 @@ ENDSCRIPT } $output .= &Apache::lonhtmlcommon::end_pick_box(). '
' + .&mt('Save').'" onclick="validate_types(this.form);" />' .''; $r->print($output); return; @@ -4164,7 +4172,8 @@ sub update_selfenroll_queue { my $hostname = &Apache::lonnet::hostname($chome); my $protocol = $Apache::lonnet::protocol{$chome}; $protocol = 'http' if ($protocol ne 'https'); - my (@existing,@missingreq,@invalidusers,@limitexceeded,@enrolled,@enrollerrors,); + my (@existing,@missingreq,@invalidusers,@limitexceeded,@enrolled, + @enrollerrors,@warn_approves,@warn_rejects); my $now = time; my $sender = $env{'user.name'}.':'.$env{'user.domain'}; my $approvedmsg = [{ @@ -4217,6 +4226,19 @@ sub update_selfenroll_queue { $stucounts->{'selfenrolled'} ++; &Apache::selfenroll::send_notification($uname.':'.$udom,$approvedmsg,$cid, $coursedesc,$now,'enroller',$sender); + my %userrequest = ( + $cdom.'_'.$cnum => { + timestamp => $now, + section => $usec, + adjudicator => $env{'user.name'}.':'.$env{'user.domain'}, + status => 'approved', + } + ); + my $userresult = + &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname); + if ($userresult ne 'ok') { + push(@warn_approves,$uname.':'.$udom); + } } else { push(@enrollerrors,$uname.':'.$udom); } @@ -4230,6 +4252,19 @@ sub update_selfenroll_queue { foreach my $user (@rejections) { &Apache::selfenroll::send_notification($user,$rejectedmsg,$cid, $coursedesc,$now,'enroller',$sender); + my ($uname,$udom) = split(/:/,$user); + my %userrequest = ( + $cdom.'_'.$cnum => { + timestamp => $now, + adjudicator => $env{'user.name'}.':'.$env{'user.domain'}, + status => 'rejected', + } + ); + my $userresult = + &Apache::lonnet::put($namespace,\%userrequest,$udom,$uname); + if ($userresult ne 'ok') { + push(@warn_rejects,$user); + } } } if (@changes) { @@ -4239,7 +4274,7 @@ sub update_selfenroll_queue { &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'}).' ('.$env{'user.name'}.':'.$env{'user.domain'}.')'; my $chgmsg = "'Action was taken on the following enrollment requests by [_1].',$namelink"; my ($approvedlist,$rejectedlist); - if (@enrolled) { + if (@enrolled) { $approvedlist = join("\n",@enrolled); $r->print('

'.&mt('The following were enrolled in the course:').'

'); } + if (@warn_approves) { + $r->print('

'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'

'); + } + if (@warn_rejects) { + $r->print('

'.&mt("For the following users, an error occurred when updating the user's own self-enroll requests record:").'

'); + } return; } @@ -4329,7 +4378,7 @@ sub visible_in_cat { miss => 'Your course does not currently appear in the Course Catalog for this domain.', yous => 'You should remedy this if you plan to allow self-enrollment, otherwise students will have difficulty finding your course.', coca => 'Courses can be absent from the Catalog, because they do not have an institutional code, have no assigned category, or have been specifically excluded.', - make => 'Make any changes to self-enrollment settings below, click "Save changes", then take action to include the course in the Catalog:', + make => 'Make any changes to self-enrollment settings below, click "Save", then take action to include the course in the Catalog:', take => 'Take the following action to ensure the course appears in the Catalog:', dc_unhide => 'Ask a domain coordinator to change the "Exclude from course catalog" setting.', dc_addinst => 'Ask a domain coordinator to enable display the catalog of "Official courses (with institutional codes)".',