--- loncom/interface/selfenroll.pm 2009/05/24 00:05:04 1.20 +++ loncom/interface/selfenroll.pm 2009/08/11 00:39:46 1.21 @@ -1,7 +1,7 @@ # The LearningOnline Network # Allow users to self-enroll in a course # -# $Id: selfenroll.pm,v 1.20 2009/05/24 00:05:04 bisitz Exp $ +# $Id: selfenroll.pm,v 1.21 2009/08/11 00:39:46 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -34,6 +34,7 @@ use Apache::lonnet; use Apache::loncommon; use Apache::lonlocal; use Apache::createaccount; +use Apache::loncoursequeueadmin; use LONCAPA qw(:DEFAULT :match); sub handler { @@ -580,8 +581,9 @@ sub store_selfenroll_request { my $fullname = &Apache::loncommon::plainname($uname,$udom); my %courseinfo = &Apache::lonnet::coursedescription($cdom.'_'.$cnum); my $coursedesc = $courseinfo{'description'}; - &send_notification($selfenroll_notifylist,$fullname,$cdom. - '_'.$cnum,$coursedesc,$now,'request',$owner); + &Apache::loncoursequeueadmin::send_selfserver_notification( + $selfenroll_notifylist,$fullname,$cdom.'_'.$cnum, + $coursedesc,$now,'selfenrollreq',$owner); } } else { $output = ''.&mt('An error occurred when recording your request.').''; @@ -591,104 +593,6 @@ sub store_selfenroll_request { return $output; } -sub send_notification { - my ($notifylist,$textstr,$cid,$coursedesc,$timestamp,$context,$sender, - $approvedlist,$rejectedlist) = @_; -# FIXME locallocaltime needs to be able to take $sender_lh as an argument -# so this can be localized to the recipients date display format/time zone - $timestamp =&Apache::lonlocal::locallocaltime($timestamp); - my $msgcc; - my ($rawsubj,@rawmsg,$subject,$message,$namelink); - $namelink = &Apache::loncommon::aboutmewrapper( - &Apache::loncommon::plainname($env{'user.name'},$env{'user.domain'})); - if ($context eq 'managers') { - $rawsubj = 'Self-enrollment requests processed'; - push(@rawmsg,{ - mt => 'Enrollment requests in the following course: [_1] have been processed.', - args => ["\n$coursedesc\n"], - }); - } elsif ($context eq 'enroller') { - $rawsubj = 'Enrollment request'; - push(@rawmsg,{ - mt => 'Your request for enrollment in the following course: [_1], requested on [_2], has been reviewed by a Course Coordinator.', - args => ["\n$coursedesc\n","$timestamp\n"], - - }); - if (ref($textstr) eq 'ARRAY') { - push(@rawmsg,@{$textstr}); - } - } else { - $rawsubj = 'Self-enrollment request'; - push(@rawmsg,{ - mt => 'Enrollment in the following course: [_1] was requested by [_2] on [_3].', - args => ["\n$coursedesc\n",$textstr,$timestamp], - }, - { - mt =>'As Course Coordinator, use: [_1]Main Menu -> Manage Course Users -> Enrollment Requests[_1] to display a list of pending enrollment requests,[_1] which you can either approve or reject.', - args => ["\n"], - }); - } - my @to_notify = split(/,/,$notifylist); - my $numsent = 0; - my @recusers; - my @recudoms; - foreach my $cc (@to_notify) { - my ($ccname,$ccdom) = split(/:/,$cc); - if (!exists($msgcc->{$ccname.':'.$ccdom})) { - push(@recusers,$ccname); - push(@recudoms,$ccdom); - $msgcc->{$ccname.':'.$ccdom}=''; - $numsent ++; - } - } - my %reciphash = ( - cc => $msgcc, - ); - my ($uname,$udom); - if ($sender =~ /:/) { - ($uname,$udom) = split(/:/,$sender); - } else { - $uname = $sender; - my %courseinfo = &Apache::lonnet::coursedescription($cid); - $udom = $courseinfo{'num'}; - } - my %sentmessage; - my $stamp = time; - my $msgcount = &Apache::lonmsg::get_uniq(); - my $sender_lh = &Apache::loncommon::user_lang($uname,$udom,$cid); - $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj); - $message = ''; - foreach my $item (@rawmsg) { - if (ref($item) eq 'HASH') { - $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt},@{$item->{args}})."\n"; - } - } - &Apache::lonmsg::process_sent_mail($subject,'',$numsent,$stamp,$uname,$udom,$msgcount,$cid,$$,$message,\@recusers,\@recudoms); - my ($recipid,$recipstatus) = - &Apache::lonmsg::store_recipients($subject,$uname,$udom,\%reciphash); - foreach my $recip (sort(keys(%{$msgcc}))) { - my ($ccname,$ccdom) = split(/:/,$recip); - my $recip_lh = &Apache::loncommon::user_lang($ccname,$ccdom,$cid); - my $subject = &Apache::lonlocal::mt_user($sender_lh,$rawsubj); - my $message = ''; - foreach my $item (@rawmsg) { - if (ref($item) eq 'HASH') { - $message .= &Apache::lonlocal::mt_user($sender_lh,$item->{mt}, - @{$item->{args}})."\n"; - } - } - if ($context eq 'managers') { - if ($approvedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Approved enrollments:')."\n".$approvedlist; - } - if ($rejectedlist) { - $message .= "\n\n".&Apache::lonlocal::mt_user($sender_lh,'Rejected enrollments:')."\n".$rejectedlist; - } - } - my $status = &Apache::lonmsg::user_normal_msg($ccname,$ccdom,$subject,$message,undef,undef,undef,1,\%sentmessage,undef,undef,undef,1,$recipid); - } -} - sub jump_to_role { my ($role) = @_; my $output = <<"END";