--- loncom/interface/lonmsgdisplay.pm 2006/05/01 16:17:56 1.21 +++ 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.21 2006/05/01 16:17:56 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,133 +260,21 @@ sub movemsg { # ======================================================= Display a course list sub discourse { - my $r=shift; - my $classlist = &Apache::loncoursedata::get_classlist(); - my ($classgroups,$studentgroups) = - &Apache::loncoursedata::get_group_memberships($classlist); - my %lt=&Apache::lonlocal::texthash('cfa' => 'Check All', - 'cfs' => 'Check Section/Group', - 'cfn' => 'Uncheck All'); - if (defined($env{'form.group'})) { - $r->print(''."\n"); - } - $r->print(< - -  - -  - -

-ENDDISHEADER - my %coursepersonnel=&Apache::lonnet::get_course_adv_roles(); - $r->print(&Apache::loncommon::start_data_table()); - if (keys(%coursepersonnel) > 0) { - $r->print('

Non-students

'); - $r->print(&Apache::loncommon::start_data_table()); - $r->print('NameUsername:DomainRole'); - foreach my $role (sort(keys(%coursepersonnel))) { - foreach my $user (split(/\,/,$coursepersonnel{$role})) { - my ($puname,$pudom)=split(/\:/,$user); - $r->print(&Apache::loncommon::start_data_table_row()); - $r->print(''. - '('.$user.'),'.$role.''); - $r->print(&Apache::loncommon::end_data_table_row()); - } - } - $r->print(&Apache::loncommon::end_data_table()); - } - if (keys(%{$classlist}) > 0) { - $r->print('

Students

'); - $r->print(&Apache::loncommon::start_data_table()); - $r->print('NameUsername:DomainSectionGroups'); - 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 @studentsgroups = - &Apache::loncoursedata::get_students_groups($student,$status, - $classgroups); - my $grouplist = join(', ',@studentsgroups); - my $key = 'send_to_&&&'.$section.'&&&_'.$student; - if (! defined($fullname) || $fullname eq '') {$fullname = $sname;} - my $checked = ''; - my $groupcount = 0; - my $groupitems; - $r->print(&Apache::loncommon::start_data_table_row()); - $r->print(''.$groupitems. - ''.$sname.':'.$sdom.''.$section. - ''.$grouplist.''); - $r->print(&Apache::loncommon::end_data_table_row()); - } - $r->print(&Apache::loncommon::end_data_table()); - } + return $result; } # ==================================================== Display Critical Message @@ -901,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". @@ -976,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'). @@ -1654,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'))); } @@ -1731,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); @@ -1747,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}=''; + } } } @@ -1881,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)").'

'); } } @@ -1902,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','group']); + 'showcommentbaseurl','dismode','group','subject','text']); $sqs='&sortedby='.$env{'form.sortedby'}; # ------------------------------------------------------ They checked for email