# The LearningOnline Network with CAPA
# Routines for messaging display
#
# $Id: lonmsgdisplay.pm,v 1.23 2006/05/11 19:04:31 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
package Apache::lonmsgdisplay;
=pod
=head1 NAME
Apache::lonmsg: 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.
=head1 OVERVIEW
=head2 Messaging Overview
X
ENDDISHEADER
my %coursepersonnel=&Apache::lonnet::get_course_adv_roles();
$r->print(&Apache::loncommon::start_data_table());
if (keys(%coursepersonnel) > 0) {
$r->print(' ' . $crithelp .
' '.
'' . $crithelp .
'
'.
&mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
}
# =============================================================== Status Change
sub statuschange {
my ($msgid,$newstatus,$folder)=@_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
unless ($status{$msgid}) { $status{$msgid}='new'; }
unless (($status{$msgid} eq 'replied') ||
($status{$msgid} eq 'forwarded')) {
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
}
if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
}
if ($newstatus eq 'deleted') {
return &movemsg($msgid,$folder,'trash');
}
return ;
}
# ============================================================= Make new folder
sub makefolder {
my ($newfolder)=@_;
if (($newfolder eq 'sent')
|| ($newfolder eq 'critical')
|| ($newfolder eq 'trash')
|| ($newfolder eq 'new')) { return; }
&Apache::lonnet::put('email_folders',{$newfolder => time});
}
# ======================================================== Move between folders
sub movemsg {
my ($msgid,$srcfolder,$trgfolder)=@_;
if ($srcfolder eq 'new') { $srcfolder=''; }
my $srcsuffix=&Apache::lonmsg::foldersuffix($srcfolder);
my $trgsuffix=&Apache::lonmsg::foldersuffix($trgfolder);
if ($srcsuffix eq $trgsuffix) {
return (0,&mt('Message not moved, Attempted to move message to the same folder as it already is in.'));
}
# Copy message
my %message=&Apache::lonnet::get('nohist_email'.$srcsuffix,[$msgid]);
if (!exists($message{$msgid}) || $message{$msgid} eq '') {
if (&Apache::slotrequest::network_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.'));
}
}
my $result =&Apache::lonnet::put('nohist_email'.$trgsuffix,
{$msgid => $message{$msgid}});
if (&Apache::slotrequest::network_error($result)) {
return (0,&mt('Message not moved, A network error occurred.'));
}
# Copy status
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)) {
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)) {
return (0,&mt('Message copied to new folder but status was not, A network error occurred.'));
}
}
# Delete orginals
my $result_del_msg =
&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)) {
return (0,&mt('Message copied, but unable to delete the original from the source folder.'));
}
if (&Apache::slotrequest::network_error($result_del_stat)) {
return (0,&mt('Message copied, but unable to delete the original status from the source folder.'));
}
return (1);
}
# ======================================================= 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(<Non-students
');
$r->print(&Apache::loncommon::start_data_table());
$r->print(' ');
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('Name Username:Domain Role '.
' ('.$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(' ');
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('Name Username:Domain Section Groups '.$groupitems.
' '.$sname.':'.$sdom.' '.$section.
' '.$grouplist.' ');
$r->print(&Apache::loncommon::end_data_table_row());
}
$r->print(&Apache::loncommon::end_data_table());
}
}
# ==================================================== Display Critical Message
sub discrit {
my $r=shift;
my $header = ''.&mt('Critical Messages').'
'.
'');
}
sub sortedmessages {
my ($blocked,$startblock,$endblock,$numblocked,$folder) = @_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
my @messages = &Apache::lonnet::getkeys('nohist_email'.$suffix);
#unpack the varibles and repack into temp for sorting
my @temp;
my %descriptions;
my %status_cache =
&Apache::lonnet::get('email_status'.&Apache::lonmsg::foldersuffix($folder),\@messages);
my $get_received;
if ($folder eq 'sent'
&& ($env{'form.sortedby'} =~ m/^(rev)?(user|domain)$/)) {
$get_received = 1;
}
foreach my $msgid (@messages) {
my $esc_msgid=&Apache::lonnet::escape($msgid);
my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($esc_msgid,$folder,undef,
\%status_cache);
my $description = &get_course_desc($fromcid,\%descriptions);
my @temp1 = ($sendtime,$shortsubj,$fromname,$fromdomain,$status,
$esc_msgid,$description);
if ($get_received) {
my %message = &Apache::lonnet::get('nohist_email'.$suffix,
[$msgid]);
my %content = &Apache::lonmsg::unpackagemsg($message{$msgid});
push(@temp1,$content{'recuser'},$content{'recdomain'});
}
# Check whether message was sent during blocking period.
if ($sendtime >= $startblock && ($sendtime <= $endblock && $endblock > 0) ) {
$$blocked{$msgid} = 'ON';
$$numblocked ++;
} else {
push @temp ,\@temp1;
}
}
#default sort
@temp = sort {$a->[0] <=> $b->[0]} @temp;
if ($env{'form.sortedby'} eq "date"){
@temp = sort {$a->[0] <=> $b->[0]} @temp;
}
if ($env{'form.sortedby'} eq "revdate"){
@temp = sort {$b->[0] <=> $a->[0]} @temp;
}
if ($env{'form.sortedby'} eq "user"){
if ($get_received) {
@temp = sort {lc($a->[7][0]) cmp lc($b->[7][0])} @temp;
} else {
@temp = sort {lc($a->[2]) cmp lc($b->[2])} @temp;
}
}
if ($env{'form.sortedby'} eq "revuser"){
if ($get_received) {
@temp = sort {lc($b->[7][0]) cmp lc($a->[7][0])} @temp;
} else {
@temp = sort {lc($b->[2]) cmp lc($a->[2])} @temp;
}
}
if ($env{'form.sortedby'} eq "domain"){
if ($get_received) {
@temp = sort {$a->[8][0] cmp $b->[8][0]} @temp;
} else {
@temp = sort {$a->[3] cmp $b->[3]} @temp;
}
}
if ($env{'form.sortedby'} eq "revdomain"){
if ($get_received) {
@temp = sort {$b->[8][0] cmp $a->[8][0]} @temp;
} else {
@temp = sort {$b->[3] cmp $a->[3]} @temp;
}
}
if ($env{'form.sortedby'} eq "subject"){
@temp = sort {lc($a->[1]) cmp lc($b->[1])} @temp;
}
if ($env{'form.sortedby'} eq "revsubject"){
@temp = sort {lc($b->[1]) cmp lc($a->[1])} @temp;
}
if ($env{'form.sortedby'} eq "course"){
@temp = sort {lc($a->[6]) cmp lc($b->[6])} @temp;
}
if ($env{'form.sortedby'} eq "revcourse"){
@temp = sort {lc($b->[6]) cmp lc($a->[6])} @temp;
}
if ($env{'form.sortedby'} eq "status"){
@temp = sort {$a->[4] cmp $b->[4]} @temp;
}
if ($env{'form.sortedby'} eq "revstatus"){
@temp = sort {$b->[4] cmp $a->[4]} @temp;
}
return @temp;
}
sub get_course_desc {
my ($fromcid,$descriptions) = @_;
my $description;
if (!$fromcid) {
return $description;
} else {
if (defined($$descriptions{$fromcid})) {
$description = $$descriptions{$fromcid};
} else {
if (defined($env{'course.'.$fromcid.'.description'})) {
$description = $env{'course.'.$fromcid.'.description'};
} else {
my %courseinfo=&Apache::lonnet::coursedescription($fromcid); $description = $courseinfo{'description'};
$description = $courseinfo{'description'};
}
$$descriptions{$fromcid} = $description;
}
return $description;
}
}
# ======================================================== Display new messages
sub disnew {
my $r=shift;
my %lt=&Apache::lonlocal::texthash(
'nm' => 'New Messages',
'su' => 'Subject',
'co' => 'Course',
'da' => 'Date',
'us' => 'Username',
'op' => 'Open',
'do' => 'Domain'
);
my @msgids = sort(&Apache::lonnet::getkeys('nohist_email'));
my @newmsgs;
my %setters = ();
my $startblock = 0;
my $endblock = 0;
my %blocked = ();
my $numblocked = 0;
# Check for blocking of display because of scheduled online exams.
&blockcheck(\%setters,\$startblock,\$endblock);
my %status_cache =
&Apache::lonnet::get('email_status',\@msgids);
my %descriptions;
foreach (@msgids) {
my $msgid=&Apache::lonnet::escape($_);
my ($sendtime,$shortsubj,$fromname,$fromdom,$status,$fromcid)=
&Apache::lonmsg::unpackmsgid($msgid,undef,undef,\%status_cache);
if (defined($sendtime) && $sendtime!~/error/) {
my $description = &get_course_desc($fromcid,\%descriptions);
my $numsendtime = $sendtime;
$sendtime = &Apache::lonlocal::locallocaltime($sendtime);
if ($status eq 'new') {
if ($numsendtime >= $startblock && ($numsendtime <= $endblock && $endblock > 0) ) {
$blocked{$_} = 'ON';
$numblocked ++;
} else {
push @newmsgs, {
msgid => $msgid,
sendtime => $sendtime,
shortsub => $shortsubj,
from => $fromname,
fromdom => $fromdom,
course => $description
}
}
}
}
}
if ($#newmsgs >= 0) {
$r->print(<
');
} elsif ($numblocked == 0) {
$r->print("
TABLEHEAD
foreach my $msg (@newmsgs) {
$r->print(<<"ENDLINK");
 
$lt{'da'} $lt{'us'} $lt{'do'} $lt{'su'} $lt{'co'}
");
}
$r->print('$lt{'op'}
ENDLINK
foreach ('sendtime','from','fromdom','shortsub','course') {
$r->print("$msg->{$_} ");
}
$r->print("".&mt('You have no unread messages')."
");
}
if ($numblocked > 0) {
my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
if ($numblocked == 1) {
$r->print("".&mt('You have').' '.$numblocked.' '.&mt('blocked unread message').".
");
$r->print(&mt('This message is not viewable because').' ');
} else {
$r->print("".&mt('You have').' '.$numblocked.' '.&mt('blocked unread messages').".
");
$r->print(&mt('These').' '.$numblocked.' '.&mt('messages are not viewable because '));
}
$r->print(
&mt('display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams').'.');
&build_block_table($r,$startblock,$endblock,\%setters);
}
}
# ======================================================== Display all messages
sub disall {
my ($r,$folder)=@_;
$r->print(&folderlist($folder));
if ($folder eq 'new') {
&disnew($r);
} elsif ($folder eq 'critical') {
&discrit($r);
} else {
&disfolder($r,$folder);
}
}
# ============================================================ Display a folder
sub disfolder {
my ($r,$folder)=@_;
my %blocked = ();
my %setters = ();
my $startblock;
my $endblock;
my $numblocked = 0;
&blockcheck(\%setters,\$startblock,\$endblock);
$r->print(<'.&mt('Empty Folder').'
');
return;
}
unless ($interdis) {
$interdis=20;
}
my $number=int($totalnumber/$interdis);
if (($startdis<0) || ($startdis>$number)) { $startdis=$number; }
my $firstdis=$interdis*$startdis;
if ($firstdis>$#temp) { $firstdis=$#temp-$interdis+1; }
my $lastdis=$firstdis+$interdis-1;
if ($lastdis>$#temp) { $lastdis=$#temp; }
$r->print(&scrollbuttons($startdis,$number,$firstdis,$lastdis,$totalnumber));
$r->print('');
if ($numblocked > 0) {
my $beginblock = &Apache::lonlocal::locallocaltime($startblock);
my $finishblock = &Apache::lonlocal::locallocaltime($endblock);
$r->print('
'.
$numblocked.' '.&mt('message(s) is/are not viewable because display of LON-CAPA messages sent to you by other students between').' '.$beginblock.' '.&mt('and').' '.$finishblock.' '.&mt('is currently being blocked because of online exams.'));
&build_block_table($r,$startblock,$endblock,\%setters);
}
}
# ============================================================== Compose output
sub compout {
my ($r,$forwarding,$replying,$broadcast,$replycrit,$folder,$dismode)=@_;
my $suffix=&Apache::lonmsg::foldersuffix($folder);
if ($broadcast eq 'individual') {
&printheader($r,'/adm/email?compose=individual',
'Send a Message');
} elsif ($broadcast) {
&printheader($r,'/adm/email?compose=group',
'Broadcast Message');
} elsif ($forwarding) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/email?display=".&Apache::lonnet::escape($forwarding),
text=>"Display Message"});
&printheader($r,'/adm/email?forward='.&Apache::lonnet::escape($forwarding),
'Forwarding a Message');
} elsif ($replying) {
&Apache::lonhtmlcommon::add_breadcrumb
({href=>"/adm/email?display=".&Apache::lonnet::escape($replying),
text=>"Display Message"});
&printheader($r,'/adm/email?replyto='.&Apache::lonnet::escape($replying),
'Replying to a Message');
} elsif ($replycrit) {
$r->print(''.&mt('Replying to a Critical Message').'
');
$replying=$replycrit;
} else {
&printheader($r,'/adm/email?compose=upload',
'Distribute from Uploaded File');
}
my $dispcrit='';
my $dissub='';
my $dismsg='';
my $disbase='';
my $func=&mt('Send New');
my %lt=&Apache::lonlocal::texthash('us' => 'Username',
'do' => 'Domain',
'ad' => 'Additional Recipients',
'sb' => 'Subject',
'ca' => 'Cancel',
'ma' => 'Mail');
if (&Apache::lonnet::allowed('srm',$env{'request.course.id'})
|| &Apache::lonnet::allowed('srm',$env{'request.course.id'}.
'/'.$env{'request.course.sec'})) {
my $crithelp = Apache::loncommon::help_open_topic("Course_Critical_Message");
$dispcrit=
'
';
}
}
}
my $citation=&displayresource(%content);
if ($env{'form.recdom'}) { $defdom=$env{'form.recdom'}; }
if ($env{'form.text'}) { $dismsg=$env{'form.text'}; }
if ($env{'form.subject'}) { $dissub=$env{'form.subject'}; }
$r->print(
'
Subject:
General message text
The file format for the uploaded portion of the message is:
username1\@domain1: text username2\@domain2: text username3\@domain1: text
The messages will be assembled from all lines with the respective username\@domain, and appended to the general message text.
$dispcrit
ENDUPLOAD } if ($broadcast eq 'group') { &discourse($r); } $r->print(''. &Apache::lonfeedback::generate_preview_button('compemail','message'). &Apache::lonhtmlcommon::htmlareaselectactive('message')); } # ---------------------------------------------------- Display all face to face sub retrieve_instructor_comments { my ($user,$domain)=@_; my $target=$env{'form.grade_target'}; if (! $env{'request.course.id'}) { return; } if (! &Apache::lonnet::allowed('srm',$env{'request.course.id'}) && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { return; } my %records=&Apache::lonnet::dump('nohist_email', $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}, '%255b'.$user.'%253a'.$domain.'%255d'); my $result=''; foreach (sort(keys(%records))) { my %content=&Apache::lonmsg::unpackagemsg($records{$_}); next if ($content{'senderdomain'} eq ''); next if ($content{'subject'} !~ /^Record/); # &Apache::lonfeedback::newline_to_br(\$content{'message'}); $result.='Recorded by '. $content{'sendername'}.':'.$content{'senderdomain'}."\n"; $result.= &Apache::lontexconvert::msgtexconverted($content{'message'})."\n"; } return $result; } sub disfacetoface { my ($r,$user,$domain)=@_; my $target=$env{'form.grade_target'}; unless ($env{'request.course.id'}) { return; } if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'}) && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { $r->print('Not allowed'); return; } my %records=&Apache::lonnet::dump('nohist_email', $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}, '%255b'.$user.'%253a'.$domain.'%255d'); my $result=''; foreach (sort keys %records) { my %content=&Apache::lonmsg::unpackagemsg($records{$_}); next if ($content{'senderdomain'} eq ''); &Apache::lonfeedback::newline_to_br(\$content{'message'}); if ($content{'subject'}=~/^Record/) { $result.=''. &Apache::lontexconvert::msgtexconverted($content{'message'}). ''; } # Check to see if there were any messages. if ($result eq '') { if ($target ne 'tex') { $r->print("
".&mt("No notes, face-to-face discussion records, critical messages, or broadcast messages in this course.")."
"); } else { $r->print('\textbf{'.&mt("No notes, face-to-face discussion records, critical messages or broadcast messages in this course.").'}\\\\'); } } else { $r->print($result); } } sub general_message { my ($crsmsgid) = @_; my %general_content; if ($crsmsgid) { my %course_content = &Apache::lonnet::get('nohist_email',[$crsmsgid], $env{'course.'.$env{'request.course.id'}.'.domain'}, $env{'course.'.$env{'request.course.id'}.'.num'}); %general_content = &Apache::lonmsg::unpackagemsg($course_content{$crsmsgid}); } return $general_content{'message'}; } # ---------------------------------------------------------------- Face to face sub facetoface { my ($r,$stage)=@_; if (!&Apache::lonnet::allowed('srm',$env{'request.course.id'}) && ! &Apache::lonnet::allowed('srm',$env{'request.course.id'}. '/'.$env{'request.course.sec'})) { $r->print('Not allowed'); return; } &printheader($r, '/adm/email?recordftf=query', "User Notes, Face-to-Face, Critical Messages, Broadcast Messages"); # from query string if ($env{'form.recname'}) { $env{'form.recuname'}=$env{'form.recname'}; } if ($env{'form.recdom'}) { $env{'form.recdomain'}=$env{'form.recdom'}; } my $defdom=$env{'user.domain'}; # already filled in if ($env{'form.recdomain'}) { $defdom=$env{'form.recdomain'}; } # generate output my $domform = &Apache::loncommon::select_dom_form($defdom,'recdomain'); my $stdbrws = &Apache::loncommon::selectstudent_link ('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', 'subm' => 'Retrieve discussion and message records', 'newr' => 'New Record (record is visible to course faculty and staff)', 'post' => 'Post this Record'); $r->print(<<"ENDTREC");'); my $escmsgid=&Apache::lonnet::escape($msgid); foreach (@messages) { if ($_->[5] eq $escmsgid){ last; } $counter++; } $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'}); my %courseinfo=&Apache::lonnet::coursedescription($content{'courseid'}); # Functions $r->print('
'.&mt('Functions').': | '. ''.&mt('Reply').' | '. ''.&mt('Forward').' | '. ''.&mt('Mark Unread').' | '. ''.&mt('Delete').' | '. ''.&mt('Back to Folder Display').' | '); if ($counter > 0){ $r->print(''.&mt('Previous').' | '); } if ($counter < $number_of_messages - 1){ $r->print(''.&mt('Next').' | '); } $r->print('
'.&mt('Currently available actions (will open extra window)').': | '); my $symb=&Apache::lonnet::symbread($content{'baseurl'}); if (&Apache::lonnet::allowed('vgr',$env{'request.course.id'})) { $r->print(''.&Apache::loncommon::track_student_link(&mt('View recent activity'),$content{'sendername'},$content{'senderdomain'},'check').' | '); } if (&Apache::lonnet::allowed('opa',$env{'request.course.id'}) && $symb) { $r->print(''.&Apache::loncommon::pprmlink(&mt('Set/Change parameters'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); } if (&Apache::lonnet::allowed('mgr',$env{'request.course.id'}) && $symb) { $r->print(''.&Apache::loncommon::pgrdlink(&mt('Set/Change grades'),$content{'sendername'},$content{'senderdomain'},$symb,'check').' | '); } $r->print('
'. &Apache::lontexconvert::msgtexconverted($content{'message'},1). '
'.&mt('Could not deliver message').' '. &mt('Please use the browser "Back" button and correct the recipient addresses').'
'); } } # ===================================================================== Handler sub handler { my $r=shift; # ----------------------------------------------------------- Set document type &Apache::loncommon::content_type($r,'text/html'); $r->send_http_header; return OK if $r->header_only; # --------------------------- Get query string for limited number of parameters &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'}, ['display','replyto','forward','markread','markdel','markunread', 'sendreply','compose','sendmail','critical','recname','recdom', 'recordftf','sortedby','block','folder','startdis','interdis', 'showcommentbaseurl','dismode','group','subject','text']); $sqs='&sortedby='.$env{'form.sortedby'}; # ------------------------------------------------------ They checked for email unless ($env{'form.block'}) { &Apache::lonnet::put('email_status',{'recnewemail'=>0}); } # ----------------------------------------------------------------- Breadcrumbs &Apache::lonhtmlcommon::clear_breadcrumbs(); &Apache::lonhtmlcommon::add_breadcrumb ({href=>"/adm/communicate", text=>"Communication/Messages", faq=>12,bug=>'Communication Tools',}); # ------------------------------------------------------------------ Get Folder my $folder=$env{'form.folder'}; unless ($folder) { $folder=''; } else { $sqs.='&folder='.&Apache::lonnet::escape($folder); } # ------------------------------------------------------------ Get Display Mode my $dismode=$env{'form.dismode'}; unless ($dismode) { $dismode=''; } else { $sqs.='&dismode='.&Apache::lonnet::escape($dismode); } # --------------------------------------------------------------------- Display $startdis=$env{'form.startdis'}; $startdis--; unless ($startdis) { $startdis=0; } $interdis=$env{'form.interdis'}; unless ($interdis) { $interdis=20; } $sqs.='&interdis='.$interdis; if ($env{'form.firstview'}) { $startdis=0; } if ($env{'form.lastview'}) { $startdis=-1; } if ($env{'form.prevview'}) { $startdis--; } if ($env{'form.nextview'}) { $startdis++; } my $postedstartdis=$startdis+1; $sqs.='&startdis='.$postedstartdis; # --------------------------------------------------------------- Render Output if ($env{'form.display'}) { &displaymessage($r,$env{'form.display'},$folder); } elsif ($env{'form.replyto'}) { &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode); } elsif ($env{'form.confirm'}) { &printheader($r,'','Confirmed Receipt'); foreach (keys %env) { if ($_=~/^form\.rec\_(.*)$/) { $r->print(''.&mt('Confirming Receipt').': '. &Apache::lonmsg::user_crit_received($1).''. &mt('Failed to delete the message.').'
'. ''.$msg."
\n"); } &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode)); } elsif ($env{'form.markedmove'}) { my ($total,$failed,@failed_msg)=(0,0); foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = &movemsg(&Apache::lonnet::unescape($1),$folder, $env{'form.movetofolder'}); if ($result) { $total++; } else { $failed++; push(@failed_msg,$msg); } } } &printheader($r,'','Moved Messages'); if ($failed) { $r->print(''.&mt('Failed to move [_1] message(s)',$failed). '
'); $r->print(''. join("
\n",@failed_msg). "
\n"); } $r->print(&mt('Moved [_1] message(s)',$total).''); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode)); } elsif ($env{'form.markeddel'}) { my ($total,$failed,@failed_msg)=(0,0); foreach my $key (keys(%env)) { if ($key=~/^form\.delmark_(.*)$/) { my ($result,$msg) = &statuschange(&Apache::lonnet::unescape($1),'deleted', $folder); if ($result) { $total++; } else { $failed++; push(@failed_msg,$msg); } } } &printheader($r,'','Deleted Messages'); if ($failed) { $r->print('
'.&mt('Failed to delete [_1] message(s)',$failed). '
'); $r->print(''. join("
\n",@failed_msg). "
\n"); } $r->print(&mt('Deleted [_1] message(s)',$total).''); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode)); } elsif ($env{'form.markunread'}) { &printheader($r,'','Marked Message as Unread'); &statuschange($env{'form.markunread'},'new'); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode)); } elsif ($env{'form.compose'}) { &compout($r,'','',$env{'form.compose'}); } elsif ($env{'form.recordftf'}) { &facetoface($r,$env{'form.recordftf'}); } elsif ($env{'form.block'}) { &examblock($r,$env{'form.block'}); } elsif ($env{'form.sendmail'}) { &sendoffmail($r,$folder); if ($env{'form.storebasecomment'}) { &storecomment($r); } if (($env{'form.rsspost'}) && ($env{'request.course.id'})) { &Apache::lonrss::addentry($env{'course.'.$env{'request.course.id'}.'.num'}, $env{'course.'.$env{'request.course.id'}.'.domain'}, 'Course_Announcements', $env{'form.subject'}, $env{'form.message'},'/adm/communicate','public'); } &disall($r,($folder?$folder:$dismode)); } elsif ($env{'form.newfolder'}) { &printheader($r,'','New Folder'); &makefolder($env{'form.newfolder'}); &Apache::loncommunicate::menu($r); &disall($r,$env{'form.newfolder'}); } elsif ($env{'form.showcommentbaseurl'}) { &storedcommentlisting($r); } else { &printheader($r,'','Display All Messages'); &Apache::loncommunicate::menu($r); &disall($r,($folder?$folder:$dismode)); } $r->print(&Apache::loncommon::end_page()); return OK; } # ================================================= Main program, reset counter =pod =back =cut 1; __END__