--- loncom/interface/lonmsgdisplay.pm 2006/04/25 23:13:25 1.17
+++ loncom/interface/lonmsgdisplay.pm 2006/05/23 21:42:09 1.28
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.17 2006/04/25 23:13:25 albertel Exp $
+# $Id: lonmsgdisplay.pm,v 1.28 2006/05/23 21:42:09 foxr 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,32 @@ 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('
');
+ my $result;
+ my ($course_personnel,
+ $current_members,
+ $expired_members,
+ $future_members) =
+ &Apache::lonselstudent::get_people_in_class($env{'request.course.sec'});
+ unshift @$current_members, (@$course_personnel);
+ my %defaultUsers;
+
+ $result = &Apache::lonselstudent::render_student_list($current_members,
+ "compemail",
+ "current",
+ \%defaultUsers,
+ 1,"selectedusers",1);
+
+ $result .= &Apache::lonselstudent::render_student_list($expired_members,
+ "compemail",
+ "expired",
+ \%defaultUsers,
+ 1, "selectedusers",0);
+ $result .= &Apache::lonselstudent::render_student_list($future_members,
+ "compemail",
+ "future",
+ \%defaultUsers,
+ 1, "selectedusers", 0);
+ return $result;
}
# ==================================================== Display Critical Message
@@ -857,7 +801,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(
''.
&Apache::lonfeedback::generate_preview_button('compemail','message').
@@ -1291,8 +1239,8 @@ sub display_blocker_status {
'modi' => 'Modify',
'canc' => 'Cancel',
);
+ $r->print(&Apache::loncommon::start_data_table());
$r->print(<<"END");
-
$$ltext{'dura'}
$$ltext{'setb'}
@@ -1300,26 +1248,27 @@ sub display_blocker_status {
$$ltext{'actn'}?
END
- foreach (sort keys %{$records}) {
- my $iter = $parmcount%2;
+ foreach my $record (sort(keys(%{$records}))) {
my $onchange = 'onFocus="javascript:window.document.forms['.
"'blockform'].elements['modify_".$parmcount."'].".
'checked=true;"';
- my ($start,$end) = split/____/,$_;
+ my ($start,$end) = split(/____/,$record);
my $startform = &Apache::lonhtmlcommon::date_setter('blockform','startdate_'.$parmcount,$start,$onchange);
my $endform = &Apache::lonhtmlcommon::date_setter('blockform','enddate_'.$parmcount,$end,$onchange);
- my ($setuname,$setudom,$title) = &parse_block_record($$records{$_});
+ my ($setuname,$setudom,$title) =
+ &parse_block_record($$records{$record});
+ $title = &HTML::Entities::encode($title,'"<>&');
my $settername = &Apache::loncommon::plainname($setuname,$setudom);
+ $r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
$$ltext{'star'}: $startform $$ltext{'endd'}: $endform
$settername
-
+
$lt{'modi'}? $lt{'canc'}?
-
END
- $parmcount ++;
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $parmcount++;
}
$r->print(<<"END");
@@ -1358,19 +1307,23 @@ sub display_addblocker_table {
);
$r->print(<<"END");
$lt{'addn'}
-
END
+ $r->print(&Apache::loncommon::end_data_table_row());
+ $r->print(&Apache::loncommon::end_data_table());
return;
}
@@ -1388,12 +1341,9 @@ sub blockcheck {
# for students.
return if (!%live_courses);
- &Apache::lonnet::logthis("hmm");
- &Apache::lonnet::logthis(join(" ",%live_courses));
- &Apache::lonnet::logthis(join(" ",%staff_of));
-
foreach my $course (keys(%live_courses)) {
- my ($cdom,$cnum) = split(/_/,$course);
+ my $cdom = $env{'course.'.$course.'.domain'};
+ my $cnum = $env{'course.'.$course.'.num'};
# if they are a staff member and are currently not playing student
next if ( $staff_of{$course}
@@ -1428,31 +1378,35 @@ sub build_block_table {
'cour' => 'Course',
'dura' => 'Duration',
'blse' => 'Block set by'
- );
+ );
+ $r->print(<<"END");
+ $lt{'cacb'}:
+END
+ $r->print(&Apache::loncommon::start_data_table());
$r->print(<<"END");
- $lt{'cacb'}:
-
$lt{'cour'}
$lt{'dura'}
$lt{'blse'}
END
- foreach (keys %{$setters}) {
- my %courseinfo=&Apache::lonnet::coursedescription($_);
- for (my $i=0; $i<@{$$setters{$_}{staff}}; $i++) {
- my ($uname,$udom) = @{$$setters{$_}{staff}[$i]};
+ foreach my $course (keys(%{$setters})) {
+ my %courseinfo=&Apache::lonnet::coursedescription($course);
+ for (my $i=0; $i<@{$$setters{$course}{staff}}; $i++) {
+ my ($uname,$udom) = @{$$setters{$course}{staff}[$i]};
my $fullname = &Apache::loncommon::plainname($uname,$udom);
- my ($openblock,$closeblock) = @{$$setters{$_}{times}[$i]};
+ my ($openblock,$closeblock) = @{$$setters{$course}{times}[$i]};
$openblock = &Apache::lonlocal::locallocaltime($openblock);
$closeblock= &Apache::lonlocal::locallocaltime($closeblock);
- $r->print(''.$courseinfo{'description'}.' '.
+ $r->print(&Apache::loncommon::start_data_table_row().
+ ''.$courseinfo{'description'}.' '.
''.$openblock.' to '.$closeblock.' '.
''.$fullname.' ('.$uname.':'.$udom.
- ') ');
+ ')'.
+ &Apache::loncommon::end_data_table_row());
}
}
- $r->print('
');
+ $r->print(&Apache::loncommon::end_data_table());
}
# ----------------------------------------------------------- Display a message
@@ -1604,7 +1558,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')));
}
@@ -1681,13 +1635,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);
@@ -1697,12 +1664,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}='';
+ }
}
}
@@ -1831,7 +1802,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)").'');
}
}
@@ -1852,7 +1823,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