--- loncom/interface/lonmsgdisplay.pm 2006/12/08 20:32:36 1.51
+++ loncom/interface/lonmsgdisplay.pm 2011/05/12 21:56:13 1.157
@@ -1,7 +1,7 @@
-# The LearningOnline Network with CAPA
+# $textareaclass The LearningOnline Network with CAPA
# Routines for messaging display
#
-# $Id: lonmsgdisplay.pm,v 1.51 2006/12/08 20:32:36 raeburn Exp $
+# $Id: lonmsgdisplay.pm,v 1.157 2011/05/12 21:56:13 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -33,12 +33,13 @@ package Apache::lonmsgdisplay;
=head1 NAME
-Apache::lonmsg: supports internal messaging
+Apache::lonmsgdisplay: supports internal messaging
=head1 SYNOPSIS
-lonmsg provides routines for sending messages, receiving messages, and
-a handler to allow users to read, send, and delete messages.
+lonmsgdisplay provides a handler to allow users to read, send,
+and delete messages, and to create and delete message folders,
+and to move messages between folders.
=head1 OVERVIEW
@@ -93,25 +94,6 @@ addresses on their B screen, but g
are much more useful than traditional email can be made to be, even
with HTML support.
-Right now, this document will cover just how to send a message, since
-it is likely you will not need to programmatically read messages,
-since lonmsg already implements that functionality.
-
-The routines used to package messages and unpackage messages are not
-only used by lonmsg when creating/extracting messages for LON-CAPA's
-internal messaging system, but also by lonnotify.pm which is available
-for use by Domain Coordinators to broadcast standard e-mail to specified
-users in their domain. The XML packaging used in the two cases is very
-similar. The differences are the use of $uname and
-$udom in stored internal messages, compared
-with $email in stored
-Domain Coordinator e-mail for the storage of information about
-recipients of the message/e-mail.
-
-=head1 FUNCTIONS
-
-=over 4
-
=cut
use strict;
@@ -119,6 +101,7 @@ use Apache::lonnet;
use HTML::TokeParser();
use Apache::Constants qw(:common);
use Apache::loncommon();
+use Apache::lonhtmlcommon();
use Apache::lontexconvert();
use HTML::Entities();
use Apache::lonlocal;
@@ -127,21 +110,21 @@ use Apache::lonfeedback;
use Apache::lonrss();
use Apache::lonselstudent();
use lib '/home/httpd/lib/perl/';
-use LONCAPA;
+use LONCAPA qw(:DEFAULT :match);
# Querystring component with sorting type
-my $sqs;
-my $startdis;
-my $interdis;
+my $sqs='';
+my $startdis='';
# ============================================================ List all folders
sub folderlist {
- my $folder=shift;
+ my ($folder,$msgstatus) = @_;
my %lt = &Apache::lonlocal::texthash(
actn => 'Action',
fold => 'Folder',
show => 'Show',
+ status => 'Message Status',
go => 'Go',
nnff => 'New Name for Folder',
newn => 'New Name',
@@ -153,6 +136,9 @@ sub folderlist {
);
+ # set se lastvisit for the new mail check in the toplevel menu
+ &Apache::lonnet::appenv({'user.mailcheck.lastvisit'=>time});
+
my %actions = &Apache::lonlocal::texthash(
view => 'View Folder',
rename => 'Rename Folder',
@@ -160,6 +146,10 @@ sub folderlist {
);
$actions{'select_form_order'} = ['view','rename','delete'];
+ my %statushash = &Apache::lonlocal::texthash(&get_msgstatus_types());
+
+ $statushash{'select_form_order'} = ['','new','read','replied','forwarded'];
+
my %permfolders = &get_permanent_folders();
my $permlist = join("','",sort(keys(%permfolders)));
my ($permlistkeys,$permlistvals);
@@ -173,6 +163,7 @@ sub folderlist {
my %userfolders;
foreach my $key (keys(%gotfolders)) {
+ $key =~ s/(['"])/\$1/g; #' stupid emacs
$userfolders{$key} = $key;
}
my @userorder = sort(keys(%userfolders));
@@ -180,8 +171,9 @@ sub folderlist {
my $folderlist = join("','",@userorder);
$folderlist .= "','".$permlistvals;
- $formhash{'select_form_order'} = ['','critical','new',@userorder,'sent','trash'];
+ $formhash{'select_form_order'} = ['','critical',@userorder,'sent','trash'];
my $output = qq||;
+ my %show = ('select_form_order' => [10,20,50,100,200],
+ map {$_=>$_} (10,20,50,100,200));
+
$output .= '
+ my $latexHelp = &Apache::loncommon::helpLatexCheatsheet(undef,undef,1);
+ my $textareaclass;
+ if (&Apache::lonhtmlcommon::htmlareabrowser()) {
+ $r->print(&Apache::lonhtmlcommon::htmlareaselectactive());
+ $textareaclass = 'class="LC_richDefaultOff"';
+ }
+ my $subj_size;
+ if ($multiforward) {
+ $r->print(&additional_rec_row(\%lt));
+ $r->print('
'.
+ &mt('Unless you choose otherwise:').'
'.
+ &mt("The subject in each forwarded message will be 'Forwarding:' followed by the original subject.").'
'.
+ &mt("The message itself will begin with a first line: 'Forwarded message from' followed by the original sender's name.").'
');
+ $func1='Forward'; # do not translate here!
+ $dissub = &mt('Forwarding').': ';
+ $subj_size = '10';
+ my $extra = '<'.&mt('original subject').'> '.
+ ''.&mt('Yes').' '.&mt('No');
+ $dismsg = &mt('Forwarded message from ').' ';
+ my $sender = &mt("sender's name");
+ $r->print(&msg_subject_row($dissub,\%lt,$subj_size,$extra));
+ $r->print('
'.&mt('Message begins with:').'
'.$sender.' '.&mt('Yes').' '.&mt('No').'
+
+
+
'."\n".
+$latexHelp." \n".
+&mt("Any new text to display before the text of the original messages:").' '."\n".
+'');
+ my @to_forward = &Apache::loncommon::get_env_multiple('form.delmark');
+ foreach my $msg (@to_forward) {
+ $r->print('');
+ }
+ $r->print(&submit_button_row($folder,$dismode,&mt($func1.' '.$func2{'msg'}),
+ \%lt));
+ } elsif ($broadcast ne 'upload') {
+ $subj_size = '50';
+ $r->print(&additional_rec_row(\%lt));
+ if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
+ || &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
+ '/'.$env{'request.course.sec'})) {
+ $r->print(&reply_to_row(\%lt));
+ }
+ $r->print(&msg_subject_row($dissub,\%lt,$subj_size));
+ $r->print(<<"ENDCOMP");
+$attachrow
+
ENDREC
return $output;
}
+sub reply_to_row {
+ my ($lt) = @_;
+ my $radioyes = &mt('Yes');
+ my $radiono = &mt('No');
+ my $output = <<"ENDREP";
+
$lt->{'ar'}: $lt->{'rt'}:
+ENDREP
+ return $output;
+}
+
+sub additional_rec_row {
+ my ($lt) = @_;
+ my $cc = &mt('Cc:');
+ my $bcc = &mt('Bcc:');
+ my $exmpl = &mt('username:domain,username:domain,...');
+ my $output = <<"ENDADD";
+
+ENDADD
+ return $output;
+}
+
+sub submit_button_row {
+ my ($folder,$dismode,$sendtext,$lt,$is_crsform,$group) = @_;
+ my $pre=&mt("Show Preview and Check Spelling");
+ my $value=&mt('Send');
+ my $prevbutton = '';
+ my $output = qq|
+
+|;
+ if ($is_crsform) {
+ $output .= ''."\n";
+ if ($group ne '') {
+ $output .= ''."\n";
+ }
+ }
+ $output .= qq|
+
+
+
+
$prevbutton
+|;
+ return $output;
+}
+
+sub msg_subject_row {
+ my ($dissub,$lt,$subj_size,$extra) = @_;
+ my $output = '
'.$lt->{'sb'}.': '.$extra.
+ '
';
+ return $output;
+}
+
+sub generate_preview_form {
+ my $prevbutton = (<
+
+
+
+ENDPREVIEW
+}
+
+# ---------------------------------------------------- Display all face to face
+
sub retrieve_instructor_comments {
my ($user,$domain)=@_;
my $target=$env{'form.grade_target'};
@@ -1377,8 +1869,10 @@ sub retrieve_instructor_comments {
}
sub disfacetoface {
- my ($r,$user,$domain)=@_;
- my $target=$env{'form.grade_target'};
+ my ($r,$user,$domain,$target)=@_;
+ if ($target eq '') {
+ $target=$env{'form.grade_target'};
+ }
unless ($env{'request.course.id'}) { return; }
if (!&Apache::lonnet::allowed('dff',$env{'request.course.id'})
&& ! &Apache::lonnet::allowed('dff',$env{'request.course.id'}.
@@ -1390,11 +1884,13 @@ sub disfacetoface {
$env{'course.'.$env{'request.course.id'}.'.domain'},
$env{'course.'.$env{'request.course.id'}.'.num'},
'%255b'.$user.'%253a'.$domain.'%255d');
- my $result='';
+ my $result='
';
foreach my $key (sort(keys(%records))) {
my %content=&Apache::lonmsg::unpackagemsg($records{$key});
next if ($content{'senderdomain'} eq '');
- &Apache::lonfeedback::newline_to_br(\$content{'message'});
+ if (!&Apache::lonfeedback::contains_block_html($content{'message'})) {
+ &Apache::lonfeedback::newline_to_br(\$content{'message'});
+ }
if ($content{'subject'}=~/^Record/) {
$result.='
';
+ if (defined($content{'coursemsgid'})) {
+ my $crsmsgid = &escape($content{'coursemsgid'});
+ my $archive_message = &general_message($crsmsgid);
+ $content{'message'} = ''.&mt('Subject').': '.$content{'message'}.' '.$archive_message;
+ } else {
+ %content=&Apache::lonmsg::unpackagemsg($content{'message'});
+ $content{'message'} =
+ ''.&mt('Subject').': '.$content{'subject'}.' '.&mt('Critical Message').'';
if (defined($content{'coursemsgid'})) {
@@ -1435,15 +1944,17 @@ $content{'sendername'}.':'.
}
# Check to see if there were any messages.
if ($result eq '') {
- my $lctype = lc(&Apache::loncommon::course_type());
+ my $lctype = &mt(lc(&Apache::loncommon::course_type()));
if ($target ne 'tex') {
$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 [_1].',$lctype).'}\\\\');
}
+ } elsif ($target ne 'tex') {
+ $r->print($result.'
');
} else {
- $r->print($result);
- }
+ $r->print(&Apache::lonxml::xmlparse($r, 'tex', $result));
+ }
}
sub general_message {
@@ -1469,11 +1980,11 @@ sub facetoface {
return;
}
my $crstype = &Apache::loncommon::course_type();
- my $leaders = ($crstype eq 'Group') ? 'coordinators and leaders'
- : 'faculty and staff';
+ my $leaders = ($crstype eq 'Community') ? 'coordinators and leaders'
+ : 'faculty and staff';
&printheader($r,
'/adm/email?recordftf=query',
- "User Notes, Face-to-Face, Critical Messages, Broadcast Messages");
+ "User Notes, Face-to-Face, Critical Messages, Broadcast Messages, Archived Messages");
# from query string
if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; }
@@ -1488,25 +1999,28 @@ 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 $crstype",
+ 'head' => "User Notes, Records of Face-To-Face Discussions, Critical Messages, Broadcast Messages and Archived Messages in $crstype",
'subm' => 'Retrieve discussion and message records',
'newr' => 'New Record (record is visible to '.lc($crstype).' '.$leaders.')',
'post' => 'Post this Record');
- $r->print(<<"ENDTREC");
-
'
+ .&mt('Discussion and message records for [_1] ([_2])'
+ ,$aboutmelink
+ ,$env{'form.recuname'}.':'.$env{'form.recdomain'})
+ .'
'
+ );
&disfacetoface($r,$env{'form.recuname'},$env{'form.recdomain'});
$r->print(<
@@ -1545,15 +2068,21 @@ sub examblock {
$r->print('Not allowed');
return;
}
- my $usertype = (&Apache::loncommon::course_type() eq 'Group') ? 'members'
- : 'students';
+ my $usertype;
+ my $crstype = &Apache::loncommon::course_type();
+ if ($crstype eq 'Community') {
+ $usertype = 'members';
+ } else {
+ $usertype = 'students';
+ }
+ my $lctype = lc($crstype);
my %lt=&Apache::lonlocal::texthash(
'comb' => 'Communication Blocking',
'cbds' => 'Communication blocking during scheduled exams',
- 'desc' => "You can use communication blocking to prevent $usertype enrolled in this course from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA course, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.",
+ 'desc' => "You can use communication blocking to prevent $usertype enrolled in this $lctype from displaying LON-CAPA messages sent by other $usertype during an online exam. As blocking of communication could potentially interrupt legitimate communication between $usertype who are also both enrolled in a different LON-CAPA course or community, please be careful that you select the correct start and end times for your scheduled exam when setting or modifying these parameters.",
'mecb' => 'Modify existing communication blocking periods',
- 'ncbc' => 'No communication blocks currently stored',
- 'stor' => 'Store',
+ 'ncbc' => 'No communication blocks currently saved',
+ 'stor' => 'Save',
);
my %ltext = &Apache::lonlocal::texthash(
@@ -1727,7 +2256,7 @@ sub display_blocker_status {
$ltext->{'setb'}
$ltext->{'even'}
$ltext->{'blck'}
-
$ltext->{'actn'}?
+
$ltext->{'actn'}
END
foreach my $record (sort(keys(%{$records}))) {
@@ -1747,7 +2276,7 @@ END
$setuname,$setudom);
$r->print(&Apache::loncommon::start_data_table_row());
$r->print(<<"END");
-
@@ -1755,13 +2284,18 @@ END
foreach my $block (@{$typeorder}) {
my $blockstatus = '';
if ($blocks->{$block} eq 'on') {
- $blockstatus = 'checked="true"';
+ $blockstatus = 'checked="checked"';
}
- $r->print(' ');
+ $r->print(' ');
}
$r->print(<<"END");
-
+
+
END
$r->print(&Apache::loncommon::end_data_table_row());
$parmcount++;
@@ -1798,7 +2332,7 @@ END
$ltext->{'dura'}
$ltext->{'even'} $lt{'exam'}
$ltext->{'blck'}
-
$ltext->{'actn'}?
+
$ltext->{'actn'}
END
$r->print(&Apache::loncommon::start_data_table_row());
@@ -1808,11 +2342,13 @@ END
END
foreach my $block (@{$typeorder}) {
- $r->print(' ');
+ $r->print(' ');
}
$r->print(<<"END");
-
-
+
+
END
$r->print(&Apache::loncommon::end_data_table_row());
$r->print(&Apache::loncommon::end_data_table());
@@ -1822,7 +2358,7 @@ END
sub blocktype_text {
my %types = &Apache::lonlocal::texthash(
'com' => 'Messaging',
- 'chat' => 'Chat',
+ 'chat' => 'Chat Room',
'boards' => 'Discussion',
'port' => 'Portfolio',
'groups' => 'Groups',
@@ -1835,7 +2371,7 @@ sub blocktype_text {
# ----------------------------------------------------------- Display a message
sub displaymessage {
- my ($r,$msgid,$folder)=@_;
+ my ($r,$msgid,$folder,$msgstatus)=@_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my %blocked = ();
my %setters = ();
@@ -1844,19 +2380,21 @@ sub displaymessage {
# info to generate "next" and "previous" buttons and check if message is blocked
my ($startblock,$endblock) = &Apache::loncommon::blockcheck(\%setters,'com');
- my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder);
+ my @messages=&sortedmessages(\%blocked,$startblock,$endblock,\$numblocked,$folder,$msgstatus);
if ( $blocked{$msgid} eq 'ON' ) {
&printheader($r,'/adm/email',&mt('Display a Message'));
- $r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
- &build_block_table($r,$startblock,$endblock,\%setters);
+ #$r->print(&mt('You attempted to display a message that is currently blocked because you are enrolled in one or more courses for which there is an ongoing online exam.'));
+ #&build_block_table($r,$startblock,$endblock,\%setters);
+ my($blocked, $blocktext) = &Apache::loncommon::blocking_status("com");
+ $r->print(" ".$blocktext);
return;
}
- &statuschange($msgid,'read',$folder);
+ if ($msgstatus eq '') {
+ &statuschange($msgid,'read',$folder);
+ }
my %message=&Apache::lonnet::get('nohist_email'.$suffix,[$msgid]);
my %content=&Apache::lonmsg::unpackagemsg($message{$msgid});
-
my $counter=0;
- $r->print('
');
my $escmsgid=&escape($msgid);
foreach (@messages) {
if ($_->[5] eq $escmsgid){
@@ -1864,74 +2402,501 @@ sub displaymessage {
}
$counter++;
}
- $r->print('
');
+
+ my $see_anonymous;
+ my $from_student = 0;
+ if ($env{'request.course.id'} eq $content{'courseid'}) {
+ my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+ my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+ my $username = $content{'sendername'}.':'.$content{'senderdomain'};
+ my %classlist_entry =
+ &Apache::lonnet::get('classlist',[$username],$cdom,$cnum);
+ if (exists($classlist_entry{$username})) {
+ $from_student = 1;
+ $see_anonymous = &Apache::lonnet::allowed('rin',$env{'request.course.id'}.($env{'request.course.sec'}?'/'.$env{'request.course.sec'}:''));
+ }
+ }
+
+
my $number_of_messages = scalar(@messages); #subtract 1 for last index
# start output
&printheader($r,'/adm/email?display='.&escape($msgid),'Display a Message','',$content{'baseurl'});
- my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'});
-# Functions
- $r->print('