--- loncom/interface/lonmsgdisplay.pm 2006/05/11 19:04:31 1.23
+++ loncom/interface/lonmsgdisplay.pm 2006/06/30 02:06:15 1.35.2.2
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.23 2006/05/11 19:04:31 www Exp $
+# $Id: lonmsgdisplay.pm,v 1.35.2.2 2006/06/30 02:06:15 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -125,6 +125,9 @@ use Apache::lonlocal;
use Apache::loncommunicate;
use Apache::lonfeedback;
use Apache::lonrss();
+use Apache::lonselstudent();
+use lib '/home/httpd/lib/perl/';
+use LONCAPA;
# Querystring component with sorting type
my $sqs;
@@ -214,7 +217,7 @@ sub movemsg {
# Copy message
my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
if (!exists($message{$msgid}) || $message{$msgid} eq '') {
- if (&Apache::slotrequest::network_error(%message)) {
+ if (&Apache::lonnet::error(%message)) {
return (0,&mt('Message not moved, A network error occurred.'));
} else {
return (0,&mt('Message not moved as the message is no longer in the source folder.'));
@@ -223,7 +226,7 @@ sub movemsg {
my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
{$msgid => $message{$msgid}});
- if (&Apache::slotrequest::network_error($result)) {
+ if (&Apache::lonnet::error($result)) {
return (0,&mt('Message not moved, A network error occurred.'));
}
@@ -231,12 +234,12 @@ sub movemsg {
unless ($trgfolder eq 'trash') {
my %status=&Apache::lonnet::get('email_status'.$srcsuffix,[$msgid]);
# a non-existant status is the mark of an unread msg
- if (&Apache::slotrequest::network_error(%status)) {
+ if (&Apache::lonnet::error(%status)) {
return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
}
my $result=&Apache::lonnet::put('email_status'.$trgsuffix,
{$msgid => $status{$msgid}});
- if (&Apache::slotrequest::network_error($result)) {
+ if (&Apache::lonnet::error($result)) {
return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
}
}
@@ -246,10 +249,10 @@ sub movemsg {
&Apache::lonnet::del('nohist_email'.$srcsuffix,[$msgid]);
my $result_del_stat =
&Apache::lonnet::del('email_status'.$srcsuffix,[$msgid]);
- if (&Apache::slotrequest::network_error($result_del_msg)) {
+ if (&Apache::lonnet::error($result_del_msg)) {
return (0,&mt('Message copied, but unable to delete the original from the source folder.'));
}
- if (&Apache::slotrequest::network_error($result_del_stat)) {
+ if (&Apache::lonnet::error($result_del_stat)) {
return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
}
@@ -259,133 +262,32 @@ 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('
".&mt("No notes, face-to-face discussion records, critical messages, or broadcast messages in this course.")."
"); + $r->print("".&mt('No notes, face-to-face discussion records, critical messages, or broadcast messages in this [_1].',$lctype)."
"); } else { - $r->print('\textbf{'.&mt("No notes, face-to-face discussion records, critical messages or broadcast messages in this course.").'}\\\\'); + $r->print('\textbf{'.&mt('No notes, face-to-face discussion records, critical messages or broadcast messages in this [_1].',$lctype).'}\\\\'); } } else { $r->print($result); @@ -1104,6 +1012,9 @@ sub facetoface { $r->print('Not allowed'); return; } + my $crstype = &Apache::loncommon::course_type(); + my $leaders = ($crstype eq 'Group') ? 'coordinators and leaders' + : 'faculty and staff'; &printheader($r, '/adm/email?recordftf=query', "User Notes, Face-to-Face, Critical Messages, Broadcast Messages"); @@ -1121,9 +1032,9 @@ sub facetoface { ('stdselect','recuname','recdomain'); my %lt=&Apache::lonlocal::texthash('user' => 'Username', 'dom' => 'Domain', - 'head' => 'User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in Course', + 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, and Broadcast Messages in $crstype", 'subm' => 'Retrieve discussion and message records', - 'newr' => 'New Record (record is visible to course faculty and staff)', + 'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')', 'post' => 'Post this Record'); $r->print(<<"ENDTREC");'); - my $escmsgid=&Apache::lonnet::escape($msgid); + my $escmsgid=&escape($msgid); foreach (@messages) { if ($_->[5] eq $escmsgid){ last; @@ -1542,17 +1453,17 @@ sub displaymessage { $r->print(''); my $number_of_messages = scalar(@messages); #subtract 1 for last index # start output - &printheader($r,'/adm/email?display='.&Apache::lonnet::escape($msgid),'Display a Message','',$content{'baseurl'}); + &printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'}); my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'}); # Functions $r->print('
'.&mt('Functions').': | '. - ''.&mt('Reply').' | '. - ''.&mt('Forward').' | '. - ''.&mt('Mark Unread').' | '. - ''.&mt('Delete').' | '. ''.
$content{'baseurl'}.' ('.&Apache::lonnet::gettitle($content{'baseurl'}).')':'').
@@ -1681,14 +1592,14 @@ sub storecomment {
$cleanmsgtxt.=$_."\n";
}
}
- my $key=&Apache::lonnet::escape($env{'form.baseurl'}).'___'.time;
+ my $key=&escape($env{'form.baseurl'}).'___'.time;
&Apache::lonnet::put('nohist_stored_comments',{ $key => $cleanmsgtxt });
}
sub storedcommentlisting {
my ($r)=@_;
my %msgs=&Apache::lonnet::dump('nohist_stored_comments',undef,undef,
- '^'.&Apache::lonnet::escape(&Apache::lonnet::escape($env{'form.showcommentbaseurl'})));
+ '^'.&escape(&escape($env{'form.showcommentbaseurl'})));
$r->print(&Apache::loncommon::start_page('Stored Comment Listing',undef,
{'onlybody' => 1}));
if ((keys %msgs)[0]=~/^error\:/) {
@@ -1733,13 +1644,27 @@ sub sendoffmail {
&statuschange($msgid,'replied',$folder);
}
+ my @to =
+ &Apache::loncommon::get_env_multiple('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);
@@ -1749,12 +1674,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}='';
+ }
}
}
@@ -1823,20 +1752,20 @@ sub sendoffmail {
my ($specialmsgid,$specialresult);
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
- my $course_str = &Apache::lonnet::escape('['.$cnum.':'.$cdom.']');
+ my $course_str = &escape('['.$cnum.':'.$cdom.']');
if ($numspecial) {
$specialresult = &Apache::lonmsg::user_normal_msg_raw($cnum,$cdom,$subj_prefix.
' '.$course_str,$savemsg,undef,undef,undef,
undef,undef,\$specialmsgid);
- $specialmsgid = &Apache::lonnet::unescape($specialmsgid);
+ $specialmsgid = &unescape($specialmsgid);
}
if ($specialresult eq 'ok') {
my $record_sent;
my @recusers;
my @recudoms;
my ($stamp,$crssubj,$msgname,$msgdom,$msgcount,$context,$pid) =
- split(/\:/,&Apache::lonnet::unescape($specialmsgid));
+ split(/\:/,&unescape($specialmsgid));
foreach my $recipient (sort(keys(%toaddr))) {
if ($specialmsg_status{$recipient} eq 'ok') {
@@ -1883,7 +1812,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)").''); } } @@ -1926,7 +1855,7 @@ sub handler { unless ($folder) { $folder=''; } else { - $sqs.='&folder='.&Apache::lonnet::escape($folder); + $sqs.='&folder='.&escape($folder); } # ------------------------------------------------------------ Get Display Mode @@ -1934,7 +1863,7 @@ sub handler { unless ($dismode) { $dismode=''; } else { - $sqs.='&dismode='.&Apache::lonnet::escape($dismode); + $sqs.='&dismode='.&escape($dismode); } # --------------------------------------------------------------------- Display @@ -1970,6 +1899,7 @@ sub handler { &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode); } elsif ($env{'form.confirm'}) { &printheader($r,'','Confirmed Receipt'); + my $replying = 0; foreach (keys %env) { if ($_=~/^form\.rec\_(.*)$/) { $r->print(''.&mt('Confirming Receipt').': '. @@ -1980,9 +1910,12 @@ sub handler { $r->print(''.&mt('Confirming Receipt').': '. &Apache::lonmsg::user_crit_received($msgid).''); &compout($r,'','','',$msgid); + $replying = 1; } } - &discrit($r); + if (!$replying) { + &discrit($r); + } } elsif ($env{'form.critical'}) { &printheader($r,'','Displaying Critical Messages'); &discrit($r); @@ -2004,7 +1937,7 @@ sub handler { foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = - &movemsg(&Apache::lonnet::unescape($1),$folder, + &movemsg(&unescape($1),$folder, $env{'form.movetofolder'}); if ($result) { $total++; @@ -2031,7 +1964,7 @@ sub handler { foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = - &statuschange(&Apache::lonnet::unescape($1),'deleted', + &statuschange(&unescape($1),'deleted', $folder); if ($result) { $total++; @@ -2076,7 +2009,9 @@ sub handler { $env{'form.subject'}, $env{'form.message'},'/adm/communicate','public'); } - &disall($r,($folder?$folder:$dismode)); + if (!$env{'form.displayedcrit'}) { + &disall($r,($folder?$folder:$dismode)); + } } elsif ($env{'form.newfolder'}) { &printheader($r,'','New Folder'); &makefolder($env{'form.newfolder'}); |