--- loncom/interface/lonmsg.pm 2005/04/07 06:56:23 1.140
+++ loncom/interface/lonmsg.pm 2005/11/18 13:35:30 1.155
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Routines for messaging
#
-# $Id: lonmsg.pm,v 1.140 2005/04/07 06:56:23 albertel Exp $
+# $Id: lonmsg.pm,v 1.155 2005/11/18 13:35:30 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -114,6 +114,8 @@ use HTML::Entities();
use Mail::Send;
use Apache::lonlocal;
use Apache::loncommunicate;
+use Apache::lonfeedback;
+use Apache::lonrss();
# Querystring component with sorting type
my $sqs;
@@ -141,7 +143,8 @@ sub packagemsg {
$partsubj=&Apache::lonnet::escape($partsubj);
my $msgid=&Apache::lonnet::escape(
$now.':'.$partsubj.':'.$env{'user.name'}.':'.
- $env{'user.domain'}.':'.$msgcount.':'.$$);
+ $env{'user.domain'}.':'.$msgcount.':'.
+ $env{'request.course.id'}.':'.$$);
my $result=''.$env{'user.name'}.''.
''.$env{'user.domain'}.''.
''.$subject.''.
@@ -209,13 +212,13 @@ sub unpackmsgid {
my ($msgid,$folder)=@_;
$msgid=&Apache::lonnet::unescape($msgid);
my $suffix=&foldersuffix($folder);
- my ($sendtime,$shortsubj,$fromname,$fromdomain)=split(/\:/,
+ my ($sendtime,$shortsubj,$fromname,$fromdomain,$count,$fromcid)=split(/\:/,
&Apache::lonnet::unescape($msgid));
my %status=&Apache::lonnet::get('email_status'.$suffix,[$msgid]);
if ($status{$msgid}=~/^error\:/) { $status{$msgid}=''; }
unless ($status{$msgid}) { $status{$msgid}='new'; }
- return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid});
-}
+ return ($sendtime,$shortsubj,$fromname,$fromdomain,$status{$msgid},$fromcid);
+}
sub sendemail {
@@ -336,7 +339,20 @@ sub del_url_author_res_msg {
}
return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author);
}
+# =================================== Clear out all author messages in URL path
+sub clear_author_res_msg {
+ my $url=shift;
+ $url=&Apache::lonnet::declutter($url);
+ my ($domain,$author)=($url=~/^(\w+)\/(\w+)\//);
+ my @delmsgs=();
+ foreach (&Apache::lonnet::getkeys('nohist_res_msgs',$domain,$author)) {
+ if ($_=~/^\Q$url\E/) {
+ push (@delmsgs,$_);
+ }
+ }
+ return &Apache::lonnet::del('nohist_res_msgs',\@delmsgs,$domain,$author);
+}
# ================= Return hash with URLs for which there is a resource message
sub all_url_author_res_msg {
@@ -563,13 +579,14 @@ sub scrollbuttons {
my ($start,$maxdis,$first,$finish,$total)=@_;
unless ($total>0) { return ''; }
$start++; $maxdis++;$first++;$finish++;
- return
+ return
+ &mt('Page').': '.
''.
''.
' of '.$maxdis.
''.
'
'.
- &mt('Messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
+ &mt('Showing messages [_1] through [_2] of [_3]',$first,$finish,$total).'';
}
# =============================================================== Folder suffix
@@ -595,6 +612,9 @@ sub statuschange {
if (($newstatus eq 'deleted') || ($newstatus eq 'new')) {
&Apache::lonnet::put('email_status'.$suffix,{$msgid => $newstatus});
}
+ if ($newstatus eq 'deleted') {
+ &movemsg(&Apache::lonnet::unescape($msgid),$folder,'trash');
+ }
}
# ============================================================= Make new folder
@@ -612,6 +632,7 @@ sub makefolder {
sub movemsg {
my ($msgid,$srcfolder,$trgfolder)=@_;
+ if ($srcfolder eq 'new') { $srcfolder=''; }
my $srcsuffix=&foldersuffix($srcfolder);
my $trgsuffix=&foldersuffix($trgfolder);
@@ -705,6 +726,8 @@ ENDDISHEADER
&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 $key = 'send_to_&&&'.$section.'&&&_'.$student;
if (! defined($fullname) || $fullname eq '') { $fullname = $sname; }
$r->print('
| '.
''.&mt('Back to Folder Display').' | ');
@@ -1783,6 +1812,20 @@ sub displaymessage {
'">'.&mt('Next').'');
}
$r->print('
');
+ if ($env{'user.adv'}) {
+ $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('
');
+ }
$r->print('
'.&mt('Subject').': '.$content{'subject'}.
($folder ne 'sent'?'
'.&mt('From').': '.
&Apache::loncommon::aboutmewrapper(
@@ -1846,7 +1889,8 @@ sub header {
my ($r,$title,$baseurl)=@_;
$r->print(&Apache::lonxml::xmlbegin().
''.&Apache::lonxml::fontsettings().
- 'Communication and Messages');
+ 'Communication and Messages'.
+ &Apache::lonhtmlcommon::htmlareaheaders());
if ($baseurl) {
$r->print("");
}
@@ -2047,6 +2091,14 @@ sub handler {
} 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
@@ -2078,7 +2130,7 @@ sub handler {
if ($env{'form.display'}) {
&displaymessage($r,$env{'form.display'},$folder);
} elsif ($env{'form.replyto'}) {
- &compout($r,'',$env{'form.replyto'},undef,undef,$folder);
+ &compout($r,'',$env{'form.replyto'},undef,undef,$folder,$dismode);
} elsif ($env{'form.confirm'}) {
&printheader($r,'','Confirmed Receipt');
foreach (keys %env) {
@@ -2103,7 +2155,7 @@ sub handler {
&printheader($r,'','Deleted Message');
&statuschange($env{'form.markdel'},'deleted',$folder);
&Apache::loncommunicate::menu($r);
- &disall($r,$folder);
+ &disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.markedmove'}) {
my $total=0;
foreach (keys %env) {
@@ -2116,7 +2168,7 @@ sub handler {
&printheader($r,'','Moved Messages');
$r->print('Moved '.$total.' message(s)');
&Apache::loncommunicate::menu($r);
- &disall($r,$folder);
+ &disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.markeddel'}) {
my $total=0;
foreach (keys %env) {
@@ -2128,12 +2180,12 @@ sub handler {
&printheader($r,'','Deleted Messages');
$r->print('Deleted '.$total.' message(s)
');
&Apache::loncommunicate::menu($r);
- &disall($r,$folder);
+ &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);
+ &disall($r,($folder?$folder:$dismode));
} elsif ($env{'form.compose'}) {
&compout($r,'','',$env{'form.compose'});
} elsif ($env{'form.recordftf'}) {
@@ -2145,7 +2197,14 @@ sub handler {
if ($env{'form.storebasecomment'}) {
&storecomment($r);
}
- &disall($r,$folder);
+ 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'});
@@ -2155,8 +2214,8 @@ sub handler {
&storedcommentlisting($r);
} else {
&printheader($r,'','Display All Messages');
- &Apache::loncommunicate::menu($r);
- &disall($r,$folder);
+ &Apache::loncommunicate::menu($r);
+ &disall($r,($folder?$folder:$dismode));
}
$r->print(&Apache::loncommon::endbodytag().'');
return OK;