--- loncom/interface/lonmsgdisplay.pm 2006/04/26 14:43:03 1.19 +++ loncom/interface/lonmsgdisplay.pm 2006/05/17 14:58:28 1.27 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # Routines for messaging display # -# $Id: lonmsgdisplay.pm,v 1.19 2006/04/26 14:43:03 albertel Exp $ +# $Id: lonmsgdisplay.pm,v 1.27 2006/05/17 14:58:28 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -125,6 +125,7 @@ use Apache::lonlocal; use Apache::loncommunicate; use Apache::lonfeedback; use Apache::lonrss(); +use Apache::lonselstudent(); # Querystring component with sorting type my $sqs; @@ -259,89 +260,21 @@ sub movemsg { # ======================================================= Display a course list sub discourse { - my $r=shift; - my $classlist = &Apache::loncoursedata::get_classlist(); - my $now=time; - my %lt=&Apache::lonlocal::texthash('cfa' => 'Check All', - 'cfs' => 'Check Section/Group', - 'cfn' => 'Uncheck All'); - $r->print(< - -  - -  - -

-ENDDISHEADER - my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); - $r->print(''); - foreach my $role (sort keys %coursepersonnel) { - foreach (split(/\,/,$coursepersonnel{$role})) { - my ($puname,$pudom)=split(/\:/,$_); - $r->print(''. - ''); - } - } - $r->print('
('.$_.'),'.$role.'
'); - my $sort = sub { - my $aname=lc($classlist->{$a}[&Apache::loncoursedata::CL_FULLNAME()]); - if (!$aname) { $aname=$a; } - my $bname=lc($classlist->{$b}[&Apache::loncoursedata::CL_FULLNAME()]); - if (!$bname) { $bname=$b; } - return $aname cmp $bname; - }; - foreach my $student (sort $sort (keys(%{$classlist}))) { - my $info=$classlist->{$student}; - my ($sname,$sdom,$status,$fullname,$section) = - (@{$info}[&Apache::loncoursedata::CL_SNAME(), - &Apache::loncoursedata::CL_SDOM(), - &Apache::loncoursedata::CL_STATUS(), - &Apache::loncoursedata::CL_FULLNAME(), - &Apache::loncoursedata::CL_SECTION()]); - next if ($status ne 'Active'); - next if ($env{'request.course.sec'} && - $section ne $env{'request.course.sec'}); - my $key = 'send_to_&&&'.$section.'&&&_'.$student; - if (! defined($fullname) || $fullname eq '') { $fullname = $sname; } - $r->print(''); - } - $r->print('
'.$sname.':'.$sdom.''.$section. - '
'); + return $result; } # ==================================================== Display Critical Message @@ -857,7 +790,9 @@ sub compout { } my $citation=&displayresource(%content); if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; } - $r->print( + if ($env{'form.text'}) { $dismsg=$env{'form.text'}; } + if ($env{'form.subject'}) { $dissub=$env{'form.subject'}; } + $r->print( '

'."\n". ''."\n". @@ -932,6 +867,8 @@ ENDUPLOAD } if ($broadcast eq 'group') { &discourse($r); + my $studentsel = &discourse(); + $r->print($studentsel); } $r->print('
'. &Apache::lonfeedback::generate_preview_button('compemail','message'). @@ -1310,7 +1247,7 @@ END my ($setuname,$setudom,$title) = &parse_block_record($$records{$record}); - $title = &HTML::Entities::encode($title,'"<>'); + $title = &HTML::Entities::encode($title,'"<>&'); my $settername = &Apache::loncommon::plainname($setuname,$setudom); $r->print(&Apache::loncommon::start_data_table_row()); $r->print(<<"END"); @@ -1610,7 +1547,7 @@ sub header { $r->print(&Apache::loncommon::start_page('Communication and Messages', $extra)); $r->print(&Apache::lonhtmlcommon::breadcrumbs - (undef,($title?$title:'Communication and Messages'))); + (($title?$title:'Communication and Messages'))); } @@ -1687,13 +1624,26 @@ sub sendoffmail { &statuschange($msgid,'replied',$folder); } + my $to = $env{'form.selectedusers.forminput'}; + my $mode = $env{'form.sendmode'}; + my %toaddr; - if ($env{'form.sendmode'} eq 'group') { - foreach my $address (keys(%env)) { - if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { - $toaddr{$1}=''; + if ($to) { + foreach my $dest (@$to) { + my ($user,$domain) = split(/:/, $dest); + if (($user ne '') && ($domain ne '')) { + my $address = $user.":".$domain; # How the code below expects it. + $toaddr{$address} = ''; } } + } + + if ($env{'form.sendmode'} eq 'group') { + foreach my $address (keys(%env)) { + if ($address=~/^form\.send\_to\_\&\&\&[^\&]*\&\&\&\_(.+)$/) { + $toaddr{$1}=''; + } + } } elsif ($env{'form.sendmode'} eq 'upload') { foreach my $line (split(/[\n\r\f]+/,$env{'form.upfile'})) { my ($rec,$txt)=split(/\s*\:\s*/,$line); @@ -1703,12 +1653,16 @@ sub sendoffmail { } } } else { - $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}=''; + if (($env{'form.recuname'} ne '') && ($env{'form.recdomain'} ne '')) { + $toaddr{$env{'form.recuname'}.':'.$env{'form.recdomain'}}=''; + } } if ($env{'form.additionalrec'}) { foreach (split(/\,/,$env{'form.additionalrec'})) { my ($auname,$audom)=split(/\@/,$_); - $toaddr{$auname.':'.$audom}=''; + if (($auname ne "") && ($audom ne "")) { + $toaddr{$auname.':'.$audom}=''; + } } } @@ -1837,7 +1791,7 @@ sub sendoffmail { } } else { $r->print('

'.&mt('Could not deliver message').' '. - &mt('Please use the browser "Back" button and correct the recipient addresses').'

'); + &mt('Please use the browser "Back" button and correct the recipient addresses '."($sendstatus)").'

'); } } @@ -1858,7 +1812,7 @@ sub handler { ['display','replyto','forward','markread','markdel','markunread', 'sendreply','compose','sendmail','critical','recname','recdom', 'recordftf','sortedby','block','folder','startdis','interdis', - 'showcommentbaseurl','dismode']); + 'showcommentbaseurl','dismode','group','subject','text']); $sqs='&sortedby='.$env{'form.sortedby'}; # ------------------------------------------------------ They checked for email